Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new chaindata publish ci #61

Merged
merged 17 commits into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Generate a read-only token at https://github.com/settings/tokens
# Only needed when running `bun run build` locally
# When it's run on the CI, GitHub automatically generates a GITHUB_TOKEN for the job
GITHUB_TOKEN=
2 changes: 0 additions & 2 deletions .gitattributes

This file was deleted.

56 changes: 56 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Chaindata Publish

on:
# runs on each commit pushed to the `main` branch
push:
branches: [main]
# runs at `0 minutes past the hour, every 6 hours`, starting at midnight UTC
schedule:
- cron: '0 0/6 * * *'
# can be run manually from the `Actions` tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

concurrency:
# only run 1 job per branch/pr/etc at a time
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
publish:
name: 'Build & publish chaindata to GitHub Pages'
timeout-minutes: 15
runs-on: ubuntu-latest

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Setup pnpm
uses: pnpm/action-setup@v2
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: 'package.json'
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build chaindata
run: pnpm build
- name: Upload pages artifact
uses: actions/upload-pages-artifact@v2
with:
path: 'dist'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
14 changes: 8 additions & 6 deletions .github/workflows/ci.yml → .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Talisman Chaindata CI
name: Chaindata Validate

on:
push:
Expand All @@ -21,14 +21,16 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup Node.js environment
- name: Setup pnpm
uses: pnpm/action-setup@v2
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
node-version-file: 'package.json'
cache: pnpm
- name: Install dependencies
run: yarn --immutable
run: pnpm install --frozen-lockfile
- name: Validate JSON format & schema
# prettier will exit with a non-zero status code if the JSON format is not valid
# ajv will exit with a non-zero status code if the JSON schema is not valid
run: yarn validate
run: pnpm validate
19 changes: 4 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

.DS_Store
*.pem
.DS_Store
dist
node_modules
tsconfig.tsbuildinfo

.env
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
yarn-error.log*
6 changes: 0 additions & 6 deletions .prettierrc

This file was deleted.

7 changes: 0 additions & 7 deletions .vscode/settings.json

This file was deleted.

873 changes: 0 additions & 873 deletions .yarn/releases/yarn-3.5.1.cjs

This file was deleted.

5 changes: 0 additions & 5 deletions .yarn/sdks/integrations.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .yarn/sdks/prettier/index.js

This file was deleted.

6 changes: 0 additions & 6 deletions .yarn/sdks/prettier/package.json

This file was deleted.

1 change: 0 additions & 1 deletion .yarnrc.yml

This file was deleted.

59 changes: 43 additions & 16 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=graphql%20api&logo=graphql&logoColor=white&style=flat-square&up_message=online&down_message=offline&url=https%3A%2F%2Fsquid.subsquid.io%2Fchaindata%2Fv%2Fv4%2Fgraphql)](https://squid.subsquid.io/chaindata/v/v4/graphql)
[![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%2Ftalismansociety.github.io%2Fchaindata)](https://talismansociety.github.io/chaindata)
[![discord-link](https://img.shields.io/discord/858891448271634473?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/talisman)

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 @@ -11,27 +11,54 @@ The goals of this repo are:

1. Provide a community-managed index of Polkadot parachains and their connection information (rpcs, chainspecs)
1. Provide a source of chain and token assets across the ecosystem
1. Enable developers to retrieve this information via an API suitable to their project (graphql, rest [**soon™**](https://github.com/TalismanSociety/chaindata/issues/35), npm [**soon™**](https://github.com/TalismanSociety/chaindata/issues/35))
1. Enable developers to retrieve this information via an API suitable to their project (json/rest, npm [**soon™**](https://github.com/TalismanSociety/chaindata/issues/35))
1. Move towards a decentralised model

---

## Usage

At this time, this repo is used to configure an API which scrapes information from each chain and exposes it via graphql.
The API can be interacted with via this URL: https://squid.subsquid.io/chaindata/v/v4/graphql
The files in this repo, `chaindata.json`, `testnets-chaindata.json` and `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 on GitHub Pages.

The published files can be browsed at this URL: https://talismansociety.github.io/chaindata

As an example, you could use this query to get the name, [genesisHash](## 'the hash of the first block on the chain') and [address type prefix](https://wiki.polkadot.network/docs/learn-account-advanced#address-format) for each chain:
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):

```graphql
query {
chains {
genesisHash
prefix
name
}
}
```ts
const chainsSummaryUrl = "https://talismansociety.github.io/chaindata/chains/summary.json"
const summary = await fetch(chainsSummaryUrl).then(result => result.json())
```

For an example of a more advanced use-case, you can check out the [Talisman wallet](https://github.com/TalismanSociety/talisman/blob/898310b3761a7313ffaa5f2f747736dcb24fd455/packages/chaindata-provider-extension/src/graphql.ts) source code.
For an example of a more advanced use-case, you can check out the [Talisman wallet](https://github.com/TalismanSociety/talisman) source code.
The wallet uses chaindata to populate a database of chains and tokens which is used for features like account balance subscriptions and sending funds.

## Contributing

To make a contribution, please fork this repo and make your changes in your fork, then open a PR to merge your changes back into this repo.

### To add chain or token logos:

#### Substrate chain logos

1. Identify the chain `id` from `chaindata.json` or `testnets-chaindata.json`
1. Add your logo (in `svg` format) to `assets/chains/${id}.svg`

#### EVM chain logos

1. Identify the chain `id` from https://chainlist.org
**Use the base-10 id** (e.g. `1`, or `137`), **not** the base-16 id (e.g. `0x1`, or `0x89`)
1. Add your logo (in `svg` format) to `assets/chains/${id}.svg`

#### Token logos

1. Identify the token symbol (e.g. `KSM`)
1. Add your logo (in `svg` format) to `assets/tokens/${symbol}.svg`

### To build the github pages endpoint locally:

1. Install [pnpm](pnpm.io)
1. Clone the repo via
`git clone [email protected]:TalismanSociety/chaindata.git`
1. Install the deps via
`pnpm install`
1. Copy `.env.sample` to `.env` and fill in the variables
1. Run the build via
`pnpm build`
Loading