mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-05-31 14:31:03 +00:00
keyringOption expose
This commit is contained in:
@@ -15,7 +15,7 @@ import { base64Decode, createKeyMulti } from '@polkadot/util-crypto';
|
|||||||
import env from './observable/development';
|
import env from './observable/development';
|
||||||
import Base from './Base';
|
import Base from './Base';
|
||||||
import { accountKey, addressKey, accountRegex, addressRegex, contractKey, contractRegex } from './defaults';
|
import { accountKey, addressKey, accountRegex, addressRegex, contractKey, contractRegex } from './defaults';
|
||||||
import { KeyringOption } from './options';
|
import keyringOption from './options';
|
||||||
|
|
||||||
const RECENT_EXPIRY = 24 * 60 * 60;
|
const RECENT_EXPIRY = 24 * 60 * 60;
|
||||||
|
|
||||||
@@ -23,8 +23,6 @@ const RECENT_EXPIRY = 24 * 60 * 60;
|
|||||||
// Chain determination occurs outside of Keyring. Loading `keyring.loadAll({ type: 'ed25519' | 'sr25519' })` is triggered
|
// Chain determination occurs outside of Keyring. Loading `keyring.loadAll({ type: 'ed25519' | 'sr25519' })` is triggered
|
||||||
// from the API after the chain is received
|
// from the API after the chain is received
|
||||||
export class Keyring extends Base implements KeyringStruct {
|
export class Keyring extends Base implements KeyringStruct {
|
||||||
#keyringOption = new KeyringOption();
|
|
||||||
|
|
||||||
#stores = {
|
#stores = {
|
||||||
account: (): AddressSubject => this.accounts,
|
account: (): AddressSubject => this.accounts,
|
||||||
address: (): AddressSubject => this.addresses,
|
address: (): AddressSubject => this.addresses,
|
||||||
@@ -279,7 +277,7 @@ export class Keyring extends Base implements KeyringStruct {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.#keyringOption.init(this);
|
keyringOption.init(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public restoreAccount (json: KeyringPair$Json, password: string): KeyringPair {
|
public restoreAccount (json: KeyringPair$Json, password: string): KeyringPair {
|
||||||
|
|||||||
@@ -2,20 +2,18 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import { KeyringStruct } from '../types';
|
import { KeyringStruct } from '../types';
|
||||||
import { KeyringOption } from '.';
|
import keyringOption from '.';
|
||||||
|
|
||||||
const keyringOptionInstance = new KeyringOption();
|
|
||||||
|
|
||||||
describe('KeyringOption', (): void => {
|
describe('KeyringOption', (): void => {
|
||||||
it('should not allow initOptions to be called more than once', (): void => {
|
it('should not allow initOptions to be called more than once', (): void => {
|
||||||
const state: Partial<KeyringStruct> = {};
|
const state: Partial<KeyringStruct> = {};
|
||||||
|
|
||||||
// first call
|
// first call
|
||||||
keyringOptionInstance.init(state as KeyringStruct);
|
keyringOption.init(state as KeyringStruct);
|
||||||
|
|
||||||
// second call
|
// second call
|
||||||
expect((): void => {
|
expect((): void => {
|
||||||
keyringOptionInstance.init(state as KeyringStruct);
|
keyringOption.init(state as KeyringStruct);
|
||||||
}).toThrowError('Unable to initialise options more than once');
|
}).toThrowError('Unable to initialise options more than once');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -138,3 +138,7 @@ export class KeyringOption implements KeyringOptionInstance {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const keyringOption = new KeyringOption();
|
||||||
|
|
||||||
|
export default keyringOption;
|
||||||
|
|||||||
Reference in New Issue
Block a user