mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-05-31 11:01: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);
|
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);
|
super.initKeyring(options);
|
||||||
|
|
||||||
this._store.all((key: string, json: KeyringJson) => {
|
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);
|
keyringOption.init(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,12 @@ export default function genericSubject (keyCreator: (address: string) => string,
|
|||||||
option: createOptionItem(address, json.meta.name, !json.meta.isRecent)
|
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();
|
next();
|
||||||
|
|
||||||
return current[address];
|
return current[address];
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export type KeyringOptions = KeyringOptionsBase & {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type KeyringJson$Meta = {
|
export type KeyringJson$Meta = {
|
||||||
|
isInjected?: boolean,
|
||||||
isRecent?: boolean,
|
isRecent?: boolean,
|
||||||
isTesting?: boolean,
|
isTesting?: boolean,
|
||||||
name?: string,
|
name?: string,
|
||||||
|
|||||||
Reference in New Issue
Block a user