mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-05-31 19:11:04 +00:00
Pass KeyringStore to observables (#128)
This commit is contained in:
@@ -105,7 +105,7 @@ export default class Base {
|
||||
.forEach((pair: KeyringPair) => {
|
||||
const address = pair.address();
|
||||
|
||||
this.accounts.add(address, {
|
||||
this.accounts.add(this._store, address, {
|
||||
address,
|
||||
meta: pair.getMeta()
|
||||
});
|
||||
|
||||
@@ -89,16 +89,16 @@ export class Keyring extends Base implements KeyringStruct {
|
||||
json.meta.whenEdited = Date.now();
|
||||
|
||||
this.keyring.addFromJson(json);
|
||||
this.accounts.add(json.address, json);
|
||||
this.accounts.add(this._store, json.address, json);
|
||||
}
|
||||
|
||||
forgetAccount (address: string): void {
|
||||
this.keyring.removePair(address);
|
||||
this.accounts.remove(address);
|
||||
this.accounts.remove(this._store, address);
|
||||
}
|
||||
|
||||
forgetAddress (address: string): void {
|
||||
this.addresses.remove(address);
|
||||
this.addresses.remove(this._store, address);
|
||||
}
|
||||
|
||||
getAccount (address: string | Uint8Array): KeyringAddress {
|
||||
@@ -157,7 +157,7 @@ export class Keyring extends Base implements KeyringStruct {
|
||||
// FIXME Just for the transition period (ignoreChecksum)
|
||||
const pair = this.keyring.addFromJson(json as KeyringPair$Json, true);
|
||||
|
||||
this.accounts.add(pair.address(), json);
|
||||
this.accounts.add(this._store, pair.address(), json);
|
||||
}
|
||||
|
||||
const [, hexAddr] = key.split(':');
|
||||
@@ -181,7 +181,7 @@ export class Keyring extends Base implements KeyringStruct {
|
||||
);
|
||||
const [, hexAddr] = key.split(':');
|
||||
|
||||
this.addresses.add(address, json);
|
||||
this.addresses.add(this._store, address, json);
|
||||
this.rewriteKey(json, key, hexAddr, addressKey);
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ export class Keyring extends Base implements KeyringStruct {
|
||||
const json = pair.toJson(password);
|
||||
|
||||
this.keyring.addFromJson(json);
|
||||
this.accounts.add(json.address, json);
|
||||
this.accounts.add(this._store, json.address, json);
|
||||
|
||||
return json;
|
||||
}
|
||||
@@ -237,7 +237,7 @@ export class Keyring extends Base implements KeyringStruct {
|
||||
pair.setMeta(meta);
|
||||
json.meta = pair.getMeta();
|
||||
|
||||
this.accounts.add(json.address, json);
|
||||
this.accounts.add(this._store, json.address, json);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ export class Keyring extends Base implements KeyringStruct {
|
||||
|
||||
delete json.meta.isRecent;
|
||||
|
||||
this.addresses.add(address, json);
|
||||
this.addresses.add(this._store, address, json);
|
||||
|
||||
return json as KeyringPair$Json;
|
||||
}
|
||||
@@ -275,7 +275,7 @@ export class Keyring extends Base implements KeyringStruct {
|
||||
}
|
||||
};
|
||||
|
||||
this.addresses.add(address, (json as KeyringJson));
|
||||
this.addresses.add(this._store, address, (json as KeyringJson));
|
||||
}
|
||||
|
||||
return this.addresses.subject.getValue()[address];
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { SubjectInfo, AddressSubject, SingleAddress } from './types';
|
||||
import { KeyringJson } from '../types';
|
||||
import { KeyringJson, KeyringStore } from '../types';
|
||||
|
||||
import store from 'store';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
|
||||
import createOptionItem from '../options/item';
|
||||
import development from './development';
|
||||
@@ -36,7 +35,7 @@ export default function genericSubject (keyCreator: (address: string) => string,
|
||||
development.subject.subscribe(next);
|
||||
|
||||
return {
|
||||
add: (address: string, json: KeyringJson): SingleAddress => {
|
||||
add: (store: KeyringStore, address: string, json: KeyringJson): SingleAddress => {
|
||||
current = { ...current };
|
||||
|
||||
current[address] = {
|
||||
@@ -49,7 +48,7 @@ export default function genericSubject (keyCreator: (address: string) => string,
|
||||
|
||||
return current[address];
|
||||
},
|
||||
remove: (address: string) => {
|
||||
remove: (store: KeyringStore, address: string) => {
|
||||
current = { ...current };
|
||||
|
||||
delete current[address];
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { KeyringSectionOption } from '../options/types';
|
||||
import { KeyringJson } from '../types';
|
||||
import { KeyringJson, KeyringStore } from '../types';
|
||||
|
||||
export type SingleAddress = {
|
||||
json: KeyringJson,
|
||||
@@ -16,7 +16,7 @@ export type SubjectInfo = {
|
||||
};
|
||||
|
||||
export type AddressSubject = {
|
||||
add: (address: string, json: KeyringJson) => SingleAddress,
|
||||
remove: (address: string) => void,
|
||||
add: (store: KeyringStore, address: string, json: KeyringJson) => SingleAddress,
|
||||
remove: (store: KeyringStore, address: string) => void,
|
||||
subject: BehaviorSubject<SubjectInfo>
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user