mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-05-31 08:41:03 +00:00
Pass KeyringStore to observables (#128)
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^0.91.0-beta.1",
|
||||
"@polkadot/types": "^0.79.0-beta.6",
|
||||
"@polkadot/types": "^0.79.0-beta.31",
|
||||
"@polkadot/util": "^0.91.0-beta.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -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>
|
||||
};
|
||||
|
||||
@@ -1854,7 +1854,7 @@
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/ts/-/ts-0.1.56.tgz#ffd6e9c95704a7fb90b918193b9dc5c440114b27"
|
||||
integrity sha512-wnt4zXxZXyz6WaubTO/I+nUElwV2DogFzdl6CrKfVn2PTWp8uHN06W9s40FH57ORtmQfDr9rLRP8Nq+oIyElbg==
|
||||
|
||||
"@polkadot/types@^0.79.0-beta.31", "@polkadot/types@^0.79.0-beta.6":
|
||||
"@polkadot/types@^0.79.0-beta.31":
|
||||
version "0.79.0-beta.31"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-0.79.0-beta.31.tgz#3e66dec097653a17386f687a70a86bc2520894ea"
|
||||
integrity sha512-ibVRBIirFCUYSQsMFBLSNGl0hp86tWM2RXnx3MDT5WiX4qGUOEy5aKTFU+hCDC8NhHa5+oNw8EeIDZ3waRI/4g==
|
||||
|
||||
Reference in New Issue
Block a user