@ledgerhq/device-signer-kit-ethereum 1.9.4 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/api/SignerEthBuilder.js +1 -1
- package/lib/cjs/api/SignerEthBuilder.js.map +3 -3
- package/lib/cjs/api/SignerEthBuilder.test.js +1 -1
- package/lib/cjs/api/SignerEthBuilder.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/EthAppBinder.js +1 -1
- package/lib/cjs/internal/app-binder/EthAppBinder.js.map +3 -3
- package/lib/cjs/internal/app-binder/EthAppBinder.test.js +1 -1
- package/lib/cjs/internal/app-binder/EthAppBinder.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.test.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/BuildFullContextsTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildFullContextsTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/BuildFullContextsTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildFullContextsTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/BuildSafeAddressContextTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildSafeAddressContextTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/BuildSafeAddressContextTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildSafeAddressContextTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/BuildSubcontextsTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildSubcontextsTask.js.map +2 -2
- package/lib/cjs/internal/app-binder/task/BuildSubcontextsTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildSubcontextsTask.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/task/ProvideContextTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideContextTask.js.map +2 -2
- package/lib/cjs/internal/app-binder/task/ProvideContextTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideContextTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/ProvideTransactionContextsTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideTransactionContextsTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/ProvideTransactionContextsTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideTransactionContextsTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/SendSignAuthorizationDelegationTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/SendSignAuthorizationDelegationTask.js.map +2 -2
- package/lib/cjs/internal/app-binder/task/SendSignAuthorizationDelegationTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/SendSignAuthorizationDelegationTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/SendSignPersonalMessageTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/SendSignPersonalMessageTask.js.map +2 -2
- package/lib/cjs/internal/app-binder/task/SendSignPersonalMessageTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/SendSignPersonalMessageTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/SendSignTransactionTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/SendSignTransactionTask.js.map +2 -2
- package/lib/cjs/internal/app-binder/task/SendSignTransactionTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/SendSignTransactionTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/SignTypedDataLegacyTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/SignTypedDataLegacyTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/SignTypedDataLegacyTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/SignTypedDataLegacyTask.test.js.map +3 -3
- package/lib/cjs/internal/di.js +1 -1
- package/lib/cjs/internal/di.js.map +3 -3
- package/lib/cjs/internal/externalTypes.js +1 -1
- package/lib/cjs/internal/externalTypes.js.map +2 -2
- package/lib/cjs/package.json +2 -2
- package/lib/esm/api/SignerEthBuilder.js +1 -1
- package/lib/esm/api/SignerEthBuilder.js.map +3 -3
- package/lib/esm/api/SignerEthBuilder.test.js +1 -1
- package/lib/esm/api/SignerEthBuilder.test.js.map +3 -3
- package/lib/esm/internal/app-binder/EthAppBinder.js +1 -1
- package/lib/esm/internal/app-binder/EthAppBinder.js.map +3 -3
- package/lib/esm/internal/app-binder/EthAppBinder.test.js +1 -1
- package/lib/esm/internal/app-binder/EthAppBinder.test.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js +1 -1
- package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js +1 -1
- package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js +1 -1
- package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js +1 -1
- package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.js +1 -1
- package/lib/esm/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.test.js +1 -1
- package/lib/esm/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/BuildFullContextsTask.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildFullContextsTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/BuildFullContextsTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildFullContextsTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/BuildSafeAddressContextTask.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildSafeAddressContextTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/BuildSafeAddressContextTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildSafeAddressContextTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/BuildSubcontextsTask.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildSubcontextsTask.js.map +2 -2
- package/lib/esm/internal/app-binder/task/BuildSubcontextsTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildSubcontextsTask.test.js.map +2 -2
- package/lib/esm/internal/app-binder/task/ProvideContextTask.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideContextTask.js.map +2 -2
- package/lib/esm/internal/app-binder/task/ProvideContextTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideContextTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/ProvideTransactionContextsTask.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideTransactionContextsTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/ProvideTransactionContextsTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideTransactionContextsTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/SendSignAuthorizationDelegationTask.js +1 -1
- package/lib/esm/internal/app-binder/task/SendSignAuthorizationDelegationTask.js.map +2 -2
- package/lib/esm/internal/app-binder/task/SendSignAuthorizationDelegationTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/SendSignAuthorizationDelegationTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/SendSignPersonalMessageTask.js +1 -1
- package/lib/esm/internal/app-binder/task/SendSignPersonalMessageTask.js.map +2 -2
- package/lib/esm/internal/app-binder/task/SendSignPersonalMessageTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/SendSignPersonalMessageTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/SendSignTransactionTask.js +1 -1
- package/lib/esm/internal/app-binder/task/SendSignTransactionTask.js.map +2 -2
- package/lib/esm/internal/app-binder/task/SendSignTransactionTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/SendSignTransactionTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/SignTypedDataLegacyTask.js +1 -1
- package/lib/esm/internal/app-binder/task/SignTypedDataLegacyTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/SignTypedDataLegacyTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/SignTypedDataLegacyTask.test.js.map +3 -3
- package/lib/esm/internal/di.js +1 -1
- package/lib/esm/internal/di.js.map +3 -3
- package/lib/esm/internal/externalTypes.js +1 -1
- package/lib/esm/internal/externalTypes.js.map +2 -2
- package/lib/esm/package.json +2 -2
- package/lib/types/api/SignerEthBuilder.d.ts.map +1 -1
- package/lib/types/internal/app-binder/EthAppBinder.d.ts +3 -2
- package/lib/types/internal/app-binder/EthAppBinder.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts +7 -1
- package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.d.ts +7 -1
- package/lib/types/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.d.ts +7 -1
- package/lib/types/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/BuildEIP712ContextTask.d.ts +3 -2
- package/lib/types/internal/app-binder/task/BuildEIP712ContextTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/BuildFullContextsTask.d.ts +2 -1
- package/lib/types/internal/app-binder/task/BuildFullContextsTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/BuildSafeAddressContextTask.d.ts +2 -1
- package/lib/types/internal/app-binder/task/BuildSafeAddressContextTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/BuildSubcontextsTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/ProvideContextTask.d.ts +5 -1
- package/lib/types/internal/app-binder/task/ProvideContextTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/ProvideEIP712ContextTask.d.ts +2 -1
- package/lib/types/internal/app-binder/task/ProvideEIP712ContextTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/ProvideTransactionContextsTask.d.ts +5 -1
- package/lib/types/internal/app-binder/task/ProvideTransactionContextsTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/SendSignAuthorizationDelegationTask.d.ts +3 -1
- package/lib/types/internal/app-binder/task/SendSignAuthorizationDelegationTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/SendSignPersonalMessageTask.d.ts +3 -1
- package/lib/types/internal/app-binder/task/SendSignPersonalMessageTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/SendSignTransactionTask.d.ts +3 -1
- package/lib/types/internal/app-binder/task/SendSignTransactionTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/SignTypedDataLegacyTask.d.ts +3 -2
- package/lib/types/internal/app-binder/task/SignTypedDataLegacyTask.d.ts.map +1 -1
- package/lib/types/internal/di.d.ts.map +1 -1
- package/lib/types/internal/externalTypes.d.ts +1 -0
- package/lib/types/internal/externalTypes.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +9 -9
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("@ledgerhq/device-management-kit"),
|
|
1
|
+
"use strict";var e=require("@ledgerhq/device-management-kit"),C=require("ethers"),d=require("purify-ts"),t=require("../../../api/model/ClearSigningType"),s=require("../../app-binder/command/SignTransactionCommand"),b=require("../../app-binder/command/StartTransactionCommand"),w=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),c=require("./SendSignTransactionTask");const i={debug:vi.fn(),info:vi.fn(),warn:vi.fn(),error:vi.fn(),subscribers:[]},l=new Uint8Array([5,128,0,0,44,128,0,0,60,128,0,0,0,0,0,0,0,0,0,0,0]),r=new Uint8Array([5,128,0,0,44,128,0,0,60,128,0,0,0,0,0,0,0,0,0,0,0,248,107,130,6,126,132,87,25,19,31,131,1,16,104,148,218,193,127,149,141,46,229,35,162,32,98,6,153,69,151,193,61,131,30,199,128,184,68,169,5,156,187,0,0]),u=new Uint8Array([249,8,175,38,133,1,178,61,148,131,131,5,193,252,148,222,241,192,222,217,190,199,241,161,103,8,25,131,50,64,240,39,178,94,255,128,185,8,136,65,85,101,176,0,0,0,0,0,0,0,0,0,0,0,0,31,152,64,168,93,90,245,191,29,23,98,249,37,189,173,220,66,1,249,132,0,0,0,0,0,0,0,0,0,0,0,0,160,184,105,145,198,33,139,54,193,209,157,74,46,158,176,206,54,6,235,72,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,97,233,51,89,83,149,108,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,51,239,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,96,0,0,0,0,0,0,0,0,0]);describe("SendSignTransactionTask",()=>{const x=(0,w.makeDeviceActionInternalApiMock)(),f={v:27,r:"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",s:"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"},g=(0,e.CommandResultFactory)({data:(0,d.Just)(f)}),m=(0,e.CommandResultFactory)({data:d.Nothing});beforeEach(()=>{vi.resetAllMocks()}),describe("run",()=>{it("should send the transaction in one command",async()=>{const n={derivationPath:"44'/60'/0'/0/0",serializedTransaction:r,chainId:1,transactionType:1,clearSigningType:t.ClearSigningType.BASIC,logger:i};x.sendCommand.mockResolvedValueOnce(g);const a=await new c.SendSignTransactionTask(x,n).run();expect(x.sendCommand.mock.calls).toHaveLength(1),expect(x.sendCommand.mock.calls[0][0]).toStrictEqual(new s.SignTransactionCommand({serializedTransaction:new Uint8Array([...l,...r]),isFirstChunk:!0})),expect(a.data).toStrictEqual(f)}),it("Generic-parser transaction should be signed without payload",async()=>{const n={derivationPath:"44'/60'/0'/0/0",serializedTransaction:r,chainId:1,transactionType:1,clearSigningType:t.ClearSigningType.EIP7730,logger:i};x.sendCommand.mockResolvedValueOnce(g);const a=await new c.SendSignTransactionTask(x,n).run();expect(x.sendCommand.mock.calls).toHaveLength(1),expect(x.sendCommand.mock.calls[0][0]).toStrictEqual(new b.StartTransactionCommand),expect(a.data).toStrictEqual(f)}),it("should send the transaction in chunks",async()=>{const n={derivationPath:"44'/60'/0'/0/0",serializedTransaction:u,chainId:1,transactionType:1,clearSigningType:t.ClearSigningType.BASIC,logger:i};x.sendCommand.mockResolvedValueOnce(m),x.sendCommand.mockResolvedValueOnce(g);const a=await new c.SendSignTransactionTask(x,n).run();expect(x.sendCommand.mock.calls).toHaveLength(2),expect(x.sendCommand.mock.calls[0][0]).toStrictEqual(new s.SignTransactionCommand({serializedTransaction:new Uint8Array([...l,...u]).slice(0,e.APDU_MAX_PAYLOAD),isFirstChunk:!0})),expect(x.sendCommand.mock.calls[1][0]).toStrictEqual(new s.SignTransactionCommand({serializedTransaction:new Uint8Array([...l,...u]).slice(e.APDU_MAX_PAYLOAD,e.APDU_MAX_PAYLOAD*2),isFirstChunk:!1})),expect(a.data).toStrictEqual(f)}),it.each([[458,127,254],[458,0x818181818181,254],[452,0x818181818181,251]])("should prevent chunking legacy transactions just before the [r,s,v] for dataSize %i, chainId %i",async(n,a,p)=>{const o=new C.Transaction;o.to="0x0123456789abcdef0123456789abcdef01234567",o.nonce=0,o.value=0n,o.gasLimit=1n,o.gasPrice=2n,o.data="0x"+new Array(n).fill("00").join(""),o.chainId=a,o.type=0;const y=(0,e.hexaStringToBuffer)(o.unsignedSerialized),T={derivationPath:"44'/60'/0'/0/0",serializedTransaction:y,chainId:a,transactionType:0,clearSigningType:t.ClearSigningType.BASIC,logger:i};x.sendCommand.mockResolvedValueOnce(m),x.sendCommand.mockResolvedValueOnce(m),x.sendCommand.mockResolvedValue(g),await new c.SendSignTransactionTask(x,T).run();const h=Uint8Array.from([...l,...y]);expect(x.sendCommand.mock.calls).toHaveLength(3),expect(x.sendCommand.mock.calls[0][0]).toStrictEqual(new s.SignTransactionCommand({serializedTransaction:h.slice(0,p),isFirstChunk:!0})),expect(x.sendCommand.mock.calls[1][0]).toStrictEqual(new s.SignTransactionCommand({serializedTransaction:h.slice(p,p*2),isFirstChunk:!1})),expect(x.sendCommand.mock.calls[2][0]).toStrictEqual(new s.SignTransactionCommand({serializedTransaction:h.slice(p*2),isFirstChunk:!1}))}),it("should return an error if the command fails",async()=>{const n={derivationPath:"44'/60'/0'/0/0",serializedTransaction:r,chainId:1,transactionType:1,clearSigningType:t.ClearSigningType.BASIC,logger:i};x.sendCommand.mockResolvedValueOnce(m);const a=await new c.SendSignTransactionTask(x,n).run();expect(x.sendCommand.mock.calls).toHaveLength(1),expect(x.sendCommand.mock.calls[0][0]).toStrictEqual(new s.SignTransactionCommand({serializedTransaction:new Uint8Array([...l,...r]),isFirstChunk:!0})),expect(a.error).toStrictEqual(new e.InvalidStatusWordError("no signature returned"))}),it("should return an error if the generic-parser command fails",async()=>{const n={derivationPath:"44'/60'/0'/0/0",serializedTransaction:r,chainId:1,transactionType:1,clearSigningType:t.ClearSigningType.EIP7730,logger:i};x.sendCommand.mockResolvedValueOnce(m);const a=await new c.SendSignTransactionTask(x,n).run();expect(x.sendCommand.mock.calls).toHaveLength(1),expect(x.sendCommand.mock.calls[0][0]).toStrictEqual(new b.StartTransactionCommand),expect(a.error).toStrictEqual(new e.InvalidStatusWordError("no signature returned"))}),it("should return an error if the command fails in the middle of the transaction",async()=>{const n={derivationPath:"44'/60'/0'/0/0",serializedTransaction:u,chainId:1,transactionType:1,clearSigningType:t.ClearSigningType.BASIC,logger:i};x.sendCommand.mockResolvedValueOnce(m),x.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({error:new e.InvalidStatusWordError("An error")}));const a=await new c.SendSignTransactionTask(x,n).run();expect(x.sendCommand.mock.calls).toHaveLength(2),expect(x.sendCommand.mock.calls[0][0]).toStrictEqual(new s.SignTransactionCommand({serializedTransaction:new Uint8Array([...l,...u]).slice(0,e.APDU_MAX_PAYLOAD),isFirstChunk:!0})),expect(x.sendCommand.mock.calls[1][0]).toStrictEqual(new s.SignTransactionCommand({serializedTransaction:new Uint8Array([...l,...u]).slice(e.APDU_MAX_PAYLOAD,e.APDU_MAX_PAYLOAD*2),isFirstChunk:!1})),expect(a.error).toStrictEqual(new e.InvalidStatusWordError("An error"))}),it("legacy transaction with small chainId",async()=>{const n={derivationPath:"44'/60'/0'/0/0",serializedTransaction:r,chainId:56,transactionType:0,clearSigningType:t.ClearSigningType.BASIC,logger:i};x.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({data:(0,d.Just)({v:147,r:"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",s:"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"})}));const a=await new c.SendSignTransactionTask(x,n).run();expect(a.data.v).toStrictEqual(147)}),it("legacy transaction with small chainId with positive parity",async()=>{const n={derivationPath:"44'/60'/0'/0/0",serializedTransaction:r,chainId:56,transactionType:0,clearSigningType:t.ClearSigningType.BASIC,logger:i};x.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({data:(0,d.Just)({v:148,r:"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",s:"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"})}));const a=await new c.SendSignTransactionTask(x,n).run();expect(a.data.v).toStrictEqual(148)}),it("legacy transaction with big chainId",async()=>{const n={derivationPath:"44'/60'/0'/0/0",serializedTransaction:r,chainId:11297108109,transactionType:0,clearSigningType:t.ClearSigningType.BASIC,logger:i};x.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({data:(0,d.Just)({v:131,r:"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",s:"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"})}));const a=await new c.SendSignTransactionTask(x,n).run();expect(a.data.v).toStrictEqual(22594216253)}),it("legacy transaction with big chainId with positive parity",async()=>{const n={derivationPath:"44'/60'/0'/0/0",serializedTransaction:r,chainId:11297108109,transactionType:0,clearSigningType:t.ClearSigningType.BASIC,logger:i};x.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({data:(0,d.Just)({v:132,r:"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",s:"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"})}));const a=await new c.SendSignTransactionTask(x,n).run();expect(a.data.v).toStrictEqual(22594216254)})})});
|
|
2
2
|
//# sourceMappingURL=SendSignTransactionTask.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/task/SendSignTransactionTask.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n APDU_MAX_PAYLOAD,\n CommandResultFactory,\n hexaStringToBuffer,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport { Transaction } from \"ethers\";\nimport { Just, Nothing } from \"purify-ts\";\n\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { SignTransactionCommand } from \"@internal/app-binder/command/SignTransactionCommand\";\nimport { StartTransactionCommand } from \"@internal/app-binder/command/StartTransactionCommand\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\n\nimport { SendSignTransactionTask } from \"./SendSignTransactionTask\";\n\nconst PATH = new Uint8Array([\n 0x05, 0x80, 0x00, 0x00, 0x2c, 0x80, 0x00, 0x00, 0x3c, 0x80, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n]);\n\nconst SIMPLE_TRANSACTION = new Uint8Array([\n 0x05, 0x80, 0x00, 0x00, 0x2c, 0x80, 0x00, 0x00, 0x3c, 0x80, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x6b, 0x82, 0x06, 0x7e,\n 0x84, 0x57, 0x19, 0x13, 0x1f, 0x83, 0x01, 0x10, 0x68, 0x94, 0xda, 0xc1, 0x7f,\n 0x95, 0x8d, 0x2e, 0xe5, 0x23, 0xa2, 0x20, 0x62, 0x06, 0x99, 0x45, 0x97, 0xc1,\n 0x3d, 0x83, 0x1e, 0xc7, 0x80, 0xb8, 0x44, 0xa9, 0x05, 0x9c, 0xbb, 0x00, 0x00,\n]);\n\nconst BIG_TRANSACTION = new Uint8Array([\n 0xf9, 0x08, 0xaf, 0x26, 0x85, 0x01, 0xb2, 0x3d, 0x94, 0x83, 0x83, 0x05, 0xc1,\n 0xfc, 0x94, 0xde, 0xf1, 0xc0, 0xde, 0xd9, 0xbe, 0xc7, 0xf1, 0xa1, 0x67, 0x08,\n 0x19, 0x83, 0x32, 0x40, 0xf0, 0x27, 0xb2, 0x5e, 0xff, 0x80, 0xb9, 0x08, 0x88,\n 0x41, 0x55, 0x65, 0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x1f, 0x98, 0x40, 0xa8, 0x5d, 0x5a, 0xf5, 0xbf, 0x1d, 0x17,\n 0x62, 0xf9, 0x25, 0xbd, 0xad, 0xdc, 0x42, 0x01, 0xf9, 0x84, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0xb8, 0x69, 0x91,\n 0xc6, 0x21, 0x8b, 0x36, 0xc1, 0xd1, 0x9d, 0x4a, 0x2e, 0x9e, 0xb0, 0xce, 0x36,\n 0x06, 0xeb, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x61, 0xe9, 0x33, 0x59, 0x53, 0x95, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x33,\n 0xef, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x40,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x05, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x40, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x03, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n]);\n\ndescribe(\"SendSignTransactionTask\", () => {\n const apiMock = makeDeviceActionInternalApiMock();\n const signature = {\n v: 27,\n r: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n s: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n };\n const resultOk = CommandResultFactory({\n data: Just(signature),\n });\n const resultNothing = CommandResultFactory({ data: Nothing });\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"run\", () => {\n it(\"should send the transaction in one command\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n serializedTransaction: SIMPLE_TRANSACTION,\n chainId: 1,\n transactionType: 1,\n clearSigningType: ClearSigningType.BASIC,\n };\n apiMock.sendCommand.mockResolvedValueOnce(resultOk);\n\n // WHEN\n const result = await new SendSignTransactionTask(apiMock, args).run();\n\n // THEN\n expect(apiMock.sendCommand.mock.calls).toHaveLength(1);\n expect(apiMock.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new SignTransactionCommand({\n serializedTransaction: new Uint8Array([\n ...PATH,\n ...SIMPLE_TRANSACTION,\n ]),\n isFirstChunk: true,\n }),\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n expect((result as any).data).toStrictEqual(signature);\n });\n\n it(\"Generic-parser transaction should be signed without payload\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n serializedTransaction: SIMPLE_TRANSACTION,\n chainId: 1,\n transactionType: 1,\n clearSigningType: ClearSigningType.EIP7730,\n };\n apiMock.sendCommand.mockResolvedValueOnce(resultOk);\n\n // WHEN\n const result = await new SendSignTransactionTask(apiMock, args).run();\n\n // THEN\n expect(apiMock.sendCommand.mock.calls).toHaveLength(1);\n expect(apiMock.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new StartTransactionCommand(),\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n expect((result as any).data).toStrictEqual(signature);\n });\n\n it(\"should send the transaction in chunks\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n serializedTransaction: BIG_TRANSACTION,\n chainId: 1,\n transactionType: 1,\n clearSigningType: ClearSigningType.BASIC,\n };\n apiMock.sendCommand.mockResolvedValueOnce(resultNothing);\n apiMock.sendCommand.mockResolvedValueOnce(resultOk);\n\n // WHEN\n const result = await new SendSignTransactionTask(apiMock, args).run();\n\n // THEN\n expect(apiMock.sendCommand.mock.calls).toHaveLength(2);\n expect(apiMock.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new SignTransactionCommand({\n serializedTransaction: new Uint8Array([\n ...PATH,\n ...BIG_TRANSACTION,\n ]).slice(0, APDU_MAX_PAYLOAD),\n isFirstChunk: true,\n }),\n );\n expect(apiMock.sendCommand.mock.calls[1]![0]).toStrictEqual(\n new SignTransactionCommand({\n serializedTransaction: new Uint8Array([\n ...PATH,\n ...BIG_TRANSACTION,\n ]).slice(APDU_MAX_PAYLOAD, APDU_MAX_PAYLOAD * 2),\n isFirstChunk: false,\n }),\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n expect((result as any).data).toStrictEqual(signature);\n });\n\n it.each([\n [458, 127, 254],\n [458, 0x818181818181, 254],\n [452, 0x818181818181, 251],\n ])(\n \"should prevent chunking legacy transactions just before the [r,s,v] for dataSize %i, chainId %i\",\n async (dataSize, chainId, chunkSize) => {\n // GIVEN\n const transaction = new Transaction();\n transaction.to = \"0x0123456789abcdef0123456789abcdef01234567\";\n transaction.nonce = 0;\n transaction.value = 0n;\n transaction.gasLimit = 1n;\n transaction.gasPrice = 2n;\n transaction.data = \"0x\" + new Array(dataSize).fill(\"00\").join(\"\");\n transaction.chainId = chainId;\n transaction.type = 0;\n const serialized = hexaStringToBuffer(transaction.unsignedSerialized)!;\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n serializedTransaction: serialized,\n chainId,\n transactionType: 0,\n clearSigningType: ClearSigningType.BASIC,\n };\n apiMock.sendCommand.mockResolvedValueOnce(resultNothing);\n apiMock.sendCommand.mockResolvedValueOnce(resultNothing);\n apiMock.sendCommand.mockResolvedValue(resultOk);\n\n // WHEN\n await new SendSignTransactionTask(apiMock, args).run();\n\n // THEN\n const payload = Uint8Array.from([...PATH, ...serialized]);\n expect(apiMock.sendCommand.mock.calls).toHaveLength(3);\n expect(apiMock.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new SignTransactionCommand({\n serializedTransaction: payload.slice(0, chunkSize),\n isFirstChunk: true,\n }),\n );\n expect(apiMock.sendCommand.mock.calls[1]![0]).toStrictEqual(\n new SignTransactionCommand({\n serializedTransaction: payload.slice(chunkSize, chunkSize * 2),\n isFirstChunk: false,\n }),\n );\n expect(apiMock.sendCommand.mock.calls[2]![0]).toStrictEqual(\n new SignTransactionCommand({\n serializedTransaction: payload.slice(chunkSize * 2),\n isFirstChunk: false,\n }),\n );\n },\n );\n\n it(\"should return an error if the command fails\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n serializedTransaction: SIMPLE_TRANSACTION,\n chainId: 1,\n transactionType: 1,\n clearSigningType: ClearSigningType.BASIC,\n };\n apiMock.sendCommand.mockResolvedValueOnce(resultNothing);\n\n // WHEN\n const result = await new SendSignTransactionTask(apiMock, args).run();\n\n // THEN\n expect(apiMock.sendCommand.mock.calls).toHaveLength(1);\n expect(apiMock.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new SignTransactionCommand({\n serializedTransaction: new Uint8Array([\n ...PATH,\n ...SIMPLE_TRANSACTION,\n ]),\n isFirstChunk: true,\n }),\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n expect((result as any).error).toStrictEqual(\n new InvalidStatusWordError(\"no signature returned\"),\n );\n });\n\n it(\"should return an error if the generic-parser command fails\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n serializedTransaction: SIMPLE_TRANSACTION,\n chainId: 1,\n transactionType: 1,\n clearSigningType: ClearSigningType.EIP7730,\n };\n apiMock.sendCommand.mockResolvedValueOnce(resultNothing);\n\n // WHEN\n const result = await new SendSignTransactionTask(apiMock, args).run();\n\n // THEN\n expect(apiMock.sendCommand.mock.calls).toHaveLength(1);\n expect(apiMock.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new StartTransactionCommand(),\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n expect((result as any).error).toStrictEqual(\n new InvalidStatusWordError(\"no signature returned\"),\n );\n });\n\n it(\"should return an error if the command fails in the middle of the transaction\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n serializedTransaction: BIG_TRANSACTION,\n chainId: 1,\n transactionType: 1,\n clearSigningType: ClearSigningType.BASIC,\n };\n apiMock.sendCommand.mockResolvedValueOnce(resultNothing);\n apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"An error\"),\n }),\n );\n\n // WHEN\n const result = await new SendSignTransactionTask(apiMock, args).run();\n\n // THEN\n expect(apiMock.sendCommand.mock.calls).toHaveLength(2);\n expect(apiMock.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new SignTransactionCommand({\n serializedTransaction: new Uint8Array([\n ...PATH,\n ...BIG_TRANSACTION,\n ]).slice(0, APDU_MAX_PAYLOAD),\n isFirstChunk: true,\n }),\n );\n expect(apiMock.sendCommand.mock.calls[1]![0]).toStrictEqual(\n new SignTransactionCommand({\n serializedTransaction: new Uint8Array([\n ...PATH,\n ...BIG_TRANSACTION,\n ]).slice(APDU_MAX_PAYLOAD, APDU_MAX_PAYLOAD * 2),\n isFirstChunk: false,\n }),\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n expect((result as any).error).toStrictEqual(\n new InvalidStatusWordError(\"An error\"),\n );\n });\n\n it(\"legacy transaction with small chainId\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n serializedTransaction: SIMPLE_TRANSACTION,\n chainId: 56,\n transactionType: 0,\n clearSigningType: ClearSigningType.BASIC,\n };\n apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({\n data: Just({\n v: 147,\n r: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n s: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n }),\n }),\n );\n\n // WHEN\n const result = await new SendSignTransactionTask(apiMock, args).run();\n\n // THEN\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n expect((result as any).data.v).toStrictEqual(147);\n });\n\n it(\"legacy transaction with small chainId with positive parity\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n serializedTransaction: SIMPLE_TRANSACTION,\n chainId: 56,\n transactionType: 0,\n clearSigningType: ClearSigningType.BASIC,\n };\n apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({\n data: Just({\n v: 148,\n r: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n s: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n }),\n }),\n );\n\n // WHEN\n const result = await new SendSignTransactionTask(apiMock, args).run();\n\n // THEN\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n expect((result as any).data.v).toStrictEqual(148);\n });\n\n it(\"legacy transaction with big chainId\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n serializedTransaction: SIMPLE_TRANSACTION,\n chainId: 11297108109,\n transactionType: 0,\n clearSigningType: ClearSigningType.BASIC,\n };\n apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({\n data: Just({\n v: 131,\n r: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n s: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n }),\n }),\n );\n\n // WHEN\n const result = await new SendSignTransactionTask(apiMock, args).run();\n\n // THEN\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n expect((result as any).data.v).toStrictEqual(22594216253);\n });\n\n it(\"legacy transaction with big chainId with positive parity\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n serializedTransaction: SIMPLE_TRANSACTION,\n chainId: 11297108109,\n transactionType: 0,\n clearSigningType: ClearSigningType.BASIC,\n };\n apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({\n data: Just({\n v: 132,\n r: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n s: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n }),\n }),\n );\n\n // WHEN\n const result = await new SendSignTransactionTask(apiMock, args).run();\n\n // THEN\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n expect((result as any).data.v).toStrictEqual(22594216254);\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "aAAA,IAAAA,EAKO,2CACPC,EAA4B,kBAC5BC,EAA8B,qBAE9BC,EAAiC,uCACjCC,EAAuC,+DACvCC,EAAwC,gEACxCC,EAAgD,6EAEhDC,EAAwC,qCAExC,MAAMC,EAAO,IAAI,WAAW,CAC1B,EAAM,IAAM,EAAM,EAAM,GAAM,IAAM,EAAM,EAAM,GAAM,IAAM,EAAM,EAAM,EACxE,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,CAC5C,CAAC,EAEKC,EAAqB,IAAI,WAAW,CACxC,EAAM,IAAM,EAAM,EAAM,GAAM,IAAM,EAAM,EAAM,GAAM,IAAM,EAAM,EAAM,EACxE,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,IAAM,IAAM,IAAM,EAAM,IACxE,IAAM,GAAM,GAAM,GAAM,GAAM,IAAM,EAAM,GAAM,IAAM,IAAM,IAAM,IAAM,IACxE,IAAM,IAAM,GAAM,IAAM,GAAM,IAAM,GAAM,GAAM,EAAM,IAAM,GAAM,IAAM,IACxE,GAAM,IAAM,GAAM,IAAM,IAAM,IAAM,GAAM,IAAM,EAAM,IAAM,IAAM,EAAM,CAC1E,CAAC,EAEKC,EAAkB,IAAI,WAAW,CACrC,IAAM,EAAM,IAAM,GAAM,IAAM,EAAM,IAAM,GAAM,IAAM,IAAM,IAAM,EAAM,IACxE,IAAM,IAAM,IAAM,IAAM,IAAM,IAAM,IAAM,IAAM,IAAM,IAAM,IAAM,IAAM,EACxE,GAAM,IAAM,GAAM,GAAM,IAAM,GAAM,IAAM,GAAM,IAAM,IAAM,IAAM,EAAM,IACxE,GAAM,GAAM,IAAM,IAAM,EAAM,EAAM,EAAM,EAAM,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M,EAAM,GAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,CAC1E,CAAC,EAED,SAAS,0BAA2B,IAAM,CACxC,MAAMC,KAAU,mCAAgC,EAC1CC,EAAY,CAChB,EAAG,GACH,EAAG,qEACH,EAAG,oEACL,EACMC,KAAW,wBAAqB,CACpC,QAAM,QAAKD,CAAS,CACtB,CAAC,EACKE,KAAgB,wBAAqB,CAAE,KAAM,SAAQ,CAAC,EAE5D,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,SAAS,MAAO,IAAM,CACpB,GAAG,6CAA8C,SAAY,CAE3D,MAAMC,EAAO,CACX,eAAgB,iBAChB,sBAAuBN,EACvB,QAAS,EACT,gBAAiB,EACjB,iBAAkB,mBAAiB,
|
|
6
|
-
"names": ["import_device_management_kit", "import_ethers", "import_purify_ts", "import_ClearSigningType", "import_SignTransactionCommand", "import_StartTransactionCommand", "import_makeInternalApi", "import_SendSignTransactionTask", "PATH", "SIMPLE_TRANSACTION", "BIG_TRANSACTION", "apiMock", "signature", "resultOk", "resultNothing", "args", "result", "dataSize", "chainId", "chunkSize", "transaction", "serialized", "payload"]
|
|
4
|
+
"sourcesContent": ["import {\n APDU_MAX_PAYLOAD,\n CommandResultFactory,\n hexaStringToBuffer,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport { Transaction } from \"ethers\";\nimport { Just, Nothing } from \"purify-ts\";\n\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { SignTransactionCommand } from \"@internal/app-binder/command/SignTransactionCommand\";\nimport { StartTransactionCommand } from \"@internal/app-binder/command/StartTransactionCommand\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\n\nimport { SendSignTransactionTask } from \"./SendSignTransactionTask\";\n\nconst mockLogger = {\n debug: vi.fn(),\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n subscribers: [],\n};\n\nconst PATH = new Uint8Array([\n 0x05, 0x80, 0x00, 0x00, 0x2c, 0x80, 0x00, 0x00, 0x3c, 0x80, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n]);\n\nconst SIMPLE_TRANSACTION = new Uint8Array([\n 0x05, 0x80, 0x00, 0x00, 0x2c, 0x80, 0x00, 0x00, 0x3c, 0x80, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x6b, 0x82, 0x06, 0x7e,\n 0x84, 0x57, 0x19, 0x13, 0x1f, 0x83, 0x01, 0x10, 0x68, 0x94, 0xda, 0xc1, 0x7f,\n 0x95, 0x8d, 0x2e, 0xe5, 0x23, 0xa2, 0x20, 0x62, 0x06, 0x99, 0x45, 0x97, 0xc1,\n 0x3d, 0x83, 0x1e, 0xc7, 0x80, 0xb8, 0x44, 0xa9, 0x05, 0x9c, 0xbb, 0x00, 0x00,\n]);\n\nconst BIG_TRANSACTION = new Uint8Array([\n 0xf9, 0x08, 0xaf, 0x26, 0x85, 0x01, 0xb2, 0x3d, 0x94, 0x83, 0x83, 0x05, 0xc1,\n 0xfc, 0x94, 0xde, 0xf1, 0xc0, 0xde, 0xd9, 0xbe, 0xc7, 0xf1, 0xa1, 0x67, 0x08,\n 0x19, 0x83, 0x32, 0x40, 0xf0, 0x27, 0xb2, 0x5e, 0xff, 0x80, 0xb9, 0x08, 0x88,\n 0x41, 0x55, 0x65, 0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x1f, 0x98, 0x40, 0xa8, 0x5d, 0x5a, 0xf5, 0xbf, 0x1d, 0x17,\n 0x62, 0xf9, 0x25, 0xbd, 0xad, 0xdc, 0x42, 0x01, 0xf9, 0x84, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0xb8, 0x69, 0x91,\n 0xc6, 0x21, 0x8b, 0x36, 0xc1, 0xd1, 0x9d, 0x4a, 0x2e, 0x9e, 0xb0, 0xce, 0x36,\n 0x06, 0xeb, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x61, 0xe9, 0x33, 0x59, 0x53, 0x95, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x33,\n 0xef, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x40,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x05, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x40, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x03, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n]);\n\ndescribe(\"SendSignTransactionTask\", () => {\n const apiMock = makeDeviceActionInternalApiMock();\n const signature = {\n v: 27,\n r: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n s: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n };\n const resultOk = CommandResultFactory({\n data: Just(signature),\n });\n const resultNothing = CommandResultFactory({ data: Nothing });\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"run\", () => {\n it(\"should send the transaction in one command\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n serializedTransaction: SIMPLE_TRANSACTION,\n chainId: 1,\n transactionType: 1,\n clearSigningType: ClearSigningType.BASIC,\n logger: mockLogger,\n };\n apiMock.sendCommand.mockResolvedValueOnce(resultOk);\n\n // WHEN\n const result = await new SendSignTransactionTask(apiMock, args).run();\n\n // THEN\n expect(apiMock.sendCommand.mock.calls).toHaveLength(1);\n expect(apiMock.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new SignTransactionCommand({\n serializedTransaction: new Uint8Array([\n ...PATH,\n ...SIMPLE_TRANSACTION,\n ]),\n isFirstChunk: true,\n }),\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n expect((result as any).data).toStrictEqual(signature);\n });\n\n it(\"Generic-parser transaction should be signed without payload\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n serializedTransaction: SIMPLE_TRANSACTION,\n chainId: 1,\n transactionType: 1,\n clearSigningType: ClearSigningType.EIP7730,\n logger: mockLogger,\n };\n apiMock.sendCommand.mockResolvedValueOnce(resultOk);\n\n // WHEN\n const result = await new SendSignTransactionTask(apiMock, args).run();\n\n // THEN\n expect(apiMock.sendCommand.mock.calls).toHaveLength(1);\n expect(apiMock.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new StartTransactionCommand(),\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n expect((result as any).data).toStrictEqual(signature);\n });\n\n it(\"should send the transaction in chunks\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n serializedTransaction: BIG_TRANSACTION,\n chainId: 1,\n transactionType: 1,\n clearSigningType: ClearSigningType.BASIC,\n logger: mockLogger,\n };\n apiMock.sendCommand.mockResolvedValueOnce(resultNothing);\n apiMock.sendCommand.mockResolvedValueOnce(resultOk);\n\n // WHEN\n const result = await new SendSignTransactionTask(apiMock, args).run();\n\n // THEN\n expect(apiMock.sendCommand.mock.calls).toHaveLength(2);\n expect(apiMock.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new SignTransactionCommand({\n serializedTransaction: new Uint8Array([\n ...PATH,\n ...BIG_TRANSACTION,\n ]).slice(0, APDU_MAX_PAYLOAD),\n isFirstChunk: true,\n }),\n );\n expect(apiMock.sendCommand.mock.calls[1]![0]).toStrictEqual(\n new SignTransactionCommand({\n serializedTransaction: new Uint8Array([\n ...PATH,\n ...BIG_TRANSACTION,\n ]).slice(APDU_MAX_PAYLOAD, APDU_MAX_PAYLOAD * 2),\n isFirstChunk: false,\n }),\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n expect((result as any).data).toStrictEqual(signature);\n });\n\n it.each([\n [458, 127, 254],\n [458, 0x818181818181, 254],\n [452, 0x818181818181, 251],\n ])(\n \"should prevent chunking legacy transactions just before the [r,s,v] for dataSize %i, chainId %i\",\n async (dataSize, chainId, chunkSize) => {\n // GIVEN\n const transaction = new Transaction();\n transaction.to = \"0x0123456789abcdef0123456789abcdef01234567\";\n transaction.nonce = 0;\n transaction.value = 0n;\n transaction.gasLimit = 1n;\n transaction.gasPrice = 2n;\n transaction.data = \"0x\" + new Array(dataSize).fill(\"00\").join(\"\");\n transaction.chainId = chainId;\n transaction.type = 0;\n const serialized = hexaStringToBuffer(transaction.unsignedSerialized)!;\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n serializedTransaction: serialized,\n chainId,\n transactionType: 0,\n clearSigningType: ClearSigningType.BASIC,\n logger: mockLogger,\n };\n apiMock.sendCommand.mockResolvedValueOnce(resultNothing);\n apiMock.sendCommand.mockResolvedValueOnce(resultNothing);\n apiMock.sendCommand.mockResolvedValue(resultOk);\n\n // WHEN\n await new SendSignTransactionTask(apiMock, args).run();\n\n // THEN\n const payload = Uint8Array.from([...PATH, ...serialized]);\n expect(apiMock.sendCommand.mock.calls).toHaveLength(3);\n expect(apiMock.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new SignTransactionCommand({\n serializedTransaction: payload.slice(0, chunkSize),\n isFirstChunk: true,\n }),\n );\n expect(apiMock.sendCommand.mock.calls[1]![0]).toStrictEqual(\n new SignTransactionCommand({\n serializedTransaction: payload.slice(chunkSize, chunkSize * 2),\n isFirstChunk: false,\n }),\n );\n expect(apiMock.sendCommand.mock.calls[2]![0]).toStrictEqual(\n new SignTransactionCommand({\n serializedTransaction: payload.slice(chunkSize * 2),\n isFirstChunk: false,\n }),\n );\n },\n );\n\n it(\"should return an error if the command fails\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n serializedTransaction: SIMPLE_TRANSACTION,\n chainId: 1,\n transactionType: 1,\n clearSigningType: ClearSigningType.BASIC,\n logger: mockLogger,\n };\n apiMock.sendCommand.mockResolvedValueOnce(resultNothing);\n\n // WHEN\n const result = await new SendSignTransactionTask(apiMock, args).run();\n\n // THEN\n expect(apiMock.sendCommand.mock.calls).toHaveLength(1);\n expect(apiMock.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new SignTransactionCommand({\n serializedTransaction: new Uint8Array([\n ...PATH,\n ...SIMPLE_TRANSACTION,\n ]),\n isFirstChunk: true,\n }),\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n expect((result as any).error).toStrictEqual(\n new InvalidStatusWordError(\"no signature returned\"),\n );\n });\n\n it(\"should return an error if the generic-parser command fails\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n serializedTransaction: SIMPLE_TRANSACTION,\n chainId: 1,\n transactionType: 1,\n clearSigningType: ClearSigningType.EIP7730,\n logger: mockLogger,\n };\n apiMock.sendCommand.mockResolvedValueOnce(resultNothing);\n\n // WHEN\n const result = await new SendSignTransactionTask(apiMock, args).run();\n\n // THEN\n expect(apiMock.sendCommand.mock.calls).toHaveLength(1);\n expect(apiMock.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new StartTransactionCommand(),\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n expect((result as any).error).toStrictEqual(\n new InvalidStatusWordError(\"no signature returned\"),\n );\n });\n\n it(\"should return an error if the command fails in the middle of the transaction\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n serializedTransaction: BIG_TRANSACTION,\n chainId: 1,\n transactionType: 1,\n clearSigningType: ClearSigningType.BASIC,\n logger: mockLogger,\n };\n apiMock.sendCommand.mockResolvedValueOnce(resultNothing);\n apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"An error\"),\n }),\n );\n\n // WHEN\n const result = await new SendSignTransactionTask(apiMock, args).run();\n\n // THEN\n expect(apiMock.sendCommand.mock.calls).toHaveLength(2);\n expect(apiMock.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new SignTransactionCommand({\n serializedTransaction: new Uint8Array([\n ...PATH,\n ...BIG_TRANSACTION,\n ]).slice(0, APDU_MAX_PAYLOAD),\n isFirstChunk: true,\n }),\n );\n expect(apiMock.sendCommand.mock.calls[1]![0]).toStrictEqual(\n new SignTransactionCommand({\n serializedTransaction: new Uint8Array([\n ...PATH,\n ...BIG_TRANSACTION,\n ]).slice(APDU_MAX_PAYLOAD, APDU_MAX_PAYLOAD * 2),\n isFirstChunk: false,\n }),\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n expect((result as any).error).toStrictEqual(\n new InvalidStatusWordError(\"An error\"),\n );\n });\n\n it(\"legacy transaction with small chainId\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n serializedTransaction: SIMPLE_TRANSACTION,\n chainId: 56,\n transactionType: 0,\n clearSigningType: ClearSigningType.BASIC,\n logger: mockLogger,\n };\n apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({\n data: Just({\n v: 147,\n r: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n s: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n }),\n }),\n );\n\n // WHEN\n const result = await new SendSignTransactionTask(apiMock, args).run();\n\n // THEN\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n expect((result as any).data.v).toStrictEqual(147);\n });\n\n it(\"legacy transaction with small chainId with positive parity\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n serializedTransaction: SIMPLE_TRANSACTION,\n chainId: 56,\n transactionType: 0,\n clearSigningType: ClearSigningType.BASIC,\n logger: mockLogger,\n };\n apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({\n data: Just({\n v: 148,\n r: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n s: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n }),\n }),\n );\n\n // WHEN\n const result = await new SendSignTransactionTask(apiMock, args).run();\n\n // THEN\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n expect((result as any).data.v).toStrictEqual(148);\n });\n\n it(\"legacy transaction with big chainId\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n serializedTransaction: SIMPLE_TRANSACTION,\n chainId: 11297108109,\n transactionType: 0,\n clearSigningType: ClearSigningType.BASIC,\n logger: mockLogger,\n };\n apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({\n data: Just({\n v: 131,\n r: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n s: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n }),\n }),\n );\n\n // WHEN\n const result = await new SendSignTransactionTask(apiMock, args).run();\n\n // THEN\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n expect((result as any).data.v).toStrictEqual(22594216253);\n });\n\n it(\"legacy transaction with big chainId with positive parity\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n serializedTransaction: SIMPLE_TRANSACTION,\n chainId: 11297108109,\n transactionType: 0,\n clearSigningType: ClearSigningType.BASIC,\n logger: mockLogger,\n };\n apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({\n data: Just({\n v: 132,\n r: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n s: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n }),\n }),\n );\n\n // WHEN\n const result = await new SendSignTransactionTask(apiMock, args).run();\n\n // THEN\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n expect((result as any).data.v).toStrictEqual(22594216254);\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAKO,2CACPC,EAA4B,kBAC5BC,EAA8B,qBAE9BC,EAAiC,uCACjCC,EAAuC,+DACvCC,EAAwC,gEACxCC,EAAgD,6EAEhDC,EAAwC,qCAExC,MAAMC,EAAa,CACjB,MAAO,GAAG,GAAG,EACb,KAAM,GAAG,GAAG,EACZ,KAAM,GAAG,GAAG,EACZ,MAAO,GAAG,GAAG,EACb,YAAa,CAAC,CAChB,EAEMC,EAAO,IAAI,WAAW,CAC1B,EAAM,IAAM,EAAM,EAAM,GAAM,IAAM,EAAM,EAAM,GAAM,IAAM,EAAM,EAAM,EACxE,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,CAC5C,CAAC,EAEKC,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N,EACvB,QAAS,YACT,gBAAiB,EACjB,iBAAkB,mBAAiB,MACnC,OAAQF,CACV,EACAI,EAAQ,YAAY,yBAClB,wBAAqB,CACnB,QAAM,QAAK,CACT,EAAG,IACH,EAAG,qEACH,EAAG,oEACL,CAAC,CACH,CAAC,CACH,EAGA,MAAMK,EAAS,MAAM,IAAI,0BAAwBL,EAASI,CAAI,EAAE,IAAI,EAIpE,OAAQC,EAAe,KAAK,CAAC,EAAE,cAAc,WAAW,CAC1D,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_device_management_kit", "import_ethers", "import_purify_ts", "import_ClearSigningType", "import_SignTransactionCommand", "import_StartTransactionCommand", "import_makeInternalApi", "import_SendSignTransactionTask", "mockLogger", "PATH", "SIMPLE_TRANSACTION", "BIG_TRANSACTION", "apiMock", "signature", "resultOk", "resultNothing", "args", "result", "dataSize", "chainId", "chunkSize", "transaction", "serialized", "payload"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var o=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var
|
|
1
|
+
"use strict";var o=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var g=(t,a)=>{for(var r in a)o(t,r,{get:a[r],enumerable:!0})},l=(t,a,r,i)=>{if(a&&typeof a=="object"||typeof a=="function")for(let e of y(a))!h.call(t,e)&&e!==r&&o(t,e,{get:()=>a[e],enumerable:!(i=m(a,e))||i.enumerable});return t};var c=t=>l(o({},"__esModule",{value:!0}),t);var T={};g(T,{SignTypedDataLegacyTask:()=>u});module.exports=c(T);var n=require("ethers"),d=require("purify-ts"),s=require("../../app-binder/command/SignEIP712Command");class u{constructor(a,r,i,e){this.api=a;this.data=r;this.derivationPath=i;this.logger=e}async run(){this.logger.debug("[run] Starting SignTypedDataLegacyTask",{data:{derivationPath:this.derivationPath,primaryType:this.data.primaryType}});const a=n.TypedDataEncoder.hashDomain(this.data.domain);if(!this.data.types[this.data.primaryType])throw this.logger.error("[run] Primary type not defined in types",{data:{primaryType:this.data.primaryType}}),new Error(`Primary type "${this.data.primaryType}" is not defined in the types.`);const r=this.data.types,{EIP712Domain:i,...e}=r,p=n.TypedDataEncoder.hashStruct(this.data.primaryType,e,this.data.message);return this.logger.debug("[run] Computed hashes, sending blind sign command"),await this.api.sendCommand(new s.SignEIP712Command({derivationPath:this.derivationPath,legacyArgs:(0,d.Just)({domainHash:a,messageHash:p})}))}}0&&(module.exports={SignTypedDataLegacyTask});
|
|
2
2
|
//# sourceMappingURL=SignTypedDataLegacyTask.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/task/SignTypedDataLegacyTask.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n CommandResult,\n InternalApi,\n} from \"@ledgerhq/device-management-kit\";\nimport type { TypedDataField } from \"ethers\";\nimport { TypedDataEncoder } from \"ethers\";\nimport { Just } from \"purify-ts\";\n\nimport type { Signature } from \"@api/model/Signature\";\nimport type { TypedData } from \"@api/model/TypedData\";\nimport { SignEIP712Command } from \"@internal/app-binder/command/SignEIP712Command\";\nimport type { EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\n\nexport class SignTypedDataLegacyTask {\n constructor(\n private readonly api: InternalApi,\n private readonly data: TypedData,\n private readonly derivationPath: string,\n ) {}\n\n async run(): Promise<CommandResult<Signature, EthErrorCodes>> {\n // Compute domain hash and message hash on client side\n const domainHash = TypedDataEncoder.hashDomain(this.data.domain);\n\n if (!this.data.types[this.data.primaryType]) {\n throw new Error(\n `Primary type \"${this.data.primaryType}\" is not defined in the types.`,\n );\n }\n\n const typesRecord: Record<string, TypedDataField[]> = this.data.types;\n const { EIP712Domain, ...rest } = typesRecord;\n const messageHash = TypedDataEncoder.hashStruct(\n this.data.primaryType,\n rest,\n this.data.message,\n );\n\n // Blind sign the hash\n return await this.api.sendCommand(\n new SignEIP712Command({\n derivationPath: this.derivationPath,\n legacyArgs: Just({\n domainHash,\n messageHash,\n }),\n }),\n );\n }\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,
|
|
6
|
-
"names": ["SignTypedDataLegacyTask_exports", "__export", "SignTypedDataLegacyTask", "__toCommonJS", "import_ethers", "import_purify_ts", "import_SignEIP712Command", "api", "data", "derivationPath", "domainHash", "typesRecord", "EIP712Domain", "rest", "messageHash"]
|
|
4
|
+
"sourcesContent": ["import type {\n CommandResult,\n InternalApi,\n LoggerPublisherService,\n} from \"@ledgerhq/device-management-kit\";\nimport type { TypedDataField } from \"ethers\";\nimport { TypedDataEncoder } from \"ethers\";\nimport { Just } from \"purify-ts\";\n\nimport type { Signature } from \"@api/model/Signature\";\nimport type { TypedData } from \"@api/model/TypedData\";\nimport { SignEIP712Command } from \"@internal/app-binder/command/SignEIP712Command\";\nimport type { EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\n\nexport class SignTypedDataLegacyTask {\n constructor(\n private readonly api: InternalApi,\n private readonly data: TypedData,\n private readonly derivationPath: string,\n private readonly logger: LoggerPublisherService,\n ) {}\n\n async run(): Promise<CommandResult<Signature, EthErrorCodes>> {\n this.logger.debug(\"[run] Starting SignTypedDataLegacyTask\", {\n data: {\n derivationPath: this.derivationPath,\n primaryType: this.data.primaryType,\n },\n });\n\n // Compute domain hash and message hash on client side\n const domainHash = TypedDataEncoder.hashDomain(this.data.domain);\n\n if (!this.data.types[this.data.primaryType]) {\n this.logger.error(\"[run] Primary type not defined in types\", {\n data: { primaryType: this.data.primaryType },\n });\n throw new Error(\n `Primary type \"${this.data.primaryType}\" is not defined in the types.`,\n );\n }\n\n const typesRecord: Record<string, TypedDataField[]> = this.data.types;\n const { EIP712Domain, ...rest } = typesRecord;\n const messageHash = TypedDataEncoder.hashStruct(\n this.data.primaryType,\n rest,\n this.data.message,\n );\n\n this.logger.debug(\"[run] Computed hashes, sending blind sign command\");\n\n // Blind sign the hash\n return await this.api.sendCommand(\n new SignEIP712Command({\n derivationPath: this.derivationPath,\n legacyArgs: Just({\n domainHash,\n messageHash,\n }),\n }),\n );\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GAMA,IAAAI,EAAiC,kBACjCC,EAAqB,qBAIrBC,EAAkC,0DAG3B,MAAMJ,CAAwB,CACnC,YACmBK,EACAC,EACAC,EACAC,EACjB,CAJiB,SAAAH,EACA,UAAAC,EACA,oBAAAC,EACA,YAAAC,CAChB,CAEH,MAAM,KAAwD,CAC5D,KAAK,OAAO,MAAM,yCAA0C,CAC1D,KAAM,CACJ,eAAgB,KAAK,eACrB,YAAa,KAAK,KAAK,WACzB,CACF,CAAC,EAGD,MAAMC,EAAa,mBAAiB,WAAW,KAAK,KAAK,MAAM,EAE/D,GAAI,CAAC,KAAK,KAAK,MAAM,KAAK,KAAK,WAAW,EACxC,WAAK,OAAO,MAAM,0CAA2C,CAC3D,KAAM,CAAE,YAAa,KAAK,KAAK,WAAY,CAC7C,CAAC,EACK,IAAI,MACR,iBAAiB,KAAK,KAAK,WAAW,gCACxC,EAGF,MAAMC,EAAgD,KAAK,KAAK,MAC1D,CAAE,aAAAC,EAAc,GAAGC,CAAK,EAAIF,EAC5BG,EAAc,mBAAiB,WACnC,KAAK,KAAK,YACVD,EACA,KAAK,KAAK,OACZ,EAEA,YAAK,OAAO,MAAM,mDAAmD,EAG9D,MAAM,KAAK,IAAI,YACpB,IAAI,oBAAkB,CACpB,eAAgB,KAAK,eACrB,cAAY,QAAK,CACf,WAAAH,EACA,YAAAI,CACF,CAAC,CACH,CAAC,CACH,CACF,CACF",
|
|
6
|
+
"names": ["SignTypedDataLegacyTask_exports", "__export", "SignTypedDataLegacyTask", "__toCommonJS", "import_ethers", "import_purify_ts", "import_SignEIP712Command", "api", "data", "derivationPath", "logger", "domainHash", "typesRecord", "EIP712Domain", "rest", "messageHash"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t=require("@ledgerhq/device-management-kit"),s=require("purify-ts"),
|
|
1
|
+
"use strict";var t=require("@ledgerhq/device-management-kit"),s=require("purify-ts"),c=require("../../app-binder/command/SignEIP712Command"),d=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),i=require("./SignTypedDataLegacyTask");const o={debug:vi.fn(),info:vi.fn(),warn:vi.fn(),error:vi.fn(),subscribers:[]};describe("SignTypedDataLegacyTask",()=>{const e=(0,d.makeDeviceActionInternalApiMock)(),r={domain:{name:"Permit2",chainId:137,verifyingContract:"0x000000000022d473030f116ddee9f6b43ac78ba3"},primaryType:"PermitSingle",message:{details:{token:"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",amount:"69420000000000000000",expiration:"1718184249",nonce:"0"},spender:"0xec7be89e9d109e7e3fec59c222cf297125fefda2",sigDeadline:"1715594049"},types:{PermitSingle:[{name:"details",type:"PermitDetails"},{name:"spender",type:"address"},{name:"sigDeadline",type:"uint256"}],PermitDetails:[{name:"token",type:"address"},{name:"amount",type:"uint"},{name:"expiration",type:"uint"},{name:"nonce",type:"uint"}]}};beforeEach(()=>{vi.resetAllMocks()}),it("Successful legagy signing",async()=>{const n=new i.SignTypedDataLegacyTask(e,r,"44'/60'/0'/0/0",o);e.sendCommand.mockResolvedValue((0,t.CommandResultFactory)({data:{r:"0x24",s:"0x42",v:0}}));const a=await n.run();expect(e.sendCommand).toHaveBeenCalledWith(new c.SignEIP712Command({derivationPath:"44'/60'/0'/0/0",legacyArgs:(0,s.Just)({domainHash:"0xf033048cb2764f596bc4d98e089fa38bb84b4be3d5da2e77f9bfac0e4d6c68ca",messageHash:"0x1087495b5e10337738059920fe1de8216235299745e8c97e21b409009a4c362a"})})),expect(a).toStrictEqual((0,t.CommandResultFactory)({data:{r:"0x24",s:"0x42",v:0}}))}),it("Should throw error if no primary type",async()=>{const n=new i.SignTypedDataLegacyTask(e,{...r,primaryType:"Wat?"},"44'/60'/0'/0/0",o);e.sendCommand.mockResolvedValue((0,t.CommandResultFactory)({data:{r:"0x24",s:"0x42",v:0}}));try{await n.run()}catch(a){expect(a).toBeInstanceOf(Error),expect(a.message).toBe('Primary type "Wat?" is not defined in the types.')}})});
|
|
2
2
|
//# sourceMappingURL=SignTypedDataLegacyTask.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/task/SignTypedDataLegacyTask.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { CommandResultFactory } from \"@ledgerhq/device-management-kit\";\nimport { Just } from \"purify-ts\";\n\nimport { SignEIP712Command } from \"@internal/app-binder/command/SignEIP712Command\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\n\nimport { SignTypedDataLegacyTask } from \"./SignTypedDataLegacyTask\";\n\ndescribe(\"SignTypedDataLegacyTask\", () => {\n const apiMock = makeDeviceActionInternalApiMock();\n\n const TEST_DATA = {\n domain: {\n name: \"Permit2\",\n chainId: 137,\n verifyingContract: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n },\n primaryType: \"PermitSingle\",\n message: {\n details: {\n token: \"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619\",\n amount: \"69420000000000000000\",\n expiration: \"1718184249\",\n nonce: \"0\",\n },\n spender: \"0xec7be89e9d109e7e3fec59c222cf297125fefda2\",\n sigDeadline: \"1715594049\",\n },\n types: {\n PermitSingle: [\n {\n name: \"details\",\n type: \"PermitDetails\",\n },\n {\n name: \"spender\",\n type: \"address\",\n },\n {\n name: \"sigDeadline\",\n type: \"uint256\",\n },\n ],\n PermitDetails: [\n { name: \"token\", type: \"address\" },\n { name: \"amount\", type: \"uint\" },\n { name: \"expiration\", type: \"uint\" },\n { name: \"nonce\", type: \"uint\" },\n ],\n },\n };\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"Successful legagy signing\", async () => {\n // GIVEN\n const task = new SignTypedDataLegacyTask(\n apiMock,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n );\n apiMock.sendCommand.mockResolvedValue(\n CommandResultFactory({\n data: {\n r: \"0x24\",\n s: \"0x42\",\n v: 0,\n },\n }),\n );\n // WHEN\n const signature = await task.run();\n // THEN\n expect(apiMock.sendCommand).toHaveBeenCalledWith(\n new SignEIP712Command({\n derivationPath: \"44'/60'/0'/0/0\",\n legacyArgs: Just({\n domainHash:\n \"0xf033048cb2764f596bc4d98e089fa38bb84b4be3d5da2e77f9bfac0e4d6c68ca\",\n messageHash:\n \"0x1087495b5e10337738059920fe1de8216235299745e8c97e21b409009a4c362a\",\n }),\n }),\n );\n expect(signature).toStrictEqual(\n CommandResultFactory({\n data: {\n r: \"0x24\",\n s: \"0x42\",\n v: 0,\n },\n }),\n );\n });\n\n it(\"Should throw error if no primary type\", async () => {\n // GIVEN\n const task = new SignTypedDataLegacyTask(\n apiMock,\n {\n ...TEST_DATA,\n primaryType: \"Wat?\",\n },\n \"44'/60'/0'/0/0\",\n );\n apiMock.sendCommand.mockResolvedValue(\n CommandResultFactory({\n data: {\n r: \"0x24\",\n s: \"0x42\",\n v: 0,\n },\n }),\n );\n // WHEN\n try {\n await task.run();\n } catch (e) {\n // THEN\n expect(e).toBeInstanceOf(Error);\n // @ts-expect-error\n expect(e.message).toBe(\n 'Primary type \"Wat?\" is not defined in the types.',\n );\n }\n });\n});\n"],
|
|
5
|
-
"mappings": "aAAA,IAAAA,EAAqC,2CACrCC,EAAqB,qBAErBC,EAAkC,0DAClCC,EAAgD,6EAEhDC,EAAwC,qCAExC,SAAS,0BAA2B,IAAM,CACxC,MAAMC,KAAU,mCAAgC,EAE1CC,EAAY,CAChB,OAAQ,CACN,KAAM,UACN,QAAS,IACT,kBAAmB,4CACrB,EACA,YAAa,eACb,QAAS,CACP,QAAS,CACP,MAAO,6CACP,OAAQ,uBACR,WAAY,aACZ,MAAO,GACT,EACA,QAAS,6CACT,YAAa,YACf,EACA,MAAO,CACL,aAAc,CACZ,CACE,KAAM,UACN,KAAM,eACR,EACA,CACE,KAAM,UACN,KAAM,SACR,EACA,CACE,KAAM,cACN,KAAM,SACR,CACF,EACA,cAAe,CACb,CAAE,KAAM,QAAS,KAAM,SAAU,EACjC,CAAE,KAAM,SAAU,KAAM,MAAO,EAC/B,CAAE,KAAM,aAAc,KAAM,MAAO,EACnC,CAAE,KAAM,QAAS,KAAM,MAAO,CAChC,CACF,CACF,EAEA,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,GAAG,4BAA6B,SAAY,CAE1C,MAAMC,EAAO,IAAI,0BACfF,EACAC,EACA,
|
|
6
|
-
"names": ["import_device_management_kit", "import_purify_ts", "import_SignEIP712Command", "import_makeInternalApi", "import_SignTypedDataLegacyTask", "apiMock", "TEST_DATA", "task", "signature", "e"]
|
|
4
|
+
"sourcesContent": ["import { CommandResultFactory } from \"@ledgerhq/device-management-kit\";\nimport { Just } from \"purify-ts\";\n\nimport { SignEIP712Command } from \"@internal/app-binder/command/SignEIP712Command\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\n\nimport { SignTypedDataLegacyTask } from \"./SignTypedDataLegacyTask\";\n\nconst mockLogger = {\n debug: vi.fn(),\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n subscribers: [],\n};\n\ndescribe(\"SignTypedDataLegacyTask\", () => {\n const apiMock = makeDeviceActionInternalApiMock();\n\n const TEST_DATA = {\n domain: {\n name: \"Permit2\",\n chainId: 137,\n verifyingContract: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n },\n primaryType: \"PermitSingle\",\n message: {\n details: {\n token: \"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619\",\n amount: \"69420000000000000000\",\n expiration: \"1718184249\",\n nonce: \"0\",\n },\n spender: \"0xec7be89e9d109e7e3fec59c222cf297125fefda2\",\n sigDeadline: \"1715594049\",\n },\n types: {\n PermitSingle: [\n {\n name: \"details\",\n type: \"PermitDetails\",\n },\n {\n name: \"spender\",\n type: \"address\",\n },\n {\n name: \"sigDeadline\",\n type: \"uint256\",\n },\n ],\n PermitDetails: [\n { name: \"token\", type: \"address\" },\n { name: \"amount\", type: \"uint\" },\n { name: \"expiration\", type: \"uint\" },\n { name: \"nonce\", type: \"uint\" },\n ],\n },\n };\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"Successful legagy signing\", async () => {\n // GIVEN\n const task = new SignTypedDataLegacyTask(\n apiMock,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n mockLogger,\n );\n apiMock.sendCommand.mockResolvedValue(\n CommandResultFactory({\n data: {\n r: \"0x24\",\n s: \"0x42\",\n v: 0,\n },\n }),\n );\n // WHEN\n const signature = await task.run();\n // THEN\n expect(apiMock.sendCommand).toHaveBeenCalledWith(\n new SignEIP712Command({\n derivationPath: \"44'/60'/0'/0/0\",\n legacyArgs: Just({\n domainHash:\n \"0xf033048cb2764f596bc4d98e089fa38bb84b4be3d5da2e77f9bfac0e4d6c68ca\",\n messageHash:\n \"0x1087495b5e10337738059920fe1de8216235299745e8c97e21b409009a4c362a\",\n }),\n }),\n );\n expect(signature).toStrictEqual(\n CommandResultFactory({\n data: {\n r: \"0x24\",\n s: \"0x42\",\n v: 0,\n },\n }),\n );\n });\n\n it(\"Should throw error if no primary type\", async () => {\n // GIVEN\n const task = new SignTypedDataLegacyTask(\n apiMock,\n {\n ...TEST_DATA,\n primaryType: \"Wat?\",\n },\n \"44'/60'/0'/0/0\",\n mockLogger,\n );\n apiMock.sendCommand.mockResolvedValue(\n CommandResultFactory({\n data: {\n r: \"0x24\",\n s: \"0x42\",\n v: 0,\n },\n }),\n );\n // WHEN\n try {\n await task.run();\n } catch (e) {\n // THEN\n expect(e).toBeInstanceOf(Error);\n // @ts-expect-error\n expect(e.message).toBe(\n 'Primary type \"Wat?\" is not defined in the types.',\n );\n }\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAAqC,2CACrCC,EAAqB,qBAErBC,EAAkC,0DAClCC,EAAgD,6EAEhDC,EAAwC,qCAExC,MAAMC,EAAa,CACjB,MAAO,GAAG,GAAG,EACb,KAAM,GAAG,GAAG,EACZ,KAAM,GAAG,GAAG,EACZ,MAAO,GAAG,GAAG,EACb,YAAa,CAAC,CAChB,EAEA,SAAS,0BAA2B,IAAM,CACxC,MAAMC,KAAU,mCAAgC,EAE1CC,EAAY,CAChB,OAAQ,CACN,KAAM,UACN,QAAS,IACT,kBAAmB,4CACrB,EACA,YAAa,eACb,QAAS,CACP,QAAS,CACP,MAAO,6CACP,OAAQ,uBACR,WAAY,aACZ,MAAO,GACT,EACA,QAAS,6CACT,YAAa,YACf,EACA,MAAO,CACL,aAAc,CACZ,CACE,KAAM,UACN,KAAM,eACR,EACA,CACE,KAAM,UACN,KAAM,SACR,EACA,CACE,KAAM,cACN,KAAM,SACR,CACF,EACA,cAAe,CACb,CAAE,KAAM,QAAS,KAAM,SAAU,EACjC,CAAE,KAAM,SAAU,KAAM,MAAO,EAC/B,CAAE,KAAM,aAAc,KAAM,MAAO,EACnC,CAAE,KAAM,QAAS,KAAM,MAAO,CAChC,CACF,CACF,EAEA,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,GAAG,4BAA6B,SAAY,CAE1C,MAAMC,EAAO,IAAI,0BACfF,EACAC,EACA,iBACAF,CACF,EACAC,EAAQ,YAAY,qBAClB,wBAAqB,CACnB,KAAM,CACJ,EAAG,OACH,EAAG,OACH,EAAG,CACL,CACF,CAAC,CACH,EAEA,MAAMG,EAAY,MAAMD,EAAK,IAAI,EAEjC,OAAOF,EAAQ,WAAW,EAAE,qBAC1B,IAAI,oBAAkB,CACpB,eAAgB,iBAChB,cAAY,QAAK,CACf,WACE,qEACF,YACE,oEACJ,CAAC,CACH,CAAC,CACH,EACA,OAAOG,CAAS,EAAE,iBAChB,wBAAqB,CACnB,KAAM,CACJ,EAAG,OACH,EAAG,OACH,EAAG,CACL,CACF,CAAC,CACH,CACF,CAAC,EAED,GAAG,wCAAyC,SAAY,CAEtD,MAAMD,EAAO,IAAI,0BACfF,EACA,CACE,GAAGC,EACH,YAAa,MACf,EACA,iBACAF,CACF,EACAC,EAAQ,YAAY,qBAClB,wBAAqB,CACnB,KAAM,CACJ,EAAG,OACH,EAAG,OACH,EAAG,CACL,CACF,CAAC,CACH,EAEA,GAAI,CACF,MAAME,EAAK,IAAI,CACjB,OAASE,EAAG,CAEV,OAAOA,CAAC,EAAE,eAAe,KAAK,EAE9B,OAAOA,EAAE,OAAO,EAAE,KAChB,kDACF,CACF,CACF,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_device_management_kit", "import_purify_ts", "import_SignEIP712Command", "import_makeInternalApi", "import_SignTypedDataLegacyTask", "mockLogger", "apiMock", "TEST_DATA", "task", "signature", "e"]
|
|
7
7
|
}
|
package/lib/cjs/internal/di.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var C=(o,e)=>{for(var n in e)a(o,n,{get:e[n],enumerable:!0})},D=(o,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of M(e))!f.call(o,r)&&r!==n&&a(o,r,{get:()=>e[r],enumerable:!(t=y(e,r))||t.enumerable});return o};var F=o=>D(a({},"__esModule",{value:!0}),o);var x={};C(x,{makeContainer:()=>v});module.exports=F(x);var s=require("inversify"),m=require("./address/di/addressModule"),d=require("./app-binder/di/appBinderModule"),p=require("./eip7702/di/eip7702Module"),i=require("./externalTypes"),c=require("./message/di/messageModule"),l=require("./safe/di/safeModule"),u=require("./transaction/di/transactionModule"),g=require("./typed-data/di/typedDataModule");const v=({dmk:o,sessionId:e,contextModule:n})=>{const t=new s.Container;return t.bind(i.externalTypes.Dmk).toConstantValue(o),t.bind(i.externalTypes.ContextModule).toConstantValue(n),t.bind(i.externalTypes.SessionId).toConstantValue(e),t.bind(i.externalTypes.DmkLoggerFactory).toConstantValue(r=>o.getLoggerFactory()(["SignerEth",r])),t.loadSync((0,m.addressModuleFactory)(),(0,d.appBindingModuleFactory)(),(0,p.eip7702ModuleFactory)(),(0,c.messageModuleFactory)(),(0,u.transactionModuleFactory)(),(0,g.typedDataModuleFactory)(),(0,l.safeModuleFactory)()),t};0&&(module.exports={makeContainer});
|
|
2
2
|
//# sourceMappingURL=di.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/internal/di.ts"],
|
|
4
|
-
"sourcesContent": ["import { type ContextModule } from \"@ledgerhq/context-module\";\nimport {\n type DeviceManagementKit,\n type DeviceSessionId,\n} from \"@ledgerhq/device-management-kit\";\nimport { Container } from \"inversify\";\n\nimport { addressModuleFactory } from \"@internal/address/di/addressModule\";\nimport { appBindingModuleFactory } from \"@internal/app-binder/di/appBinderModule\";\nimport { eip7702ModuleFactory } from \"@internal/eip7702/di/eip7702Module\";\nimport { externalTypes } from \"@internal/externalTypes\";\nimport { messageModuleFactory } from \"@internal/message/di/messageModule\";\nimport { safeModuleFactory } from \"@internal/safe/di/safeModule\";\nimport { transactionModuleFactory } from \"@internal/transaction/di/transactionModule\";\nimport { typedDataModuleFactory } from \"@internal/typed-data/di/typedDataModule\";\n\nexport type MakeContainerProps = {\n dmk: DeviceManagementKit;\n sessionId: DeviceSessionId;\n contextModule: ContextModule;\n};\n\nexport const makeContainer = ({\n dmk,\n sessionId,\n contextModule,\n}: MakeContainerProps) => {\n const container = new Container();\n\n container.bind<DeviceManagementKit>(externalTypes.Dmk).toConstantValue(dmk);\n container\n .bind<ContextModule>(externalTypes.ContextModule)\n .toConstantValue(contextModule);\n container\n .bind<DeviceSessionId>(externalTypes.SessionId)\n .toConstantValue(sessionId);\n\n container.loadSync(\n addressModuleFactory(),\n appBindingModuleFactory(),\n eip7702ModuleFactory(),\n messageModuleFactory(),\n transactionModuleFactory(),\n typedDataModuleFactory(),\n safeModuleFactory(),\n );\n\n return container;\n};\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,
|
|
6
|
-
"names": ["di_exports", "__export", "makeContainer", "__toCommonJS", "import_inversify", "import_addressModule", "import_appBinderModule", "import_eip7702Module", "import_externalTypes", "import_messageModule", "import_safeModule", "import_transactionModule", "import_typedDataModule", "dmk", "sessionId", "contextModule", "container"]
|
|
4
|
+
"sourcesContent": ["import { type ContextModule } from \"@ledgerhq/context-module\";\nimport {\n type DeviceManagementKit,\n type DeviceSessionId,\n type LoggerPublisherService,\n} from \"@ledgerhq/device-management-kit\";\nimport { Container } from \"inversify\";\n\nimport { addressModuleFactory } from \"@internal/address/di/addressModule\";\nimport { appBindingModuleFactory } from \"@internal/app-binder/di/appBinderModule\";\nimport { eip7702ModuleFactory } from \"@internal/eip7702/di/eip7702Module\";\nimport { externalTypes } from \"@internal/externalTypes\";\nimport { messageModuleFactory } from \"@internal/message/di/messageModule\";\nimport { safeModuleFactory } from \"@internal/safe/di/safeModule\";\nimport { transactionModuleFactory } from \"@internal/transaction/di/transactionModule\";\nimport { typedDataModuleFactory } from \"@internal/typed-data/di/typedDataModule\";\n\nexport type MakeContainerProps = {\n dmk: DeviceManagementKit;\n sessionId: DeviceSessionId;\n contextModule: ContextModule;\n};\n\nexport const makeContainer = ({\n dmk,\n sessionId,\n contextModule,\n}: MakeContainerProps) => {\n const container = new Container();\n\n container.bind<DeviceManagementKit>(externalTypes.Dmk).toConstantValue(dmk);\n container\n .bind<ContextModule>(externalTypes.ContextModule)\n .toConstantValue(contextModule);\n container\n .bind<DeviceSessionId>(externalTypes.SessionId)\n .toConstantValue(sessionId);\n\n container\n .bind<\n (tag: string) => LoggerPublisherService\n >(externalTypes.DmkLoggerFactory)\n .toConstantValue((tag: string) =>\n dmk.getLoggerFactory()([\"SignerEth\", tag]),\n );\n\n container.loadSync(\n addressModuleFactory(),\n appBindingModuleFactory(),\n eip7702ModuleFactory(),\n messageModuleFactory(),\n transactionModuleFactory(),\n typedDataModuleFactory(),\n safeModuleFactory(),\n );\n\n return container;\n};\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAMA,IAAAI,EAA0B,qBAE1BC,EAAqC,8CACrCC,EAAwC,mDACxCC,EAAqC,8CACrCC,EAA8B,mCAC9BC,EAAqC,8CACrCC,EAAkC,wCAClCC,EAAyC,sDACzCC,EAAuC,mDAQhC,MAAMV,EAAgB,CAAC,CAC5B,IAAAW,EACA,UAAAC,EACA,cAAAC,CACF,IAA0B,CACxB,MAAMC,EAAY,IAAI,YAEtB,OAAAA,EAAU,KAA0B,gBAAc,GAAG,EAAE,gBAAgBH,CAAG,EAC1EG,EACG,KAAoB,gBAAc,aAAa,EAC/C,gBAAgBD,CAAa,EAChCC,EACG,KAAsB,gBAAc,SAAS,EAC7C,gBAAgBF,CAAS,EAE5BE,EACG,KAEC,gBAAc,gBAAgB,EAC/B,gBAAiBC,GAChBJ,EAAI,iBAAiB,EAAE,CAAC,YAAaI,CAAG,CAAC,CAC3C,EAEFD,EAAU,YACR,wBAAqB,KACrB,2BAAwB,KACxB,wBAAqB,KACrB,wBAAqB,KACrB,4BAAyB,KACzB,0BAAuB,KACvB,qBAAkB,CACpB,EAEOA,CACT",
|
|
6
|
+
"names": ["di_exports", "__export", "makeContainer", "__toCommonJS", "import_inversify", "import_addressModule", "import_appBinderModule", "import_eip7702Module", "import_externalTypes", "import_messageModule", "import_safeModule", "import_transactionModule", "import_typedDataModule", "dmk", "sessionId", "contextModule", "container", "tag"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var S=(e,o)=>{for(var t in o)m(e,t,{get:o[t],enumerable:!0})},b=(e,o,t,l)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of n(o))!s.call(e,r)&&r!==t&&m(e,r,{get:()=>o[r],enumerable:!(l=y(o,r))||l.enumerable});return e};var d=e=>b(m({},"__esModule",{value:!0}),e);var g={};S(g,{externalTypes:()=>f});module.exports=d(g);const f={Dmk:Symbol.for("Dmk"),SessionId:Symbol.for("SessionId"),ContextModule:Symbol.for("ContextModule"),DmkLoggerFactory:Symbol.for("DmkLoggerFactory")};0&&(module.exports={externalTypes});
|
|
2
2
|
//# sourceMappingURL=externalTypes.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/internal/externalTypes.ts"],
|
|
4
|
-
"sourcesContent": ["export const externalTypes = {\n Dmk: Symbol.for(\"Dmk\"),\n SessionId: Symbol.for(\"SessionId\"),\n ContextModule: Symbol.for(\"ContextModule\"),\n};\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAgB,CAC3B,IAAK,OAAO,IAAI,KAAK,EACrB,UAAW,OAAO,IAAI,WAAW,EACjC,cAAe,OAAO,IAAI,eAAe,
|
|
4
|
+
"sourcesContent": ["export const externalTypes = {\n Dmk: Symbol.for(\"Dmk\"),\n SessionId: Symbol.for(\"SessionId\"),\n ContextModule: Symbol.for(\"ContextModule\"),\n DmkLoggerFactory: Symbol.for(\"DmkLoggerFactory\"),\n};\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAgB,CAC3B,IAAK,OAAO,IAAI,KAAK,EACrB,UAAW,OAAO,IAAI,WAAW,EACjC,cAAe,OAAO,IAAI,eAAe,EACzC,iBAAkB,OAAO,IAAI,kBAAkB,CACjD",
|
|
6
6
|
"names": ["externalTypes_exports", "__export", "externalTypes", "__toCommonJS"]
|
|
7
7
|
}
|
package/lib/cjs/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"@ledgerhq/signer-utils": "
|
|
3
|
+
"@ledgerhq/signer-utils": "^1.1.2",
|
|
4
4
|
"ethers": "catalog:",
|
|
5
5
|
"inversify": "catalog:",
|
|
6
6
|
"purify-ts": "catalog:",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"watch:builds": "pnpm ldmk-tool watch --entryPoints src/index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
63
63
|
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
|
|
64
64
|
},
|
|
65
|
-
"version": "1.
|
|
65
|
+
"version": "1.10.0"
|
|
66
66
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ContextModuleBuilder as o}from"@ledgerhq/context-module";import{DefaultSignerEth as n}from"../internal/DefaultSignerEth";class u{_dmk;_sessionId;_customContextModule;_originToken;constructor({dmk:e,sessionId:t,originToken:i}){this._dmk=e,this._sessionId=t,this._originToken=i}withContextModule(e){return this._customContextModule=e,this}build(){const e=this._customContextModule??new o({originToken:this._originToken}).build();return new n({dmk:this._dmk,sessionId:this._sessionId,contextModule:e})}}export{u as SignerEthBuilder};
|
|
1
|
+
import{ContextModuleBuilder as o}from"@ledgerhq/context-module";import{DefaultSignerEth as n}from"../internal/DefaultSignerEth";class u{_dmk;_sessionId;_customContextModule;_originToken;constructor({dmk:e,sessionId:t,originToken:i}){this._dmk=e,this._sessionId=t,this._originToken=i}withContextModule(e){return this._customContextModule=e,this}build(){const e=this._customContextModule??new o({originToken:this._originToken,loggerFactory:t=>this._dmk.getLoggerFactory()(["ContextModule",t])}).build();return new n({dmk:this._dmk,sessionId:this._sessionId,contextModule:e})}}export{u as SignerEthBuilder};
|
|
2
2
|
//# sourceMappingURL=SignerEthBuilder.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/api/SignerEthBuilder.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type ContextModule,\n ContextModuleBuilder,\n} from \"@ledgerhq/context-module\";\nimport {\n type DeviceManagementKit,\n type DeviceSessionId,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { DefaultSignerEth } from \"@internal/DefaultSignerEth\";\n\ntype SignerEthBuilderConstructorArgs = {\n dmk: DeviceManagementKit;\n sessionId: DeviceSessionId;\n originToken?: string;\n};\n\n/**\n * Builder for the `SignerEth` class.\n *\n * @example\n * ```\n * const dmk = new SignerEthBuilder(dmk)\n * .build();\n * ```\n */\nexport class SignerEthBuilder {\n private _dmk: DeviceManagementKit;\n private _sessionId: DeviceSessionId;\n private _customContextModule: ContextModule | undefined;\n private _originToken: string | undefined;\n\n constructor({\n dmk,\n sessionId,\n originToken,\n }: SignerEthBuilderConstructorArgs) {\n this._dmk = dmk;\n this._sessionId = sessionId;\n this._originToken = originToken;\n }\n\n /**\n * Override the default context module\n *\n * @param contextModule\n * @returns this\n */\n withContextModule(contextModule: ContextModule) {\n this._customContextModule = contextModule;\n return this;\n }\n\n /**\n * Build the ethereum signer\n *\n * @returns the ethereum signer\n */\n public build() {\n const contextModule =\n this._customContextModule ??\n new ContextModuleBuilder({
|
|
5
|
-
"mappings": "AAAA,OAEE,wBAAAA,MACK,2BAMP,OAAS,oBAAAC,MAAwB,6BAiB1B,MAAMC,CAAiB,CACpB,KACA,WACA,qBACA,aAER,YAAY,CACV,IAAAC,EACA,UAAAC,EACA,YAAAC,CACF,EAAoC,CAClC,KAAK,KAAOF,EACZ,KAAK,WAAaC,EAClB,KAAK,aAAeC,CACtB,CAQA,kBAAkBC,EAA8B,CAC9C,YAAK,qBAAuBA,EACrB,IACT,CAOO,OAAQ,CACb,MAAMA,EACJ,KAAK,sBACL,IAAIN,EAAqB,
|
|
6
|
-
"names": ["ContextModuleBuilder", "DefaultSignerEth", "SignerEthBuilder", "dmk", "sessionId", "originToken", "contextModule"]
|
|
4
|
+
"sourcesContent": ["import {\n type ContextModule,\n ContextModuleBuilder,\n} from \"@ledgerhq/context-module\";\nimport {\n type DeviceManagementKit,\n type DeviceSessionId,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { DefaultSignerEth } from \"@internal/DefaultSignerEth\";\n\ntype SignerEthBuilderConstructorArgs = {\n dmk: DeviceManagementKit;\n sessionId: DeviceSessionId;\n originToken?: string;\n};\n\n/**\n * Builder for the `SignerEth` class.\n *\n * @example\n * ```\n * const dmk = new SignerEthBuilder(dmk)\n * .build();\n * ```\n */\nexport class SignerEthBuilder {\n private _dmk: DeviceManagementKit;\n private _sessionId: DeviceSessionId;\n private _customContextModule: ContextModule | undefined;\n private _originToken: string | undefined;\n\n constructor({\n dmk,\n sessionId,\n originToken,\n }: SignerEthBuilderConstructorArgs) {\n this._dmk = dmk;\n this._sessionId = sessionId;\n this._originToken = originToken;\n }\n\n /**\n * Override the default context module\n *\n * @param contextModule\n * @returns this\n */\n withContextModule(contextModule: ContextModule) {\n this._customContextModule = contextModule;\n return this;\n }\n\n /**\n * Build the ethereum signer\n *\n * @returns the ethereum signer\n */\n public build() {\n const contextModule =\n this._customContextModule ??\n new ContextModuleBuilder({\n originToken: this._originToken,\n loggerFactory: (tag: string) =>\n this._dmk.getLoggerFactory()([\"ContextModule\", tag]),\n }).build();\n\n return new DefaultSignerEth({\n dmk: this._dmk,\n sessionId: this._sessionId,\n contextModule,\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAEE,wBAAAA,MACK,2BAMP,OAAS,oBAAAC,MAAwB,6BAiB1B,MAAMC,CAAiB,CACpB,KACA,WACA,qBACA,aAER,YAAY,CACV,IAAAC,EACA,UAAAC,EACA,YAAAC,CACF,EAAoC,CAClC,KAAK,KAAOF,EACZ,KAAK,WAAaC,EAClB,KAAK,aAAeC,CACtB,CAQA,kBAAkBC,EAA8B,CAC9C,YAAK,qBAAuBA,EACrB,IACT,CAOO,OAAQ,CACb,MAAMA,EACJ,KAAK,sBACL,IAAIN,EAAqB,CACvB,YAAa,KAAK,aAClB,cAAgBO,GACd,KAAK,KAAK,iBAAiB,EAAE,CAAC,gBAAiBA,CAAG,CAAC,CACvD,CAAC,EAAE,MAAM,EAEX,OAAO,IAAIN,EAAiB,CAC1B,IAAK,KAAK,KACV,UAAW,KAAK,WAChB,cAAAK,CACF,CAAC,CACH,CACF",
|
|
6
|
+
"names": ["ContextModuleBuilder", "DefaultSignerEth", "SignerEthBuilder", "dmk", "sessionId", "originToken", "contextModule", "tag"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{SignerEthBuilder as o}from"./SignerEthBuilder";import{DefaultSignerEth as
|
|
1
|
+
import{SignerEthBuilder as o}from"./SignerEthBuilder";import{DefaultSignerEth as r}from"../internal/DefaultSignerEth";import{externalTypes as s}from"../internal/externalTypes";const c={debug:vi.fn(),info:vi.fn(),warn:vi.fn(),error:vi.fn(),subscribers:[]};describe("SignerEthBuilder",()=>{const i={dmk:{getLoggerFactory:()=>()=>c},sessionId:"",originToken:"test"};test("should be an instance of SignerEth",()=>{const e=new o(i);e.build(),expect(e).toBeInstanceOf(o)}),test("should instanciate with default context module",()=>{const t=new o(i).build(),n=t._container.get(s.ContextModule);expect(t).toBeInstanceOf(r),expect(n).toBeDefined()}),test("should instanciate with custom context module",()=>{const e=new o(i),t={},n=e.withContextModule(t).build();expect(n).toBeInstanceOf(r),expect(n._container.get(s.ContextModule)).toBe(t)})});
|
|
2
2
|
//# sourceMappingURL=SignerEthBuilder.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/api/SignerEthBuilder.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { type ContextModule } from \"@ledgerhq/context-module\";\nimport { type DeviceManagementKit } from \"@ledgerhq/device-management-kit\";\n\nimport { SignerEthBuilder } from \"@api/SignerEthBuilder\";\nimport { DefaultSignerEth } from \"@internal/DefaultSignerEth\";\nimport { externalTypes } from \"@internal/externalTypes\";\n\ndescribe(\"SignerEthBuilder\", () => {\n const dmk: DeviceManagementKit = {} as DeviceManagementKit;\n const defaultConstructorArgs = { dmk, sessionId: \"\", originToken: \"test\" };\n\n test(\"should be an instance of SignerEth\", () => {\n // GIVEN\n const builder = new SignerEthBuilder(defaultConstructorArgs);\n\n // WHEN\n builder.build();\n\n // THEN\n expect(builder).toBeInstanceOf(SignerEthBuilder);\n });\n\n test(\"should instanciate with default context module\", () => {\n // GIVEN\n const builder = new SignerEthBuilder(defaultConstructorArgs);\n\n // WHEN\n const signer = builder.build();\n const contextModule = signer[\"_container\"].get<ContextModule>(\n externalTypes.ContextModule,\n );\n\n // THEN\n expect(signer).toBeInstanceOf(DefaultSignerEth);\n expect(contextModule).toBeDefined();\n });\n\n test(\"should instanciate with custom context module\", () => {\n // GIVEN\n const builder = new SignerEthBuilder(defaultConstructorArgs);\n const contextModule = {} as ContextModule;\n\n // WHEN\n const signer = builder.withContextModule(contextModule).build();\n\n // THEN\n expect(signer).toBeInstanceOf(DefaultSignerEth);\n expect(\n signer[\"_container\"].get<ContextModule>(externalTypes.ContextModule),\n ).toBe(contextModule);\n });\n});\n"],
|
|
5
|
-
"mappings": "AAGA,OAAS,oBAAAA,MAAwB,wBACjC,OAAS,oBAAAC,MAAwB,6BACjC,OAAS,iBAAAC,MAAqB,0BAE9B,SAAS,mBAAoB,IAAM,
|
|
6
|
-
"names": ["SignerEthBuilder", "DefaultSignerEth", "externalTypes", "defaultConstructorArgs", "builder", "signer", "contextModule"]
|
|
4
|
+
"sourcesContent": ["import { type ContextModule } from \"@ledgerhq/context-module\";\nimport { type DeviceManagementKit } from \"@ledgerhq/device-management-kit\";\n\nimport { SignerEthBuilder } from \"@api/SignerEthBuilder\";\nimport { DefaultSignerEth } from \"@internal/DefaultSignerEth\";\nimport { externalTypes } from \"@internal/externalTypes\";\n\nconst mockLogger = {\n debug: vi.fn(),\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n subscribers: [],\n};\n\ndescribe(\"SignerEthBuilder\", () => {\n const dmk: DeviceManagementKit = {\n getLoggerFactory: () => () => mockLogger,\n } as unknown as DeviceManagementKit;\n const defaultConstructorArgs = { dmk, sessionId: \"\", originToken: \"test\" };\n\n test(\"should be an instance of SignerEth\", () => {\n // GIVEN\n const builder = new SignerEthBuilder(defaultConstructorArgs);\n\n // WHEN\n builder.build();\n\n // THEN\n expect(builder).toBeInstanceOf(SignerEthBuilder);\n });\n\n test(\"should instanciate with default context module\", () => {\n // GIVEN\n const builder = new SignerEthBuilder(defaultConstructorArgs);\n\n // WHEN\n const signer = builder.build();\n const contextModule = signer[\"_container\"].get<ContextModule>(\n externalTypes.ContextModule,\n );\n\n // THEN\n expect(signer).toBeInstanceOf(DefaultSignerEth);\n expect(contextModule).toBeDefined();\n });\n\n test(\"should instanciate with custom context module\", () => {\n // GIVEN\n const builder = new SignerEthBuilder(defaultConstructorArgs);\n const contextModule = {} as ContextModule;\n\n // WHEN\n const signer = builder.withContextModule(contextModule).build();\n\n // THEN\n expect(signer).toBeInstanceOf(DefaultSignerEth);\n expect(\n signer[\"_container\"].get<ContextModule>(externalTypes.ContextModule),\n ).toBe(contextModule);\n });\n});\n"],
|
|
5
|
+
"mappings": "AAGA,OAAS,oBAAAA,MAAwB,wBACjC,OAAS,oBAAAC,MAAwB,6BACjC,OAAS,iBAAAC,MAAqB,0BAE9B,MAAMC,EAAa,CACjB,MAAO,GAAG,GAAG,EACb,KAAM,GAAG,GAAG,EACZ,KAAM,GAAG,GAAG,EACZ,MAAO,GAAG,GAAG,EACb,YAAa,CAAC,CAChB,EAEA,SAAS,mBAAoB,IAAM,CAIjC,MAAMC,EAAyB,CAAE,IAHA,CAC/B,iBAAkB,IAAM,IAAMD,CAChC,EACsC,UAAW,GAAI,YAAa,MAAO,EAEzE,KAAK,qCAAsC,IAAM,CAE/C,MAAME,EAAU,IAAIL,EAAiBI,CAAsB,EAG3DC,EAAQ,MAAM,EAGd,OAAOA,CAAO,EAAE,eAAeL,CAAgB,CACjD,CAAC,EAED,KAAK,iDAAkD,IAAM,CAK3D,MAAMM,EAHU,IAAIN,EAAiBI,CAAsB,EAGpC,MAAM,EACvBG,EAAgBD,EAAO,WAAc,IACzCJ,EAAc,aAChB,EAGA,OAAOI,CAAM,EAAE,eAAeL,CAAgB,EAC9C,OAAOM,CAAa,EAAE,YAAY,CACpC,CAAC,EAED,KAAK,gDAAiD,IAAM,CAE1D,MAAMF,EAAU,IAAIL,EAAiBI,CAAsB,EACrDG,EAAgB,CAAC,EAGjBD,EAASD,EAAQ,kBAAkBE,CAAa,EAAE,MAAM,EAG9D,OAAOD,CAAM,EAAE,eAAeL,CAAgB,EAC9C,OACEK,EAAO,WAAc,IAAmBJ,EAAc,aAAa,CACrE,EAAE,KAAKK,CAAa,CACtB,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["SignerEthBuilder", "DefaultSignerEth", "externalTypes", "mockLogger", "defaultConstructorArgs", "builder", "signer", "contextModule"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var y=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var g=(s,e,i,t)=>{for(var r=t>1?void 0:t?v(e,i):e,a=s.length-1,p;a>=0;a--)(p=s[a])&&(r=(t?p(e,i,r):p(r))||r);return t&&r&&y(e,i,r),r},n=(s,e)=>(i,t)=>e(i,t,s);import{CallTaskInAppDeviceAction as A,SendCommandInAppDeviceAction as h}from"@ledgerhq/device-management-kit";import{UserInteractionRequired as c}from"@ledgerhq/device-management-kit";import{inject as o,injectable as D}from"inversify";import{SignTypedDataDeviceAction as l}from"../app-binder/device-action/SignTypedData/SignTypedDataDeviceAction";import{SendSignPersonalMessageTask as k}from"../app-binder/task/SendSignPersonalMessageTask";import{externalTypes as d}from"../externalTypes";import{transactionTypes as u}from"../transaction/di/transactionTypes";import{GetAddressCommand as S}from"./command/GetAddressCommand";import{SignTransactionDeviceAction as T}from"./device-action/SignTransaction/SignTransactionDeviceAction";import{VerifySafeAddressDeviceAction as f}from"./device-action/VerifySafeAddress/VerifySafeAddress";import{SendSignAuthorizationDelegationTask as I}from"./task/SendSignAuthorizationDelegationTask";let m=class{constructor(e,i,t,r,a,p){this.dmk=e;this.contextModule=i;this.mapper=t;this.parser=r;this.sessionId=a;this.dmkLoggerFactory=p}getAddress(e){return this.dmk.executeDeviceAction({sessionId:this.sessionId,deviceAction:new h({input:{command:new S(e),appName:"Ethereum",requiredUserInteraction:e.checkOnDevice?c.VerifyAddress:c.None,skipOpenApp:e.skipOpenApp},logger:this.dmkLoggerFactory("SendCommandInAppDeviceAction")})})}verifySafeAddress(e){return this.dmk.executeDeviceAction({sessionId:this.sessionId,deviceAction:new f({input:{safeContractAddress:e.safeContractAddress,contextModule:this.contextModule,options:e.options??{chainId:1}},loggerFactory:this.dmkLoggerFactory})})}signPersonalMessage(e){const i=this.dmkLoggerFactory("SendSignPersonalMessageTask");return this.dmk.executeDeviceAction({sessionId:this.sessionId,deviceAction:new A({input:{task:async t=>new k(t,{...e,logger:i}).run(),appName:"Ethereum",requiredUserInteraction:c.SignPersonalMessage,skipOpenApp:e.skipOpenApp},logger:this.dmkLoggerFactory("CallTaskInAppDeviceAction")})})}signTransaction(e){return this.dmk.executeDeviceAction({sessionId:this.sessionId,deviceAction:new T({input:{derivationPath:e.derivationPath,transaction:e.transaction,mapper:this.mapper,parser:this.parser,contextModule:this.contextModule,options:e.options??{}},loggerFactory:this.dmkLoggerFactory})})}signTypedData(e){return this.dmk.executeDeviceAction({sessionId:this.sessionId,deviceAction:new l({input:{derivationPath:e.derivationPath,data:e.data,parser:e.parser,transactionMapper:this.mapper,transactionParser:this.parser,contextModule:this.contextModule,skipOpenApp:e.skipOpenApp},loggerFactory:this.dmkLoggerFactory})})}signDelegationAuthorization(e){const i=this.dmkLoggerFactory("SendSignAuthorizationDelegationTask");return this.dmk.executeDeviceAction({sessionId:this.sessionId,deviceAction:new A({input:{task:async t=>new I(t,{...e,logger:i}).run(),appName:"Ethereum",requiredUserInteraction:c.SignDelegationAuthorization,skipOpenApp:!1},logger:this.dmkLoggerFactory("CallTaskInAppDeviceAction")})})}};m=g([D(),n(0,o(d.Dmk)),n(1,o(d.ContextModule)),n(2,o(u.TransactionMapperService)),n(3,o(u.TransactionParserService)),n(4,o(d.SessionId)),n(5,o(d.DmkLoggerFactory))],m);export{m as EthAppBinder};
|
|
2
2
|
//# sourceMappingURL=EthAppBinder.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/internal/app-binder/EthAppBinder.ts"],
|
|
4
|
-
"sourcesContent": ["import { type ContextModule } from \"@ledgerhq/context-module\";\nimport {\n DeviceManagementKit,\n type DeviceSessionId,\n} from \"@ledgerhq/device-management-kit\";\nimport {\n CallTaskInAppDeviceAction,\n SendCommandInAppDeviceAction,\n} from \"@ledgerhq/device-management-kit\";\nimport { UserInteractionRequired } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { type GetAddressDAReturnType } from \"@api/app-binder/GetAddressDeviceActionTypes\";\nimport { SignDelegationAuthorizationDAReturnType } from \"@api/app-binder/SignDelegationAuthorizationTypes\";\nimport { type SignPersonalMessageDAReturnType } from \"@api/app-binder/SignPersonalMessageDeviceActionTypes\";\nimport { type SignTransactionDAReturnType } from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nimport { type SignTypedDataDAReturnType } from \"@api/app-binder/SignTypedDataDeviceActionTypes\";\nimport { VerifySafeAddressDAReturnType } from \"@api/app-binder/VerifySafeAddressDeviceActionTypes\";\nimport { SafeAddressOptions } from \"@api/model/SafeAddressOptions\";\nimport { type TransactionOptions } from \"@api/model/TransactionOptions\";\nimport { type TypedData } from \"@api/model/TypedData\";\nimport { SignTypedDataDeviceAction } from \"@internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction\";\nimport { SendSignPersonalMessageTask } from \"@internal/app-binder/task/SendSignPersonalMessageTask\";\nimport { externalTypes } from \"@internal/externalTypes\";\nimport { transactionTypes } from \"@internal/transaction/di/transactionTypes\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\nimport { TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\nimport { type TypedDataParserService } from \"@internal/typed-data/service/TypedDataParserService\";\n\nimport { GetAddressCommand } from \"./command/GetAddressCommand\";\nimport { SignTransactionDeviceAction } from \"./device-action/SignTransaction/SignTransactionDeviceAction\";\nimport { VerifySafeAddressDeviceAction } from \"./device-action/VerifySafeAddress/VerifySafeAddress\";\nimport { SendSignAuthorizationDelegationTask } from \"./task/SendSignAuthorizationDelegationTask\";\n\n@injectable()\nexport class EthAppBinder {\n constructor(\n @inject(externalTypes.Dmk) private dmk: DeviceManagementKit,\n @inject(externalTypes.ContextModule) private contextModule: ContextModule,\n @inject(transactionTypes.TransactionMapperService)\n private mapper: TransactionMapperService,\n @inject(transactionTypes.TransactionParserService)\n private parser: TransactionParserService,\n @inject(externalTypes.SessionId) private sessionId: DeviceSessionId,\n ) {}\n\n getAddress(args: {\n derivationPath: string;\n checkOnDevice: boolean;\n returnChainCode: boolean;\n skipOpenApp: boolean;\n }): GetAddressDAReturnType {\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetAddressCommand(args),\n appName: \"Ethereum\",\n requiredUserInteraction: args.checkOnDevice\n ? UserInteractionRequired.VerifyAddress\n : UserInteractionRequired.None,\n skipOpenApp: args.skipOpenApp,\n },\n }),\n });\n }\n\n verifySafeAddress(args: {\n safeContractAddress: string;\n options?: SafeAddressOptions;\n }): VerifySafeAddressDAReturnType {\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new VerifySafeAddressDeviceAction({\n input: {\n safeContractAddress: args.safeContractAddress,\n contextModule: this.contextModule,\n options: args.options ?? { chainId: 1 },\n },\n }),\n });\n }\n\n signPersonalMessage(args: {\n derivationPath: string;\n message: string | Uint8Array;\n skipOpenApp: boolean;\n }): SignPersonalMessageDAReturnType {\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n new SendSignPersonalMessageTask(internalApi, args).run(),\n appName: \"Ethereum\",\n requiredUserInteraction: UserInteractionRequired.SignPersonalMessage,\n skipOpenApp: args.skipOpenApp,\n },\n }),\n });\n }\n\n signTransaction(args: {\n derivationPath: string;\n transaction: Uint8Array;\n options?: TransactionOptions;\n }): SignTransactionDAReturnType {\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new SignTransactionDeviceAction({\n input: {\n derivationPath: args.derivationPath,\n transaction: args.transaction,\n mapper: this.mapper,\n parser: this.parser,\n contextModule: this.contextModule,\n options: args.options ?? {},\n },\n }),\n });\n }\n\n signTypedData(args: {\n derivationPath: string;\n parser: TypedDataParserService;\n data: TypedData;\n skipOpenApp: boolean;\n }): SignTypedDataDAReturnType {\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new SignTypedDataDeviceAction({\n input: {\n derivationPath: args.derivationPath,\n data: args.data,\n parser: args.parser,\n transactionMapper: this.mapper,\n transactionParser: this.parser,\n contextModule: this.contextModule,\n skipOpenApp: args.skipOpenApp,\n },\n }),\n });\n }\n\n signDelegationAuthorization(args: {\n derivationPath: string;\n chainId: number;\n address: string;\n nonce: number;\n }): SignDelegationAuthorizationDAReturnType {\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n new SendSignAuthorizationDelegationTask(internalApi, args).run(),\n appName: \"Ethereum\",\n requiredUserInteraction:\n UserInteractionRequired.SignDelegationAuthorization,\n skipOpenApp: false,\n },\n }),\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["CallTaskInAppDeviceAction", "SendCommandInAppDeviceAction", "UserInteractionRequired", "inject", "injectable", "SignTypedDataDeviceAction", "SendSignPersonalMessageTask", "externalTypes", "transactionTypes", "GetAddressCommand", "SignTransactionDeviceAction", "VerifySafeAddressDeviceAction", "SendSignAuthorizationDelegationTask", "EthAppBinder", "dmk", "contextModule", "mapper", "parser", "sessionId", "args", "SendCommandInAppDeviceAction", "GetAddressCommand", "UserInteractionRequired", "VerifySafeAddressDeviceAction", "CallTaskInAppDeviceAction", "internalApi", "SendSignPersonalMessageTask", "SignTransactionDeviceAction", "SignTypedDataDeviceAction", "SendSignAuthorizationDelegationTask", "__decorateClass", "injectable", "__decorateParam", "inject", "externalTypes", "transactionTypes"]
|
|
4
|
+
"sourcesContent": ["import { type ContextModule } from \"@ledgerhq/context-module\";\nimport {\n DeviceManagementKit,\n type DeviceSessionId,\n type LoggerPublisherService,\n} from \"@ledgerhq/device-management-kit\";\nimport {\n CallTaskInAppDeviceAction,\n SendCommandInAppDeviceAction,\n} from \"@ledgerhq/device-management-kit\";\nimport { UserInteractionRequired } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { type GetAddressDAReturnType } from \"@api/app-binder/GetAddressDeviceActionTypes\";\nimport { SignDelegationAuthorizationDAReturnType } from \"@api/app-binder/SignDelegationAuthorizationTypes\";\nimport { type SignPersonalMessageDAReturnType } from \"@api/app-binder/SignPersonalMessageDeviceActionTypes\";\nimport { type SignTransactionDAReturnType } from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nimport { type SignTypedDataDAReturnType } from \"@api/app-binder/SignTypedDataDeviceActionTypes\";\nimport { VerifySafeAddressDAReturnType } from \"@api/app-binder/VerifySafeAddressDeviceActionTypes\";\nimport { SafeAddressOptions } from \"@api/model/SafeAddressOptions\";\nimport { type TransactionOptions } from \"@api/model/TransactionOptions\";\nimport { type TypedData } from \"@api/model/TypedData\";\nimport { SignTypedDataDeviceAction } from \"@internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction\";\nimport { SendSignPersonalMessageTask } from \"@internal/app-binder/task/SendSignPersonalMessageTask\";\nimport { externalTypes } from \"@internal/externalTypes\";\nimport { transactionTypes } from \"@internal/transaction/di/transactionTypes\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\nimport { TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\nimport { type TypedDataParserService } from \"@internal/typed-data/service/TypedDataParserService\";\n\nimport { GetAddressCommand } from \"./command/GetAddressCommand\";\nimport { SignTransactionDeviceAction } from \"./device-action/SignTransaction/SignTransactionDeviceAction\";\nimport { VerifySafeAddressDeviceAction } from \"./device-action/VerifySafeAddress/VerifySafeAddress\";\nimport { SendSignAuthorizationDelegationTask } from \"./task/SendSignAuthorizationDelegationTask\";\n\n@injectable()\nexport class EthAppBinder {\n constructor(\n @inject(externalTypes.Dmk) private dmk: DeviceManagementKit,\n @inject(externalTypes.ContextModule) private contextModule: ContextModule,\n @inject(transactionTypes.TransactionMapperService)\n private mapper: TransactionMapperService,\n @inject(transactionTypes.TransactionParserService)\n private parser: TransactionParserService,\n @inject(externalTypes.SessionId) private sessionId: DeviceSessionId,\n @inject(externalTypes.DmkLoggerFactory)\n private dmkLoggerFactory: (tag: string) => LoggerPublisherService,\n ) {}\n\n getAddress(args: {\n derivationPath: string;\n checkOnDevice: boolean;\n returnChainCode: boolean;\n skipOpenApp: boolean;\n }): GetAddressDAReturnType {\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetAddressCommand(args),\n appName: \"Ethereum\",\n requiredUserInteraction: args.checkOnDevice\n ? UserInteractionRequired.VerifyAddress\n : UserInteractionRequired.None,\n skipOpenApp: args.skipOpenApp,\n },\n logger: this.dmkLoggerFactory(\"SendCommandInAppDeviceAction\"),\n }),\n });\n }\n\n verifySafeAddress(args: {\n safeContractAddress: string;\n options?: SafeAddressOptions;\n }): VerifySafeAddressDAReturnType {\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new VerifySafeAddressDeviceAction({\n input: {\n safeContractAddress: args.safeContractAddress,\n contextModule: this.contextModule,\n options: args.options ?? { chainId: 1 },\n },\n loggerFactory: this.dmkLoggerFactory,\n }),\n });\n }\n\n signPersonalMessage(args: {\n derivationPath: string;\n message: string | Uint8Array;\n skipOpenApp: boolean;\n }): SignPersonalMessageDAReturnType {\n const taskLogger = this.dmkLoggerFactory(\"SendSignPersonalMessageTask\");\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n new SendSignPersonalMessageTask(internalApi, {\n ...args,\n logger: taskLogger,\n }).run(),\n appName: \"Ethereum\",\n requiredUserInteraction: UserInteractionRequired.SignPersonalMessage,\n skipOpenApp: args.skipOpenApp,\n },\n logger: this.dmkLoggerFactory(\"CallTaskInAppDeviceAction\"),\n }),\n });\n }\n\n signTransaction(args: {\n derivationPath: string;\n transaction: Uint8Array;\n options?: TransactionOptions;\n }): SignTransactionDAReturnType {\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new SignTransactionDeviceAction({\n input: {\n derivationPath: args.derivationPath,\n transaction: args.transaction,\n mapper: this.mapper,\n parser: this.parser,\n contextModule: this.contextModule,\n options: args.options ?? {},\n },\n loggerFactory: this.dmkLoggerFactory,\n }),\n });\n }\n\n signTypedData(args: {\n derivationPath: string;\n parser: TypedDataParserService;\n data: TypedData;\n skipOpenApp: boolean;\n }): SignTypedDataDAReturnType {\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new SignTypedDataDeviceAction({\n input: {\n derivationPath: args.derivationPath,\n data: args.data,\n parser: args.parser,\n transactionMapper: this.mapper,\n transactionParser: this.parser,\n contextModule: this.contextModule,\n skipOpenApp: args.skipOpenApp,\n },\n loggerFactory: this.dmkLoggerFactory,\n }),\n });\n }\n\n signDelegationAuthorization(args: {\n derivationPath: string;\n chainId: number;\n address: string;\n nonce: number;\n }): SignDelegationAuthorizationDAReturnType {\n const taskLogger = this.dmkLoggerFactory(\n \"SendSignAuthorizationDelegationTask\",\n );\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n new SendSignAuthorizationDelegationTask(internalApi, {\n ...args,\n logger: taskLogger,\n }).run(),\n appName: \"Ethereum\",\n requiredUserInteraction:\n UserInteractionRequired.SignDelegationAuthorization,\n skipOpenApp: false,\n },\n logger: this.dmkLoggerFactory(\"CallTaskInAppDeviceAction\"),\n }),\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "iOAMA,OACE,6BAAAA,EACA,gCAAAC,MACK,kCACP,OAAS,2BAAAC,MAA+B,kCACxC,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YAWnC,OAAS,6BAAAC,MAAiC,6EAC1C,OAAS,+BAAAC,MAAmC,wDAC5C,OAAS,iBAAAC,MAAqB,0BAC9B,OAAS,oBAAAC,MAAwB,4CAKjC,OAAS,qBAAAC,MAAyB,8BAClC,OAAS,+BAAAC,MAAmC,8DAC5C,OAAS,iCAAAC,MAAqC,sDAC9C,OAAS,uCAAAC,MAA2C,6CAG7C,IAAMC,EAAN,KAAmB,CACxB,YACqCC,EACUC,EAErCC,EAEAC,EACiCC,EAEjCC,EACR,CAT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AAC,CAC5B,EACA,cAAe,KAAK,gBACtB,CAAC,CACH,CAAC,CACH,CAEA,cAAcA,EAKgB,CAC5B,OAAO,KAAK,IAAI,oBAAoB,CAClC,UAAW,KAAK,UAChB,aAAc,IAAIU,EAA0B,CAC1C,MAAO,CACL,eAAgBV,EAAK,eACrB,KAAMA,EAAK,KACX,OAAQA,EAAK,OACb,kBAAmB,KAAK,OACxB,kBAAmB,KAAK,OACxB,cAAe,KAAK,cACpB,YAAaA,EAAK,WACpB,EACA,cAAe,KAAK,gBACtB,CAAC,CACH,CAAC,CACH,CAEA,4BAA4BA,EAKgB,CAC1C,MAAMK,EAAa,KAAK,iBACtB,qCACF,EACA,OAAO,KAAK,IAAI,oBAAoB,CAClC,UAAW,KAAK,UAChB,aAAc,IAAIC,EAA0B,CAC1C,MAAO,CACL,KAAM,MAAOC,GACX,IAAII,EAAoCJ,EAAa,CACnD,GAAGP,EACH,OAAQK,CACV,CAAC,EAAE,IAAI,EACT,QAAS,WACT,wBACEF,EAAwB,4BAC1B,YAAa,EACf,EACA,OAAQ,KAAK,iBAAiB,2BAA2B,CAC3D,CAAC,CACH,CAAC,CACH,CACF,EAnJaV,EAANmB,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAc,GAAG,GACxBF,EAAA,EAAAC,EAAOC,EAAc,aAAa,GAClCF,EAAA,EAAAC,EAAOE,EAAiB,wBAAwB,GAEhDH,EAAA,EAAAC,EAAOE,EAAiB,wBAAwB,GAEhDH,EAAA,EAAAC,EAAOC,EAAc,SAAS,GAC9BF,EAAA,EAAAC,EAAOC,EAAc,gBAAgB,IAT7BvB",
|
|
6
|
+
"names": ["CallTaskInAppDeviceAction", "SendCommandInAppDeviceAction", "UserInteractionRequired", "inject", "injectable", "SignTypedDataDeviceAction", "SendSignPersonalMessageTask", "externalTypes", "transactionTypes", "GetAddressCommand", "SignTransactionDeviceAction", "VerifySafeAddressDeviceAction", "SendSignAuthorizationDelegationTask", "EthAppBinder", "dmk", "contextModule", "mapper", "parser", "sessionId", "dmkLoggerFactory", "args", "SendCommandInAppDeviceAction", "GetAddressCommand", "UserInteractionRequired", "VerifySafeAddressDeviceAction", "taskLogger", "CallTaskInAppDeviceAction", "internalApi", "SendSignPersonalMessageTask", "SignTransactionDeviceAction", "SignTypedDataDeviceAction", "SendSignAuthorizationDelegationTask", "__decorateClass", "injectable", "__decorateParam", "inject", "externalTypes", "transactionTypes"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{hexaStringToBuffer as
|
|
1
|
+
import{hexaStringToBuffer as S}from"@ledgerhq/device-management-kit";import{DeviceActionStatus as c}from"@ledgerhq/device-management-kit";import{UserInteractionRequired as h}from"@ledgerhq/device-management-kit";import{Transaction as y}from"ethers";import{from as g}from"rxjs";import{GetAddressCommand as f}from"./command/GetAddressCommand";import{EthAppBinder as A}from"./EthAppBinder";const m=()=>({debug:vi.fn(),info:vi.fn(),warn:vi.fn(),error:vi.fn(),subscribers:[]});describe("EthAppBinder",()=>{const r={sendCommand:vi.fn(),executeDeviceAction:vi.fn()},d={getFieldContext:vi.fn(),getContexts:vi.fn(),getTypedDataFilters:vi.fn()},l={mapTransactionToSubset:vi.fn()},D={extractValue:vi.fn()};beforeEach(()=>{vi.clearAllMocks()}),describe("getAddress",()=>{it("should return the address, publicKey, and chainCode",()=>new Promise((i,a)=>{const e="0xF7C69BedB292Dd3fC2cA4103989B5BD705164c43",s="04e3785ca";vi.spyOn(r,"executeDeviceAction").mockReturnValue({observable:g([{status:c.Completed,output:{address:e,publicKey:s,chainCode:void 0}}]),cancel:vi.fn()});const u=new A(r,d,l,D,"sessionId",m),{observable:o}=u.getAddress({derivationPath:"44'/60'/3'/2/1",checkOnDevice:!1,returnChainCode:!1,skipOpenApp:!1}),t=[];o.subscribe({next:n=>{t.push(n)},error:n=>{a(n)},complete:()=>{try{expect(t).toEqual([{status:c.Completed,output:{address:e,publicKey:s,chainCode:void 0}}]),i()}catch(n){a(n)}}})})),describe("calls of executeDeviceAction with the correct params",()=>{const i={derivationPath:"44'/60'/3'/2/1",checkOnDevice:!1,returnChainCode:!1,skipOpenApp:!1};test("when checkOnDevice is true: UserInteractionRequired.VerifyAddress",()=>{const e={...i,checkOnDevice:!0};new A(r,d,l,D,"sessionId",m).getAddress(e),expect(r.executeDeviceAction).toHaveBeenCalledWith(expect.objectContaining({sessionId:"sessionId",deviceAction:expect.objectContaining({input:{command:new f(e),appName:"Ethereum",requiredUserInteraction:h.VerifyAddress,skipOpenApp:!1}})}))}),test("when checkOnDevice is false: UserInteractionRequired.None",()=>{const e={...i,checkOnDevice:!1};new A(r,d,l,D,"sessionId",m).getAddress(e),expect(r.executeDeviceAction).toHaveBeenCalledWith(expect.objectContaining({sessionId:"sessionId",deviceAction:expect.objectContaining({input:{command:new f(e),appName:"Ethereum",requiredUserInteraction:h.None,skipOpenApp:!1}})}))})})}),describe("signTransaction",()=>{it("should return the signature",()=>new Promise((i,a)=>{const e={r:"0xDEAD",s:"0xBEEF",v:0},s=S(y.from({to:"0x1234567890123456789012345678901234567890",value:0n}).unsignedSerialized),p={};vi.spyOn(r,"executeDeviceAction").mockReturnValue({observable:g([{status:c.Completed,output:e}]),cancel:vi.fn()});const u=new A(r,d,l,D,"sessionId",m),{observable:o}=u.signTransaction({derivationPath:"44'/60'/3'/2/1",transaction:s,options:p}),t=[];o.subscribe({next:n=>{t.push(n)},error:n=>{a(n)},complete:()=>{try{expect(t).toEqual([{status:c.Completed,output:e}]),i()}catch(n){a(n)}}})})),it("should return the signature without options",()=>new Promise((i,a)=>{const e={r:"0xDEAD",s:"0xBEEF",v:0},s=S(y.from({to:"0x1234567890123456789012345678901234567890",value:0n}).unsignedSerialized);vi.spyOn(r,"executeDeviceAction").mockReturnValue({observable:g([{status:c.Completed,output:e}]),cancel:vi.fn()});const p=new A(r,d,l,D,"sessionId",m),{observable:u}=p.signTransaction({derivationPath:"44'/60'/3'/2/1",transaction:s,options:void 0}),o=[];u.subscribe({next:t=>{o.push(t)},error:t=>{a(t)},complete:()=>{try{expect(o).toEqual([{status:c.Completed,output:e}]),i()}catch(t){a(t)}}})}))}),describe("signMessage",()=>{it("should return the signature",()=>new Promise((i,a)=>{const e={r:"0xDEAD",s:"0xBEEF",v:0},s="Hello, World!";vi.spyOn(r,"executeDeviceAction").mockReturnValue({observable:g([{status:c.Completed,output:e}]),cancel:vi.fn()});const p=new A(r,d,l,D,"sessionId",m),{observable:u}=p.signPersonalMessage({derivationPath:"44'/60'/3'/2/1",message:s,skipOpenApp:!1}),o=[];u.subscribe({next:t=>{o.push(t)},error:t=>{a(t)},complete:()=>{try{expect(o).toEqual([{status:c.Completed,output:e}]),i()}catch(t){a(t)}}})}))}),describe("signDelegationAuthorization",()=>{it("should return the signature",()=>new Promise((i,a)=>{const e={r:"0xDEAD",s:"0xBEEF",v:0},s=2,p=42,u="0xaddress";vi.spyOn(r,"executeDeviceAction").mockReturnValue({observable:g([{status:c.Completed,output:e}]),cancel:vi.fn()});const o=new A(r,d,l,D,"sessionId",m),{observable:t}=o.signDelegationAuthorization({derivationPath:"44'/60'/3'/2/1",chainId:s,address:u,nonce:p}),n=[];t.subscribe({next:v=>{n.push(v)},error:v=>{a(v)},complete:()=>{try{expect(n).toEqual([{status:c.Completed,output:e}]),i()}catch(v){a(v)}}})}))}),describe("signTypedData",()=>{it("should return the signature",()=>new Promise((i,a)=>{const e={r:"0xDEAD",s:"0xBEEF",v:0},s={domain:{},types:{},primaryType:"test",message:{}},p={parse:vi.fn()};vi.spyOn(r,"executeDeviceAction").mockReturnValue({observable:g([{status:c.Completed,output:e}]),cancel:vi.fn()});const u=new A(r,d,l,D,"sessionId",m),{observable:o}=u.signTypedData({derivationPath:"44'/60'/3'/2/1",parser:p,data:s,skipOpenApp:!1}),t=[];o.subscribe({next:n=>{t.push(n)},error:n=>{a(n)},complete:()=>{try{expect(t).toEqual([{status:c.Completed,output:e}]),i()}catch(n){a(n)}}})}))})});
|
|
2
2
|
//# sourceMappingURL=EthAppBinder.test.js.map
|