mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-06-09 21:21:06 +00:00
Bump deps (#315)
This commit is contained in:
+2
-2
@@ -32,8 +32,8 @@
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.9.0",
|
||||
"@babel/runtime": "^7.9.2",
|
||||
"@polkadot/dev": "^0.52.11",
|
||||
"@polkadot/ts": "^0.3.18",
|
||||
"@polkadot/dev": "^0.52.15",
|
||||
"@polkadot/ts": "^0.3.19",
|
||||
"@types/jest": "^25.2.1",
|
||||
"babel-plugin-transform-vue-template": "^0.4.2",
|
||||
"empty": "^0.10.1",
|
||||
|
||||
@@ -40,9 +40,9 @@
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.9.0",
|
||||
"@babel/runtime": "^7.9.2",
|
||||
"@polkadot/keyring": "^2.9.0-beta.1",
|
||||
"@polkadot/util": "^2.9.0-beta.1",
|
||||
"@polkadot/util-crypto": "^2.9.0-beta.1",
|
||||
"@polkadot/keyring": "^2.9.1",
|
||||
"@polkadot/util": "^2.9.1",
|
||||
"@polkadot/util-crypto": "^2.9.1",
|
||||
"@react-native-community/cli-platform-ios": "^4.7.0",
|
||||
"@types/react-test-renderer": "16.9.2",
|
||||
"babel-jest": "^25.4.0",
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
"react-is": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^2.9.0-beta.1",
|
||||
"@polkadot/util": "^2.9.0-beta.1",
|
||||
"@polkadot/util-crypto": "^2.9.0-beta.1",
|
||||
"@polkadot/keyring": "^2.9.1",
|
||||
"@polkadot/util": "^2.9.1",
|
||||
"@polkadot/util-crypto": "^2.9.1",
|
||||
"@types/react-copy-to-clipboard": "^4.3.0",
|
||||
"@types/react-dom": "^16.9.6",
|
||||
"@types/styled-components": "^5.1.0",
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"react-native": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util-crypto": "^2.9.0-beta.1",
|
||||
"@polkadot/util-crypto": "^2.9.1",
|
||||
"@types/react-native": "^0.62.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
"store": "^2.0.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^2.9.0-beta.1",
|
||||
"@polkadot/types": "^1.12.0-beta.6",
|
||||
"@polkadot/util": "^2.9.0-beta.1",
|
||||
"@polkadot/keyring": "^2.9.1",
|
||||
"@polkadot/types": "^1.13.0-beta.15",
|
||||
"@polkadot/util": "^2.9.1",
|
||||
"@types/ledgerhq__hw-transport-node-hid": "^4.22.1",
|
||||
"@types/ledgerhq__hw-transport-u2f": "^4.21.1",
|
||||
"@types/mkdirp": "^1.0.0",
|
||||
|
||||
@@ -24,42 +24,43 @@ const transports = allNode.concat(allWeb);
|
||||
// - it connects automatically, creating an app as required
|
||||
// - Promises return errors (instead of wrapper errors)
|
||||
export default class Ledger {
|
||||
private app: LedgerApp | null = null;
|
||||
private type: LedgerTypes;
|
||||
#app: LedgerApp | null = null;
|
||||
|
||||
#type: LedgerTypes;
|
||||
|
||||
constructor (type: LedgerTypes) {
|
||||
assert(['hid', 'u2f', 'webusb'].includes(type), `Unsupported transport ${type}`);
|
||||
|
||||
this.type = type;
|
||||
this.#type = type;
|
||||
}
|
||||
|
||||
private async getApp (): Promise<LedgerApp> {
|
||||
if (!this.app) {
|
||||
const def = transports.find(({ type }): boolean => type === this.type);
|
||||
private async _getApp (): Promise<LedgerApp> {
|
||||
if (!this.#app) {
|
||||
const def = transports.find(({ type }) => type === this.#type);
|
||||
|
||||
assert(def, `Unable to find a transport for ${this.type}`);
|
||||
assert(def, `Unable to find a transport for ${this.#type}`);
|
||||
|
||||
const transport = await def.create();
|
||||
|
||||
this.app = new LedgerApp(transport);
|
||||
this.#app = new LedgerApp(transport);
|
||||
}
|
||||
|
||||
return this.app;
|
||||
return this.#app;
|
||||
}
|
||||
|
||||
private async withApp <T> (fn: (app: LedgerApp) => Promise<T>): Promise<T> {
|
||||
private async _withApp <T> (fn: (app: LedgerApp) => Promise<T>): Promise<T> {
|
||||
try {
|
||||
const app = await this.getApp();
|
||||
const app = await this._getApp();
|
||||
|
||||
return await fn(app);
|
||||
} catch (error) {
|
||||
this.app = null;
|
||||
this.#app = null;
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
private async wrapError <T extends ResponseBase> (promise: Promise<T>): Promise<T> {
|
||||
private async _wrapError <T extends ResponseBase> (promise: Promise<T>): Promise<T> {
|
||||
const result = await promise;
|
||||
|
||||
assert(result.return_code === SUCCESS_CODE, result.error_message);
|
||||
@@ -68,8 +69,8 @@ export default class Ledger {
|
||||
}
|
||||
|
||||
public async getAddress (confirm = false, account = LEDGER_DEFAULT_ACCOUNT, change = LEDGER_DEFAULT_CHANGE, addressIndex = LEDGER_DEFAULT_INDEX): Promise<LedgerAddress> {
|
||||
return this.withApp(async (app: LedgerApp): Promise<LedgerAddress> => {
|
||||
const { address, pubKey } = await this.wrapError(app.getAddress(account, change, addressIndex, confirm));
|
||||
return this._withApp(async (app: LedgerApp): Promise<LedgerAddress> => {
|
||||
const { address, pubKey } = await this._wrapError(app.getAddress(account, change, addressIndex, confirm));
|
||||
|
||||
return {
|
||||
address,
|
||||
@@ -79,8 +80,8 @@ export default class Ledger {
|
||||
}
|
||||
|
||||
public async getVersion (): Promise<LedgerVersion> {
|
||||
return this.withApp(async (app: LedgerApp): Promise<LedgerVersion> => {
|
||||
const { device_locked: isLocked, major, minor, patch, test_mode: isTestMode } = await this.wrapError(app.getVersion());
|
||||
return this._withApp(async (app: LedgerApp): Promise<LedgerVersion> => {
|
||||
const { device_locked: isLocked, major, minor, patch, test_mode: isTestMode } = await this._wrapError(app.getVersion());
|
||||
|
||||
return {
|
||||
isLocked,
|
||||
@@ -91,9 +92,9 @@ export default class Ledger {
|
||||
}
|
||||
|
||||
public async sign (message: Uint8Array, account = LEDGER_DEFAULT_ACCOUNT, change = LEDGER_DEFAULT_CHANGE, addressIndex = LEDGER_DEFAULT_INDEX): Promise<LedgerSignature> {
|
||||
return this.withApp(async (app: LedgerApp): Promise<LedgerSignature> => {
|
||||
return this._withApp(async (app: LedgerApp): Promise<LedgerSignature> => {
|
||||
const buffer = u8aToBuffer(message);
|
||||
const { signature } = await this.wrapError(app.sign(account, change, addressIndex, buffer));
|
||||
const { signature } = await this._wrapError(app.sign(account, change, addressIndex, buffer));
|
||||
|
||||
return {
|
||||
signature: u8aToHex(bufferToU8a(signature))
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"store": "^2.0.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "^2.9.0-beta.1",
|
||||
"@polkadot/util": "^2.9.1",
|
||||
"@types/store": "^2.0.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
"@polkadot/util-crypto": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "^2.9.0-beta.1",
|
||||
"@polkadot/util-crypto": "^2.9.0-beta.1",
|
||||
"@polkadot/util": "^2.9.1",
|
||||
"@polkadot/util-crypto": "^2.9.1",
|
||||
"@types/color": "^3.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"vue": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util-crypto": "^2.9.0-beta.1",
|
||||
"@polkadot/util-crypto": "^2.9.1",
|
||||
"vue": "^2.6.11"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user