This repository has been archived by the owner on Nov 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c55802
commit d9e2b87
Showing
23 changed files
with
167 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { expect, test, it } from "bun:test"; | ||
|
||
test("caip2", async () => { | ||
it("Dummy max length(8 + 1 + 32 = 41 chars / bytes)", async () => { | ||
expect(true).toBeTrue(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { expect, test, it } from "bun:test"; | ||
|
||
test("web3icons", async () => { | ||
it("web3icons does not exists", async () => { | ||
expect(true).toBeTrue(); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
{ | ||
"id": "arbitrum-one", | ||
"name": "Arbitrum One", | ||
"block": "ethereum" | ||
"namespace": "eip155", | ||
"block": "ethereum", | ||
"genesis_hash": "0x7ee576b35482195fc49205cec9af72ce14f003b9ae69f6ba0faef4514be8b442", | ||
"chain_id": 42161, | ||
"network_id": 42161 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"id": "bitcoin", | ||
"name": "Bitcoin", | ||
"namespace": "bip122", | ||
"block": "bitcoin", | ||
"genesis_hash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f", | ||
"chain_id": "000000000019d6689c085ae165831e93" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
{ | ||
"id": "mainnet", | ||
"name": "Ethereum", | ||
"block": "ethereum" | ||
"namespace": "eip155", | ||
"block": "ethereum", | ||
"genesis_hash": "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3", | ||
"chain_id": 1, | ||
"network_id": 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"id": "solana", | ||
"name": "Solana", | ||
"namespace": "solana", | ||
"block": "solana", | ||
"genesis_hash": "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d", | ||
"chain_id": "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp" | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import fs from "fs"; | ||
import path from "path"; | ||
import web3icons from '../download/web3icons.json'; | ||
|
||
const base = path.join(__dirname, "..", "..", "_data"); | ||
|
||
// read & parse chains | ||
const ids: Set<string> = new Set(); | ||
const chain_ids: Map<number, string> = new Map(); | ||
const names: Map<string, string> = new Map(); | ||
for (const filename of fs.readdirSync(path.join(base, "chains"))) { | ||
const id = path.parse(filename).name; | ||
const json = JSON.parse(fs.readFileSync(path.join(base, "chains", filename), "utf-8")); | ||
chain_ids.set(json.chain_id, id); | ||
names.set(json.name, id); | ||
ids.add(id); | ||
} | ||
|
||
async function download(web3icon: typeof web3icons[0], id: string) { | ||
for (const variant of web3icon.variants) { | ||
const url = `https://raw.githubusercontent.com/0xa3k5/web3icons/refs/heads/main/packages/core/src/svgs/networks/${variant}/${web3icon.id}.svg`; | ||
const filename = path.join(base, "icons", variant, `${id}.svg`); | ||
if (fs.existsSync(filename)) continue; // skip if already exists | ||
const response = await fetch(url); | ||
if (response.ok) { | ||
const svg = await response.text(); | ||
fs.writeFileSync(filename, svg); | ||
} | ||
} | ||
} | ||
|
||
function getId(web3icon: typeof web3icons[0]) { | ||
if (ids.has(web3icon.id)) { | ||
return web3icon.id; | ||
} | ||
// by chain_id | ||
if (web3icon.chainId) { | ||
const id = chain_ids.get(web3icon.chainId); | ||
return id; | ||
} | ||
// by name | ||
const id = names.get(web3icon.name); | ||
return id; | ||
} | ||
|
||
// download web3icons if match by chain_id or name | ||
for (const web3icon of web3icons) { | ||
const id = getId(web3icon); | ||
if (id) { | ||
await download(web3icon, id); | ||
} | ||
} |