Skip to content

Commit

Permalink
feat: build new miniMetadatas into pub/v1 dir
Browse files Browse the repository at this point in the history
  • Loading branch information
alecdwm committed Apr 11, 2024
1 parent 485a354 commit c93603c
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 132 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
publish:
name: 'Build & publish chaindata to dist folder'
name: 'Build & publish chaindata to pub folder'
timeout-minutes: 15
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<img src="assets/talisman.svg" alt="Talisman" width="15%" align="right" />

[![api-link](https://img.shields.io/website?label=api&logo=github&logoColor=white&style=flat-square&up_message=online&down_message=offline&url=https%3A%2F%2Fraw.githubusercontent.com%2FTalismanSociety%2Fchaindata%2Fmain%2Fdist%2Findex.txt)](https://raw.githubusercontent.com/TalismanSociety/chaindata/main/dist/index.txt)
[![api-link](https://img.shields.io/website?label=api&logo=github&logoColor=white&style=flat-square&up_message=online&down_message=offline&url=https%3A%2F%2Fraw.githubusercontent.com%2FTalismanSociety%2Fchaindata%2Fmain%2Fpub%2Fv1%2Findex.txt)](https://raw.githubusercontent.com/TalismanSociety/chaindata/main/pub/v1/index.txt)

A **community controlled** repository of [relay](https://wiki.polkadot.network/docs/learn-architecture#relay-chain) and [parachain](https://wiki.polkadot.network/docs/learn-architecture#parachain-and-parathread-slots) information in the [Polkadot ecosystem](https://polkadot.network/).

Expand All @@ -15,14 +15,14 @@ The goals of this repo are:

## Usage

The files in this repo, `data/chaindata.json`, `data/testnets-chaindata.json` and `data/evm-networks.json` are used to configure a GitHub workflow which scrapes information from each chain and publishes it as a collection of JSON files in the `dist` directory of this repo.
The files in this repo, `data/chaindata.json`, `data/testnets-chaindata.json` and `data/evm-networks.json` are used to configure a GitHub workflow which scrapes information from each chain and publishes it as a collection of JSON files in the `pub` directory of this repo.

The published files can be browsed at this URL: https://raw.githubusercontent.com/TalismanSociety/chaindata/main/dist/index.txt
The published files can be browsed at this URL: https://raw.githubusercontent.com/TalismanSociety/chaindata/main/pub/v1/index.txt

As an example, you could use this request to get a summary of all chains including the the names, logos, [genesisHashes](## 'the hash of the first block on the chain') and [address type prefixes](https://wiki.polkadot.network/docs/learn-account-advanced#address-format):

```ts
const chainsSummaryUrl = "https://raw.githubusercontent.com/TalismanSociety/chaindata/main/dist/chains/summary.json"
const chainsSummaryUrl = "https://raw.githubusercontent.com/TalismanSociety/chaindata/main/pub/v1/chains/summary.json"
const summary = await fetch(chainsSummaryUrl).then(result => result.json())
```

Expand Down Expand Up @@ -51,7 +51,7 @@ To make a contribution, please fork this repo and make your changes in your fork
1. Identify the token symbol (e.g. `KSM`)
1. Add your logo (in `svg` format) to `assets/tokens/${symbol}.svg`

### To build the dist directory locally:
### To build the pub directory locally:

1. Install [pnpm](pnpm.io)
1. Clone the repo via
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"typecheck": "tsc --noEmit",
"fetch-external": "tsx scripts/fetch-external.ts",
"build": "pnpm run validate && tsx scripts/build.ts",
"clean": "rm -rf dist"
"clean": "rm -rf pub"
},
"dependencies": {
"@polkadot/api": "^10.11.2",
Expand All @@ -33,11 +33,11 @@
"@polkadot/util": "^12.6.2",
"@polkadot/util-crypto": "^12.6.2",
"@supercharge/promise-pool": "^3.1.0",
"@talismn/balances": "0.0.0-pr1348-20240308055042",
"@talismn/chain-connector": "0.0.0-pr1348-20240308055042",
"@talismn/chain-connector-evm": "0.0.0-pr1348-20240308055042",
"@talismn/chaindata-provider": "0.0.0-pr1348-20240308055042",
"@talismn/scale": "0.0.0-pr1348-20240308055042",
"@talismn/balances": "0.0.0-pr1394-20240411002942",
"@talismn/chain-connector": "0.0.0-pr1394-20240411002942",
"@talismn/chain-connector-evm": "0.0.0-pr1394-20240411002942",
"@talismn/chaindata-provider": "0.0.0-pr1394-20240411002942",
"@talismn/scale": "0.0.0-pr1394-20240411002942",
"axios": "^1.6.2",
"dotenv": "^16.3.1",
"extract-colors": "^2.0.6",
Expand Down
245 changes: 132 additions & 113 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/build/steps/addEvmNetworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const addEvmNetworks = async () => {
sortIndex: null,
name: configEvmNetwork.name ?? substrateChain?.name ?? substrateConfig?.name ?? null,
themeColor: configEvmNetwork.themeColor ?? substrateChain?.themeColor ?? substrateChain?.themeColor ?? null,
logo: substrateChain?.logo ?? configEvmNetwork.logo ?? null, // TODO: Copy chain & token assets into dist output
logo: substrateChain?.logo ?? configEvmNetwork.logo ?? null, // TODO: Copy chain & token assets into pub output
nativeToken: null,
tokens: [],
explorerUrl: configEvmNetwork.explorerUrl ?? null,
Expand Down
2 changes: 1 addition & 1 deletion scripts/fetch-external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { fetchExternalSteps } from './fetch-external/steps'
// // update local data
// ...fetchExternalSteps,

// // update dist folder (use only for local testing, on github this will be run by the build script)
// // update pub folder (use only for local testing, on github this will be run by the build script)
// ...buildSteps
// ]

Expand Down
4 changes: 2 additions & 2 deletions scripts/fetch-external/coingecko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const fetchAssetPlatforms = async () => {

// // TODO for debugging only, remove when ready
// await writeFile(
// 'dist/assetPlatforms.json',
// `${DIR_OUTPUT}/assetPlatforms.json`,
// await prettier.format(JSON.stringify(assetPlatforms, null, 2), {
// ...PRETTIER_CONFIG,
// parser: 'json',
Expand All @@ -26,7 +26,7 @@ export const fetchCoins = async () => {

// // TODO for debugging only, remove when ready
// await writeFile(
// 'dist/coins.json',
// `${DIR_OUTPUT}/coins.json`,
// await prettier.format(JSON.stringify(coins, null, 2), {
// ...PRETTIER_CONFIG,
// parser: 'json',
Expand Down
12 changes: 10 additions & 2 deletions scripts/find-missing-coingeckoIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@ import { readFile, writeFile } from 'node:fs/promises'

import groupBy from 'lodash/groupBy'

import { DIR_OUTPUT } from './shared/constants'

const main = async () => {
const allChains = new Map<string, { id?: string; name?: string }>(
JSON.parse((await readFile('dist/chains/all.json')).toString('utf8')).map((chain: any) => [chain.id, chain]),
JSON.parse((await readFile(`${DIR_OUTPUT}/chains/all.json`)).toString('utf8')).map((chain: any) => [
chain.id,
chain,
]),
)
const allTokens = new Map<string, { id?: string; symbol?: string; chain?: { id?: string }; coingeckoId?: string }>(
JSON.parse((await readFile('dist/tokens/all.json')).toString('utf8')).map((token: any) => [token.id, token]),
JSON.parse((await readFile(`${DIR_OUTPUT}/tokens/all.json`)).toString('utf8')).map((token: any) => [
token.id,
token,
]),
)
const missing = [...allTokens.values()]
.filter((token) => (token.coingeckoId === undefined ? true : false))
Expand Down
2 changes: 1 addition & 1 deletion scripts/shared/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const GITHUB_REPO = 'chaindata'
export const GITHUB_BRANCH = 'main'

export const DIR_ASSETS_CHAINS = 'assets/chains'
export const DIR_OUTPUT = 'dist'
export const DIR_OUTPUT = 'pub/v1'

export const NOVASAMA_METADATA_PORTAL_CONFIG =
'https://raw.githubusercontent.com/novasamatech/metadata-portal/master/config.toml'
Expand Down

0 comments on commit c93603c

Please sign in to comment.