Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
itsyogesh committed Apr 20, 2023
0 parents commit ee869a8
Show file tree
Hide file tree
Showing 18 changed files with 769 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module",
"project": ["./tsconfig.json"]
},
"plugins": ["@typescript-eslint", "import"],
"extends": [
"eslint:recommended",
"plugin:eslint-comments/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:prettier/recommended",
"prettier"
],
"rules": {
// `@typescript-eslint`
// https://github.com/typescript-eslint/typescript-eslint
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": [
2,
{
"argsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_",
"destructuredArrayIgnorePattern": "^_",
"ignoreRestSiblings": true
}
],
"@typescript-eslint/no-var-requires": "off",
"import/no-named-as-default-member": "off",
// `eslint-plugin-import`
// https://github.com/benmosher/eslint-plugin-import
"import/order": [
"error",
{
"groups": ["external", "internal"],
"newlines-between": "always-and-inside-groups",
"alphabetize": {
"order": "asc"
}
}
],
"sort-imports": [
"warn",
{
"ignoreCase": false,
"ignoreDeclarationSort": true,
"ignoreMemberSort": false
}
]
},
"ignorePatterns": ["CHANGELOG.md", "build", "dist", "node_modules"],
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx", ".d.ts"]
},
"import/resolver": {
"typescript": {
"alwaysTryTypes": true
}
}
},
"env": {
"es6": true,
"browser": true,
"node": true
}
}
20 changes: 20 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: release

on:
release:
types: [created]

jobs:
publish-github-registry:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16.x
registry-url: https://npm.pkg.github.com/
- run: yarn install
- run: yarn build
- run: yarn publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.local
.DS_Store
.eslintcache
.env
.next
.yarn-debug.log*
cache
coverage
dist
node_modules
tsconfig.tsbuildinfo
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023–PRESENT Droidsize Technologies Pvt. Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# `@zigzag/chains`

A reference list for all popular Dotsama relay/parachains.

## Installation

Install the `@zigzag/chains` package.

```
npm i @zigzag/chains
```

## Usage

Import all the chain details you can use.

```tsx
import { polkadot } from '@zigzag/chains'
import { encodeAddress } from '@polkadot/keyring'
import { ApiPromise, WsProvider } from '@polkadot/api'

const provider = new WsProvider(polkadot.rpc)
const api = await ApiPromise.create({ provider })

const address = encodeAddress('0x1234567890123456789012345678901234567890', polkadot.prefix)

```

> If your bundler supports tree-shaking (most likely), only the used chains will be included in the bundle, so you don't have to worry about bundle size. 😊
## Chains

- Polkadot [x]rpc [x]explorer
- Kusama [x]rpc [x]explorer
- Acala [x]rpc [x]explorer
- Astar [x]rpc [x]explorer
- Crust Network [x]rpc [x]explorer

More chains coming soon...

## Contributing

Want to add another chain to the list? Make sure you read the [contributing guide](./CONTRIBUTING.md) first.
Empty file added docs/usage.md
Empty file.
46 changes: 46 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "@zigzag/chains",
"version": "0.1.0",
"description": "A quick way to get details for all the chains in the Dotsama ecosystem.",
"main": "dist/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/zigzag-js/chains.git"
},
"bugs": {
"url": "https://github.com/zigzag-js/chains/issues"
},
"homepage": "https://github.com/zigzag-js/chains#readme",
"author": "https://github.com/itsyogesh",
"license": "MIT",
"private": true,

"scripts": {
"build": "rollup -c",
"build:types": "tsc --emitDeclarationOnly",
"build:clean": "rm -rf dist",
"build:clean:all": "npm run build:clean && npm run build:types:clean",
"build:types:clean": "rm -rf types",
"build:types:watch": "tsc --emitDeclarationOnly --watch",
"build:watch": "rollup -c -w"
},

"type": "module",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs",
"default": "./dist/index.cjs"
},
"./package.json": "./package.json"
},

"devDependencies": {
"@types/node": "^18.15.12",
"esbuild": "^0.17.17",
"rollup": "^3.20.6",
"rollup-plugin-dts": "^5.3.0",
"rollup-plugin-esbuild": "^5.0.0",
"typescript": "^5.0.4"
}
}
33 changes: 33 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import dts from "rollup-plugin-dts";
import esbuild from "rollup-plugin-esbuild";

const bundle = (config) => ({
...config,
input: "src/index.ts",
external: (id) => !/^[./]/.test(id),
});

export default [
bundle({
plugins: [esbuild()],
output: [
{
file: 'dist/index.js',
format: "cjs",
sourcemap: true,
},
{
file: 'dist/index.esm.js',
format: "es",
sourcemap: true,
},
],
}),
bundle({
plugins: [dts()],
output: {
file: "dist/index.d.ts",
format: "es",
},
}),
];
35 changes: 35 additions & 0 deletions src/chains/astar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Chain } from "../types/chain";

export const astar: Chain = {
id: 5,
name: "Astar",
network: "astar",
para_id: 2006,
relay: false,
relay_chain: "polkadot",
prefix: 5,
account_sign_type: "sr25519",
currency: {
name: "Astar",
symbol: "ASTR",
decimals: 18,
},
website: "https://astar.network",
rpc: {
default: "wss://rpc.astar.network",
automata_1rpc: "wss://1rpc.io/astr",
blast: "wss://astar.public.blastapi.io",
dwellir: "wss://astar-rpc.dwellir.com",
onfinality: "wss://astar.api.onfinality.io/public-ws",
radiumblock: "wss://astar.public.curie.radiumblock.co/ws",
},
light: {
default: "light://substrate-connect/astar",
},
block_explorers: {
default: {
name: "AstarScan",
url: "https://astar.network",
},
},
};
36 changes: 36 additions & 0 deletions src/chains/kusama.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Chain } from "../types/chain";

export const kusama: Chain = {
id: 2,
name: "Kusama",
network: "kusama",
relay: true,
prefix: 2,
account_sign_type: "sr25519",
website: "https://kusama.network/",
currency: {
name: "Kusama",
symbol: "KSM",
decimals: 12,
},
rpc: {
default: "wss://kusama-rpc.polkadot.io",
automata_1rpc: "wss://1rpc.io/ksm",
dwellir: "wss://kusama-rpc.dwellir.com",
dwellir_tunisia: "wss://kusama-rpc-tn.dwellir.com",
ibp_geodns1: "wss://rpc.ibp.network/kusama",
ibp_geodns2: "wss://rpc.dotters.network/kusama",
onfinality: "wss://kusama.api.onfinality.io/public-ws",
parity: "wss://kusama-rpc.polkadot.io",
radiumblock: "wss://kusama.public.curie.radiumblock.co/ws",
},
light: {
default: "light://substrate-connect/kusama",
},
block_explorers: {
default: {
name: "Polkascan",
url: "https://polkascan.io/kusama",
},
},
};
48 changes: 48 additions & 0 deletions src/chains/polkadot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Chain } from "../types/chain";

export const polkadot: Chain = {
id: 0,
name: "Polkadot",
network: "polkadot",
relay: true,
prefix: 0,
account_sign_type: "sr25519",
website: "https://polkadot.network/",
currency: {
name: "Polkadot",
symbol: "DOT",
decimals: 10,
},
rpc: {
default: "wss://rpc.polkadot.io",
automata_1rpc: "wss://1rpc.io/dot",
dwellir: "wss://polkadot-rpc.dwellir.com",
dwellir_tunisia: "wss://polkadot-rpc-tn.dwellir.com",
ibp_geodns1: "wss://rpc.ibp.network/polkadot",
ibp_geodns2: "wss://rpc.dotters.network/polkadot",
onfinality: "wss://polkadot.api.onfinality.io/public-ws",
parity: "wss://rpc.polkadot.io",
radiumblock: "wss://polkadot.public.curie.radiumblock.co/ws",
},
light: {
default: "light://substrate-connect/polkadot",
},
block_explorers: {
default: {
name: "Polkascan",
url: "https://polkascan.io/polkadot",
},
},
};

/*
'Automata 1RPC': 'wss://1rpc.io/dot',
Dwellir: 'wss://polkadot-rpc.dwellir.com',
'Dwellir Tunisia': 'wss://polkadot-rpc-tn.dwellir.com',
'IBP-GeoDNS1': 'wss://rpc.ibp.network/polkadot',
'IBP-GeoDNS2': 'wss://rpc.dotters.network/polkadot',
OnFinality: 'wss://polkadot.api.onfinality.io/public-ws',
Parity: 'wss://rpc.polkadot.io',
RadiumBlock: 'wss://polkadot.public.curie.radiumblock.co/ws',
'light client': 'light://substrate-connect/polkadot'
*/
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from "./types/chain";

export { polkadot } from "./chains/polkadot";
export { kusama } from "./chains/kusama";
export { astar } from "./chains/astar";
6 changes: 6 additions & 0 deletions src/types/block-explorer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type BlockExplorer = {
name: string;
url: string;
};

export default BlockExplorer;
Loading

0 comments on commit ee869a8

Please sign in to comment.