Add contracts to ui-keyring (#137)

* add contracts to keyring

* genesisHash

* requested changes + allPlus option type

* remove duplicate fn

* add contracts to keyring

* genesisHash

* requested changes + allPlus option type

* remove duplicate fn

* changes

* contract key

* prefixes
This commit is contained in:
kwingram25
2019-06-06 13:57:07 +02:00
committed by Jaco Greeff
parent 091ab41242
commit bdfbb69946
8 changed files with 151 additions and 17 deletions
+10 -2
View File
@@ -7,6 +7,7 @@ import { decodeAddress } from '@polkadot/keyring';
const ACCOUNT_PREFIX = 'account:';
const ADDRESS_PREFIX = 'address:';
const CONTRACT_PREFIX = 'contract:';
const MAX_PASS_LEN = 32;
function toHex (address: string): string {
@@ -22,14 +23,21 @@ const accountKey = (address: string): string =>
const addressKey = (address: string): string =>
`${ADDRESS_PREFIX}${toHex(address)}`;
const accountRegex = new RegExp(`^${ACCOUNT_PREFIX}`, '');
const contractKey = (address: string): string =>
`${CONTRACT_PREFIX}${toHex(address)}`;
const addressRegex = new RegExp(`^${ADDRESS_PREFIX}`, '');
const accountRegex = new RegExp(`^${ACCOUNT_PREFIX}0x[0-9a-f]*`, '');
const addressRegex = new RegExp(`^${ADDRESS_PREFIX}0x[0-9a-f]*`, '');
const contractRegex = new RegExp(`^${CONTRACT_PREFIX}0x[0-9a-f]*`, '');
export {
accountKey,
accountRegex,
addressKey,
addressRegex,
contractKey,
contractRegex,
MAX_PASS_LEN
};