Add call-only chain metadata (#136)

This commit is contained in:
Jaco Greeff 2019-09-02 14:26:25 +02:00 committed by GitHub
parent c60d875e07
commit 2abe983266
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 22 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -5,25 +5,36 @@
import { Metadata } from '@polkadot/types';
// imports chain details, generally metadata. For the generation of these,
// curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "state_getMetadata", "params":[]}' http://localhost:9933
// inside the api, run `yarn chain:info [--ws <url>]`
import alexander from './alexander';
import devPolka051 from './dev-polkadot-051';
import kusama from './kusama';
interface Chain {
meta?: Metadata;
name: string;
genesisHash: string;
meta?: Metadata;
ss58Format: number;
tokenDecimals: number;
tokenSymbol: string;
}
const chains: Record<string, Chain> = {
'0xdcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b': {
name: 'Alexander',
meta: new Metadata(alexander.meta)
},
'0x3fd7b9eb6a00376e5be61f01abb429ffb0b104be05eaff4d458da48fcd425baf': {
name: 'Kusama CC1',
meta: new Metadata(kusama.meta)
}
};
type Chains = Record<string, Chain>;
const chains: Chains = [alexander, devPolka051, kusama].reduce((chains: Chains, { chain, genesisHash, metaCalls, ss58Format, tokenDecimals, tokenSymbol }): Chains => {
chains[genesisHash] = {
genesisHash,
meta: metaCalls
? new Metadata(Buffer.from(metaCalls, 'base64'))
: undefined,
name: chain,
ss58Format,
tokenDecimals,
tokenSymbol
};
return chains;
}, {});
export default function findChain (genesisHash: string): Chain | null {
return chains[genesisHash] || null;

File diff suppressed because one or more lines are too long