generated from ubiquity/ts-template
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from ubiquity/development
Merge development into main
- Loading branch information
Showing
39 changed files
with
3,784 additions
and
2,432 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json", | ||
"version": "0.2", | ||
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log", "lib", "dist"], | ||
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log", "lib", "dist", "dynamic.ts"], | ||
"useGitignore": true, | ||
"language": "en", | ||
"words": ["dataurl", "devpool", "outdir", "servedir"], | ||
"dictionaries": ["typescript", "node", "software-terms"], | ||
"import": ["@cspell/dict-typescript/cspell-ext.json", "@cspell/dict-node/cspell-ext.json", "@cspell/dict-software-terms"], | ||
"ignoreRegExpList": ["[0-9a-fA-F]{6}"], | ||
"ignoreWords": ["Rpcs", "ethersproject", "publicnode", "WXDAI", "XDAI", "chainlist", "Knip", "LOCALSTORAGE"] | ||
"ignoreWords": ["Rpcs", "ethersproject", "publicnode", "WXDAI", "XDAI", "chainlist", "Knip", "LOCALSTORAGE", "sonarjs", "cronos", "Cronos", "gochain"] | ||
} |
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,10 @@ | ||
const { exec } = require("child_process"); | ||
|
||
exec('cspell "**/*"', (error, stdout, stderr) => { | ||
if (error) { | ||
console.error(`exec error: ${error}`); | ||
return; | ||
} | ||
if (stdout) console.log(`stdout: ${stdout}`); | ||
if (stderr) console.error(`stderr: ${stderr}`); | ||
}); |
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
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
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 |
---|---|---|
|
@@ -10,4 +10,6 @@ node_modules | |
dist | ||
|
||
coverage | ||
junit.xml | ||
junit.xml | ||
dynamic.ts | ||
test-dashboard.md |
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,17 +1,18 @@ | ||
nodeLinker: node-modules | ||
|
||
supportedArchitectures: | ||
os: | ||
- "current" | ||
- "darwin" | ||
- "linux" | ||
- "win32" | ||
cpu: | ||
- "current" | ||
- "x64" | ||
- "x86" | ||
- "arm" | ||
- "ia32" | ||
- current | ||
- x64 | ||
- x86 | ||
- arm | ||
- ia32 | ||
libc: | ||
- "current" | ||
- "glibc" | ||
- "musl" | ||
- current | ||
- glibc | ||
- musl | ||
os: | ||
- current | ||
- darwin | ||
- linux | ||
- win32 |
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,55 @@ | ||
import { appendFile, writeFile } from "fs/promises"; | ||
import { BlockExplorer, NativeToken } from "../types/handler"; | ||
import { generateChainData } from "../lib/chainlist/utils/fetch"; | ||
|
||
/** | ||
* This produces dynamic types and constants for: | ||
* - CHAINS_IDS | ||
* - NETWORKS | ||
* - NETWORK_FAUCETS | ||
* - NETWORK_EXPLORERS | ||
* - NETWORK_CURRENCIES | ||
* - EXTRA_RPCS | ||
*/ | ||
|
||
export async function createDynamicTypes() { | ||
const data = await generateChainData(); | ||
const idToNetwork: Record<string, string> = {}; | ||
const networkToId: Record<string, number> = {}; | ||
const idToRpc: Record<string, string[]> = {}; | ||
const idToFaucet: Record<string, string[]> = {}; | ||
const idToExplorers = {} as Record<string, BlockExplorer[]>; | ||
const idToNativeCurrency: Record<string, NativeToken> = {}; | ||
const extraRpcs: Record<string, string[]> = {}; | ||
|
||
for (const chain of data) { | ||
let { name, chainId, networkId, rpc, faucets, explorers, nativeCurrency } = chain; | ||
name = name.toLowerCase().replace(/\s/g, "-"); | ||
idToNetwork[chainId] = name; | ||
networkToId[name] = networkId; | ||
idToRpc[chainId] = rpc; | ||
idToFaucet[chainId] = faucets; | ||
|
||
if (explorers && explorers.length > 0) { | ||
idToExplorers[chainId] = explorers; | ||
} | ||
|
||
if (rpc && rpc.length > 0) { | ||
extraRpcs[chainId] = rpc; | ||
} | ||
|
||
idToNativeCurrency[chainId] = nativeCurrency; | ||
} | ||
|
||
const filename = "dynamic.ts"; | ||
|
||
// Clear the file | ||
await writeFile(filename, "/* eslint-disable sonarjs/no-duplicate-string */\n\n"); | ||
|
||
appendFile(filename, `\nexport const CHAINS_IDS = ${JSON.stringify(idToNetwork, null, 2)} as const;\n`); | ||
appendFile(filename, `\nexport const NETWORKS = ${JSON.stringify(networkToId, null, 2)} as const;\n`); | ||
appendFile(filename, `\nexport const NETWORK_FAUCETS = ${JSON.stringify(idToFaucet, null, 2)};\n`); | ||
appendFile(filename, `\nexport const NETWORK_EXPLORERS = ${JSON.stringify(idToExplorers, null, 2)};\n`); | ||
appendFile(filename, `\nexport const NETWORK_CURRENCIES = ${JSON.stringify(idToNativeCurrency, null, 2)};\n`); | ||
appendFile(filename, `\nexport const EXTRA_RPCS = ${JSON.stringify(extraRpcs, null, 2)};\n`); | ||
} |
Oops, something went wrong.