From 972d40e97981494823080385a6debcf66496bd64 Mon Sep 17 00:00:00 2001 From: Louis Aussedat Date: Mon, 6 Jan 2025 11:40:53 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20(signer-eth):=20Remove=20ethers?= =?UTF-8?q?=20dependency=20from=20api=20and=20accept=20only=20raw=20tx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/sample/package.json | 1 - .../src/components/SignerEthView/index.tsx | 16 +- packages/signer/signer-eth/package.json | 3 +- .../signer/signer-eth/src/api/SignerEth.ts | 3 +- .../SignTransactionDeviceActionTypes.ts | 4 +- packages/signer/signer-eth/src/api/index.ts | 2 +- .../{Transaction.ts => TransactionType.ts} | 5 - .../src/internal/DefaultSignerEth.test.ts | 4 +- .../src/internal/DefaultSignerEth.ts | 3 +- .../internal/app-binder/EthAppBinder.test.ts | 21 +- .../src/internal/app-binder/EthAppBinder.ts | 3 +- .../SignTransactionDeviceAction.test.ts | 17 +- .../SignTransactionDeviceAction.ts | 4 +- .../task/BuildTransactionContextTask.test.ts | 17 +- .../task/BuildTransactionContextTask.ts | 4 +- .../task/SendSignTransactionTask.test.ts | 2 +- .../task/SendSignTransactionTask.ts | 4 +- .../transaction/di/transactionModule.test.ts | 4 +- .../transaction/di/transactionModule.ts | 6 +- .../mapper/EthersRawTransactionMapper.test.ts | 133 +++++ .../mapper/EthersRawTransactionMapper.ts | 27 + .../mapper/EthersV5TransactionMapper.test.ts | 146 ----- .../mapper/EthersV5TransactionMapper.ts | 65 -- .../mapper/EthersV6TransactionMapper.test.ts | 147 ----- .../mapper/EthersV6TransactionMapper.ts | 53 -- .../service/mapper/TransactionMapper.ts | 4 +- .../mapper/TransactionMapperService.test.ts | 8 +- .../mapper/TransactionMapperService.ts | 3 +- .../mapper/model/TransactionMapperResult.ts | 2 +- .../parser/TransactionParserService.test.ts | 2 +- .../parser/TransactionParserService.ts | 2 +- .../use-case/SignTransactionUseCase.test.ts | 12 +- .../use-case/SignTransactionUseCase.ts | 3 +- pnpm-lock.yaml | 555 ++---------------- 34 files changed, 297 insertions(+), 988 deletions(-) rename packages/signer/signer-eth/src/api/model/{Transaction.ts => TransactionType.ts} (52%) create mode 100644 packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersRawTransactionMapper.test.ts create mode 100644 packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersRawTransactionMapper.ts delete mode 100644 packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersV5TransactionMapper.test.ts delete mode 100644 packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersV5TransactionMapper.ts delete mode 100644 packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersV6TransactionMapper.test.ts delete mode 100644 packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersV6TransactionMapper.ts diff --git a/apps/sample/package.json b/apps/sample/package.json index d297405ad..097952ec3 100644 --- a/apps/sample/package.json +++ b/apps/sample/package.json @@ -28,7 +28,6 @@ "@ledgerhq/react-ui": "^0.17.0", "@playwright/test": "^1.49.0", "@sentry/nextjs": "^8.42.0", - "ethers": "6.13.4", "next": "14.2.15", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/apps/sample/src/components/SignerEthView/index.tsx b/apps/sample/src/components/SignerEthView/index.tsx index 0aa711ea3..7234f4ec1 100644 --- a/apps/sample/src/components/SignerEthView/index.tsx +++ b/apps/sample/src/components/SignerEthView/index.tsx @@ -1,4 +1,5 @@ import React, { useMemo } from "react"; +import { hexaStringToBuffer } from "@ledgerhq/device-management-kit"; import { type GetAddressDAError, type GetAddressDAIntermediateValue, @@ -14,7 +15,6 @@ import { type SignTypedDataDAOutput, type TypedData, } from "@ledgerhq/device-signer-kit-ethereum"; -import { ethers } from "ethers"; import { DeviceActionsList } from "@/components/DeviceActionsView/DeviceActionsList"; import { type DeviceActionProps } from "@/components/DeviceActionsView/DeviceActionTester"; @@ -103,11 +103,15 @@ export const SignerEthView: React.FC<{ sessionId: string }> = ({ if (!signer) { throw new Error("Signer not initialized"); } - return signer.signTransaction( - derivationPath, - ethers.Transaction.from(transaction), - { domain: recipientDomain }, - ); + + const tx = hexaStringToBuffer(transaction); + if (!tx) { + throw new Error("Invalid transaction format"); + } + + return signer.signTransaction(derivationPath, tx, { + domain: recipientDomain, + }); }, initialValues: { derivationPath: "44'/60'/0'/0/0", diff --git a/packages/signer/signer-eth/package.json b/packages/signer/signer-eth/package.json index cb5b1876b..2778e8a56 100644 --- a/packages/signer/signer-eth/package.json +++ b/packages/signer/signer-eth/package.json @@ -36,8 +36,7 @@ }, "dependencies": { "@ledgerhq/signer-utils": "workspace:*", - "ethers-v5": "npm:ethers@^5.7.2", - "ethers-v6": "npm:ethers@6.13.4", + "ethers": "6.13.4", "inversify": "^6.2.1", "inversify-logger-middleware": "^3.1.0", "purify-ts": "^2.1.0", diff --git a/packages/signer/signer-eth/src/api/SignerEth.ts b/packages/signer/signer-eth/src/api/SignerEth.ts index 074bd2b04..f33763796 100644 --- a/packages/signer/signer-eth/src/api/SignerEth.ts +++ b/packages/signer/signer-eth/src/api/SignerEth.ts @@ -1,7 +1,6 @@ import { type GetAddressDAReturnType } from "@api/app-binder/GetAddressDeviceActionTypes"; import { type SignTypedDataDAReturnType } from "@api/app-binder/SignTypedDataDeviceActionTypes"; import { type AddressOptions } from "@api/model/AddressOptions"; -import { type Transaction } from "@api/model/Transaction"; import { type TransactionOptions } from "@api/model/TransactionOptions"; import { type TypedData } from "@api/model/TypedData"; @@ -11,7 +10,7 @@ import { type SignTransactionDAReturnType } from "./app-binder/SignTransactionDe export interface SignerEth { signTransaction: ( derivationPath: string, - transaction: Transaction, + transaction: Uint8Array, options?: TransactionOptions, ) => SignTransactionDAReturnType; signMessage: ( diff --git a/packages/signer/signer-eth/src/api/app-binder/SignTransactionDeviceActionTypes.ts b/packages/signer/signer-eth/src/api/app-binder/SignTransactionDeviceActionTypes.ts index 0c7502d80..9969cf17a 100644 --- a/packages/signer/signer-eth/src/api/app-binder/SignTransactionDeviceActionTypes.ts +++ b/packages/signer/signer-eth/src/api/app-binder/SignTransactionDeviceActionTypes.ts @@ -12,8 +12,8 @@ import { } from "@ledgerhq/device-management-kit"; import { type Signature } from "@api/model/Signature"; -import { type Transaction, type TransactionType } from "@api/model/Transaction"; import { type TransactionOptions } from "@api/model/TransactionOptions"; +import { type TransactionType } from "@api/model/TransactionType"; import { type ProvideTransactionContextTaskErrorCodes } from "@internal/app-binder/task/ProvideTransactionContextTask"; import { type GenericContext } from "@internal/app-binder/task/ProvideTransactionGenericContextTask"; import { type TransactionMapperService } from "@internal/transaction/service/mapper/TransactionMapperService"; @@ -23,7 +23,7 @@ export type SignTransactionDAOutput = Signature; export type SignTransactionDAInput = { readonly derivationPath: string; - readonly transaction: Transaction; + readonly transaction: Uint8Array; readonly mapper: TransactionMapperService; readonly parser: TransactionParserService; readonly contextModule: ContextModule; diff --git a/packages/signer/signer-eth/src/api/index.ts b/packages/signer/signer-eth/src/api/index.ts index be120956a..03168bbf1 100644 --- a/packages/signer/signer-eth/src/api/index.ts +++ b/packages/signer/signer-eth/src/api/index.ts @@ -23,8 +23,8 @@ export { export * from "@api/model/Address"; export * from "@api/model/AddressOptions"; export * from "@api/model/Signature"; -export * from "@api/model/Transaction"; export * from "@api/model/TransactionOptions"; +export * from "@api/model/TransactionType"; export * from "@api/model/TypedData"; export * from "@api/SignerEth"; export * from "@api/SignerEthBuilder"; diff --git a/packages/signer/signer-eth/src/api/model/Transaction.ts b/packages/signer/signer-eth/src/api/model/TransactionType.ts similarity index 52% rename from packages/signer/signer-eth/src/api/model/Transaction.ts rename to packages/signer/signer-eth/src/api/model/TransactionType.ts index dc820e079..598cf07c7 100644 --- a/packages/signer/signer-eth/src/api/model/Transaction.ts +++ b/packages/signer/signer-eth/src/api/model/TransactionType.ts @@ -1,8 +1,3 @@ -import { type Transaction as EthersV5Transaction } from "ethers-v5"; -import { type Transaction as EthersV6Transaction } from "ethers-v6"; - -export type Transaction = EthersV5Transaction | EthersV6Transaction; - /** * The ethereum transaction type as according to eip-2718 transactions * https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2718.md diff --git a/packages/signer/signer-eth/src/internal/DefaultSignerEth.test.ts b/packages/signer/signer-eth/src/internal/DefaultSignerEth.test.ts index ddc1a2938..de5e65f33 100644 --- a/packages/signer/signer-eth/src/internal/DefaultSignerEth.test.ts +++ b/packages/signer/signer-eth/src/internal/DefaultSignerEth.test.ts @@ -9,7 +9,7 @@ import { addressTypes } from "./address/di/addressTypes"; import { messageTypes } from "./message/di/messageTypes"; import { transactionTypes } from "./transaction/di/transactionTypes"; import { typedDataTypes } from "./typed-data/di/typedDataTypes"; -import { type Transaction, type TypedData } from ".."; +import { type TypedData } from ".."; import { DefaultSignerEth } from "./DefaultSignerEth"; describe("DefaultSignerEth", () => { @@ -46,7 +46,7 @@ describe("DefaultSignerEth", () => { it("should sign a transaction", async () => { // GIVEN const derivationPath = "derivationPath"; - const transaction = {} as Transaction; + const transaction = new Uint8Array(0); // WHEN const result = await signer.signTransaction(derivationPath, transaction); diff --git a/packages/signer/signer-eth/src/internal/DefaultSignerEth.ts b/packages/signer/signer-eth/src/internal/DefaultSignerEth.ts index a6d985c25..d798a2928 100644 --- a/packages/signer/signer-eth/src/internal/DefaultSignerEth.ts +++ b/packages/signer/signer-eth/src/internal/DefaultSignerEth.ts @@ -10,7 +10,6 @@ import { type SignPersonalMessageDAReturnType } from "@api/app-binder/SignPerson import { type SignTransactionDAReturnType } from "@api/app-binder/SignTransactionDeviceActionTypes"; import { type SignTypedDataDAReturnType } from "@api/app-binder/SignTypedDataDeviceActionTypes"; import { type AddressOptions } from "@api/model/AddressOptions"; -import { type Transaction } from "@api/model/Transaction"; import { type TransactionOptions } from "@api/model/TransactionOptions"; import { type TypedData } from "@api/model/TypedData"; import { type SignerEth } from "@api/SignerEth"; @@ -39,7 +38,7 @@ export class DefaultSignerEth implements SignerEth { signTransaction( derivationPath: string, - transaction: Transaction, + transaction: Uint8Array, options?: TransactionOptions, ): SignTransactionDAReturnType { return this._container diff --git a/packages/signer/signer-eth/src/internal/app-binder/EthAppBinder.test.ts b/packages/signer/signer-eth/src/internal/app-binder/EthAppBinder.test.ts index 6bbd21209..2a1a4dae4 100644 --- a/packages/signer/signer-eth/src/internal/app-binder/EthAppBinder.test.ts +++ b/packages/signer/signer-eth/src/internal/app-binder/EthAppBinder.test.ts @@ -2,11 +2,12 @@ import { type ContextModule } from "@ledgerhq/context-module"; import { type DeviceActionState, type DeviceManagementKit, + hexaStringToBuffer, } from "@ledgerhq/device-management-kit"; import { DeviceActionStatus } from "@ledgerhq/device-management-kit"; import { SendCommandInAppDeviceAction } from "@ledgerhq/device-management-kit"; import { UserInteractionRequired } from "@ledgerhq/device-management-kit"; -import { Transaction } from "ethers-v6"; +import { Transaction } from "ethers"; import { from } from "rxjs"; import { @@ -199,9 +200,12 @@ describe("EthAppBinder", () => { s: `0xBEEF`, v: 0, }; - const transaction: Transaction = new Transaction(); - transaction.to = "0x1234567890123456789012345678901234567890"; - transaction.value = 0n; + const transaction: Uint8Array = hexaStringToBuffer( + Transaction.from({ + to: "0x1234567890123456789012345678901234567890", + value: 0n, + }).unsignedSerialized, + )!; const options = {}; jest.spyOn(mockedDmk, "executeDeviceAction").mockReturnValue({ @@ -268,9 +272,12 @@ describe("EthAppBinder", () => { s: `0xBEEF`, v: 0, }; - const transaction: Transaction = new Transaction(); - transaction.to = "0x1234567890123456789012345678901234567890"; - transaction.value = 0n; + const transaction: Uint8Array = hexaStringToBuffer( + Transaction.from({ + to: "0x1234567890123456789012345678901234567890", + value: 0n, + }).unsignedSerialized, + )!; jest.spyOn(mockedDmk, "executeDeviceAction").mockReturnValue({ observable: from([ diff --git a/packages/signer/signer-eth/src/internal/app-binder/EthAppBinder.ts b/packages/signer/signer-eth/src/internal/app-binder/EthAppBinder.ts index 5fa886395..ce9aeb1ef 100644 --- a/packages/signer/signer-eth/src/internal/app-binder/EthAppBinder.ts +++ b/packages/signer/signer-eth/src/internal/app-binder/EthAppBinder.ts @@ -11,7 +11,6 @@ import { type GetAddressDAReturnType } from "@api/app-binder/GetAddressDeviceAct import { type SignPersonalMessageDAReturnType } from "@api/app-binder/SignPersonalMessageDeviceActionTypes"; import { type SignTransactionDAReturnType } from "@api/app-binder/SignTransactionDeviceActionTypes"; import { type SignTypedDataDAReturnType } from "@api/app-binder/SignTypedDataDeviceActionTypes"; -import { type Transaction } from "@api/model/Transaction"; import { type TransactionOptions } from "@api/model/TransactionOptions"; import { type TypedData } from "@api/model/TypedData"; import { SignTypedDataDeviceAction } from "@internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction"; @@ -73,7 +72,7 @@ export class EthAppBinder { signTransaction(args: { derivationPath: string; - transaction: Transaction; + transaction: Uint8Array; options?: TransactionOptions; }): SignTransactionDAReturnType { return this.dmk.executeDeviceAction({ diff --git a/packages/signer/signer-eth/src/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.ts b/packages/signer/signer-eth/src/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.ts index 23f550776..1643027e5 100644 --- a/packages/signer/signer-eth/src/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.ts +++ b/packages/signer/signer-eth/src/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.ts @@ -2,15 +2,16 @@ import { type ContextModule } from "@ledgerhq/context-module"; import { CommandResultFactory, DeviceActionStatus, + hexaStringToBuffer, UnknownDAError, UserInteractionRequired, } from "@ledgerhq/device-management-kit"; import { InvalidStatusWordError } from "@ledgerhq/device-management-kit"; -import { Transaction } from "ethers-v6"; +import { Transaction } from "ethers"; import { Just, Nothing } from "purify-ts"; import { type SignTransactionDAState } from "@api/app-binder/SignTransactionDeviceActionTypes"; -import { TransactionType } from "@api/model/Transaction"; +import { TransactionType } from "@api/model/TransactionType"; import { makeDeviceActionInternalApiMock } from "@internal/app-binder/device-action/__test-utils__/makeInternalApi"; import { setupOpenAppDAMock } from "@internal/app-binder/device-action/__test-utils__/setupOpenAppDAMock"; import { testDeviceActionStates } from "@internal/app-binder/device-action/__test-utils__/testDeviceActionStates"; @@ -59,14 +60,16 @@ describe("SignTransactionDeviceAction", () => { const defaultOptions = { domain: "domain-name.eth", }; - let defaultTransaction: Transaction; + const defaultTransaction: Uint8Array = hexaStringToBuffer( + Transaction.from({ + chainId: 1n, + nonce: 0, + data: "0x", + }).unsignedSerialized, + )!; beforeEach(() => { jest.clearAllMocks(); - defaultTransaction = new Transaction(); - defaultTransaction.chainId = 1n; - defaultTransaction.nonce = 0; - defaultTransaction.data = "0x"; }); describe("Happy path", () => { diff --git a/packages/signer/signer-eth/src/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.ts b/packages/signer/signer-eth/src/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.ts index 156f8098c..8d93524ad 100644 --- a/packages/signer/signer-eth/src/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.ts +++ b/packages/signer/signer-eth/src/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.ts @@ -25,8 +25,8 @@ import { type SignTransactionDAOutput, } from "@api/app-binder/SignTransactionDeviceActionTypes"; import { type Signature } from "@api/model/Signature"; -import { type Transaction, type TransactionType } from "@api/model/Transaction"; import { type TransactionOptions } from "@api/model/TransactionOptions"; +import { type TransactionType } from "@api/model/TransactionType"; import { GetChallengeCommand, type GetChallengeCommandResponse, @@ -54,7 +54,7 @@ export type MachineDependencies = { input: { contextModule: ContextModule; mapper: TransactionMapperService; - transaction: Transaction; + transaction: Uint8Array; options: TransactionOptions; challenge: string; }; diff --git a/packages/signer/signer-eth/src/internal/app-binder/task/BuildTransactionContextTask.test.ts b/packages/signer/signer-eth/src/internal/app-binder/task/BuildTransactionContextTask.test.ts index ac1799012..5af9cf615 100644 --- a/packages/signer/signer-eth/src/internal/app-binder/task/BuildTransactionContextTask.test.ts +++ b/packages/signer/signer-eth/src/internal/app-binder/task/BuildTransactionContextTask.test.ts @@ -5,8 +5,9 @@ import { import { DeviceSessionStateType, DeviceStatus, + hexaStringToBuffer, } from "@ledgerhq/device-management-kit"; -import { Transaction } from "ethers-v6"; +import { Transaction } from "ethers"; import { Left, Right } from "purify-ts"; import { makeDeviceActionInternalApiMock } from "@internal/app-binder/device-action/__test-utils__/makeInternalApi"; @@ -30,18 +31,20 @@ describe("BuildTransactionContextTask", () => { const defaultOptions = { domain: "domain-name.eth", }; - let defaultTransaction: Transaction; + const defaultTransaction: Uint8Array = hexaStringToBuffer( + Transaction.from({ + chainId: 1n, + nonce: 0, + data: "0x", + }).unsignedSerialized, + )!; + let defaultArgs: BuildTransactionContextTaskArgs; const apiMock = makeDeviceActionInternalApiMock(); beforeEach(() => { jest.clearAllMocks(); - defaultTransaction = new Transaction(); - defaultTransaction.chainId = 1n; - defaultTransaction.nonce = 0; - defaultTransaction.data = "0x"; - defaultArgs = { contextModule: contextModuleMock, mapper: mapperMock as unknown as TransactionMapperService, diff --git a/packages/signer/signer-eth/src/internal/app-binder/task/BuildTransactionContextTask.ts b/packages/signer/signer-eth/src/internal/app-binder/task/BuildTransactionContextTask.ts index 669f97000..75f382c08 100644 --- a/packages/signer/signer-eth/src/internal/app-binder/task/BuildTransactionContextTask.ts +++ b/packages/signer/signer-eth/src/internal/app-binder/task/BuildTransactionContextTask.ts @@ -10,8 +10,8 @@ import { } from "@ledgerhq/device-management-kit"; import { gte } from "semver"; -import { type Transaction, type TransactionType } from "@api/model/Transaction"; import { type TransactionOptions } from "@api/model/TransactionOptions"; +import { type TransactionType } from "@api/model/TransactionType"; import { type TransactionMapperService } from "@internal/transaction/service/mapper/TransactionMapperService"; import { type GenericContext } from "./ProvideTransactionGenericContextTask"; @@ -26,7 +26,7 @@ export type BuildTransactionTaskResult = { export type BuildTransactionContextTaskArgs = { readonly contextModule: ContextModule; readonly mapper: TransactionMapperService; - readonly transaction: Transaction; + readonly transaction: Uint8Array; readonly options: TransactionOptions; readonly challenge: string; }; diff --git a/packages/signer/signer-eth/src/internal/app-binder/task/SendSignTransactionTask.test.ts b/packages/signer/signer-eth/src/internal/app-binder/task/SendSignTransactionTask.test.ts index 85a08b878..bc89d7865 100644 --- a/packages/signer/signer-eth/src/internal/app-binder/task/SendSignTransactionTask.test.ts +++ b/packages/signer/signer-eth/src/internal/app-binder/task/SendSignTransactionTask.test.ts @@ -4,7 +4,7 @@ import { hexaStringToBuffer, InvalidStatusWordError, } from "@ledgerhq/device-management-kit"; -import { Transaction } from "ethers-v6"; +import { Transaction } from "ethers"; import { Just, Nothing } from "purify-ts"; import { SignTransactionCommand } from "@internal/app-binder/command/SignTransactionCommand"; diff --git a/packages/signer/signer-eth/src/internal/app-binder/task/SendSignTransactionTask.ts b/packages/signer/signer-eth/src/internal/app-binder/task/SendSignTransactionTask.ts index 60d4fe985..8cbc50931 100644 --- a/packages/signer/signer-eth/src/internal/app-binder/task/SendSignTransactionTask.ts +++ b/packages/signer/signer-eth/src/internal/app-binder/task/SendSignTransactionTask.ts @@ -9,11 +9,11 @@ import { isSuccessCommandResult, } from "@ledgerhq/device-management-kit"; import { DerivationPathUtils } from "@ledgerhq/signer-utils"; -import { decodeRlp, encodeRlp } from "ethers-v6"; +import { decodeRlp, encodeRlp } from "ethers"; import { Nothing } from "purify-ts"; import { type Signature } from "@api/index"; -import { TransactionType } from "@api/model/Transaction"; +import { TransactionType } from "@api/model/TransactionType"; import { SignTransactionCommand, type SignTransactionCommandResponse, diff --git a/packages/signer/signer-eth/src/internal/transaction/di/transactionModule.test.ts b/packages/signer/signer-eth/src/internal/transaction/di/transactionModule.test.ts index d3e581399..35925291f 100644 --- a/packages/signer/signer-eth/src/internal/transaction/di/transactionModule.test.ts +++ b/packages/signer/signer-eth/src/internal/transaction/di/transactionModule.test.ts @@ -17,10 +17,10 @@ describe("transactionModuleFactory", () => { expect(mod).toBeDefined(); }); - it("should bind a list of transaction mappers", () => { + it("should bind a transaction mapper", () => { expect( container.getAll(transactionTypes.TransactionMappers), - ).toHaveLength(2); + ).toHaveLength(1); }); }); }); diff --git a/packages/signer/signer-eth/src/internal/transaction/di/transactionModule.ts b/packages/signer/signer-eth/src/internal/transaction/di/transactionModule.ts index 6ac7fb199..132602a36 100644 --- a/packages/signer/signer-eth/src/internal/transaction/di/transactionModule.ts +++ b/packages/signer/signer-eth/src/internal/transaction/di/transactionModule.ts @@ -1,8 +1,7 @@ import { ContainerModule } from "inversify"; import { transactionTypes } from "@internal/transaction/di/transactionTypes"; -import { EthersV5TransactionMapper } from "@internal/transaction/service/mapper/EthersV5TransactionMapper"; -import { EthersV6TransactionMapper } from "@internal/transaction/service/mapper/EthersV6TransactionMapper"; +import { EthersRawTransactionMapper } from "@internal/transaction/service/mapper/EthersRawTransactionMapper"; import { TransactionMapperService } from "@internal/transaction/service/mapper/TransactionMapperService"; import { TransactionParserService } from "@internal/transaction/service/parser/TransactionParserService"; import { SignTransactionUseCase } from "@internal/transaction/use-case/SignTransactionUseCase"; @@ -25,7 +24,6 @@ export const transactionModuleFactory = () => bind(transactionTypes.TransactionParserService).to( TransactionParserService, ); - bind(transactionTypes.TransactionMappers).to(EthersV5TransactionMapper); - bind(transactionTypes.TransactionMappers).to(EthersV6TransactionMapper); + bind(transactionTypes.TransactionMappers).to(EthersRawTransactionMapper); }, ); diff --git a/packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersRawTransactionMapper.test.ts b/packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersRawTransactionMapper.test.ts new file mode 100644 index 000000000..a00ca2149 --- /dev/null +++ b/packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersRawTransactionMapper.test.ts @@ -0,0 +1,133 @@ +import { hexaStringToBuffer } from "@ledgerhq/device-management-kit"; +import { getBytes, Transaction } from "ethers"; + +import { EthersRawTransactionMapper } from "./EthersRawTransactionMapper"; + +describe("RawTransactionMapper", () => { + const mapper = new EthersRawTransactionMapper(); + + it("should return Nothing when empty raw transaction", () => { + // GIVEN + const transaction = new Uint8Array(0); + + // WHEN + const result = mapper.map(transaction); + + // THEN + expect(result.isNothing()).toBeTruthy(); + }); + + it("should return Nothing when invalid raw transaction", () => { + // GIVEN + const transaction = new Uint8Array(1); + + // WHEN + const result = mapper.map(transaction); + + // THEN + expect(result.isNothing()).toBeTruthy(); + }); + + it("should return a TransactionMapperResult", () => { + // GIVEN + const transaction = hexaStringToBuffer( + Transaction.from({ + chainId: 1, + to: "0x1234567890123456789012345678901234567890", + data: "0x123456", + }).unsignedSerialized, + )!; + + // WHEN + const result = mapper.map(transaction); + + // THEN + expect(result.isJust()).toBeTruthy(); + expect(result.extract()?.serializedTransaction).toEqual( + getBytes(transaction), + ); + expect(result.extract()?.subset).toEqual({ + chainId: 1, + to: "0x1234567890123456789012345678901234567890", + data: "0x123456", + }); + expect(result.extract()?.type).toEqual(2); + }); + + it("should return a TransactionMapperResult with undefined to", () => { + // GIVEN + const transaction = hexaStringToBuffer( + Transaction.from({ + chainId: 1, + data: "0x123456", + }).unsignedSerialized, + )!; + + // WHEN + const result = mapper.map(transaction); + + // THEN + expect(result.isJust()).toBeTruthy(); + expect(result.extract()?.serializedTransaction).toEqual( + getBytes(transaction), + ); + expect(result.extract()?.subset).toEqual({ + chainId: 1, + to: undefined, + data: "0x123456", + }); + expect(result.extract()?.type).toEqual(2); + }); + + it("should return a TransactionMapperResult with empty data", () => { + // GIVEN + const transaction = hexaStringToBuffer( + Transaction.from({ + chainId: 1, + to: "0x1234567890123456789012345678901234567890", + }).unsignedSerialized, + )!; + + // WHEN + const result = mapper.map(transaction); + + // THEN + expect(result.isJust()).toBeTruthy(); + expect(result.extract()?.serializedTransaction).toEqual( + getBytes(transaction), + ); + expect(result.extract()?.subset).toEqual({ + chainId: 1, + to: "0x1234567890123456789012345678901234567890", + data: "0x", + }); + expect(result.extract()?.type).toEqual(2); + }); + + it("should return a TransactionMapperResult with a custom type", () => { + // GIVEN + const transaction = hexaStringToBuffer( + Transaction.from({ + chainId: 1, + to: "0x1234567890123456789012345678901234567890", + data: "0x123456", + type: 1, + }).unsignedSerialized, + )!; + + // WHEN + const result = mapper.map(transaction); + + // THEN + expect(result.isJust()).toBeTruthy(); + expect(result.extract()?.serializedTransaction).toEqual( + getBytes(transaction), + ); + expect(result.extract()?.subset).toEqual({ + chainId: 1, + to: "0x1234567890123456789012345678901234567890", + data: "0x123456", + }); + expect(result.extract()?.type).toEqual(1); + }); +}); diff --git a/packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersRawTransactionMapper.ts b/packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersRawTransactionMapper.ts new file mode 100644 index 000000000..e1ecbaafa --- /dev/null +++ b/packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersRawTransactionMapper.ts @@ -0,0 +1,27 @@ +import { bufferToHexaString } from "@ledgerhq/device-management-kit"; +import { ethers, getBytes } from "ethers"; +import { injectable } from "inversify"; +import { Just, Maybe, Nothing } from "purify-ts"; + +import { TransactionMapperResult } from "./model/TransactionMapperResult"; +import { TransactionMapper } from "./TransactionMapper"; + +@injectable() +export class EthersRawTransactionMapper implements TransactionMapper { + map(transaction: Uint8Array): Maybe { + try { + const tx = ethers.Transaction.from(bufferToHexaString(transaction)); + return Just({ + subset: { + chainId: Number(tx.chainId.toString()), + to: tx.to ?? undefined, + data: tx.data, + }, + serializedTransaction: getBytes(tx.unsignedSerialized), + type: tx.type || 0, + }); + } catch (_error) { + return Nothing; + } + } +} diff --git a/packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersV5TransactionMapper.test.ts b/packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersV5TransactionMapper.test.ts deleted file mode 100644 index 9b75b9161..000000000 --- a/packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersV5TransactionMapper.test.ts +++ /dev/null @@ -1,146 +0,0 @@ -import { - BigNumber as EthersV5BigNumber, - type Transaction as EthersV5Transaction, -} from "ethers-v5"; -import { Transaction as EthersV6Transaction } from "ethers-v6"; -import { Just } from "purify-ts"; - -import { type Transaction } from "@api/index"; - -import { EthersV5TransactionMapper } from "./EthersV5TransactionMapper"; -import { type TransactionMapper } from "./TransactionMapper"; - -describe("EthersV5TransactionMapper", () => { - let mapper: TransactionMapper; - - beforeEach(() => { - mapper = new EthersV5TransactionMapper(); - }); - - describe("map", () => { - it("should return the correct TransactionSubset", () => { - // GIVEN - const transaction: EthersV5Transaction = { - chainId: 1, - nonce: 0, - gasLimit: EthersV5BigNumber.from(0), - value: EthersV5BigNumber.from(0), - data: "0x", - }; - const serializedTransaction = new Uint8Array([ - 0xc9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x01, 0x80, 0x80, - ]); - - // WHEN - const result = mapper.map(transaction); - - // THEN - expect(result).toEqual( - Just({ - subset: { - chainId: 1, - to: undefined, - data: "0x", - }, - serializedTransaction, - type: 0, - }), - ); - }); - - it("should return the correct TransactionSubset with to attribute", () => { - // GIVEN - const transaction: EthersV5Transaction = { - chainId: 1, - nonce: 0, - gasLimit: EthersV5BigNumber.from(0), - value: EthersV5BigNumber.from(0), - data: "0x", - to: "0x", - }; - const serializedTransaction = new Uint8Array([ - 0xc9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x01, 0x80, 0x80, - ]); - - // WHEN - const result = mapper.map(transaction); - - // THEN - expect(result).toEqual( - Just({ - subset: { - chainId: 1, - to: "0x", - data: "0x", - }, - serializedTransaction, - type: 0, - }), - ); - }); - - it("should return the correct TransactionSubset with all attributes", () => { - // GIVEN - const transaction: EthersV5Transaction = { - chainId: 1, - nonce: 0, - gasLimit: EthersV5BigNumber.from(0), - gasPrice: EthersV5BigNumber.from(0), - value: EthersV5BigNumber.from(0), - data: "0x", - from: "0x", - r: "0x", - s: "0x", - v: 0, - type: 1, - maxFeePerGas: EthersV5BigNumber.from(0), - maxPriorityFeePerGas: EthersV5BigNumber.from(0), - }; - const serializedTransaction = new Uint8Array([ - 0xc9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x01, 0x80, 0x80, - ]); - - // WHEN - const result = mapper.map(transaction); - - // THEN - expect(result).toEqual( - Just({ - subset: { - chainId: 1, - to: undefined, - data: "0x", - }, - serializedTransaction, - type: 1, - }), - ); - }); - - it("should return Nothing when the transaction is not an EthersV5Transaction", () => { - // GIVEN - const transaction = {} as Transaction; - - // WHEN - const result = mapper.map(transaction); - - // THEN - expect(result.isNothing()).toBeTruthy(); - }); - - it("should return Nothing when the transaction is an EthersV6Transaction", () => { - // GIVEN - const transaction = new EthersV6Transaction(); - transaction.chainId = 1n; - transaction.nonce = 0; - transaction.data = "0x"; - transaction.to = "0x0123456789abcdef0123456789abcdef01234567"; - - // WHEN - const result = mapper.map(transaction); - - // THEN - expect(result.isNothing()).toBeTruthy(); - }); - }); -}); diff --git a/packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersV5TransactionMapper.ts b/packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersV5TransactionMapper.ts deleted file mode 100644 index 59f004138..000000000 --- a/packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersV5TransactionMapper.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { - BigNumber, - ethers, - Transaction as EthersV5Transaction, -} from "ethers-v5"; -import { injectable } from "inversify"; -import { Just, Maybe, Nothing } from "purify-ts"; - -import { Transaction } from "@api/index"; - -import { TransactionMapperResult } from "./model/TransactionMapperResult"; -import { TransactionMapper } from "./TransactionMapper"; - -@injectable() -export class EthersV5TransactionMapper implements TransactionMapper { - constructor() {} - - map(transaction: Transaction): Maybe { - if (this.isEthersV5Transaction(transaction)) { - // ensure that we have a valid non signed transaction - const txUnsigned = { - to: transaction.to, - nonce: transaction.nonce, - gasLimit: transaction.gasLimit, - gasPrice: transaction.gasPrice, - data: transaction.data, - value: transaction.value, - chainId: transaction.chainId, - }; - const serializedTransaction = ethers.utils.arrayify( - ethers.utils.serializeTransaction(txUnsigned), - ); - - return Just({ - subset: { - chainId: transaction.chainId, - to: transaction.to, - data: transaction.data, - }, - serializedTransaction, - type: transaction.type || 0, - }); - } - - return Nothing; - } - - private isEthersV5Transaction( - transaction: Transaction, - ): transaction is EthersV5Transaction { - const tx = transaction as EthersV5Transaction; - return ( - typeof tx === "object" && - tx !== null && - (tx.to === undefined || typeof tx.to === "string") && - typeof tx.nonce === "number" && - tx.gasLimit instanceof BigNumber && - (tx.gasPrice === undefined || tx.gasPrice instanceof BigNumber) && - typeof tx.data === "string" && - tx.value instanceof BigNumber && - typeof tx.chainId === "number" && - (tx.type === undefined || typeof tx.type === "number") - ); - } -} diff --git a/packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersV6TransactionMapper.test.ts b/packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersV6TransactionMapper.test.ts deleted file mode 100644 index 4147b98db..000000000 --- a/packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersV6TransactionMapper.test.ts +++ /dev/null @@ -1,147 +0,0 @@ -import { - BigNumber as EthersV5BigNumber, - type Transaction as EthersV5Transaction, -} from "ethers-v5"; -import { Transaction as EthersV6Transaction } from "ethers-v6"; -import { Just } from "purify-ts"; - -import { type Transaction } from "@api/index"; - -import { EthersV6TransactionMapper } from "./EthersV6TransactionMapper"; - -describe("EthersV6TransactionMapper", () => { - let mapper: EthersV6TransactionMapper; - - beforeEach(() => { - mapper = new EthersV6TransactionMapper(); - }); - - describe("map", () => { - it("should return the correct TransactionSubset", () => { - // GIVEN - const transaction = new EthersV6Transaction(); - transaction.chainId = 1n; - transaction.nonce = 0; - transaction.data = "0x"; - const serializedTransaction = new Uint8Array([ - 2, 201, 1, 128, 128, 128, 128, 128, 128, 128, 192, - ]); - - // WHEN - const result = mapper.map(transaction); - - // THEN - expect(result).toEqual( - Just({ - subset: { - chainId: 1, - to: undefined, - data: "0x", - }, - serializedTransaction, - type: 0, - }), - ); - }); - - it("should return the correct TransactionSubset with to attribute", () => { - // GIVEN - const transaction = new EthersV6Transaction(); - transaction.chainId = 1n; - transaction.nonce = 0; - transaction.data = "0x"; - transaction.to = "0x0123456789abcdef0123456789abcdef01234567"; - const serializedTransaction = new Uint8Array([ - 0x02, 0xdd, 0x01, 0x80, 0x80, 0x80, 0x80, 0x94, 0x01, 0x23, 0x45, 0x67, - 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, - 0x01, 0x23, 0x45, 0x67, 0x80, 0x80, 0xc0, - ]); - - // WHEN - const result = mapper.map(transaction); - - // THEN - expect(result).toEqual( - Just({ - subset: { - chainId: 1, - to: "0x0123456789abcDEF0123456789abCDef01234567", - data: "0x", - }, - serializedTransaction, - type: 0, - }), - ); - }); - - it("should return the correct TransactionSubset with all attributes", () => { - // GIVEN - const transaction = new EthersV6Transaction(); - transaction.type = 1; - transaction.to = "0x0123456789abcdef0123456789abcdef01234567"; - transaction.data = "0x"; - transaction.nonce = 0; - transaction.gasLimit = 0n; - transaction.gasPrice = 0n; - transaction.value = 0n; - transaction.chainId = 1n; - const serializedTransaction = new Uint8Array([ - 0x01, 0xdc, 0x01, 0x80, 0x80, 0x80, 0x94, 0x01, 0x23, 0x45, 0x67, 0x89, - 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, - 0x23, 0x45, 0x67, 0x80, 0x80, 0xc0, - ]); - - // WHEN - const result = mapper.map(transaction); - - // THEN - expect(result).toEqual( - Just({ - subset: { - chainId: 1, - to: "0x0123456789abcDEF0123456789abCDef01234567", - data: "0x", - }, - serializedTransaction, - type: 1, - }), - ); - }); - - it("should return Nothing when the transaction is not an EthersV6Transaction", () => { - // GIVEN - const transaction = {} as Transaction; - - // WHEN - const result = mapper.map(transaction); - - // THEN - expect(result.isNothing()).toBeTruthy(); - }); - - it("should return Nothing when the transaction is not an EthersV5Transaction", () => { - // GIVEN - const transaction: EthersV5Transaction = { - chainId: 1, - nonce: 0, - gasLimit: EthersV5BigNumber.from(0), - gasPrice: EthersV5BigNumber.from(0), - value: EthersV5BigNumber.from(0), - data: "0x", - from: "0x", - r: "0x", - s: "0x", - v: 0, - type: 1, - maxFeePerGas: EthersV5BigNumber.from(0), - maxPriorityFeePerGas: EthersV5BigNumber.from(0), - }; - - // WHEN - const result = mapper.map(transaction); - - // THEN - expect(result.isNothing()).toBeTruthy(); - }); - }); -}); diff --git a/packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersV6TransactionMapper.ts b/packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersV6TransactionMapper.ts deleted file mode 100644 index 220af0d29..000000000 --- a/packages/signer/signer-eth/src/internal/transaction/service/mapper/EthersV6TransactionMapper.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { - BigNumberish, - getBytes, - Transaction as EthersV6Transaction, -} from "ethers-v6"; -import { injectable } from "inversify"; -import { Just, Maybe, Nothing } from "purify-ts"; - -import { Transaction } from "@api/model/Transaction"; - -import { TransactionMapperResult } from "./model/TransactionMapperResult"; -import { TransactionMapper } from "./TransactionMapper"; - -@injectable() -export class EthersV6TransactionMapper implements TransactionMapper { - map(transaction: Transaction): Maybe { - if (this.isEthersV6Transaction(transaction)) { - const serializedTransaction = getBytes(transaction.unsignedSerialized); - return Just({ - subset: { - chainId: Number(transaction.chainId.toString()), - to: transaction.to ?? undefined, - data: transaction.data, - }, - serializedTransaction, - type: transaction.type || 0, - }); - } - - return Nothing; - } - - private isEthersV6Transaction( - transaction: Transaction, - ): transaction is EthersV6Transaction { - return ( - typeof transaction === "object" && - (transaction.hash === null || typeof transaction.hash === "string") && - (transaction.to === null || typeof transaction.to === "string") && - (transaction.gasLimit == null || isBigNumberish(transaction.gasLimit)) && - (transaction.gasPrice === null || isBigNumberish(transaction.gasPrice)) && - (transaction.value === null || isBigNumberish(transaction.value)) && - (transaction.chainId === null || - isBigNumberish(typeof transaction.chainId)) && - (transaction.type === null || typeof transaction.type === "number") - ); - } -} - -const isBigNumberish = (number: unknown): number is BigNumberish => - typeof number === "string" || - typeof number === "number" || - typeof number === "bigint"; diff --git a/packages/signer/signer-eth/src/internal/transaction/service/mapper/TransactionMapper.ts b/packages/signer/signer-eth/src/internal/transaction/service/mapper/TransactionMapper.ts index 9c614cf14..7a0ee41d1 100644 --- a/packages/signer/signer-eth/src/internal/transaction/service/mapper/TransactionMapper.ts +++ b/packages/signer/signer-eth/src/internal/transaction/service/mapper/TransactionMapper.ts @@ -1,9 +1,7 @@ import { type Maybe } from "purify-ts"; -import { type Transaction } from "@api/index"; - import { type TransactionMapperResult } from "./model/TransactionMapperResult"; export interface TransactionMapper { - map(transaction: Transaction): Maybe; + map(transaction: Uint8Array): Maybe; } diff --git a/packages/signer/signer-eth/src/internal/transaction/service/mapper/TransactionMapperService.test.ts b/packages/signer/signer-eth/src/internal/transaction/service/mapper/TransactionMapperService.test.ts index 97646783e..2c4970dbe 100644 --- a/packages/signer/signer-eth/src/internal/transaction/service/mapper/TransactionMapperService.test.ts +++ b/packages/signer/signer-eth/src/internal/transaction/service/mapper/TransactionMapperService.test.ts @@ -1,8 +1,6 @@ import { type TransactionSubset } from "@ledgerhq/context-module"; import { Just, type Maybe, Nothing, Right } from "purify-ts"; -import { type Transaction } from "@api/index"; - import { TransactionMapperService } from "./TransactionMapperService"; const transactionMapperBuilder = (value?: Maybe) => { @@ -26,7 +24,7 @@ describe("TransactionMapperService", () => { service = new TransactionMapperService(mappers); // WHEN - const result = service.mapTransactionToSubset({} as Transaction); + const result = service.mapTransactionToSubset(new Uint8Array(0)); // THEN expect(mappers[0]!.map).toHaveBeenCalled(); @@ -43,7 +41,7 @@ describe("TransactionMapperService", () => { service = new TransactionMapperService(mappers); // WHEN - const result = service.mapTransactionToSubset({} as Transaction); + const result = service.mapTransactionToSubset(new Uint8Array(0)); // THEN expect(mappers[0]!.map).toHaveBeenCalled(); @@ -60,7 +58,7 @@ describe("TransactionMapperService", () => { service = new TransactionMapperService(mappers); // WHEN - const result = service.mapTransactionToSubset({} as Transaction); + const result = service.mapTransactionToSubset(new Uint8Array(0)); // THEN expect(mappers[0]!.map).toHaveBeenCalled(); diff --git a/packages/signer/signer-eth/src/internal/transaction/service/mapper/TransactionMapperService.ts b/packages/signer/signer-eth/src/internal/transaction/service/mapper/TransactionMapperService.ts index 9a1b8f39a..ba04769fe 100644 --- a/packages/signer/signer-eth/src/internal/transaction/service/mapper/TransactionMapperService.ts +++ b/packages/signer/signer-eth/src/internal/transaction/service/mapper/TransactionMapperService.ts @@ -1,7 +1,6 @@ import { injectable, multiInject } from "inversify"; import { Either, Left, Right } from "purify-ts"; -import { Transaction } from "@api/index"; import { transactionTypes } from "@internal/transaction/di/transactionTypes"; import { TransactionMapperResult } from "./model/TransactionMapperResult"; @@ -19,7 +18,7 @@ export class TransactionMapperService { } mapTransactionToSubset( - transaction: Transaction, + transaction: Uint8Array, ): Either { for (const mapper of this._mappers) { const result = mapper.map(transaction); diff --git a/packages/signer/signer-eth/src/internal/transaction/service/mapper/model/TransactionMapperResult.ts b/packages/signer/signer-eth/src/internal/transaction/service/mapper/model/TransactionMapperResult.ts index 728d152cf..5508e554b 100644 --- a/packages/signer/signer-eth/src/internal/transaction/service/mapper/model/TransactionMapperResult.ts +++ b/packages/signer/signer-eth/src/internal/transaction/service/mapper/model/TransactionMapperResult.ts @@ -1,6 +1,6 @@ import { type TransactionSubset } from "@ledgerhq/context-module"; -import type { TransactionType } from "@api/model/Transaction"; +import type { TransactionType } from "@api/model/TransactionType"; export type TransactionMapperResult = { /** diff --git a/packages/signer/signer-eth/src/internal/transaction/service/parser/TransactionParserService.test.ts b/packages/signer/signer-eth/src/internal/transaction/service/parser/TransactionParserService.test.ts index bd221b05f..8e075f866 100644 --- a/packages/signer/signer-eth/src/internal/transaction/service/parser/TransactionParserService.test.ts +++ b/packages/signer/signer-eth/src/internal/transaction/service/parser/TransactionParserService.test.ts @@ -4,7 +4,7 @@ import { ByteArrayBuilder, hexaStringToBuffer, } from "@ledgerhq/device-management-kit"; -import { Transaction } from "ethers-v6"; +import { Transaction } from "ethers"; import { TransactionParserService } from "./TransactionParserService"; diff --git a/packages/signer/signer-eth/src/internal/transaction/service/parser/TransactionParserService.ts b/packages/signer/signer-eth/src/internal/transaction/service/parser/TransactionParserService.ts index eb5d5ad6f..dca37ebcb 100644 --- a/packages/signer/signer-eth/src/internal/transaction/service/parser/TransactionParserService.ts +++ b/packages/signer/signer-eth/src/internal/transaction/service/parser/TransactionParserService.ts @@ -14,7 +14,7 @@ import { ByteArrayParser, hexaStringToBuffer, } from "@ledgerhq/device-management-kit"; -import { Transaction } from "ethers-v6"; +import { Transaction } from "ethers"; import { injectable } from "inversify"; import { Either, Left, Maybe, Right } from "purify-ts"; diff --git a/packages/signer/signer-eth/src/internal/transaction/use-case/SignTransactionUseCase.test.ts b/packages/signer/signer-eth/src/internal/transaction/use-case/SignTransactionUseCase.test.ts index 5b17815b8..a9a27193e 100644 --- a/packages/signer/signer-eth/src/internal/transaction/use-case/SignTransactionUseCase.test.ts +++ b/packages/signer/signer-eth/src/internal/transaction/use-case/SignTransactionUseCase.test.ts @@ -1,4 +1,5 @@ -import { Transaction } from "ethers-v6"; +import { hexaStringToBuffer } from "@ledgerhq/device-management-kit"; +import { Transaction } from "ethers"; import { type EthAppBinder } from "@internal/app-binder/EthAppBinder"; @@ -8,14 +9,15 @@ describe("SignTransactionUseCase", () => { it("should call signTransaction on appBinder with the correct arguments", () => { // Given const derivationPath = "m/44'/60'/0'/0/0"; - const transaction: Transaction = new Transaction(); - transaction.to = "0x1234567890123456789012345678901234567890"; - transaction.value = 0n; - transaction.data = "0x"; + const tx: Transaction = new Transaction(); + tx.to = "0x1234567890123456789012345678901234567890"; + tx.value = 0n; + tx.data = "0x"; const appBinder: EthAppBinder = { signTransaction: jest.fn(), } as unknown as EthAppBinder; const useCase = new SignTransactionUseCase(appBinder); + const transaction = hexaStringToBuffer(tx.unsignedSerialized) as Uint8Array; // When useCase.execute(derivationPath, transaction); diff --git a/packages/signer/signer-eth/src/internal/transaction/use-case/SignTransactionUseCase.ts b/packages/signer/signer-eth/src/internal/transaction/use-case/SignTransactionUseCase.ts index cfd8d2ba0..d0c87e7c8 100644 --- a/packages/signer/signer-eth/src/internal/transaction/use-case/SignTransactionUseCase.ts +++ b/packages/signer/signer-eth/src/internal/transaction/use-case/SignTransactionUseCase.ts @@ -1,7 +1,6 @@ import { inject, injectable } from "inversify"; import { SignTransactionDAReturnType } from "@api/app-binder/SignTransactionDeviceActionTypes"; -import { Transaction } from "@api/model/Transaction"; import { TransactionOptions } from "@api/model/TransactionOptions"; import { appBinderTypes } from "@internal/app-binder/di/appBinderTypes"; import { EthAppBinder } from "@internal/app-binder/EthAppBinder"; @@ -19,7 +18,7 @@ export class SignTransactionUseCase { execute( derivationPath: string, - transaction: Transaction, + transaction: Uint8Array, options?: TransactionOptions, ): SignTransactionDAReturnType { return this._appBinding.signTransaction({ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ee8a40381..a8986954b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -166,9 +166,6 @@ importers: '@sentry/nextjs': specifier: ^8.42.0 version: 8.42.0(@opentelemetry/core@1.26.0(@opentelemetry/api@1.9.0))(@opentelemetry/instrumentation@0.54.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.26.0(@opentelemetry/api@1.9.0))(next@14.2.15(@babel/core@7.24.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.49.0)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1)(webpack@5.92.1(esbuild@0.24.0)) - ethers: - specifier: 6.13.4 - version: 6.13.4 next: specifier: 14.2.15 version: 14.2.15(@babel/core@7.24.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.49.0)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -486,12 +483,9 @@ importers: '@ledgerhq/signer-utils': specifier: workspace:* version: link:../signer-utils - ethers-v5: - specifier: npm:ethers@^5.7.2 - version: ethers@5.7.2 - ethers-v6: - specifier: npm:ethers@6.13.4 - version: ethers@6.13.4 + ethers: + specifier: 6.13.4 + version: 6.13.4 inversify: specifier: ^6.2.1 version: 6.2.1(reflect-metadata@0.2.2) @@ -2025,96 +2019,6 @@ packages: resolution: {integrity: sha512-zSkKow6H5Kdm0ZUQUB2kV5JIXqoG0+uH5YADhaEHswm664N9Db8dXSi0nMJpacpMf+MyyglF1vnZohpEg5yUtg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@ethersproject/abi@5.7.0': - resolution: {integrity: sha512-351ktp42TiRcYB3H1OP8yajPeAQstMW/yCFokj/AthP9bLHzQFPlOrxOcwYEDkUAICmOHljvN4K39OMTMUa9RA==} - - '@ethersproject/abstract-provider@5.7.0': - resolution: {integrity: sha512-R41c9UkchKCpAqStMYUpdunjo3pkEvZC3FAwZn5S5MGbXoMQOHIdHItezTETxAO5bevtMApSyEhn9+CHcDsWBw==} - - '@ethersproject/abstract-signer@5.7.0': - resolution: {integrity: sha512-a16V8bq1/Cz+TGCkE2OPMTOUDLS3grCpdjoJCYNnVBbdYEMSgKrU0+B90s8b6H+ByYTBZN7a3g76jdIJi7UfKQ==} - - '@ethersproject/address@5.7.0': - resolution: {integrity: sha512-9wYhYt7aghVGo758POM5nqcOMaE168Q6aRLJZwUmiqSrAungkG74gSSeKEIR7ukixesdRZGPgVqme6vmxs1fkA==} - - '@ethersproject/base64@5.7.0': - resolution: {integrity: sha512-Dr8tcHt2mEbsZr/mwTPIQAf3Ai0Bks/7gTw9dSqk1mQvhW3XvRlmDJr/4n+wg1JmCl16NZue17CDh8xb/vZ0sQ==} - - '@ethersproject/basex@5.7.0': - resolution: {integrity: sha512-ywlh43GwZLv2Voc2gQVTKBoVQ1mti3d8HK5aMxsfu/nRDnMmNqaSJ3r3n85HBByT8OpoY96SXM1FogC533T4zw==} - - '@ethersproject/bignumber@5.7.0': - resolution: {integrity: sha512-n1CAdIHRWjSucQO3MC1zPSVgV/6dy/fjL9pMrPP9peL+QxEg9wOsVqwD4+818B6LUEtaXzVHQiuivzRoxPxUGw==} - - '@ethersproject/bytes@5.7.0': - resolution: {integrity: sha512-nsbxwgFXWh9NyYWo+U8atvmMsSdKJprTcICAkvbBffT75qDocbuggBU0SJiVK2MuTrp0q+xvLkTnGMPK1+uA9A==} - - '@ethersproject/constants@5.7.0': - resolution: {integrity: sha512-DHI+y5dBNvkpYUMiRQyxRBYBefZkJfo70VUkUAsRjcPs47muV9evftfZ0PJVCXYbAiCgght0DtcF9srFQmIgWA==} - - '@ethersproject/contracts@5.7.0': - resolution: {integrity: sha512-5GJbzEU3X+d33CdfPhcyS+z8MzsTrBGk/sc+G+59+tPa9yFkl6HQ9D6L0QMgNTA9q8dT0XKxxkyp883XsQvbbg==} - - '@ethersproject/hash@5.7.0': - resolution: {integrity: sha512-qX5WrQfnah1EFnO5zJv1v46a8HW0+E5xuBBDTwMFZLuVTx0tbU2kkx15NqdjxecrLGatQN9FGQKpb1FKdHCt+g==} - - '@ethersproject/hdnode@5.7.0': - resolution: {integrity: sha512-OmyYo9EENBPPf4ERhR7oj6uAtUAhYGqOnIS+jE5pTXvdKBS99ikzq1E7Iv0ZQZ5V36Lqx1qZLeak0Ra16qpeOg==} - - '@ethersproject/json-wallets@5.7.0': - resolution: {integrity: sha512-8oee5Xgu6+RKgJTkvEMl2wDgSPSAQ9MB/3JYjFV9jlKvcYHUXZC+cQp0njgmxdHkYWn8s6/IqIZYm0YWCjO/0g==} - - '@ethersproject/keccak256@5.7.0': - resolution: {integrity: sha512-2UcPboeL/iW+pSg6vZ6ydF8tCnv3Iu/8tUmLLzWWGzxWKFFqOBQFLo6uLUv6BDrLgCDfN28RJ/wtByx+jZ4KBg==} - - '@ethersproject/logger@5.7.0': - resolution: {integrity: sha512-0odtFdXu/XHtjQXJYA3u9G0G8btm0ND5Cu8M7i5vhEcE8/HmF4Lbdqanwyv4uQTr2tx6b7fQRmgLrsnpQlmnig==} - - '@ethersproject/networks@5.7.1': - resolution: {integrity: sha512-n/MufjFYv3yFcUyfhnXotyDlNdFb7onmkSy8aQERi2PjNcnWQ66xXxa3XlS8nCcA8aJKJjIIMNJTC7tu80GwpQ==} - - '@ethersproject/pbkdf2@5.7.0': - resolution: {integrity: sha512-oR/dBRZR6GTyaofd86DehG72hY6NpAjhabkhxgr3X2FpJtJuodEl2auADWBZfhDHgVCbu3/H/Ocq2uC6dpNjjw==} - - '@ethersproject/properties@5.7.0': - resolution: {integrity: sha512-J87jy8suntrAkIZtecpxEPxY//szqr1mlBaYlQ0r4RCaiD2hjheqF9s1LVE8vVuJCXisjIP+JgtK/Do54ej4Sw==} - - '@ethersproject/providers@5.7.2': - resolution: {integrity: sha512-g34EWZ1WWAVgr4aptGlVBF8mhl3VWjv+8hoAnzStu8Ah22VHBsuGzP17eb6xDVRzw895G4W7vvx60lFFur/1Rg==} - - '@ethersproject/random@5.7.0': - resolution: {integrity: sha512-19WjScqRA8IIeWclFme75VMXSBvi4e6InrUNuaR4s5pTF2qNhcGdCUwdxUVGtDDqC00sDLCO93jPQoDUH4HVmQ==} - - '@ethersproject/rlp@5.7.0': - resolution: {integrity: sha512-rBxzX2vK8mVF7b0Tol44t5Tb8gomOHkj5guL+HhzQ1yBh/ydjGnpw6at+X6Iw0Kp3OzzzkcKp8N9r0W4kYSs9w==} - - '@ethersproject/sha2@5.7.0': - resolution: {integrity: sha512-gKlH42riwb3KYp0reLsFTokByAKoJdgFCwI+CCiX/k+Jm2mbNs6oOaCjYQSlI1+XBVejwH2KrmCbMAT/GnRDQw==} - - '@ethersproject/signing-key@5.7.0': - resolution: {integrity: sha512-MZdy2nL3wO0u7gkB4nA/pEf8lu1TlFswPNmy8AiYkfKTdO6eXBJyUdmHO/ehm/htHw9K/qF8ujnTyUAD+Ry54Q==} - - '@ethersproject/solidity@5.7.0': - resolution: {integrity: sha512-HmabMd2Dt/raavyaGukF4XxizWKhKQ24DoLtdNbBmNKUOPqwjsKQSdV9GQtj9CBEea9DlzETlVER1gYeXXBGaA==} - - '@ethersproject/strings@5.7.0': - resolution: {integrity: sha512-/9nu+lj0YswRNSH0NXYqrh8775XNyEdUQAuf3f+SmOrnVewcJ5SBNAjF7lpgehKi4abvNNXyf+HX86czCdJ8Mg==} - - '@ethersproject/transactions@5.7.0': - resolution: {integrity: sha512-kmcNicCp1lp8qanMTC3RIikGgoJ80ztTyvtsFvCYpSCfkjhD0jZ2LOrnbcuxuToLIUYYf+4XwD1rP+B/erDIhQ==} - - '@ethersproject/units@5.7.0': - resolution: {integrity: sha512-pD3xLMy3SJu9kG5xDGI7+xhTEmGXlEqXU4OfNapmfnxLVY4EMSSRp7j1k7eezutBPH7RBN/7QPnwR7hzNlEFeg==} - - '@ethersproject/wallet@5.7.0': - resolution: {integrity: sha512-MhmXlJXEJFBFVKrDLB4ZdDzxcBxQ3rLyCkhNqVu3CDYvR97E+8r01UgrI+TI99Le+aYm/in/0vp86guJuM7FCA==} - - '@ethersproject/web@5.7.1': - resolution: {integrity: sha512-Gueu8lSvyjBWL4cYsWsjh6MtMwM0+H4HvqFPZfB6dV8ctbP9zFAO73VG1cMWae0FLPCtz0peKPpZY8/ugJJX2w==} - - '@ethersproject/wordlists@5.7.0': - resolution: {integrity: sha512-S2TFNJNfHWVHNE6cNDjbVlZ6MgE17MIxMbMg2zv3wn+3XSJGosL1m9ZVv3GXCf/2ymSsQ+hRI5IzoMJTG6aoVA==} - '@floating-ui/core@0.3.1': resolution: {integrity: sha512-ensKY7Ub59u16qsVIFEo2hwTCqZ/r9oZZFh51ivcLGHfUwTn8l1Xzng8RJUe91H/UP8PeqeBronAGx0qmzwk2g==} @@ -3302,9 +3206,6 @@ packages: '@types/node@22.10.1': resolution: {integrity: sha512-qKgsUwfHZV2WCWLAnVP1JqnpE6Im6h3Y0+fYgMTasNQ7V++CBX5OT1as0g0f+OyubbFqhf6XVNIsmN4IIhEgGQ==} - '@types/node@22.10.2': - resolution: {integrity: sha512-Xxr6BBRCAOQixvonOye19wnzyDiUtTeqldOOmj3CkeblonbccA12PFwlufvRdrpjXxqnmUaeiU5EOA+7s5diUQ==} - '@types/node@22.10.5': resolution: {integrity: sha512-F8Q+SeGimwOo86fiovQh8qiXfFEh2/ocYv7tU5pJ3EXMSSxk1Joj5wefpFK2fHTf/N6HKGSxIDBT9f3gCxXPkQ==} @@ -3502,9 +3403,6 @@ packages: engines: {node: '>=0.4.0'} hasBin: true - aes-js@3.0.0: - resolution: {integrity: sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw==} - aes-js@4.0.0-beta.5: resolution: {integrity: sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q==} @@ -3787,9 +3685,6 @@ packages: resolution: {integrity: sha512-8PzkB0arJFV4jJWSGOYR+OEic6aeKMu/osRhBULN6RY0ykby6LKhbmuQ5ublvaas5BOwboah5D87nrHyuh8PPA==} engines: {node: '>=10.0.0'} - bech32@1.1.4: - resolution: {integrity: sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==} - bech32@2.0.0: resolution: {integrity: sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg==} @@ -3815,12 +3710,6 @@ packages: bl@4.1.0: resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==} - bn.js@4.12.0: - resolution: {integrity: sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==} - - bn.js@5.2.1: - resolution: {integrity: sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==} - boolbase@1.0.0: resolution: {integrity: sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==} @@ -3838,9 +3727,6 @@ packages: resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} engines: {node: '>=8'} - brorand@1.1.0: - resolution: {integrity: sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==} - browserslist@4.23.3: resolution: {integrity: sha512-btwCFJVjI4YWDNfau8RhZ+B1Q/VLoUITrm3RlP6y1tYGWIOa+InuYiRGXUBXo8nA1qKmHMyLB/iVQg5TT4eFoA==} engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} @@ -4625,9 +4511,6 @@ packages: elkjs@0.9.3: resolution: {integrity: sha512-f/ZeWvW/BCXbhGEf1Ujp29EASo/lk1FDnETgNKwJrsVvGZhUWCZyg3xLJjAsxfOmt8KjswHmI5EwCQcPMpOYhQ==} - elliptic@6.6.1: - resolution: {integrity: sha512-RaddvvMatK2LJHqFJ+YA4WysVN5Ita9E35botqIYspQ4TkRAlCicdzKOjlyv/1Za5RyTNn7di//eEV0uTAfe3g==} - embla-carousel-react@8.0.0-rc17: resolution: {integrity: sha512-x4aFprwFB+PQO9EsHHZsrDxARb0uYNBYn9mr5oDFdBdPez4M8G1r5yidWbUcT9pNUc8AQXC9sGzlfauBfBxVOw==} peerDependencies: @@ -4891,9 +4774,6 @@ packages: resolution: {integrity: sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==} engines: {node: '>= 0.6'} - ethers@5.7.2: - resolution: {integrity: sha512-wswUsmWo1aOK8rR7DIKiWSw9DbLWe6x98Jrn8wcTflTVvaXhAMaB5zGAXy0GYQEQp9iO1iSHWVyARQm11zUtyg==} - ethers@6.13.4: resolution: {integrity: sha512-21YtnZVg4/zKkCQPjrDj38B1r4nQvTZLopUGMLQ1ePU2zV/joCfDC3t3iKQjWRzjjjbzR+mdAIoikeBRNkdllA==} engines: {node: '>=14.0.0'} @@ -5321,9 +5201,6 @@ packages: resolution: {integrity: sha512-FwO1BUVWkyHasWDW4S8o0ssQXjvyghLV2rfVhnN36b2bbcj45eGiuzdn9XOvOpjV3TKQD7Gm2BWNXdE9V4KKYg==} engines: {node: '>=12'} - hash.js@1.1.7: - resolution: {integrity: sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==} - hasown@2.0.2: resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} engines: {node: '>= 0.4'} @@ -5383,9 +5260,6 @@ packages: resolution: {integrity: sha512-cnN7bQUm65UWOy6cbGcCcZ3rpwW8Q/j4OP5aWRhEry4Z2t2aR1cjrbp0BS+KiBN0smvP1caBgAuxutvyvJILzQ==} engines: {node: '>=8'} - hmac-drbg@1.0.1: - resolution: {integrity: sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==} - hoist-non-react-statics@3.3.2: resolution: {integrity: sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==} @@ -6001,9 +5875,6 @@ packages: js-flipper@0.270.0: resolution: {integrity: sha512-JZ3Of9/gPSnnCxkf9ugyzoSS5bG50qytliiCQdYph/lcKuMRbU5bF2ThKqSBlolKlntUNmB1KwMKe7onnK+Big==} - js-sha3@0.8.0: - resolution: {integrity: sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==} - js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} @@ -6599,12 +6470,6 @@ packages: resolution: {integrity: sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==} engines: {node: '>=18'} - minimalistic-assert@1.0.1: - resolution: {integrity: sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==} - - minimalistic-crypto-utils@1.0.1: - resolution: {integrity: sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==} - minimatch@10.0.1: resolution: {integrity: sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==} engines: {node: 20 || >=22} @@ -7670,9 +7535,6 @@ packages: scroll-into-view-if-needed@3.1.0: resolution: {integrity: sha512-49oNpRjWRvnU8NyGVmUaYG4jtTkNonFZI86MmGRDqBphEK2EXT9gdEUoQPZhuBM8yWHxCWbobltqYO5M4XrUvQ==} - scrypt-js@3.0.1: - resolution: {integrity: sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==} - section-matter@1.0.0: resolution: {integrity: sha512-vfD3pmTzGpufjScBh50YHKzEu2lxBWhVEHsNGoEXmCmn2hKGfeNLYMzCJpe8cD7gqX7TJluOVpBkAequ6dgMmA==} engines: {node: '>=4'} @@ -10332,261 +10194,6 @@ snapshots: dependencies: levn: 0.4.1 - '@ethersproject/abi@5.7.0': - dependencies: - '@ethersproject/address': 5.7.0 - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/constants': 5.7.0 - '@ethersproject/hash': 5.7.0 - '@ethersproject/keccak256': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/properties': 5.7.0 - '@ethersproject/strings': 5.7.0 - - '@ethersproject/abstract-provider@5.7.0': - dependencies: - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/networks': 5.7.1 - '@ethersproject/properties': 5.7.0 - '@ethersproject/transactions': 5.7.0 - '@ethersproject/web': 5.7.1 - - '@ethersproject/abstract-signer@5.7.0': - dependencies: - '@ethersproject/abstract-provider': 5.7.0 - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/properties': 5.7.0 - - '@ethersproject/address@5.7.0': - dependencies: - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/keccak256': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/rlp': 5.7.0 - - '@ethersproject/base64@5.7.0': - dependencies: - '@ethersproject/bytes': 5.7.0 - - '@ethersproject/basex@5.7.0': - dependencies: - '@ethersproject/bytes': 5.7.0 - '@ethersproject/properties': 5.7.0 - - '@ethersproject/bignumber@5.7.0': - dependencies: - '@ethersproject/bytes': 5.7.0 - '@ethersproject/logger': 5.7.0 - bn.js: 5.2.1 - - '@ethersproject/bytes@5.7.0': - dependencies: - '@ethersproject/logger': 5.7.0 - - '@ethersproject/constants@5.7.0': - dependencies: - '@ethersproject/bignumber': 5.7.0 - - '@ethersproject/contracts@5.7.0': - dependencies: - '@ethersproject/abi': 5.7.0 - '@ethersproject/abstract-provider': 5.7.0 - '@ethersproject/abstract-signer': 5.7.0 - '@ethersproject/address': 5.7.0 - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/constants': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/properties': 5.7.0 - '@ethersproject/transactions': 5.7.0 - - '@ethersproject/hash@5.7.0': - dependencies: - '@ethersproject/abstract-signer': 5.7.0 - '@ethersproject/address': 5.7.0 - '@ethersproject/base64': 5.7.0 - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/keccak256': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/properties': 5.7.0 - '@ethersproject/strings': 5.7.0 - - '@ethersproject/hdnode@5.7.0': - dependencies: - '@ethersproject/abstract-signer': 5.7.0 - '@ethersproject/basex': 5.7.0 - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/pbkdf2': 5.7.0 - '@ethersproject/properties': 5.7.0 - '@ethersproject/sha2': 5.7.0 - '@ethersproject/signing-key': 5.7.0 - '@ethersproject/strings': 5.7.0 - '@ethersproject/transactions': 5.7.0 - '@ethersproject/wordlists': 5.7.0 - - '@ethersproject/json-wallets@5.7.0': - dependencies: - '@ethersproject/abstract-signer': 5.7.0 - '@ethersproject/address': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/hdnode': 5.7.0 - '@ethersproject/keccak256': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/pbkdf2': 5.7.0 - '@ethersproject/properties': 5.7.0 - '@ethersproject/random': 5.7.0 - '@ethersproject/strings': 5.7.0 - '@ethersproject/transactions': 5.7.0 - aes-js: 3.0.0 - scrypt-js: 3.0.1 - - '@ethersproject/keccak256@5.7.0': - dependencies: - '@ethersproject/bytes': 5.7.0 - js-sha3: 0.8.0 - - '@ethersproject/logger@5.7.0': {} - - '@ethersproject/networks@5.7.1': - dependencies: - '@ethersproject/logger': 5.7.0 - - '@ethersproject/pbkdf2@5.7.0': - dependencies: - '@ethersproject/bytes': 5.7.0 - '@ethersproject/sha2': 5.7.0 - - '@ethersproject/properties@5.7.0': - dependencies: - '@ethersproject/logger': 5.7.0 - - '@ethersproject/providers@5.7.2': - dependencies: - '@ethersproject/abstract-provider': 5.7.0 - '@ethersproject/abstract-signer': 5.7.0 - '@ethersproject/address': 5.7.0 - '@ethersproject/base64': 5.7.0 - '@ethersproject/basex': 5.7.0 - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/constants': 5.7.0 - '@ethersproject/hash': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/networks': 5.7.1 - '@ethersproject/properties': 5.7.0 - '@ethersproject/random': 5.7.0 - '@ethersproject/rlp': 5.7.0 - '@ethersproject/sha2': 5.7.0 - '@ethersproject/strings': 5.7.0 - '@ethersproject/transactions': 5.7.0 - '@ethersproject/web': 5.7.1 - bech32: 1.1.4 - ws: 8.17.1 - transitivePeerDependencies: - - bufferutil - - utf-8-validate - - '@ethersproject/random@5.7.0': - dependencies: - '@ethersproject/bytes': 5.7.0 - '@ethersproject/logger': 5.7.0 - - '@ethersproject/rlp@5.7.0': - dependencies: - '@ethersproject/bytes': 5.7.0 - '@ethersproject/logger': 5.7.0 - - '@ethersproject/sha2@5.7.0': - dependencies: - '@ethersproject/bytes': 5.7.0 - '@ethersproject/logger': 5.7.0 - hash.js: 1.1.7 - - '@ethersproject/signing-key@5.7.0': - dependencies: - '@ethersproject/bytes': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/properties': 5.7.0 - bn.js: 5.2.1 - elliptic: 6.6.1 - hash.js: 1.1.7 - - '@ethersproject/solidity@5.7.0': - dependencies: - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/keccak256': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/sha2': 5.7.0 - '@ethersproject/strings': 5.7.0 - - '@ethersproject/strings@5.7.0': - dependencies: - '@ethersproject/bytes': 5.7.0 - '@ethersproject/constants': 5.7.0 - '@ethersproject/logger': 5.7.0 - - '@ethersproject/transactions@5.7.0': - dependencies: - '@ethersproject/address': 5.7.0 - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/constants': 5.7.0 - '@ethersproject/keccak256': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/properties': 5.7.0 - '@ethersproject/rlp': 5.7.0 - '@ethersproject/signing-key': 5.7.0 - - '@ethersproject/units@5.7.0': - dependencies: - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/constants': 5.7.0 - '@ethersproject/logger': 5.7.0 - - '@ethersproject/wallet@5.7.0': - dependencies: - '@ethersproject/abstract-provider': 5.7.0 - '@ethersproject/abstract-signer': 5.7.0 - '@ethersproject/address': 5.7.0 - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/hash': 5.7.0 - '@ethersproject/hdnode': 5.7.0 - '@ethersproject/json-wallets': 5.7.0 - '@ethersproject/keccak256': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/properties': 5.7.0 - '@ethersproject/random': 5.7.0 - '@ethersproject/signing-key': 5.7.0 - '@ethersproject/transactions': 5.7.0 - '@ethersproject/wordlists': 5.7.0 - - '@ethersproject/web@5.7.1': - dependencies: - '@ethersproject/base64': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/properties': 5.7.0 - '@ethersproject/strings': 5.7.0 - - '@ethersproject/wordlists@5.7.0': - dependencies: - '@ethersproject/bytes': 5.7.0 - '@ethersproject/hash': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/properties': 5.7.0 - '@ethersproject/strings': 5.7.0 - '@floating-ui/core@0.3.1': {} '@floating-ui/core@1.6.2': @@ -10694,7 +10301,7 @@ snapshots: '@jest/console@29.7.0': dependencies: '@jest/types': 29.6.3 - '@types/node': 22.10.1 + '@types/node': 22.10.5 chalk: 4.1.2 jest-message-util: 29.7.0 jest-util: 29.7.0 @@ -10707,14 +10314,14 @@ snapshots: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 22.10.1 + '@types/node': 22.10.5 ansi-escapes: 4.3.2 chalk: 4.1.2 ci-info: 3.9.0 exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@22.10.1)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@22.10.1)(typescript@5.6.3)) + jest-config: 29.7.0(@types/node@22.10.5)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@22.10.1)(typescript@5.6.3)) jest-haste-map: 29.7.0 jest-message-util: 29.7.0 jest-regex-util: 29.6.3 @@ -10743,7 +10350,7 @@ snapshots: dependencies: '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 22.10.1 + '@types/node': 22.10.5 jest-mock: 29.7.0 '@jest/expect-utils@29.7.0': @@ -10761,7 +10368,7 @@ snapshots: dependencies: '@jest/types': 29.6.3 '@sinonjs/fake-timers': 10.3.0 - '@types/node': 22.10.1 + '@types/node': 22.10.5 jest-message-util: 29.7.0 jest-mock: 29.7.0 jest-util: 29.7.0 @@ -10783,7 +10390,7 @@ snapshots: '@jest/transform': 29.7.0 '@jest/types': 29.6.3 '@jridgewell/trace-mapping': 0.3.25 - '@types/node': 22.10.1 + '@types/node': 22.10.5 chalk: 4.1.2 collect-v8-coverage: 1.0.2 exit: 0.1.2 @@ -10861,7 +10468,7 @@ snapshots: '@jest/schemas': 29.6.3 '@types/istanbul-lib-coverage': 2.0.6 '@types/istanbul-reports': 3.0.4 - '@types/node': 22.10.1 + '@types/node': 22.10.5 '@types/yargs': 17.0.32 chalk: 4.1.2 @@ -12167,7 +11774,7 @@ snapshots: '@types/connect@3.4.36': dependencies: - '@types/node': 22.10.2 + '@types/node': 22.10.5 '@types/crypto-js@4.2.2': {} @@ -12206,12 +11813,12 @@ snapshots: '@types/fs-extra@11.0.4': dependencies: '@types/jsonfile': 6.1.4 - '@types/node': 22.10.1 + '@types/node': 22.10.5 optional: true '@types/graceful-fs@4.1.9': dependencies: - '@types/node': 22.10.1 + '@types/node': 22.10.5 '@types/hast@2.3.10': dependencies: @@ -12247,7 +11854,7 @@ snapshots: '@types/jsonfile@6.1.4': dependencies: - '@types/node': 22.10.1 + '@types/node': 22.10.5 optional: true '@types/katex@0.16.7': {} @@ -12266,7 +11873,7 @@ snapshots: '@types/mysql@2.15.26': dependencies: - '@types/node': 22.10.2 + '@types/node': 22.10.5 '@types/node-forge@1.3.11': dependencies: @@ -12284,10 +11891,6 @@ snapshots: dependencies: undici-types: 6.20.0 - '@types/node@22.10.2': - dependencies: - undici-types: 6.20.0 - '@types/node@22.10.5': dependencies: undici-types: 6.20.0 @@ -12304,7 +11907,7 @@ snapshots: '@types/pg@8.6.1': dependencies: - '@types/node': 22.10.2 + '@types/node': 22.10.5 pg-protocol: 1.6.1 pg-types: 2.2.0 @@ -12341,7 +11944,7 @@ snapshots: '@types/tedious@4.0.14': dependencies: - '@types/node': 22.10.2 + '@types/node': 22.10.5 '@types/unist@2.0.11': {} @@ -12543,8 +12146,6 @@ snapshots: acorn@8.14.0: {} - aes-js@3.0.0: {} - aes-js@4.0.0-beta.5: {} agent-base@6.0.2: @@ -12883,8 +12484,6 @@ snapshots: basic-ftp@5.0.4: {} - bech32@1.1.4: {} - bech32@2.0.0: {} before-after-hook@2.2.3: {} @@ -12912,10 +12511,6 @@ snapshots: inherits: 2.0.4 readable-stream: 3.6.2 - bn.js@4.12.0: {} - - bn.js@5.2.1: {} - boolbase@1.0.0: {} boxen@8.0.1: @@ -12942,8 +12537,6 @@ snapshots: dependencies: fill-range: 7.1.1 - brorand@1.1.0: {} - browserslist@4.23.3: dependencies: caniuse-lite: 1.0.30001687 @@ -13795,16 +13388,6 @@ snapshots: elkjs@0.9.3: {} - elliptic@6.6.1: - dependencies: - bn.js: 4.12.0 - brorand: 1.1.0 - hash.js: 1.1.7 - hmac-drbg: 1.0.1 - inherits: 2.0.4 - minimalistic-assert: 1.0.1 - minimalistic-crypto-utils: 1.0.1 - embla-carousel-react@8.0.0-rc17(react@18.3.1): dependencies: embla-carousel: 8.0.0-rc17 @@ -14167,42 +13750,6 @@ snapshots: etag@1.8.1: {} - ethers@5.7.2: - dependencies: - '@ethersproject/abi': 5.7.0 - '@ethersproject/abstract-provider': 5.7.0 - '@ethersproject/abstract-signer': 5.7.0 - '@ethersproject/address': 5.7.0 - '@ethersproject/base64': 5.7.0 - '@ethersproject/basex': 5.7.0 - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/constants': 5.7.0 - '@ethersproject/contracts': 5.7.0 - '@ethersproject/hash': 5.7.0 - '@ethersproject/hdnode': 5.7.0 - '@ethersproject/json-wallets': 5.7.0 - '@ethersproject/keccak256': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/networks': 5.7.1 - '@ethersproject/pbkdf2': 5.7.0 - '@ethersproject/properties': 5.7.0 - '@ethersproject/providers': 5.7.2 - '@ethersproject/random': 5.7.0 - '@ethersproject/rlp': 5.7.0 - '@ethersproject/sha2': 5.7.0 - '@ethersproject/signing-key': 5.7.0 - '@ethersproject/solidity': 5.7.0 - '@ethersproject/strings': 5.7.0 - '@ethersproject/transactions': 5.7.0 - '@ethersproject/units': 5.7.0 - '@ethersproject/wallet': 5.7.0 - '@ethersproject/web': 5.7.1 - '@ethersproject/wordlists': 5.7.0 - transitivePeerDependencies: - - bufferutil - - utf-8-validate - ethers@6.13.4: dependencies: '@adraffy/ens-normalize': 1.10.1 @@ -14678,11 +14225,6 @@ snapshots: sort-keys: 5.1.0 type-fest: 1.4.0 - hash.js@1.1.7: - dependencies: - inherits: 2.0.4 - minimalistic-assert: 1.0.1 - hasown@2.0.2: dependencies: function-bind: 1.1.2 @@ -14812,12 +14354,6 @@ snapshots: dependencies: source-map: 0.7.4 - hmac-drbg@1.0.1: - dependencies: - hash.js: 1.1.7 - minimalistic-assert: 1.0.1 - minimalistic-crypto-utils: 1.0.1 - hoist-non-react-statics@3.3.2: dependencies: react-is: 16.13.1 @@ -15316,7 +14852,7 @@ snapshots: '@jest/expect': 29.7.0 '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 22.10.1 + '@types/node': 22.10.5 chalk: 4.1.2 co: 4.6.0 dedent: 1.5.1(babel-plugin-macros@3.1.0) @@ -15386,6 +14922,37 @@ snapshots: - babel-plugin-macros - supports-color + jest-config@29.7.0(@types/node@22.10.5)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@22.10.1)(typescript@5.6.3)): + dependencies: + '@babel/core': 7.24.4 + '@jest/test-sequencer': 29.7.0 + '@jest/types': 29.6.3 + babel-jest: 29.7.0(@babel/core@7.24.4) + chalk: 4.1.2 + ci-info: 3.9.0 + deepmerge: 4.3.1 + glob: 7.2.3 + graceful-fs: 4.2.11 + jest-circus: 29.7.0(babel-plugin-macros@3.1.0) + jest-environment-node: 29.7.0 + jest-get-type: 29.6.3 + jest-regex-util: 29.6.3 + jest-resolve: 29.7.0 + jest-runner: 29.7.0 + jest-util: 29.7.0 + jest-validate: 29.7.0 + micromatch: 4.0.8 + parse-json: 5.2.0 + pretty-format: 29.7.0 + slash: 3.0.0 + strip-json-comments: 3.1.1 + optionalDependencies: + '@types/node': 22.10.5 + ts-node: 10.9.2(@types/node@22.10.1)(typescript@5.6.3) + transitivePeerDependencies: + - babel-plugin-macros + - supports-color + jest-diff@29.7.0: dependencies: chalk: 4.1.2 @@ -15410,7 +14977,7 @@ snapshots: '@jest/environment': 29.7.0 '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 22.10.1 + '@types/node': 22.10.5 jest-mock: 29.7.0 jest-util: 29.7.0 @@ -15420,7 +14987,7 @@ snapshots: dependencies: '@jest/types': 29.6.3 '@types/graceful-fs': 4.1.9 - '@types/node': 22.10.1 + '@types/node': 22.10.5 anymatch: 3.1.3 fb-watchman: 2.0.2 graceful-fs: 4.2.11 @@ -15459,7 +15026,7 @@ snapshots: jest-mock@29.7.0: dependencies: '@jest/types': 29.6.3 - '@types/node': 22.10.1 + '@types/node': 22.10.5 jest-util: 29.7.0 jest-pnp-resolver@1.2.3(jest-resolve@29.7.0): @@ -15494,7 +15061,7 @@ snapshots: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 22.10.1 + '@types/node': 22.10.5 chalk: 4.1.2 emittery: 0.13.1 graceful-fs: 4.2.11 @@ -15522,7 +15089,7 @@ snapshots: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 22.10.1 + '@types/node': 22.10.5 chalk: 4.1.2 cjs-module-lexer: 1.2.3 collect-v8-coverage: 1.0.2 @@ -15568,7 +15135,7 @@ snapshots: jest-util@29.7.0: dependencies: '@jest/types': 29.6.3 - '@types/node': 22.10.1 + '@types/node': 22.10.5 chalk: 4.1.2 ci-info: 3.9.0 graceful-fs: 4.2.11 @@ -15587,7 +15154,7 @@ snapshots: dependencies: '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 22.10.1 + '@types/node': 22.10.5 ansi-escapes: 4.3.2 chalk: 4.1.2 emittery: 0.13.1 @@ -15602,7 +15169,7 @@ snapshots: jest-worker@29.7.0: dependencies: - '@types/node': 22.10.1 + '@types/node': 22.10.5 jest-util: 29.7.0 merge-stream: 2.0.0 supports-color: 8.1.1 @@ -15631,8 +15198,6 @@ snapshots: js-flipper@0.270.0: {} - js-sha3@0.8.0: {} - js-tokens@4.0.0: {} js-yaml@3.14.1: @@ -16616,10 +16181,6 @@ snapshots: mimic-function@5.0.1: {} - minimalistic-assert@1.0.1: {} - - minimalistic-crypto-utils@1.0.1: {} - minimatch@10.0.1: dependencies: brace-expansion: 2.0.1 @@ -17836,8 +17397,6 @@ snapshots: dependencies: compute-scroll-into-view: 3.1.0 - scrypt-js@3.0.1: {} - section-matter@1.0.0: dependencies: extend-shallow: 2.0.1 From 15900a8d207f79ac43724623738e3a7dfa3b3c0e Mon Sep 17 00:00:00 2001 From: Louis Aussedat Date: Mon, 6 Jan 2025 16:38:56 +0100 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=94=96=20(chore):=20Add=20changeset?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/nine-readers-roll.md | 5 +++++ .changeset/tame-crabs-design.md | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/nine-readers-roll.md create mode 100644 .changeset/tame-crabs-design.md diff --git a/.changeset/nine-readers-roll.md b/.changeset/nine-readers-roll.md new file mode 100644 index 000000000..8da92eeb6 --- /dev/null +++ b/.changeset/nine-readers-roll.md @@ -0,0 +1,5 @@ +--- +"@ledgerhq/device-signer-kit-ethereum": minor +--- + +Breaking change: remove ethers from api dependency and use only raw tx for signTransaction diff --git a/.changeset/tame-crabs-design.md b/.changeset/tame-crabs-design.md new file mode 100644 index 000000000..e35dba93f --- /dev/null +++ b/.changeset/tame-crabs-design.md @@ -0,0 +1,5 @@ +--- +"@ledgerhq/device-signer-kit-ethereum": patch +--- + +Update signTransaction transaction parameter with new api