mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-06-14 05:41:01 +00:00
JSON v3 (#348)
This commit is contained in:
@@ -25,9 +25,9 @@
|
||||
"store": "^2.0.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^2.18.1",
|
||||
"@polkadot/types": "^1.25.1",
|
||||
"@polkadot/util": "^2.18.1",
|
||||
"@polkadot/keyring": "^3.0.0-beta.2",
|
||||
"@polkadot/types": "^1.26.0-beta.1",
|
||||
"@polkadot/util": "^3.0.0-beta.2",
|
||||
"@types/ledgerhq__hw-transport-node-hid": "^4.22.1",
|
||||
"@types/ledgerhq__hw-transport-webusb": "^4.70.0",
|
||||
"@types/mkdirp": "^1.0.1",
|
||||
|
||||
@@ -11,7 +11,7 @@ import BN from 'bn.js';
|
||||
import createPair from '@polkadot/keyring/pair';
|
||||
import chains from '@polkadot/ui-settings/defaults/chains';
|
||||
import { bnToBn, hexToU8a, isHex, isString, u8aSorted } from '@polkadot/util';
|
||||
import { createKeyMulti } from '@polkadot/util-crypto';
|
||||
import { base64Decode, createKeyMulti } from '@polkadot/util-crypto';
|
||||
|
||||
import env from './observable/development';
|
||||
import Base from './Base';
|
||||
@@ -273,12 +273,14 @@ export class Keyring extends Base implements KeyringStruct {
|
||||
}
|
||||
|
||||
public restoreAccount (json: KeyringPair$Json, password: string): KeyringPair {
|
||||
const type = Array.isArray(json.encoding.content) ? json.encoding.content[1] : 'ed25519';
|
||||
const cryptoType = Array.isArray(json.encoding.content) ? json.encoding.content[1] : 'ed25519';
|
||||
const encType = Array.isArray(json.encoding.type) ? json.encoding.type : [json.encoding.type];
|
||||
const pair = createPair(
|
||||
{ toSS58: this.encodeAddress, type },
|
||||
{ toSS58: this.encodeAddress, type: cryptoType },
|
||||
{ publicKey: this.decodeAddress(json.address, true) },
|
||||
json.meta,
|
||||
hexToU8a(json.encoded)
|
||||
isHex(json.encoded) ? hexToU8a(json.encoded) : base64Decode(json.encoded),
|
||||
encType
|
||||
);
|
||||
|
||||
// unlock, save account and then lock (locking cleans secretKey, so needs to be last)
|
||||
|
||||
Reference in New Issue
Block a user