From b1568a4d7d1f7e1b6f52bbb8e6f4e900c1b492f1 Mon Sep 17 00:00:00 2001 From: Pedro Semeano Date: Tue, 7 Jan 2025 11:29:13 +0000 Subject: [PATCH 1/9] fix: aptos e2e test with speculos --- apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts | 3 --- libs/ledger-live-common/src/e2e/enum/Account.ts | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts b/apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts index af40cd54f92f..3aa124788e6c 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts @@ -194,13 +194,10 @@ const transactionE2E = [ transaction: new Transaction(Account.XRP_1, Account.XRP_2, "0.0001", undefined, "noTag"), xrayTicket: "B2CQA-2816", }, - /* - TODO: https://ledgerhq.atlassian.net/browse/LIVE-15624 needs to be done to enable it { transaction: new Transaction(Account.APTOS_1, Account.APTOS_2, "0.0001"), xrayTicket: "B2CQA-2920", }, - */ ]; const tokenTransactionInvalid = [ diff --git a/libs/ledger-live-common/src/e2e/enum/Account.ts b/libs/ledger-live-common/src/e2e/enum/Account.ts index fbd7b54aa8d4..06f329a087a2 100644 --- a/libs/ledger-live-common/src/e2e/enum/Account.ts +++ b/libs/ledger-live-common/src/e2e/enum/Account.ts @@ -17,7 +17,7 @@ export class Account { static readonly APTOS_1 = new Account( Currency.APT, "Aptos 1", - "0x17457f3e93cbd37f5c714a89b92b86a478f1350918c37e0523fff83b66f21027", + "0x98739115d8ba968aa0870a1ce6a988a0cb5aeb2e5f0cb5a0f346c7a1bb7e4a27", undefined, 0, ); @@ -25,7 +25,7 @@ export class Account { static readonly APTOS_2 = new Account( Currency.APT, "Aptos 2", - "0x6c0e2e27005620ea8e0f11762687b0e5483b721c8407dc855c6f7127f8881371", + "0xb69a68cc64f7aa193705193f4dd598320a0a74baf7e4b50c9980c5bd60a82390", undefined, 1, ); From bf2805da19d833ea26596cc06b2f4225ccdf7047 Mon Sep 17 00:00:00 2001 From: Pedro Semeano Date: Tue, 7 Jan 2025 15:23:30 +0000 Subject: [PATCH 2/9] fix: aptos bridge integration test --- .../src/families/aptos/bridge.integration.test.ts | 4 ++-- libs/ledger-live-common/src/families/aptos/bridge/js.ts | 7 +------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/libs/ledger-live-common/src/families/aptos/bridge.integration.test.ts b/libs/ledger-live-common/src/families/aptos/bridge.integration.test.ts index 8ff913a4403e..5ca829b830b1 100644 --- a/libs/ledger-live-common/src/families/aptos/bridge.integration.test.ts +++ b/libs/ledger-live-common/src/families/aptos/bridge.integration.test.ts @@ -64,9 +64,9 @@ const aptos: CurrenciesData = { family: "aptos", mode: "send", fees: "1100", - options: '{"maxGasAmount":"11","gasUnitPrice":"100"}', + options: '{ "maxGasAmount": "11", "gasUnitPrice": "100" }', estimate: - '{"maxGasAmount":"11","gasUnitPrice":"100","sequenceNumber":"1","expirationTimestampSecs":"1734535375"}', + '{ "maxGasAmount": "11", "gasUnitPrice": "100", "sequenceNumber": "1", "expirationTimestampSecs": "1734535375" }', firstEmulation: "false", errors: "{}", }), diff --git a/libs/ledger-live-common/src/families/aptos/bridge/js.ts b/libs/ledger-live-common/src/families/aptos/bridge/js.ts index 4cd4d177cbb1..634ce39005f8 100644 --- a/libs/ledger-live-common/src/families/aptos/bridge/js.ts +++ b/libs/ledger-live-common/src/families/aptos/bridge/js.ts @@ -1,8 +1,8 @@ import type { AccountBridge, CurrencyBridge } from "@ledgerhq/types-live"; import { getSerializedAddressParameters } from "@ledgerhq/coin-framework/bridge/jsHelpers"; +import { updateTransaction } from "@ledgerhq/coin-framework/bridge/jsHelpers"; import type { Transaction } from "../types"; import { makeAccountBridgeReceive } from "../../../bridge/jsHelpers"; - import { sync, scanAccounts } from "../synchronisation"; import getTransactionStatus from "../getTransactionStatus"; import prepareTransaction from "../prepareTransaction"; @@ -17,11 +17,6 @@ const currencyBridge: CurrencyBridge = { scanAccounts, }; -const updateTransaction = (t: Transaction, patch: Partial): Transaction => ({ - ...t, - ...patch, -}); - const receive = makeAccountBridgeReceive(); const accountBridge: AccountBridge = { From 03f76739a25220e4fe86dd44d66ba0c94b76aad6 Mon Sep 17 00:00:00 2001 From: Pedro Semeano Date: Tue, 7 Jan 2025 16:28:53 +0000 Subject: [PATCH 3/9] fix: remove tobe(function) assertions --- .../src/families/aptos/api/index.test.ts | 12 ------------ .../src/families/aptos/bridge/js.test.ts | 11 ----------- 2 files changed, 23 deletions(-) diff --git a/libs/ledger-live-common/src/families/aptos/api/index.test.ts b/libs/ledger-live-common/src/families/aptos/api/index.test.ts index eff5afc25973..9ad1866bd06d 100644 --- a/libs/ledger-live-common/src/families/aptos/api/index.test.ts +++ b/libs/ledger-live-common/src/families/aptos/api/index.test.ts @@ -36,34 +36,22 @@ describe("Aptos API", () => { const api = new AptosAPI("aptos"); expect(api.broadcast).toBeDefined(); - expect(typeof api.broadcast).toBe("function"); expect(api.estimateGasPrice).toBeDefined(); - expect(typeof api.estimateGasPrice).toBe("function"); expect(api.generateTransaction).toBeDefined(); - expect(typeof api.generateTransaction).toBe("function"); expect(api.getAccount).toBeDefined(); - expect(typeof api.getAccount).toBe("function"); expect(api.getAccountInfo).toBeDefined(); - expect(typeof api.getAccountInfo).toBe("function"); expect(api.simulateTransaction).toBeDefined(); - expect(typeof api.simulateTransaction).toBe("function"); }); it("builds the client properly for testnet", () => { const api = new AptosAPI("aptos_testnet"); expect(api.broadcast).toBeDefined(); - expect(typeof api.broadcast).toBe("function"); expect(api.estimateGasPrice).toBeDefined(); - expect(typeof api.estimateGasPrice).toBe("function"); expect(api.generateTransaction).toBeDefined(); - expect(typeof api.generateTransaction).toBe("function"); expect(api.getAccount).toBeDefined(); - expect(typeof api.getAccount).toBe("function"); expect(api.getAccountInfo).toBeDefined(); - expect(typeof api.getAccountInfo).toBe("function"); expect(api.simulateTransaction).toBeDefined(); - expect(typeof api.simulateTransaction).toBe("function"); }); describe("getAccount", () => { diff --git a/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts b/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts index ce24ff1fe361..9539a9e01333 100644 --- a/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts +++ b/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts @@ -13,7 +13,6 @@ describe("Aptos bridge interface ", () => { it("should have a hydrate method that is a function", () => { expect(bridge.currencyBridge.hydrate).toBeDefined(); - expect(typeof bridge.currencyBridge.hydrate).toBe("function"); const cryptoCurrency = getCryptoCurrencyById("aptos"); const result = bridge.currencyBridge.hydrate({}, cryptoCurrency); expect(result).toBeUndefined(); @@ -21,7 +20,6 @@ describe("Aptos bridge interface ", () => { it("should have a scanAccounts method that is a function", () => { expect(bridge.currencyBridge.scanAccounts).toBeDefined(); - expect(typeof bridge.currencyBridge.scanAccounts).toBe("function"); const cryptoCurrency = getCryptoCurrencyById("aptos"); const deviceId = "test-device"; const result = bridge.currencyBridge.scanAccounts({ @@ -36,23 +34,14 @@ describe("Aptos bridge interface ", () => { describe("accountBridge ", () => { it("should contain all methods", () => { expect(bridge.accountBridge.estimateMaxSpendable).toBeDefined(); - expect(typeof bridge.accountBridge.estimateMaxSpendable).toBe("function"); expect(bridge.accountBridge.createTransaction).toBeDefined(); - expect(typeof bridge.accountBridge.createTransaction).toBe("function"); expect(bridge.accountBridge.updateTransaction).toBeDefined(); - expect(typeof bridge.accountBridge.updateTransaction).toBe("function"); expect(bridge.accountBridge.getTransactionStatus).toBeDefined(); - expect(typeof bridge.accountBridge.getTransactionStatus).toBe("function"); expect(bridge.accountBridge.prepareTransaction).toBeDefined(); - expect(typeof bridge.accountBridge.prepareTransaction).toBe("function"); expect(bridge.accountBridge.sync).toBeDefined(); - expect(typeof bridge.accountBridge.sync).toBe("function"); expect(bridge.accountBridge.receive).toBeDefined(); - expect(typeof bridge.accountBridge.receive).toBe("function"); expect(bridge.accountBridge.signOperation).toBeDefined(); - expect(typeof bridge.accountBridge.signOperation).toBe("function"); expect(bridge.accountBridge.broadcast).toBeDefined(); - expect(typeof bridge.accountBridge.broadcast).toBe("function"); }); }); describe("updateTransaction", () => { From d95b9445aa91ea0afa2f1112f2b8940eeb688fea Mon Sep 17 00:00:00 2001 From: Pedro Semeano Date: Tue, 7 Jan 2025 18:37:23 +0000 Subject: [PATCH 4/9] fix: remove tobe(function) assertions from ledger account tests --- .../src/families/aptos/LedgerAccount.test.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/libs/ledger-live-common/src/families/aptos/LedgerAccount.test.ts b/libs/ledger-live-common/src/families/aptos/LedgerAccount.test.ts index e43582e7e7b3..4a25e2420db4 100644 --- a/libs/ledger-live-common/src/families/aptos/LedgerAccount.test.ts +++ b/libs/ledger-live-common/src/families/aptos/LedgerAccount.test.ts @@ -12,25 +12,15 @@ describe("LedgerAccount Test", () => { it("builds the client properly", () => { expect(LedgerAccount.fromLedgerConnection).toBeDefined(); - expect(typeof LedgerAccount.fromLedgerConnection).toBe("function"); expect(account.init).toBeDefined(); - expect(typeof account.init).toBe("function"); expect(account.toAptosAccount).toBeDefined(); - expect(typeof account.toAptosAccount).toBe("function"); expect(account.hdWalletPath).toBeDefined(); - expect(typeof account.hdWalletPath).toBe("function"); expect(account.address).toBeDefined(); - expect(typeof account.address).toBe("function"); expect(account.authKey).toBeDefined(); - expect(typeof account.authKey).toBe("function"); expect(account.pubKey).toBeDefined(); - expect(typeof account.pubKey).toBe("function"); expect(account.asyncSignBuffer).toBeDefined(); - expect(typeof account.asyncSignBuffer).toBe("function"); expect(account.asyncSignHexString).toBeDefined(); - expect(typeof account.asyncSignHexString).toBe("function"); expect(account.signTransaction).toBeDefined(); - expect(typeof account.signTransaction).toBe("function"); expect(mockedLedgerAccount).toHaveBeenCalledTimes(1); }); From 1b21cdea7489f9ee6bed59b7aeba0232fbb8a296 Mon Sep 17 00:00:00 2001 From: Pedro Semeano Date: Wed, 8 Jan 2025 15:08:41 +0000 Subject: [PATCH 5/9] chore: rollback changes --- .../src/families/aptos/api/index.test.ts | 12 ++++++++++++ .../src/families/aptos/bridge/js.test.ts | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/libs/ledger-live-common/src/families/aptos/api/index.test.ts b/libs/ledger-live-common/src/families/aptos/api/index.test.ts index 9ad1866bd06d..eff5afc25973 100644 --- a/libs/ledger-live-common/src/families/aptos/api/index.test.ts +++ b/libs/ledger-live-common/src/families/aptos/api/index.test.ts @@ -36,22 +36,34 @@ describe("Aptos API", () => { const api = new AptosAPI("aptos"); expect(api.broadcast).toBeDefined(); + expect(typeof api.broadcast).toBe("function"); expect(api.estimateGasPrice).toBeDefined(); + expect(typeof api.estimateGasPrice).toBe("function"); expect(api.generateTransaction).toBeDefined(); + expect(typeof api.generateTransaction).toBe("function"); expect(api.getAccount).toBeDefined(); + expect(typeof api.getAccount).toBe("function"); expect(api.getAccountInfo).toBeDefined(); + expect(typeof api.getAccountInfo).toBe("function"); expect(api.simulateTransaction).toBeDefined(); + expect(typeof api.simulateTransaction).toBe("function"); }); it("builds the client properly for testnet", () => { const api = new AptosAPI("aptos_testnet"); expect(api.broadcast).toBeDefined(); + expect(typeof api.broadcast).toBe("function"); expect(api.estimateGasPrice).toBeDefined(); + expect(typeof api.estimateGasPrice).toBe("function"); expect(api.generateTransaction).toBeDefined(); + expect(typeof api.generateTransaction).toBe("function"); expect(api.getAccount).toBeDefined(); + expect(typeof api.getAccount).toBe("function"); expect(api.getAccountInfo).toBeDefined(); + expect(typeof api.getAccountInfo).toBe("function"); expect(api.simulateTransaction).toBeDefined(); + expect(typeof api.simulateTransaction).toBe("function"); }); describe("getAccount", () => { diff --git a/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts b/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts index 9539a9e01333..eb6a875be90b 100644 --- a/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts +++ b/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts @@ -34,16 +34,26 @@ describe("Aptos bridge interface ", () => { describe("accountBridge ", () => { it("should contain all methods", () => { expect(bridge.accountBridge.estimateMaxSpendable).toBeDefined(); + expect(typeof bridge.accountBridge.estimateMaxSpendable).toBe("function"); expect(bridge.accountBridge.createTransaction).toBeDefined(); + expect(typeof bridge.accountBridge.createTransaction).toBe("function"); expect(bridge.accountBridge.updateTransaction).toBeDefined(); + expect(typeof bridge.accountBridge.updateTransaction).toBe("function"); expect(bridge.accountBridge.getTransactionStatus).toBeDefined(); + expect(typeof bridge.accountBridge.getTransactionStatus).toBe("function"); expect(bridge.accountBridge.prepareTransaction).toBeDefined(); + expect(typeof bridge.accountBridge.prepareTransaction).toBe("function"); expect(bridge.accountBridge.sync).toBeDefined(); + expect(typeof bridge.accountBridge.sync).toBe("function"); expect(bridge.accountBridge.receive).toBeDefined(); + expect(typeof bridge.accountBridge.receive).toBe("function"); expect(bridge.accountBridge.signOperation).toBeDefined(); + expect(typeof bridge.accountBridge.signOperation).toBe("function"); expect(bridge.accountBridge.broadcast).toBeDefined(); + expect(typeof bridge.accountBridge.broadcast).toBe("function"); }); }); + describe("updateTransaction", () => { it("should update the transaction with the given patch", () => { const initialTransaction = { From 75716279ab5763f32312170530c75f58331ea955 Mon Sep 17 00:00:00 2001 From: Pedro Semeano Date: Wed, 8 Jan 2025 15:13:40 +0000 Subject: [PATCH 6/9] chore: rollback changes --- libs/ledger-live-common/src/families/aptos/bridge/js.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts b/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts index eb6a875be90b..077b3610d480 100644 --- a/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts +++ b/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts @@ -13,6 +13,7 @@ describe("Aptos bridge interface ", () => { it("should have a hydrate method that is a function", () => { expect(bridge.currencyBridge.hydrate).toBeDefined(); + expect(typeof bridge.currencyBridge.hydrate).toBe("function"); const cryptoCurrency = getCryptoCurrencyById("aptos"); const result = bridge.currencyBridge.hydrate({}, cryptoCurrency); expect(result).toBeUndefined(); From 036ffb9da7060ee039fdd2cca9215dc64359661c Mon Sep 17 00:00:00 2001 From: Pedro Semeano Date: Wed, 8 Jan 2025 15:19:13 +0000 Subject: [PATCH 7/9] test: add unit tests for currencyBridge methods --- .../ledger-live-common/src/families/aptos/bridge/js.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts b/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts index 077b3610d480..005685ddae55 100644 --- a/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts +++ b/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts @@ -52,6 +52,12 @@ describe("Aptos bridge interface ", () => { expect(typeof bridge.accountBridge.signOperation).toBe("function"); expect(bridge.accountBridge.broadcast).toBeDefined(); expect(typeof bridge.accountBridge.broadcast).toBe("function"); + expect(bridge.currencyBridge.hydrate).toBeDefined(); + expect(typeof bridge.currencyBridge.hydrate).toBe("function"); + expect(bridge.currencyBridge.preload).toBeDefined(); + expect(typeof bridge.currencyBridge.preload).toBe("function"); + expect(bridge.currencyBridge.scanAccounts).toBeDefined(); + expect(typeof bridge.currencyBridge.scanAccounts).toBe("function"); }); }); From 555573198f64b533f9f86ac6f89d874c371dd364 Mon Sep 17 00:00:00 2001 From: Pedro Semeano Date: Wed, 8 Jan 2025 17:33:00 +0000 Subject: [PATCH 8/9] fix: bridge test --- libs/ledger-live-common/src/families/aptos/bridge/js.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts b/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts index 005685ddae55..250d2070cbe7 100644 --- a/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts +++ b/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts @@ -32,7 +32,7 @@ describe("Aptos bridge interface ", () => { }); }); - describe("accountBridge ", () => { + describe("accountBridge", () => { it("should contain all methods", () => { expect(bridge.accountBridge.estimateMaxSpendable).toBeDefined(); expect(typeof bridge.accountBridge.estimateMaxSpendable).toBe("function"); From b9440dc697f59477871c39c6c048f4cc5cdda7ac Mon Sep 17 00:00:00 2001 From: Pedro Semeano Date: Wed, 8 Jan 2025 17:33:42 +0000 Subject: [PATCH 9/9] fix: bridge test --- libs/ledger-live-common/src/families/aptos/bridge/js.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts b/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts index 250d2070cbe7..fc6a1c613328 100644 --- a/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts +++ b/libs/ledger-live-common/src/families/aptos/bridge/js.test.ts @@ -21,6 +21,7 @@ describe("Aptos bridge interface ", () => { it("should have a scanAccounts method that is a function", () => { expect(bridge.currencyBridge.scanAccounts).toBeDefined(); + expect(typeof bridge.currencyBridge.scanAccounts).toBe("function"); const cryptoCurrency = getCryptoCurrencyById("aptos"); const deviceId = "test-device"; const result = bridge.currencyBridge.scanAccounts({