mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-05-31 08:41:03 +00:00
Add externally injected accounts (not from store) (#129)
This commit is contained in:
@@ -185,7 +185,20 @@ export class Keyring extends Base implements KeyringStruct {
|
||||
this.rewriteKey(json, key, hexAddr, addressKey);
|
||||
}
|
||||
|
||||
loadAll (options: KeyringOptions): void {
|
||||
private loadInjected (address: string, name: string) {
|
||||
const json = {
|
||||
address,
|
||||
meta: {
|
||||
isInjected: true,
|
||||
name
|
||||
}
|
||||
};
|
||||
const pair = this.keyring.addFromAddress(address, json.meta);
|
||||
|
||||
this.accounts.add(this._store, pair.address(), json);
|
||||
}
|
||||
|
||||
loadAll (options: KeyringOptions, injected: Array<{ address: string, name: string }> = []): void {
|
||||
super.initKeyring(options);
|
||||
|
||||
this._store.all((key: string, json: KeyringJson) => {
|
||||
@@ -196,6 +209,10 @@ export class Keyring extends Base implements KeyringStruct {
|
||||
}
|
||||
});
|
||||
|
||||
injected.forEach(({ address, name }) =>
|
||||
this.loadInjected(address, name)
|
||||
);
|
||||
|
||||
keyringOption.init(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,12 @@ export default function genericSubject (keyCreator: (address: string) => string,
|
||||
option: createOptionItem(address, json.meta.name, !json.meta.isRecent)
|
||||
};
|
||||
|
||||
store.set(keyCreator(address), json);
|
||||
const isDevMode = development.isDevelopment();
|
||||
|
||||
if (!json.meta.isInjected && (!json.meta.isTesting || isDevMode)) {
|
||||
store.set(keyCreator(address), json);
|
||||
}
|
||||
|
||||
next();
|
||||
|
||||
return current[address];
|
||||
|
||||
@@ -19,6 +19,7 @@ export type KeyringOptions = KeyringOptionsBase & {
|
||||
};
|
||||
|
||||
export type KeyringJson$Meta = {
|
||||
isInjected?: boolean,
|
||||
isRecent?: boolean,
|
||||
isTesting?: boolean,
|
||||
name?: string,
|
||||
|
||||
Reference in New Issue
Block a user