Skip to content

Commit

Permalink
wip: github publish ci
Browse files Browse the repository at this point in the history
  • Loading branch information
alecdwm committed Sep 25, 2023
1 parent da44ce9 commit ed82e8a
Show file tree
Hide file tree
Showing 19 changed files with 337 additions and 7,290 deletions.
2 changes: 0 additions & 2 deletions .gitattributes

This file was deleted.

51 changes: 51 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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 Bun
uses: oven-sh/setup-bun@v1
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build chaindata
run: bun run 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
13 changes: 5 additions & 8 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,11 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
- name: Setup Bun
uses: oven-sh/setup-bun@v1
- name: Install dependencies
run: yarn --immutable
run: bun 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: bun run validate
18 changes: 3 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

.DS_Store
*.pem
.DS_Store
dist
node_modules

.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*
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 make this request to get the names, [genesisHashes](## 'the hash of the first block on the chain') and [address type prefixes](https://wiki.polkadot.network/docs/learn-account-advanced#address-format) for all chains:

```graphql
query {
chains {
genesisHash
prefix
name
}
}
```ts
const chains = await(
await fetch(`https://talismansociety.github.io/chaindata/chains.json`)
).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 [bun](bun.sh)
1. Clone the repo via
`git clone [email protected]:TalismanSociety/chaindata.git`
1. Install the deps via
`bun install`
1. Run the build via
`bun run build`
Binary file added bun.lockb
Binary file not shown.
Loading

0 comments on commit ed82e8a

Please sign in to comment.