mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-05-31 18:01:04 +00:00
Add chain genesis, lookups for toggle (#247)
This commit is contained in:
@@ -8,6 +8,7 @@ import { AddressSubject, SingleAddress } from './observable/types';
|
||||
import { CreateResult, KeyringAddress, KeyringAddressType, KeyringItemType, KeyringJson, KeyringJson$Meta, KeyringOptions, KeyringStruct } from './types';
|
||||
|
||||
import createPair from '@polkadot/keyring/pair';
|
||||
import chains from '@polkadot/ui-settings/defaults/chains';
|
||||
import { hexToU8a, isHex, isString } from '@polkadot/util';
|
||||
|
||||
import env from './observable/development';
|
||||
@@ -219,10 +220,14 @@ export class Keyring extends Base implements KeyringStruct {
|
||||
|
||||
private allowGenesis (json?: KeyringJson | { meta: KeyringJson$Meta } | null): boolean {
|
||||
if (json && json.meta && this.genesisHash) {
|
||||
const hashes: (string | null | undefined)[] = Object.values(chains).find((hashes): boolean =>
|
||||
hashes.includes(this.genesisHash || '')
|
||||
) || [this.genesisHash];
|
||||
|
||||
if (json.meta.genesisHash) {
|
||||
return this.genesisHash === json.meta.genesisHash;
|
||||
return hashes.includes(json.meta.genesisHash);
|
||||
} else if (json.meta.contract) {
|
||||
return this.genesisHash === json.meta.contract.genesisHash;
|
||||
return hashes.includes(json.meta.contract.genesisHash);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright 2017-2019 @polkadot/ui-settings authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
type ChainDef = string[];
|
||||
|
||||
const chains: Record<string, ChainDef> = {
|
||||
kusama: [
|
||||
'0x3fd7b9eb6a00376e5be61f01abb429ffb0b104be05eaff4d458da48fcd425baf', // Kusama CC1
|
||||
'0xe3777fa922cafbff200cadeaea1a76bd7898ad5b89f7848999058b50e715f636', // Kusama CC2
|
||||
'0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe' // Kusama CC3
|
||||
]
|
||||
};
|
||||
|
||||
export default chains;
|
||||
Reference in New Issue
Block a user