diff --git a/packages/react-components/package.json b/packages/react-components/package.json
index ef7d837817..313e21eb4f 100644
--- a/packages/react-components/package.json
+++ b/packages/react-components/package.json
@@ -14,11 +14,11 @@
"@fortawesome/react-fontawesome": "^0.1.14",
"@polkadot/keyring": "^5.3.1",
"@polkadot/react-api": "^0.76.2-1",
- "@polkadot/react-identicon": "^0.66.3",
- "@polkadot/react-qr": "^0.66.3",
+ "@polkadot/react-identicon": "^0.66.4-0",
+ "@polkadot/react-qr": "^0.66.4-0",
"@polkadot/react-query": "^0.76.2-1",
- "@polkadot/ui-keyring": "^0.66.3",
- "@polkadot/ui-settings": "^0.66.3",
+ "@polkadot/ui-keyring": "^0.66.4-0",
+ "@polkadot/ui-settings": "^0.66.4-0",
"@polkadot/util": "^5.3.1",
"@polkadot/util-crypto": "^5.3.1",
"chart.js": "^2.9.4",
diff --git a/packages/react-signer/src/Address.tsx b/packages/react-signer/src/Address.tsx
index a8a4d2fa69..51a1e2c9ae 100644
--- a/packages/react-signer/src/Address.tsx
+++ b/packages/react-signer/src/Address.tsx
@@ -11,7 +11,7 @@ import type { AddressFlags, AddressProxy } from './types';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { ApiPromise } from '@polkadot/api';
-import { InputAddress, Modal, Toggle } from '@polkadot/react-components';
+import { InputAddress, MarkError, Modal, Toggle } from '@polkadot/react-components';
import { useAccounts, useApi, useIsMountedRef } from '@polkadot/react-hooks';
import { isFunction } from '@polkadot/util';
@@ -267,6 +267,13 @@ function Address ({ currentItem, onChange, onEnter, passwordError, requestAddres
onEnter={onEnter}
/>
)}
+ {passwordError && (
+
+
+
+
+
+ )}
{proxyInfo && (
diff --git a/packages/react-signer/src/TxSigned.tsx b/packages/react-signer/src/TxSigned.tsx
index 527f1d9a82..b49e9cf0eb 100644
--- a/packages/react-signer/src/TxSigned.tsx
+++ b/packages/react-signer/src/TxSigned.tsx
@@ -211,16 +211,31 @@ function TxSigned ({ className, currentItem, requestAddress }: Props): React.Rea
);
const _unlock = useCallback(
- (): boolean => {
- const passwordError = senderInfo.signAddress && flags.isUnlockable
- ? unlockAccount(senderInfo)
- : null;
+ async (): Promise => {
+ let passwordError: string | null = null;
+
+ if (senderInfo.signAddress) {
+ if (flags.isUnlockable) {
+ passwordError = unlockAccount(senderInfo);
+ } else if (flags.isHardware) {
+ try {
+ const ledger = getLedger();
+ const { address } = await ledger.getAddress(false, flags.accountOffset, flags.addressOffset);
+
+ console.log(`Signing with Ledger address ${address}`);
+ } catch (error) {
+ console.error(error);
+
+ passwordError = t('Unable to connect the the Ledger. {{error}}', { replace: { error: (error as Error).message } });
+ }
+ }
+ }
setPasswordError(passwordError);
return !passwordError;
},
- [flags, senderInfo]
+ [flags, getLedger, senderInfo, t]
);
const _onSendPayload = useCallback(
@@ -274,23 +289,26 @@ function TxSigned ({ className, currentItem, requestAddress }: Props): React.Rea
setTimeout((): void => {
const errorHandler = (error: Error): void => {
console.error(error);
+
setBusy(false);
setError(error);
};
- try {
- if (_unlock()) {
- isSubmit
- ? currentItem.payload
- ? _onSendPayload(queueSetTxStatus, currentItem, senderInfo)
- : _onSend(queueSetTxStatus, currentItem, senderInfo).catch(errorHandler)
- : _onSign(queueSetTxStatus, currentItem, senderInfo).catch(errorHandler);
- } else {
- setBusy(false);
- }
- } catch (error) {
- errorHandler(error as Error);
- }
+ _unlock()
+ .then((isUnlocked): void => {
+ if (isUnlocked) {
+ isSubmit
+ ? currentItem.payload
+ ? _onSendPayload(queueSetTxStatus, currentItem, senderInfo)
+ : _onSend(queueSetTxStatus, currentItem, senderInfo).catch(errorHandler)
+ : _onSign(queueSetTxStatus, currentItem, senderInfo).catch(errorHandler);
+ } else {
+ setBusy(false);
+ }
+ })
+ .catch((error): void => {
+ errorHandler(error as Error);
+ });
}, 0);
},
[_onSend, _onSendPayload, _onSign, _unlock, currentItem, isSubmit, queueSetTxStatus, senderInfo]
diff --git a/packages/react-signer/src/types.ts b/packages/react-signer/src/types.ts
index 60d6e669af..adafcd67cb 100644
--- a/packages/react-signer/src/types.ts
+++ b/packages/react-signer/src/types.ts
@@ -4,6 +4,8 @@
import type { SignerResult } from '@polkadot/api/types';
export interface AddressFlags {
+ accountOffset: number;
+ addressOffset: number;
hardwareType?: string;
isHardware: boolean;
isMultisig: boolean;
diff --git a/packages/react-signer/src/util.ts b/packages/react-signer/src/util.ts
index cbb45d5c7b..863a11a1be 100644
--- a/packages/react-signer/src/util.ts
+++ b/packages/react-signer/src/util.ts
@@ -9,6 +9,7 @@ import { SubmittableResult } from '@polkadot/api';
import { keyring } from '@polkadot/ui-keyring';
const NOOP = () => undefined;
+const NO_FLAGS = { accountOffset: 0, addressOffset: 0, isHardware: false, isMultisig: false, isProxied: false, isQr: false, isUnlockable: false, threshold: 0, who: [] };
export const UNLOCK_MINS = 15;
@@ -28,7 +29,7 @@ export function lockAccount (pair: KeyringPair): void {
export function extractExternal (accountId: string | null): AddressFlags {
if (!accountId) {
- return { isHardware: false, isMultisig: false, isProxied: false, isQr: false, isUnlockable: false, threshold: 0, who: [] };
+ return NO_FLAGS;
}
let publicKey;
@@ -38,7 +39,7 @@ export function extractExternal (accountId: string | null): AddressFlags {
} catch (error) {
console.error(error);
- return { isHardware: false, isMultisig: false, isProxied: false, isQr: false, isUnlockable: false, threshold: 0, who: [] };
+ return NO_FLAGS;
}
const pair = keyring.getPair(publicKey);
@@ -54,6 +55,8 @@ export function extractExternal (accountId: string | null): AddressFlags {
}
return {
+ accountOffset: pair.meta.accountOffset as number || 0,
+ addressOffset: pair.meta.addressOffset as number || 0,
hardwareType: pair.meta.hardwareType as string,
isHardware: !!pair.meta.isHardware,
isMultisig: !!pair.meta.isMultisig,
diff --git a/yarn.lock b/yarn.lock
index bf0fc5d5d6..603e33827d 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2471,11 +2471,11 @@ __metadata:
"@fortawesome/react-fontawesome": ^0.1.14
"@polkadot/keyring": ^5.3.1
"@polkadot/react-api": ^0.76.2-1
- "@polkadot/react-identicon": ^0.66.3
- "@polkadot/react-qr": ^0.66.3
+ "@polkadot/react-identicon": ^0.66.4-0
+ "@polkadot/react-qr": ^0.66.4-0
"@polkadot/react-query": ^0.76.2-1
- "@polkadot/ui-keyring": ^0.66.3
- "@polkadot/ui-settings": ^0.66.3
+ "@polkadot/ui-keyring": ^0.66.4-0
+ "@polkadot/ui-settings": ^0.66.4-0
"@polkadot/util": ^5.3.1
"@polkadot/util-crypto": ^5.3.1
"@types/codeflask": ^1.4.2
@@ -2512,14 +2512,14 @@ __metadata:
languageName: unknown
linkType: soft
-"@polkadot/react-identicon@npm:^0.66.3":
- version: 0.66.3
- resolution: "@polkadot/react-identicon@npm:0.66.3"
+"@polkadot/react-identicon@npm:^0.66.4-0":
+ version: 0.66.4-0
+ resolution: "@polkadot/react-identicon@npm:0.66.4-0"
dependencies:
"@babel/runtime": ^7.12.5
"@polkadot/keyring": ^5.3.1
- "@polkadot/ui-settings": 0.66.3
- "@polkadot/ui-shared": 0.66.3
+ "@polkadot/ui-settings": 0.66.4-0
+ "@polkadot/ui-shared": 0.66.4-0
"@polkadot/util": ^5.3.1
"@polkadot/util-crypto": ^5.3.1
color: ^3.1.3
@@ -2535,7 +2535,7 @@ __metadata:
react-dom: "*"
react-is: "*"
styled-components: "*"
- checksum: a9bcf8ac0f8d9e95198f1f85e01c60ee4313ea2f0ac2adc88bbf5f5e529f74248d70f942f2f418a79aad8bf48ef4178f1eb3fbae13bdcd5416e5da607f05ddba
+ checksum: 9836d6ea6905a3a30c8adf88ed43da074461ad8791c181eb495495c5a7b279eaf30fd82d806ff50ad6a1ee21c5eeadfdef15450d45b6b148b3dac19a57a21daf
languageName: node
linkType: hard
@@ -2548,9 +2548,9 @@ __metadata:
languageName: unknown
linkType: soft
-"@polkadot/react-qr@npm:^0.66.3":
- version: 0.66.3
- resolution: "@polkadot/react-qr@npm:0.66.3"
+"@polkadot/react-qr@npm:^0.66.4-0":
+ version: 0.66.4-0
+ resolution: "@polkadot/react-qr@npm:0.66.4-0"
dependencies:
"@babel/runtime": ^7.12.5
"@polkadot/util": ^5.3.1
@@ -2564,7 +2564,7 @@ __metadata:
react: "*"
react-dom: "*"
styled-components: "*"
- checksum: 79e8cc7d3c7cfc23c6a939184e351c4f4c4a86c08eacb081b714f693eed9e5cda7d00d525424e3696d6140c150e07152dcf8bc640228121c7163709834187dd7
+ checksum: 0616a25e9305b3da91b088a720bf934adc73d443c1573275d4008853e4cebf41cdb6570d578eb7a8c7c13d6f48c381f3e85248cbe92a6fa3ceb314b4e29b5903
languageName: node
linkType: hard
@@ -2662,14 +2662,14 @@ __metadata:
languageName: node
linkType: hard
-"@polkadot/ui-keyring@npm:^0.66.3":
- version: 0.66.3
- resolution: "@polkadot/ui-keyring@npm:0.66.3"
+"@polkadot/ui-keyring@npm:^0.66.4-0":
+ version: 0.66.4-0
+ resolution: "@polkadot/ui-keyring@npm:0.66.4-0"
dependencies:
"@babel/runtime": ^7.12.5
"@polkadot/hw-ledger": ^5.3.1
"@polkadot/keyring": ^5.3.1
- "@polkadot/ui-settings": 0.66.3
+ "@polkadot/ui-settings": 0.66.4-0
"@polkadot/util": ^5.3.1
"@polkadot/x-rxjs": ^3.5.1
mkdirp: ^1.0.4
@@ -2678,13 +2678,13 @@ __metadata:
"@polkadot/keyring": "*"
"@polkadot/ui-settings": "*"
"@polkadot/util": "*"
- checksum: 602afd2837a7ee1b463eee839c62f22ffa774f49ad26f9862ae0f50931d56327780f2fa500eebe497b7cb2ac6c53ce96951ccb1aa9dfec16813654cd4b2ff338
+ checksum: b61c33e57e37bbf0443ea3fc8a3fd693a91d2bfba6c6ff821e5ab14c3de77197b6df88b8f0c4c3f32231b11e4583b404dabbeedabc7bd4bae58ebed68d774805
languageName: node
linkType: hard
-"@polkadot/ui-settings@npm:0.66.3, @polkadot/ui-settings@npm:^0.66.3":
- version: 0.66.3
- resolution: "@polkadot/ui-settings@npm:0.66.3"
+"@polkadot/ui-settings@npm:0.66.4-0, @polkadot/ui-settings@npm:^0.66.4-0":
+ version: 0.66.4-0
+ resolution: "@polkadot/ui-settings@npm:0.66.4-0"
dependencies:
"@babel/runtime": ^7.12.5
"@polkadot/networks": ^5.3.1
@@ -2694,20 +2694,20 @@ __metadata:
peerDependencies:
"@polkadot/networks": "*"
"@polkadot/util": "*"
- checksum: 72ad5e26a16988e4cdb378483ab6306eec9955e0e8657749aab57d83f5413e18ca9e34f84999a181febf86819056282f1e5e0f61db2a47701b279c5c7a00c85a
+ checksum: c2dfdc7af094cee4ce70a9b1c8701f9f2f5e56a6961aeb7d44c43dc6b0ec95f68cb9d1b7fe17dcceb43e3796904d496f60f896e543da2c48277ae8b2018a5e13
languageName: node
linkType: hard
-"@polkadot/ui-shared@npm:0.66.3":
- version: 0.66.3
- resolution: "@polkadot/ui-shared@npm:0.66.3"
+"@polkadot/ui-shared@npm:0.66.4-0":
+ version: 0.66.4-0
+ resolution: "@polkadot/ui-shared@npm:0.66.4-0"
dependencies:
"@babel/runtime": ^7.12.5
color: ^3.1.3
peerDependencies:
"@polkadot/util": "*"
"@polkadot/util-crypto": "*"
- checksum: 22e87fb5d0b290d50a1826be38b834833ab9040733b648a0a2b7d55d4698397e5d2bad48d46142f29087f705a9f061225634635c59b4f09facd3a84bc687b666
+ checksum: 7dfa3416bf348cc55513d597e58801179e0b84779fbf64be4edc13e21911fb27d17bbe9b11b539361b36f6815800493139e588012487fd28790c843b9cbe82f5
languageName: node
linkType: hard