Skip to content

Commit

Permalink
Merge pull request #1 from bchainhub/update/version-01
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
rastislavcore committed May 2, 2024
2 parents db01638 + 2e9511d commit 8cf47ce
Show file tree
Hide file tree
Showing 18 changed files with 231 additions and 5,955 deletions.
63 changes: 63 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Report Bug 🪲
description: Create a bug report
labels:
- bug
body:
- type: markdown
attributes:
value: |
Please, provide as much details as possible to make proper evaluation and in the end resolve the bug report faster.
- type: markdown
attributes:
value: |
Software specific details.
- type: input
id: os
attributes:
label: OS and version
description: Name and version of OS used.
placeholder: OS
validations:
required: true

- type: textarea
id: bug
attributes:
label: Bug
description: Describe the Bug.
placeholder: Bug description
validations:
required: true

- type: textarea
id: reproduce
attributes:
label: Reproduce Bug
description: Steps to reproduce the behavior.
placeholder: 1. Step 1
validations:
required: true

- type: textarea
id: expected
attributes:
label: Expected behavior
description: Describe the result you are expecting.
placeholder: Result
validations:
required: true

- type: input
id: hash
attributes:
label: Commit hash
description: Commit hash if known.
placeholder: baf2aab0128f07262b564214ec70fc07befc6bb3

- type: textarea
id: additional
attributes:
label: Additional context
description: Please, place additional content or screenshots.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Readme
url: https://github.com/bchainhub/blo#readme
about: Read more about the blo generator
43 changes: 43 additions & 0 deletions .github/ISSUE_TEMPLATE/feature.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Feature request 🔮
description: Suggest an idea for this project
labels:
- enhancement
body:
- type: markdown
attributes:
value: |
Suggest an idea for this project and developers will consider the integration.
- type: textarea
id: problem
attributes:
label: Problem
description: Is your feature request related to a problem? Please describe.
validations:
required: true

- type: textarea
id: solution
attributes:
label: Solution
description: Describe the solution you'd like.
validations:
required: true

- type: textarea
id: alternatives
attributes:
label: Alternatives
description: Describe alternatives you've considered.

- type: textarea
id: implementation
attributes:
label: Implementation
description: Describe implementation with example of the code.

- type: textarea
id: additional
attributes:
label: Additional context
description: Please, place additional content or screenshots.
35 changes: 35 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish to NPM

on:
release:
types: [created]

permissions:
id-token: write
contents: write

jobs:
build-and-publish:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'

- name: Install Dependencies
run: npm i

- name: Build Project
run: npm run build

- name: Publish package on NPM 📦
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

# Locks
package-lock.json
yarn.lock
pnpm-lock.yaml

node_modules
dist
dist-ssr
Expand Down
33 changes: 15 additions & 18 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
MIT License

Copyright (c) 2023 Pierre Bertet <https://bpier.re/>
CORE License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
of this software and associated documentation files (the "Software"),
to to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
All distribution of the Covered Software in Source Code Form, including any
Modifications and/or Contributions must be disclosed and publicly available.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE TO ANY CLAIM, DAMAGES OR
OTHER LIABILITIES, WHETHER IN AN ACTION OF A CONTRACT, TORT, OR OTHERWISE,
ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE, OR
OTHER DEALINGS IN THE SOFTWARE.
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<div align="center">
<img width="860" alt="blo" src="https://github.com/bpierre/blo/assets/36158/7ddc0bf0-076d-4c5a-8624-cc8646e4c5aa">
<br><strong>blo</strong> is a small and fast library to generate Ethereum identicons.
<img width="860" alt="blo" src="https://github.com/bchainhub/blo/assets/537310/5665a666-9dce-4869-9cb9-eb9bcd1693a1">
<br><strong>blo</strong> is a small and fast library to generate Blockchain identicons.
<br><br>
</div>

<p align=center><a href="https://www.npmjs.com/package/blo"><img src="https://badgen.net/npm/v/blo" alt="npm version"></a> <a href="https://bundlejs.com/?q=blo"><img src="https://deno.bundlejs.com/badge?q=blo" alt="bundle size"></a> <a href="https://github.com/bpierre/blo/blob/main/LICENSE"><img src="https://badgen.net/github/license/bpierre/blo" alt="License"></a></p>

## Features

- 🐥 **Small**: **[0.67 KB](https://bundlejs.com/?bundle&q=blo)** gzipped.
Expand Down Expand Up @@ -34,23 +32,29 @@
## Getting Started

```sh
npm i -S blo
pnpm add blo
yarn add blo
npm i -S @bchainhub/blo
```

```sh
pnpm add @bchainhub/blo
```

```sh
yarn add @bchainhub/blo
```

```ts
import { blo } from "blo";
import { blo } from "@bchainhub/blo";

img.src = blo("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045");
img.src = blo("cb7147879011ea207df5b35a24ca6f0859dcfb145999");
```

### React / Vue / Others

blo is fast enough to not require memoization or async rendering for common use cases.

```tsx
function AddressIcon({ address }: { address: `0x${string}` }) {
function AddressIcon(address: string) {
return (
<img
alt={address}
Expand All @@ -73,7 +77,7 @@ The `size` paramater shouldn’t usually be needed, as the image will stay sharp
Example:

```ts
import { blo } from "blo";
import { blo } from "@bchainhub/blo";

img.src = blo(address); // size inside the SVG defaults to 64px
img2.src = blo(address, 24); // set it to 24px
Expand Down Expand Up @@ -131,7 +135,7 @@ export type PaletteIndex =
export type Hsl = Uint16Array;

// An Ethereum address.
export type Address = `0x${string}`;
export type Address = string;
```

## Acknowledgements
Expand All @@ -142,28 +146,28 @@ export type Address = `0x${string}`;

## FAQ

### Does it follow the exact same algorithm as Etherscan, MetaMask and others?
### Does it follow the exact same algorithm as CorePass, Etherscan, MetaMask and others?

Yes.

### Does it work with ENS names?
### Does it work with CNS, ENS names?

No it only works with Ethereum addresses, but you can resolve the ENS name to an address (e.g. with [wagmi](https://wagmi.sh/core/actions/fetchEnsAddress)) and pass the result to blo.
Yes. You can use the ENS name directly as the `address` parameter.

### Can blo render other formats than SVG?

You can render to any format you want by using the `bloImage()` function, which returns a data structure (see [API](#api) above). Check out the [Bun](./demos/bun) and [Node](./demos/node) demos for examples of rendering an identicon in the terminal.

<img width="400" src="https://github.com/bpierre/blo/assets/36158/a7c86d01-f003-49d7-8f9e-93097b502872" alt="Ethereum identicon rendered in the terminal">
<img width="400" src="https://github.com/bchainhub/blo/assets/537310/93243626-ae78-44fb-9201-d6049a3f95e5" alt="Ethereum identicon rendered in the terminal">

### Can it be used to generate other types of identicons?

blo only focuses on the Ethereum identicons algorithm but you can use it with any data, just prefix it with `0x` to fulfill the expected `Address` type if you are using TypeScript.
blo focuses on the blockchain algorithm but you can use it with any data. Hexadecimal values prefix it with `0x` to fulfill the expected `Address` otherwise prefix is not needed.

### Why is it named blo?

blo is short for blockies, which is the name of [the original library](https://github.com/ethereum/blockies) it is based on.

## License

[MIT](./LICENSE)
[CORE](LICENSE)
20 changes: 10 additions & 10 deletions benchmark/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "blo-benchmark",
"name": "@blockchainhub/blo-benchmark",
"private": true,
"type": "module",
"scripts": {
Expand All @@ -8,24 +8,24 @@
"bench": "vitest bench"
},
"devDependencies": {
"@types/react": "^18.2.74",
"@types/react-dom": "^18.2.24",
"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react-swc": "^3.6.0",
"@vitest/browser": "^1.4.0",
"@vitest/browser": "^1.5.3",
"ethereum-blockies-base64": "^1.0.2",
"typescript": "^5.4.4",
"vite": "^5.2.8",
"vitest": "^1.4.0",
"webdriverio": "^8.35.1"
"typescript": "^5.4.5",
"vite": "^5.2.11",
"vitest": "^1.5.3",
"webdriverio": "^8.36.1"
},
"dependencies": {
"@download/blockies": "^1.0.3",
"blockies-react-svg": "^0.0.13",
"blockies-ts": "^1.0.0",
"rand-seed": "^1.0.2",
"react": "^18.2.0",
"react": "^18.3.1",
"react-blockies": "^1.4.1",
"react-component-benchmark": "^2.0.0",
"react-dom": "^18.2.0"
"react-dom": "^18.3.1"
}
}
Loading

0 comments on commit 8cf47ce

Please sign in to comment.