Skip to content

Commit

Permalink
feat/1047: Ledger transport updates, Updated Step 2 text (#1389)
Browse files Browse the repository at this point in the history
* feat: bump transport packages, namadillo

* fix: fix docs

* feat: update step description to display which index of tx is to be signed
  • Loading branch information
jurevans authored Dec 6, 2024
1 parent 6c52209 commit fbef3f9
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 40 deletions.
6 changes: 3 additions & 3 deletions apps/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
"dependencies": {
"@cosmjs/encoding": "^0.29.0",
"@dao-xyz/borsh": "^5.1.5",
"@ledgerhq/hw-transport": "^6.30.0",
"@ledgerhq/hw-transport-webhid": "^6.28.0",
"@ledgerhq/hw-transport-webusb": "^6.28.0",
"@ledgerhq/hw-transport": "^6.31.4",
"@ledgerhq/hw-transport-webhid": "^6.29.4",
"@ledgerhq/hw-transport-webusb": "^6.29.4",
"@zondax/ledger-namada": "^1.0.0",
"bignumber.js": "^9.1.1",
"buffer": "^6.0.3",
Expand Down
36 changes: 31 additions & 5 deletions apps/extension/src/Approvals/ConfirmSignLedgerTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type Props = {

const Step: React.FC<{
title: string;
description: string;
description: React.ReactNode;
icon: ReactNode;
selected: boolean;
disabled?: boolean;
Expand Down Expand Up @@ -60,7 +60,10 @@ export const ConfirmSignLedgerTx: React.FC<Props> = ({ details }) => {
const [error, setError] = useState<string>();
const [status, setStatus] = useState<Status>();
const [statusInfo, setStatusInfo] = useState("");
const [stepTwoDescription, setStepTwoDescription] =
useState<React.ReactNode>();
const [isLedgerConnected, setIsLedgerConnected] = useState(false);
const [ledger, setLedger] = useState<Ledger>();
const { msgId, signer } = details;

useEffect(() => {
Expand All @@ -75,7 +78,7 @@ export const ConfirmSignLedgerTx: React.FC<Props> = ({ details }) => {
path: string
): Promise<ResponseSign> => {
// Open ledger transport
setStatusInfo(`Review and approve transaction on your Ledger`);
setStatusInfo("Review and approve transaction on your Ledger");

// Sign with Ledger
const signature = await ledger.sign(bytes, path);
Expand All @@ -91,7 +94,7 @@ export const ConfirmSignLedgerTx: React.FC<Props> = ({ details }) => {
async (e: React.FormEvent): Promise<void> => {
e.preventDefault();
setIsLedgerConnected(false);
setStatusInfo(`Connecting Ledger...`);
setStatusInfo("Connecting Ledger...");
setStatus(Status.Pending);

const ledger = await Ledger.init().catch((e) => {
Expand All @@ -102,6 +105,7 @@ export const ConfirmSignLedgerTx: React.FC<Props> = ({ details }) => {
if (!ledger) {
return;
}
setLedger(ledger);

const {
version: { returnCode, errorMessage },
Expand All @@ -115,7 +119,7 @@ export const ConfirmSignLedgerTx: React.FC<Props> = ({ details }) => {
}

setIsLedgerConnected(true);
setStatusInfo("Preparing transaction...");
setStepTwoDescription("Preparing transaction...");

try {
const accountDetails = await requester.sendMessage(
Expand Down Expand Up @@ -144,15 +148,34 @@ export const ConfirmSignLedgerTx: React.FC<Props> = ({ details }) => {

const signatures: ResponseSign[] = [];

let txIndex = 0;
const txCount = pendingTxs.length;
const stepTwoText = "Approve on your device";

if (txCount === 1) {
setStepTwoDescription(<p>{stepTwoText}</p>);
}

for await (const tx of pendingTxs) {
if (txCount > 1) {
setStepTwoDescription(
<p>
{stepTwoText}
<br />
Tx {txIndex + 1} of {txCount}
</p>
);
}
const signature = await signLedgerTx(
ledger,
fromBase64(tx),
bip44Path
);
signatures.push(signature);
txIndex++;
}

setStepTwoDescription(<p>Submitting...</p>);
await requester.sendMessage(
Ports.Background,
new SubmitApprovedSignLedgerTxMsg(msgId, signatures)
Expand All @@ -170,6 +193,9 @@ export const ConfirmSignLedgerTx: React.FC<Props> = ({ details }) => {
);

const handleRejectButton = useCallback(() => {
if (ledger) {
void ledger.closeTransport();
}
void closeCurrentTab();
}, []);

Expand All @@ -187,7 +213,7 @@ export const ConfirmSignLedgerTx: React.FC<Props> = ({ details }) => {
/>
<Step
title="Step 2"
description="Review and approve transaction on your ledger"
description={stepTwoDescription}
icon={<ApproveIcon />}
selected={isLedgerConnected}
/>
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ The Namada SDK package
### Installation

```bash
npm install @heliaxdev/namada-sdk
npm install @namada/sdk

# Or, via yarn
yarn add @heliaxdev/namada-sdk
yarn add @namada/sdk
```

### Initializing the SDK
Expand All @@ -19,8 +19,8 @@ As this package depends on Wasm compiled from Rust to integrate with Namada, thi
developing for the Web. The following is a quick overview of some of the features of the SDK package:

```typescript
import { Sdk, getSdk } from "@heliaxdev/namada-sdk/web";
import sdkInit from "@heliaxdev/namada-sdk/web-init";
import { Sdk, getSdk } from "@namada/sdk/web";
import sdkInit from "@namada/sdk/web-init";

// Load Tx props from types package
import { BondProps, WrapperTxProps } from "@namada/types";
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ The Namada SDK package
### Installation

```bash
npm install @heliaxdev/namada-sdk
npm install @namada/sdk

# Or, via yarn
yarn add @heliaxdev/namada-sdk
yarn add @namada/sdk
```

### Initializing the SDK
Expand All @@ -21,8 +21,8 @@ As this package depends on Wasm compiled from Rust to integrate with Namada, thi
developing for the Web. The following is a quick overview of some of the features of the SDK package:

```typescript
import { Sdk, getSdk } from "@heliaxdev/namada-sdk/web";
import sdkInit from "@heliaxdev/namada-sdk/web-init";
import { Sdk, getSdk } from "@namada/sdk/web";
import sdkInit from "@namada/sdk/web-init";

// Load Tx props from types package
import { BondProps, WrapperTxProps } from "@namada/types";
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
"dependencies": {
"@cosmjs/encoding": "^0.29.0",
"@dao-xyz/borsh": "^5.1.5",
"@ledgerhq/hw-transport": "^6.30.0",
"@ledgerhq/hw-transport-webhid": "^6.28.0",
"@ledgerhq/hw-transport-webusb": "^6.28.0",
"@ledgerhq/hw-transport": "^6.31.4",
"@ledgerhq/hw-transport-webhid": "^6.29.4",
"@ledgerhq/hw-transport-webusb": "^6.29.4",
"@zondax/ledger-namada": "^1.0.0",
"bignumber.js": "^9.1.1",
"buffer": "^6.0.3",
Expand Down
73 changes: 52 additions & 21 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3233,38 +3233,57 @@ __metadata:
languageName: node
linkType: hard

"@ledgerhq/devices@npm:^8.4.4":
version: 8.4.4
resolution: "@ledgerhq/devices@npm:8.4.4"
dependencies:
"@ledgerhq/errors": "npm:^6.19.1"
"@ledgerhq/logs": "npm:^6.12.0"
rxjs: "npm:^7.8.1"
semver: "npm:^7.3.5"
checksum: ea4c3dada124c5c0aad59837e1c399bf2f41f8b4da5c996aaf73bbf8719082598808947c505dc728266ff83fc5fea71170d3f0d18a9b5d59e6e2737ae8a38f39
languageName: node
linkType: hard

"@ledgerhq/errors@npm:^6.18.0":
version: 6.18.0
resolution: "@ledgerhq/errors@npm:6.18.0"
checksum: 0dad36bd049c1eb346b83d2b99c1dde0445c53ae3a2f73d4f9a7f5e278ef61d1e589cc0b30bb81dd3082ad9a751f7d82b662214088e19b09769bded45447fb54
languageName: node
linkType: hard

"@ledgerhq/hw-transport-webhid@npm:^6.28.0":
version: 6.29.2
resolution: "@ledgerhq/hw-transport-webhid@npm:6.29.2"
"@ledgerhq/errors@npm:^6.19.1":
version: 6.19.1
resolution: "@ledgerhq/errors@npm:6.19.1"
checksum: 5cfbd5ff5e4316afc88c456a74d3dc0e0032dafd88f656e80a5cb5b297a75ba6701c53ce38ef3f38a84a8591c499b0b9248cdf352ff34c97a550440cdaddd8d2
languageName: node
linkType: hard

"@ledgerhq/hw-transport-webhid@npm:^6.29.4":
version: 6.29.4
resolution: "@ledgerhq/hw-transport-webhid@npm:6.29.4"
dependencies:
"@ledgerhq/devices": "npm:^8.4.2"
"@ledgerhq/errors": "npm:^6.18.0"
"@ledgerhq/hw-transport": "npm:^6.31.2"
"@ledgerhq/devices": "npm:^8.4.4"
"@ledgerhq/errors": "npm:^6.19.1"
"@ledgerhq/hw-transport": "npm:^6.31.4"
"@ledgerhq/logs": "npm:^6.12.0"
checksum: 86a610bf99eb44fbd93a7d0afc621f13a5f43e63fc86c64f686f88cc528d0ea62a51f674b8a6148aaa4330cc8ef2c2b2e461bbea5a71ae39305f82124a83377b
checksum: 85db88aa9c9ca4911645b9421e1a1ce828c48c32b03b7ed15caed8f8e24749dc31007540ec4f0088603d1a315274dbc06d30e4cb71c86b57160b721a664fc8dd
languageName: node
linkType: hard

"@ledgerhq/hw-transport-webusb@npm:^6.28.0":
version: 6.29.2
resolution: "@ledgerhq/hw-transport-webusb@npm:6.29.2"
"@ledgerhq/hw-transport-webusb@npm:^6.29.4":
version: 6.29.4
resolution: "@ledgerhq/hw-transport-webusb@npm:6.29.4"
dependencies:
"@ledgerhq/devices": "npm:^8.4.2"
"@ledgerhq/errors": "npm:^6.18.0"
"@ledgerhq/hw-transport": "npm:^6.31.2"
"@ledgerhq/devices": "npm:^8.4.4"
"@ledgerhq/errors": "npm:^6.19.1"
"@ledgerhq/hw-transport": "npm:^6.31.4"
"@ledgerhq/logs": "npm:^6.12.0"
checksum: 6499398c90ccd1210d9a6b91846df49001b0de7b74a97a8df0020fc35f22b90f3b886499c5237cdf198e914a616f310ccd22238f5136df46699561f6dd2412ed
checksum: cddd324c12de64e755422c6dc0d509bc344f2f048c2b743bc5737db9c097ffb6c201fc577d971543e196ccb34a72507450ed3262a2b6d39c753424d299fafc2f
languageName: node
linkType: hard

"@ledgerhq/hw-transport@npm:^6.30.0, @ledgerhq/hw-transport@npm:^6.30.6, @ledgerhq/hw-transport@npm:^6.31.2":
"@ledgerhq/hw-transport@npm:^6.30.6":
version: 6.31.2
resolution: "@ledgerhq/hw-transport@npm:6.31.2"
dependencies:
Expand All @@ -3276,6 +3295,18 @@ __metadata:
languageName: node
linkType: hard

"@ledgerhq/hw-transport@npm:^6.31.4":
version: 6.31.4
resolution: "@ledgerhq/hw-transport@npm:6.31.4"
dependencies:
"@ledgerhq/devices": "npm:^8.4.4"
"@ledgerhq/errors": "npm:^6.19.1"
"@ledgerhq/logs": "npm:^6.12.0"
events: "npm:^3.3.0"
checksum: 033acb802d991788efcda9223356528d0987a268e94c34cbafde499541722363e7cfa6e2734365ef3282c0a80a69f4964a6d728690ff7494662a650516530b02
languageName: node
linkType: hard

"@ledgerhq/logs@npm:^6.12.0":
version: 6.12.0
resolution: "@ledgerhq/logs@npm:6.12.0"
Expand Down Expand Up @@ -3441,9 +3472,9 @@ __metadata:
"@babel/plugin-transform-modules-commonjs": "npm:^7.20.11"
"@cosmjs/encoding": "npm:^0.29.0"
"@dao-xyz/borsh": "npm:^5.1.5"
"@ledgerhq/hw-transport": "npm:^6.30.0"
"@ledgerhq/hw-transport-webhid": "npm:^6.28.0"
"@ledgerhq/hw-transport-webusb": "npm:^6.28.0"
"@ledgerhq/hw-transport": "npm:^6.31.4"
"@ledgerhq/hw-transport-webhid": "npm:^6.29.4"
"@ledgerhq/hw-transport-webusb": "npm:^6.29.4"
"@svgr/webpack": "npm:^6.3.1"
"@types/chrome": "npm:^0.0.237"
"@types/dompurify": "npm:^3.0.5"
Expand Down Expand Up @@ -3719,9 +3750,9 @@ __metadata:
"@babel/preset-typescript": "npm:^7.23.3"
"@cosmjs/encoding": "npm:^0.29.0"
"@dao-xyz/borsh": "npm:^5.1.5"
"@ledgerhq/hw-transport": "npm:^6.30.0"
"@ledgerhq/hw-transport-webhid": "npm:^6.28.0"
"@ledgerhq/hw-transport-webusb": "npm:^6.28.0"
"@ledgerhq/hw-transport": "npm:^6.31.4"
"@ledgerhq/hw-transport-webhid": "npm:^6.29.4"
"@ledgerhq/hw-transport-webusb": "npm:^6.29.4"
"@release-it/conventional-changelog": "npm:^8.0.1"
"@types/jest": "npm:^29.5.12"
"@types/node": "npm:^20.11.4"
Expand Down

1 comment on commit fbef3f9

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.