@ledgerhq/device-signer-kit-ethereum 0.0.0-rn-ble-pairing-removed-while-reconnecting-20250731133348 → 0.0.0-rn-ble-pairing-removed-while-reconnecting-20250807094338
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/app-binder/SignTransactionDeviceActionTypes.js +1 -1
- package/lib/cjs/api/app-binder/SignTransactionDeviceActionTypes.js.map +2 -2
- 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/task/BuildSubContextTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildSubContextTask.js.map +2 -2
- package/lib/cjs/internal/app-binder/task/BuildSubContextTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildSubContextTask.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/PreBuildContextTask.js +2 -0
- package/lib/cjs/internal/app-binder/task/PreBuildContextTask.js.map +7 -0
- package/lib/cjs/internal/transaction/service/mapper/EthersTransactionMapperService.js +1 -1
- package/lib/cjs/internal/transaction/service/mapper/EthersTransactionMapperService.js.map +3 -3
- package/lib/cjs/internal/transaction/service/mapper/EthersTransactionMapperService.test.js +1 -1
- package/lib/cjs/internal/transaction/service/mapper/EthersTransactionMapperService.test.js.map +2 -2
- package/lib/cjs/internal/transaction/service/parser/TransactionParserService.js +1 -1
- package/lib/cjs/internal/transaction/service/parser/TransactionParserService.js.map +3 -3
- package/lib/cjs/internal/transaction/service/parser/TransactionParserService.test.js +1 -1
- package/lib/cjs/internal/transaction/service/parser/TransactionParserService.test.js.map +3 -3
- package/lib/esm/api/app-binder/SignTransactionDeviceActionTypes.js +1 -1
- package/lib/esm/api/app-binder/SignTransactionDeviceActionTypes.js.map +2 -2
- 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/task/BuildSubContextTask.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildSubContextTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/BuildSubContextTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildSubContextTask.test.js.map +2 -2
- package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.js +1 -1
- package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/PreBuildContextTask.js +2 -0
- package/lib/esm/internal/app-binder/task/PreBuildContextTask.js.map +7 -0
- package/lib/esm/internal/transaction/service/mapper/EthersTransactionMapperService.js +1 -1
- package/lib/esm/internal/transaction/service/mapper/EthersTransactionMapperService.js.map +3 -3
- package/lib/esm/internal/transaction/service/mapper/EthersTransactionMapperService.test.js +1 -1
- package/lib/esm/internal/transaction/service/mapper/EthersTransactionMapperService.test.js.map +2 -2
- package/lib/esm/internal/transaction/service/parser/TransactionParserService.js +1 -1
- package/lib/esm/internal/transaction/service/parser/TransactionParserService.js.map +3 -3
- package/lib/esm/internal/transaction/service/parser/TransactionParserService.test.js +1 -1
- package/lib/esm/internal/transaction/service/parser/TransactionParserService.test.js.map +3 -3
- package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts +3 -3
- package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts +9 -20
- package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/BuildSubContextTask.d.ts +2 -3
- package/lib/types/internal/app-binder/task/BuildSubContextTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/BuildTransactionContextTask.d.ts +3 -8
- package/lib/types/internal/app-binder/task/BuildTransactionContextTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/GetWeb3CheckTask.d.ts +2 -3
- package/lib/types/internal/app-binder/task/GetWeb3CheckTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/PreBuildContextTask.d.ts +17 -0
- package/lib/types/internal/app-binder/task/PreBuildContextTask.d.ts.map +1 -0
- package/lib/types/internal/transaction/service/mapper/EthersTransactionMapperService.d.ts.map +1 -1
- package/lib/types/internal/transaction/service/parser/TransactionParserService.d.ts +2 -2
- package/lib/types/internal/transaction/service/parser/TransactionParserService.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +6 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/transaction/service/parser/TransactionParserService.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { ContainerPath, type DataPathElement } from \"@ledgerhq/context-module\";\nimport {\n bufferToHexaString,\n ByteArrayBuilder,\n hexaStringToBuffer,\n} from \"@ledgerhq/device-management-kit\";\nimport { Transaction } from \"ethers\";\n\nimport { TransactionParserService } from \"./TransactionParserService\";\n\ndescribe(\"TransactionParserService\", () => {\n const parser = new TransactionParserService();\n\n const TO = hexaStringToBuffer(\"0x3f32cF0B1DF94157EE1c3876c49BE3732C92a98f\")!;\n const VALUE = 81818275935222000n;\n const VALUE_BIN = new ByteArrayBuilder()\n .add256BitUIntToData(81818275935222000n)\n .build();\n\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n describe(\"Container paths\", () => {\n it(\"should extract TO of the container\", () => {\n // GIVEN\n const transaction = hexaStringToBuffer(\n Transaction.from({\n to: bufferToHexaString(TO),\n value: VALUE,\n data: \"0x\",\n }).unsignedSerialized,\n )!;\n\n // WHEN\n const value = parser.extractValue(transaction, ContainerPath.TO);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([TO]);\n });\n\n it(\"should extract VALUE of the container\", () => {\n // GIVEN\n const transaction = hexaStringToBuffer(\n Transaction.from({\n to: bufferToHexaString(TO),\n value: VALUE,\n data: \"0x\",\n }).unsignedSerialized,\n )!;\n\n // WHEN\n const value = parser.extractValue(transaction, ContainerPath.VALUE);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([VALUE_BIN]);\n });\n\n it(\"Unavailable container fields\", () => {\n // GIVEN\n const transaction = hexaStringToBuffer(\n Transaction.from({\n data: \"0x\",\n signature: {\n r: \"0x73b969418389828a6328fdb96e747296226832894b8bb46d60f231a9960ec3b5\",\n s: \"0x4806aaccc52354f4a42ef9efe0d89dd8cf95210829443ad7f4a9017d6b02de07\",\n v: 1,\n },\n }).unsignedSerialized,\n )!;\n\n // WHEN\n const from = parser.extractValue(transaction, ContainerPath.FROM);\n const to = parser.extractValue(transaction, ContainerPath.TO);\n\n // THEN\n expect(from.isRight()).toStrictEqual(false);\n expect(to.isRight()).toStrictEqual(false);\n });\n\n it(\"invalid transaction format\", () => {\n // GIVEN\n const transaction = hexaStringToBuffer(\"0xdeadbeef\")!;\n\n // WHEN\n const from = parser.extractValue(transaction, ContainerPath.FROM);\n\n // THEN\n expect(from.isRight()).toStrictEqual(false);\n });\n });\n\n describe(\"Data paths in a calldata with static elements\", () => {\n // Example from abi specification:\n // https://docs.soliditylang.org/en/latest/abi-spec.html\n //\n // function baz(uint32 x, bool y)\n // parameters: x = 69\n // y = true\n // calldata:\n // 0xcdcd77c0\n // [0] 0x0000000000000000000000000000000000000000000000000000000000000045\n // [1] 0x0000000000000000000000000000000000000000000000000000000000000001\n const TX = hexaStringToBuffer(\n Transaction.from({\n to: bufferToHexaString(TO),\n value: VALUE,\n data: \"0xcdcd77c000000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000001\",\n }).unsignedSerialized,\n )!;\n\n it(\"Extract the first element\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000045\",\n )!,\n ]);\n });\n\n it(\"Extract the second element\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000001\",\n )!,\n ]);\n });\n\n it(\"Slice the static leaf\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n {\n type: \"SLICE\",\n start: -4,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\"0x00000045\")!,\n ]);\n });\n\n it(\"Out of bounds\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 2,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n });\n\n describe(\"Data paths in a calldata with dynamic elements\", () => {\n // Example from abi specification:\n // https://docs.soliditylang.org/en/latest/abi-spec.html\n //\n // function g(uint256[][] x, string[] x)\n // parameters: x = [[1, 2], [3]]\n // y = [\"one\", \"two\", \"three\"]\n // calldata:\n // 0x2289b18c\n // [0] 0x0000000000000000000000000000000000000000000000000000000000000040: offset of x\n // [1] 0x0000000000000000000000000000000000000000000000000000000000000140: offset of y\n // [2] 0x0000000000000000000000000000000000000000000000000000000000000002: length of x\n // [3] 0x0000000000000000000000000000000000000000000000000000000000000040: offset of x[0]\n // [4] 0x00000000000000000000000000000000000000000000000000000000000000a0: offset of x[1]\n // [5] 0x0000000000000000000000000000000000000000000000000000000000000002: length of x[0]\n // [6] 0x0000000000000000000000000000000000000000000000000000000000000001: value of x[0][0] = 1\n // [7] 0x0000000000000000000000000000000000000000000000000000000000000002: value of x[0][1] = 2\n // [8] 0x0000000000000000000000000000000000000000000000000000000000000001: length of x[1]\n // [9] 0x0000000000000000000000000000000000000000000000000000000000000003: value of x[1][0] = 3\n // [10] 0x0000000000000000000000000000000000000000000000000000000000000003: length of y\n // [11] 0x0000000000000000000000000000000000000000000000000000000000000060: offset of y[0]\n // [12] 0x00000000000000000000000000000000000000000000000000000000000000a0: offset of y[1]\n // [13] 0x00000000000000000000000000000000000000000000000000000000000000e0: offset of y[2]\n // [14] 0x0000000000000000000000000000000000000000000000000000000000000003: length of y[0]\n // [15] 0x6f6e650000000000000000000000000000000000000000000000000000000000: value of y[0] = \"one\"\n // [16] 0x0000000000000000000000000000000000000000000000000000000000000003: length of y[1]\n // [17] 0x74776f0000000000000000000000000000000000000000000000000000000000: value of y[1] = \"two\"\n // [18] 0x0000000000000000000000000000000000000000000000000000000000000005: length of y[2]\n // [19] 0x7468726565000000000000000000000000000000000000000000000000000000: value of y[2] = \"three\"\n const TX = hexaStringToBuffer(\n Transaction.from({\n to: bufferToHexaString(TO),\n value: VALUE,\n data: \"0x2289b18c000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000036f6e650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000374776f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000057468726565000000000000000000000000000000000000000000000000000000\",\n }).unsignedSerialized,\n )!;\n\n it(\"Extract all the elements of x, concatenated together\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000001\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000002\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000003\",\n )!,\n ]);\n });\n\n it(\"Extract all the elements of x[0]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 0,\n end: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000001\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000002\",\n )!,\n ]);\n });\n\n it(\"Extract all the elements of x[0:-1][-1:]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 0,\n end: -1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: -1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000002\",\n )!,\n ]);\n });\n\n it(\"Array out of bounds\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 0,\n end: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 2,\n end: 3,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Extract all the elements of x[1]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\"0x6f6e65\")!,\n hexaStringToBuffer(\"0x74776f\")!,\n hexaStringToBuffer(\"0x7468726565\")!,\n ]);\n });\n\n it(\"Extract all the elements of x[1][:2]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n end: 2,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\"0x6f6e65\")!,\n hexaStringToBuffer(\"0x74776f\")!,\n ]);\n });\n\n it(\"Slice the dynamic leaf with [1:-2]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 2,\n end: 3,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n {\n type: \"SLICE\",\n start: 1,\n end: -2,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\"0x6872\")!,\n ]);\n });\n\n it(\"Slice the dynamic leaf with [-1:]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 2,\n end: 3,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n {\n type: \"SLICE\",\n start: -1,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([hexaStringToBuffer(\"0x65\")!]);\n });\n\n it(\"Slice the dynamic leaf with [:1]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 2,\n end: 3,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n {\n type: \"SLICE\",\n end: 1,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([hexaStringToBuffer(\"0x74\")!]);\n });\n\n it(\"Error no leaf\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Error slice not at the end\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"SLICE\",\n start: 0,\n end: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Error empty slice\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n {\n type: \"SLICE\",\n start: 0,\n end: 0,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n });\n\n describe(\"Array of tuples, with bigger itemSize\", () => {\n // Example constructed with an array of tuples just for the tests\n //\n // function baz((uint32, uint32) myTuple[])\n // parameters: myTuple = [ (1, 2), (3, 4), (5, 6) ]\n // calldata:\n // 0xcdcd77c0\n // [0] 0x0000000000000000000000000000000000000000000000000000000000000020\n // [1] 0x0000000000000000000000000000000000000000000000000000000000000003\n // [2] 0x0000000000000000000000000000000000000000000000000000000000000001\n // [3] 0x0000000000000000000000000000000000000000000000000000000000000002\n // [4] 0x0000000000000000000000000000000000000000000000000000000000000003\n // [5] 0x0000000000000000000000000000000000000000000000000000000000000004\n // [6] 0x0000000000000000000000000000000000000000000000000000000000000005\n // [7] 0x0000000000000000000000000000000000000000000000000000000000000006\n const TX = hexaStringToBuffer(\n Transaction.from({\n to: bufferToHexaString(TO),\n value: VALUE,\n data: \"0xcdcd77c000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000006\",\n }).unsignedSerialized,\n )!;\n\n it(\"Extract the first tuple element of all array elements\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 2,\n },\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000001\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000003\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000005\",\n )!,\n ]);\n });\n\n it(\"Extract the second tuple element of all array elements\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 2,\n },\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000002\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000004\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000006\",\n )!,\n ]);\n });\n });\n\n describe(\"Malformed calldata\", () => {\n // Example constructed with invalid data just for the tests\n //\n // calldata:\n // 0x2289b18c\n // [0] 0x0000000000000000000000000000000000000000000000000000000000000080\n // [1] 0xf000000000000000000000000000000000000000000000000000000000000140\n // [2] 0xf000000000000000000000000000000000000000000000000000000000000002\n const TX = hexaStringToBuffer(\n Transaction.from({\n to: bufferToHexaString(TO),\n value: VALUE,\n data: \"0x2289b18c0000000000000000000000000000000000000000000000000000000000000080f000000000000000000000000000000000000000000000000000000000000140f000000000000000000000000000000000000000000000000000000000000002\",\n }).unsignedSerialized,\n )!;\n\n it(\"Dynamic leaf length overflow\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Calldata smaller than dynamic leaf\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Array length overflow\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Calldata smaller than array length\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Ref out of bounds\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": ["ContainerPath", "bufferToHexaString", "ByteArrayBuilder", "hexaStringToBuffer", "
|
|
4
|
+
"sourcesContent": ["import {\n ContainerPath,\n type DataPathElement,\n type TransactionSubset,\n} from \"@ledgerhq/context-module\";\nimport {\n bufferToHexaString,\n ByteArrayBuilder,\n hexaStringToBuffer,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { TransactionParserService } from \"./TransactionParserService\";\n\ndescribe(\"TransactionParserService\", () => {\n const parser = new TransactionParserService();\n\n const TO = hexaStringToBuffer(\"0x3f32cF0B1DF94157EE1c3876c49BE3732C92a98f\")!;\n const VALUE = 81818275935222000n;\n const VALUE_BIN = new ByteArrayBuilder()\n .add256BitUIntToData(81818275935222000n)\n .build();\n\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n describe(\"Container paths\", () => {\n it(\"should extract TO of the container\", () => {\n // GIVEN\n const subset = {\n chainId: 1,\n data: \"0x\",\n selector: \"0x\",\n to: bufferToHexaString(TO),\n value: VALUE,\n };\n\n // WHEN\n const value = parser.extractValue(subset, ContainerPath.TO);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([TO]);\n });\n\n it(\"should extract VALUE of the container\", () => {\n // GIVEN\n\n const subset = {\n chainId: 1,\n data: \"0x\",\n selector: \"0x\",\n to: bufferToHexaString(TO),\n value: VALUE,\n };\n\n // WHEN\n const value = parser.extractValue(subset, ContainerPath.VALUE);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([VALUE_BIN]);\n });\n\n it(\"Unavailable container fields\", () => {\n // GIVEN\n const subset = {\n chainId: 1,\n data: \"0x\",\n selector: \"0x\",\n to: undefined,\n from: undefined,\n value: VALUE,\n };\n\n // WHEN\n const from = parser.extractValue(subset, ContainerPath.FROM);\n const to = parser.extractValue(subset, ContainerPath.TO);\n\n // THEN\n expect(from.isRight()).toStrictEqual(false);\n expect(to.isRight()).toStrictEqual(false);\n });\n\n it(\"invalid transaction format\", () => {\n // GIVEN\n const transaction = hexaStringToBuffer(\n \"0xdeadbeef\",\n ) as unknown as TransactionSubset;\n\n // WHEN\n const from = parser.extractValue(transaction, ContainerPath.FROM);\n\n // THEN\n expect(from.isRight()).toStrictEqual(false);\n });\n });\n\n describe(\"Data paths in a calldata with static elements\", () => {\n // Example from abi specification:\n // https://docs.soliditylang.org/en/latest/abi-spec.html\n //\n // function baz(uint32 x, bool y)\n // parameters: x = 69\n // y = true\n // calldata:\n // 0xcdcd77c0\n // [0] 0x0000000000000000000000000000000000000000000000000000000000000045\n // [1] 0x0000000000000000000000000000000000000000000000000000000000000001\n const subset = {\n chainId: 1,\n data: \"0xcdcd77c000000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000001\",\n selector: \"0xcdcd77c\",\n to: bufferToHexaString(TO),\n value: VALUE,\n };\n\n it(\"Extract the first element\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(subset, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000045\",\n )!,\n ]);\n });\n\n it(\"Extract the second element\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(subset, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000001\",\n )!,\n ]);\n });\n\n it(\"Slice the static leaf\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n {\n type: \"SLICE\",\n start: -4,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(subset, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\"0x00000045\")!,\n ]);\n });\n\n it(\"Out of bounds\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 2,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n // WHEN\n const value = parser.extractValue(subset, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n });\n\n describe(\"Data paths in a calldata with dynamic elements\", () => {\n // Example from abi specification:\n // https://docs.soliditylang.org/en/latest/abi-spec.html\n //\n // function g(uint256[][] x, string[] x)\n // parameters: x = [[1, 2], [3]]\n // y = [\"one\", \"two\", \"three\"]\n // calldata:\n // 0x2289b18c\n // [0] 0x0000000000000000000000000000000000000000000000000000000000000040: offset of x\n // [1] 0x0000000000000000000000000000000000000000000000000000000000000140: offset of y\n // [2] 0x0000000000000000000000000000000000000000000000000000000000000002: length of x\n // [3] 0x0000000000000000000000000000000000000000000000000000000000000040: offset of x[0]\n // [4] 0x00000000000000000000000000000000000000000000000000000000000000a0: offset of x[1]\n // [5] 0x0000000000000000000000000000000000000000000000000000000000000002: length of x[0]\n // [6] 0x0000000000000000000000000000000000000000000000000000000000000001: value of x[0][0] = 1\n // [7] 0x0000000000000000000000000000000000000000000000000000000000000002: value of x[0][1] = 2\n // [8] 0x0000000000000000000000000000000000000000000000000000000000000001: length of x[1]\n // [9] 0x0000000000000000000000000000000000000000000000000000000000000003: value of x[1][0] = 3\n // [10] 0x0000000000000000000000000000000000000000000000000000000000000003: length of y\n // [11] 0x0000000000000000000000000000000000000000000000000000000000000060: offset of y[0]\n // [12] 0x00000000000000000000000000000000000000000000000000000000000000a0: offset of y[1]\n // [13] 0x00000000000000000000000000000000000000000000000000000000000000e0: offset of y[2]\n // [14] 0x0000000000000000000000000000000000000000000000000000000000000003: length of y[0]\n // [15] 0x6f6e650000000000000000000000000000000000000000000000000000000000: value of y[0] = \"one\"\n // [16] 0x0000000000000000000000000000000000000000000000000000000000000003: length of y[1]\n // [17] 0x74776f0000000000000000000000000000000000000000000000000000000000: value of y[1] = \"two\"\n // [18] 0x0000000000000000000000000000000000000000000000000000000000000005: length of y[2]\n // [19] 0x7468726565000000000000000000000000000000000000000000000000000000: value of y[2] = \"three\"\n const subset = {\n to: bufferToHexaString(TO),\n value: VALUE,\n chainId: 1,\n data: \"0x2289b18c000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000036f6e650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000374776f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000057468726565000000000000000000000000000000000000000000000000000000\",\n selector: \"0x2289b18c\",\n };\n it(\"Extract all the elements of x, concatenated together\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(subset, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000001\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000002\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000003\",\n )!,\n ]);\n });\n\n it(\"Extract all the elements of x[0]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 0,\n end: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(subset, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000001\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000002\",\n )!,\n ]);\n });\n\n it(\"Extract all the elements of x[0:-1][-1:]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 0,\n end: -1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: -1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(subset, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000002\",\n )!,\n ]);\n });\n\n it(\"Array out of bounds\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 0,\n end: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 2,\n end: 3,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(subset, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Extract all the elements of x[1]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(subset, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\"0x6f6e65\")!,\n hexaStringToBuffer(\"0x74776f\")!,\n hexaStringToBuffer(\"0x7468726565\")!,\n ]);\n });\n\n it(\"Extract all the elements of x[1][:2]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n end: 2,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(subset, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\"0x6f6e65\")!,\n hexaStringToBuffer(\"0x74776f\")!,\n ]);\n });\n\n it(\"Slice the dynamic leaf with [1:-2]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 2,\n end: 3,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n {\n type: \"SLICE\",\n start: 1,\n end: -2,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(subset, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\"0x6872\")!,\n ]);\n });\n\n it(\"Slice the dynamic leaf with [-1:]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 2,\n end: 3,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n {\n type: \"SLICE\",\n start: -1,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(subset, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([hexaStringToBuffer(\"0x65\")!]);\n });\n\n it(\"Slice the dynamic leaf with [:1]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 2,\n end: 3,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n {\n type: \"SLICE\",\n end: 1,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(subset, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([hexaStringToBuffer(\"0x74\")!]);\n });\n\n it(\"Error no leaf\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(subset, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Error slice not at the end\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"SLICE\",\n start: 0,\n end: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(subset, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Error empty slice\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n {\n type: \"SLICE\",\n start: 0,\n end: 0,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(subset, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n });\n\n describe(\"Array of tuples, with bigger itemSize\", () => {\n // Example constructed with an array of tuples just for the tests\n //\n // function baz((uint32, uint32) myTuple[])\n // parameters: myTuple = [ (1, 2), (3, 4), (5, 6) ]\n // calldata:\n // 0xcdcd77c0\n // [0] 0x0000000000000000000000000000000000000000000000000000000000000020\n // [1] 0x0000000000000000000000000000000000000000000000000000000000000003\n // [2] 0x0000000000000000000000000000000000000000000000000000000000000001\n // [3] 0x0000000000000000000000000000000000000000000000000000000000000002\n // [4] 0x0000000000000000000000000000000000000000000000000000000000000003\n // [5] 0x0000000000000000000000000000000000000000000000000000000000000004\n // [6] 0x0000000000000000000000000000000000000000000000000000000000000005\n // [7] 0x0000000000000000000000000000000000000000000000000000000000000006\n const subset = {\n chainId: 1,\n data: \"0xcdcd77c000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000006\",\n selector: \"0xcdcd77c\",\n to: bufferToHexaString(TO),\n value: VALUE,\n };\n\n it(\"Extract the first tuple element of all array elements\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 2,\n },\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(subset, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000001\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000003\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000005\",\n )!,\n ]);\n });\n\n it(\"Extract the second tuple element of all array elements\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 2,\n },\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(subset, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000002\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000004\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000006\",\n )!,\n ]);\n });\n });\n\n describe(\"Malformed calldata\", () => {\n // Example constructed with invalid data just for the tests\n //\n // calldata:\n // 0x2289b18c\n // [0] 0x0000000000000000000000000000000000000000000000000000000000000080\n // [1] 0xf000000000000000000000000000000000000000000000000000000000000140\n // [2] 0xf000000000000000000000000000000000000000000000000000000000000002\n const subset = {\n chainId: 1,\n data: \"0x2289b18c0000000000000000000000000000000000000000000000000000000000000080f000000000000000000000000000000000000000000000000000000000000140f000000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0x2289b18c\",\n to: bufferToHexaString(TO),\n value: VALUE,\n };\n\n it(\"Dynamic leaf length overflow\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(subset, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Calldata smaller than dynamic leaf\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(subset, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Array length overflow\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(subset, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Calldata smaller than array length\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(subset, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Ref out of bounds\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(subset, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,iBAAAA,MAGK,2BACP,OACE,sBAAAC,EACA,oBAAAC,EACA,sBAAAC,MACK,kCAEP,OAAS,4BAAAC,MAAgC,6BAEzC,SAAS,2BAA4B,IAAM,CACzC,MAAMC,EAAS,IAAID,EAEbE,EAAKH,EAAmB,4CAA4C,EACpEI,EAAQ,mBACRC,EAAY,IAAIN,EAAiB,EACpC,oBAAoB,kBAAkB,EACtC,MAAM,EAET,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,SAAS,kBAAmB,IAAM,CAChC,GAAG,qCAAsC,IAAM,CAE7C,MAAMO,EAAS,CACb,QAAS,EACT,KAAM,KACN,SAAU,KACV,GAAIR,EAAmBK,CAAE,EACzB,MAAOC,CACT,EAGMG,EAAQL,EAAO,aAAaI,EAAQT,EAAc,EAAE,EAG1D,OAAOU,EAAM,QAAQ,CAAC,EAAE,cAAc,EAAI,EAC1C,OAAOA,EAAM,aAAa,CAAC,EAAE,cAAc,CAACJ,CAAE,CAAC,CACjD,CAAC,EAED,GAAG,wCAAyC,IAAM,CAGhD,MAAMG,EAAS,CACb,QAAS,EACT,KAAM,KACN,SAAU,KACV,GAAIR,EAAmBK,CAAE,EACzB,MAAOC,CACT,EAGMG,EAAQL,EAAO,aAAaI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,CAAC,EAED,GAAG,oBAAqB,IAAM,CAE5B,MAAMI,EAA0B,CAC9B,CACE,KAAM,QACN,OAAQ,CACV,EACA,CACE,KAAM,KACR,EACA,CACE,KAAM,OACN,SAAU,aACZ,CACF,EAGMJ,EAAQL,EAAO,aAAaI,EAAQK,CAAI,EAG9C,OAAOJ,EAAM,QAAQ,CAAC,EAAE,cAAc,EAAK,CAC7C,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["ContainerPath", "bufferToHexaString", "ByteArrayBuilder", "hexaStringToBuffer", "TransactionParserService", "parser", "TO", "VALUE", "VALUE_BIN", "subset", "value", "from", "to", "transaction", "path"]
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ClearSignContextSuccess, type ContextModule } from "@ledgerhq/context-module";
|
|
1
|
+
import { type ClearSignContextSuccess, type ContextModule, type TransactionSubset } from "@ledgerhq/context-module";
|
|
2
2
|
import { type CommandErrorResult, type DeviceActionState, type ExecuteDeviceActionReturnType, type OpenAppDAError, type OpenAppDARequiredInteraction, type UserInteractionRequired } from "@ledgerhq/device-management-kit";
|
|
3
3
|
import { type GetConfigCommandResponse } from "../app-binder/GetConfigCommandTypes";
|
|
4
4
|
import { type ClearSigningType } from "../model/ClearSigningType";
|
|
@@ -13,6 +13,7 @@ export declare enum SignTransactionDAStep {
|
|
|
13
13
|
GET_APP_CONFIG = "signer.eth.steps.getAppConfig",
|
|
14
14
|
WEB3_CHECKS_OPT_IN = "signer.eth.steps.web3ChecksOptIn",
|
|
15
15
|
WEB3_CHECKS_OPT_IN_RESULT = "signer.eth.steps.web3ChecksOptInResult",
|
|
16
|
+
PRE_BUILD_CONTEXT = "signer.eth.steps.preBuildContext",
|
|
16
17
|
BUILD_CONTEXT = "signer.eth.steps.buildContext",
|
|
17
18
|
BUILD_SUB_CONTEXT_AND_PROVIDE = "signer.eth.steps.buildSubContextAndProvide",
|
|
18
19
|
SIGN_TRANSACTION = "signer.eth.steps.signTransaction"
|
|
@@ -42,8 +43,7 @@ export type SignTransactionDAInternalState = {
|
|
|
42
43
|
readonly appConfig: GetConfigCommandResponse | null;
|
|
43
44
|
readonly clearSignContexts: ClearSignContextSuccess[] | null;
|
|
44
45
|
readonly clearSignContextsOptional: ClearSignContextSuccess[] | null;
|
|
45
|
-
readonly
|
|
46
|
-
readonly chainId: number | null;
|
|
46
|
+
readonly subset: TransactionSubset | null;
|
|
47
47
|
readonly transactionType: TransactionType | null;
|
|
48
48
|
readonly clearSigningType: ClearSigningType | null;
|
|
49
49
|
readonly signature: Signature | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignTransactionDeviceActionTypes.d.ts","sourceRoot":"","sources":["../../../../src/api/app-binder/SignTransactionDeviceActionTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"SignTransactionDeviceActionTypes.d.ts","sourceRoot":"","sources":["../../../../src/api/app-binder/SignTransactionDeviceActionTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACnB,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAC7B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,E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sBAAsB,GAAG,iBAAiB,CACpD,uBAAuB,EACvB,sBAAsB,EACtB,kCAAkC,CACnC,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,QAAQ,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAC9C,QAAQ,CAAC,SAAS,EAAE,wBAAwB,GAAG,IAAI,CAAC;IACpD,QAAQ,CAAC,iBAAiB,EAAE,uBAAuB,EAAE,GAAG,IAAI,CAAC;IAC7D,QAAQ,CAAC,yBAAyB,EAAE,uBAAuB,EAAE,GAAG,IAAI,CAAC;IACrE,QAAQ,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC1C,QAAQ,CAAC,eAAe,EAAE,eAAe,GAAG,IAAI,CAAC;IACjD,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACnD,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,6BAA6B,CACrE,uBAAuB,EACvB,sBAAsB,EACtB,kCAAkC,CACnC,CAAC"}
|
package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts
CHANGED
|
@@ -1,39 +1,28 @@
|
|
|
1
|
-
import { type ClearSignContextSuccess, type ContextModule } from "@ledgerhq/context-module";
|
|
2
1
|
import { type CommandErrorResult, type CommandResult, type DeviceActionStateMachine, type InternalApi, XStateDeviceAction } from "@ledgerhq/device-management-kit";
|
|
3
2
|
import { type Either } from "purify-ts";
|
|
4
3
|
import { type GetConfigCommandResponse } from "../../../../api/app-binder/GetConfigCommandTypes";
|
|
5
4
|
import { type SignTransactionDAError, type SignTransactionDAInput, type SignTransactionDAIntermediateValue, type SignTransactionDAInternalState, type SignTransactionDAOutput } from "../../../../api/app-binder/SignTransactionDeviceActionTypes";
|
|
6
5
|
import { type ClearSigningType } from "../../../../api/model/ClearSigningType";
|
|
7
6
|
import { type Signature } from "../../../../api/model/Signature";
|
|
8
|
-
import { type TransactionOptions } from "../../../../api/model/TransactionOptions";
|
|
9
7
|
import { type TransactionType } from "../../../../api/model/TransactionType";
|
|
10
8
|
import { type EthErrorCodes } from "../../../app-binder/command/utils/ethAppErrors";
|
|
11
9
|
import { type Web3CheckOptInCommandResponse } from "../../../app-binder/command/Web3CheckOptInCommand";
|
|
12
|
-
import { type
|
|
13
|
-
import { type
|
|
14
|
-
import { type
|
|
10
|
+
import { type BuildSubContextTaskArgs } from "../../../app-binder/task/BuildSubContextTask";
|
|
11
|
+
import { type BuildTransactionContextTaskArgs, type BuildTransactionTaskResult } from "../../../app-binder/task/BuildTransactionContextTask";
|
|
12
|
+
import { type PreBuildContextTaskArgs, type PreBuildContextTaskResult } from "../../../app-binder/task/PreBuildContextTask";
|
|
15
13
|
export type MachineDependencies = {
|
|
16
14
|
readonly getAppConfig: () => Promise<CommandResult<GetConfigCommandResponse, EthErrorCodes>>;
|
|
17
15
|
readonly web3CheckOptIn: () => Promise<CommandResult<Web3CheckOptInCommandResponse, EthErrorCodes>>;
|
|
16
|
+
readonly preBuildContext: (arg0: {
|
|
17
|
+
input: PreBuildContextTaskArgs;
|
|
18
|
+
}) => Promise<PreBuildContextTaskResult>;
|
|
18
19
|
readonly buildContext: (arg0: {
|
|
19
|
-
input:
|
|
20
|
-
contextModule: ContextModule;
|
|
21
|
-
mapper: TransactionMapperService;
|
|
22
|
-
transaction: Uint8Array;
|
|
23
|
-
options: TransactionOptions;
|
|
24
|
-
appConfig: GetConfigCommandResponse;
|
|
25
|
-
derivationPath: string;
|
|
26
|
-
};
|
|
20
|
+
input: BuildTransactionContextTaskArgs;
|
|
27
21
|
}) => Promise<BuildTransactionTaskResult>;
|
|
28
22
|
readonly buildSubContextAndProvide: (arg0: {
|
|
29
|
-
input: {
|
|
30
|
-
context: ClearSignContextSuccess;
|
|
31
|
-
contextOptional: ClearSignContextSuccess[];
|
|
32
|
-
transactionParser: TransactionParserService;
|
|
33
|
-
serializedTransaction: Uint8Array;
|
|
34
|
-
contextModule: ContextModule;
|
|
35
|
-
chainId: number;
|
|
23
|
+
input: BuildSubContextTaskArgs & {
|
|
36
24
|
derivationPath: string;
|
|
25
|
+
transaction: Uint8Array;
|
|
37
26
|
};
|
|
38
27
|
}) => Promise<Either<CommandErrorResult<EthErrorCodes>, void>>;
|
|
39
28
|
readonly signTransaction: (arg0: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignTransactionDeviceAction.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"SignTransactionDeviceAction.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAE7B,KAAK,WAAW,EAMhB,kBAAkB,EACnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,MAAM,EAAe,MAAM,WAAW,CAAC;AAGrD,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,kCAAkC,EACvC,KAAK,8BAA8B,EACnC,KAAK,uBAAuB,EAE7B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iDAAiD,CAAC;AACrF,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,oDAAoD,CAAC;AAC5D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S,EAAE,aAAa,CAAC,CAAC,CAAC;CACxD,CAAC;AAEF,qBAAa,2BAA4B,SAAQ,kBAAkB,CACjE,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,kCAAkC,EAClC,8BAA8B,CAC/B;IACC,gBAAgB,CACd,WAAW,EAAE,WAAW,GACvB,wBAAwB,CACzB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,kCAAkC,EAClC,8BAA8B,CAC/B;IAwaD,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,mBAAmB;CA2DnE"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { type ClearSignContext, type ClearSignContextSuccess, type ContextModule } from "@ledgerhq/context-module";
|
|
1
|
+
import { type ClearSignContext, type ClearSignContextSuccess, type ContextModule, type TransactionSubset } from "@ledgerhq/context-module";
|
|
2
2
|
import { type InternalApi } from "@ledgerhq/device-management-kit";
|
|
3
3
|
import { type TransactionParserService } from "../../transaction/service/parser/TransactionParserService";
|
|
4
4
|
export type BuildSubContextTaskArgs = {
|
|
5
5
|
readonly context: ClearSignContextSuccess;
|
|
6
6
|
readonly contextOptional: ClearSignContextSuccess[];
|
|
7
7
|
readonly transactionParser: TransactionParserService;
|
|
8
|
-
readonly
|
|
8
|
+
readonly subset: TransactionSubset;
|
|
9
9
|
readonly contextModule: ContextModule;
|
|
10
|
-
readonly chainId: number;
|
|
11
10
|
};
|
|
12
11
|
export type BuildSubContextTaskResult = {
|
|
13
12
|
subcontextCallbacks: (() => Promise<ClearSignContext>)[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildSubContextTask.d.ts","sourceRoot":"","sources":["../../../../../src/internal/app-binder/task/BuildSubContextTask.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EAErB,KAAK,uBAAuB,EAE5B,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"BuildSubContextTask.d.ts","sourceRoot":"","sources":["../../../../../src/internal/app-binder/task/BuildSubContextTask.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EAErB,KAAK,uBAAuB,EAE5B,KAAK,aAAa,EAElB,KAAK,iBAAiB,EACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAEL,KAAK,WAAW,EAEjB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,+DAA+D,CAAC;AAE9G,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,OAAO,EAAE,uBAAuB,CAAC;IAC1C,QAAQ,CAAC,eAAe,EAAE,uBAAuB,EAAE,CAAC;IACpD,QAAQ,CAAC,iBAAiB,EAAE,wBAAwB,CAAC;IACrD,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,mBAAmB,EAAE,CAAC,MAAM,OAAO,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC;CAC1D,CAAC;AAEF,qBAAa,mBAAmB;IAE5B,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBADJ,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,uBAAuB;IAGhD,GAAG,IAAI,yBAAyB;CAwIjC"}
|
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
import { type ClearSignContextSuccess, type ContextModule } from "@ledgerhq/context-module";
|
|
1
|
+
import { type ClearSignContextSuccess, type ContextModule, type TransactionSubset } from "@ledgerhq/context-module";
|
|
2
2
|
import { type InternalApi } from "@ledgerhq/device-management-kit";
|
|
3
3
|
import { type GetConfigCommandResponse } from "../../../api/app-binder/GetConfigCommandTypes";
|
|
4
4
|
import { ClearSigningType } from "../../../api/model/ClearSigningType";
|
|
5
5
|
import { type TransactionOptions } from "../../../api/model/TransactionOptions";
|
|
6
|
-
import { type TransactionType } from "../../../api/model/TransactionType";
|
|
7
6
|
import { GetWeb3CheckTask, type GetWeb3CheckTaskArgs } from "../../app-binder/task/GetWeb3CheckTask";
|
|
8
|
-
import { type TransactionMapperService } from "../../transaction/service/mapper/TransactionMapperService";
|
|
9
7
|
export type BuildTransactionTaskResult = {
|
|
10
8
|
readonly clearSignContexts: ClearSignContextSuccess[];
|
|
11
9
|
readonly clearSignContextsOptional: ClearSignContextSuccess[];
|
|
12
|
-
readonly serializedTransaction: Uint8Array;
|
|
13
|
-
readonly chainId: number;
|
|
14
|
-
readonly transactionType: TransactionType;
|
|
15
10
|
readonly clearSigningType: ClearSigningType;
|
|
16
11
|
};
|
|
17
12
|
export type BuildTransactionContextTaskArgs = {
|
|
18
13
|
readonly contextModule: ContextModule;
|
|
19
|
-
readonly mapper: TransactionMapperService;
|
|
20
|
-
readonly transaction: Uint8Array;
|
|
21
14
|
readonly options: TransactionOptions;
|
|
22
15
|
readonly appConfig: GetConfigCommandResponse;
|
|
23
16
|
readonly derivationPath: string;
|
|
17
|
+
readonly transaction: Uint8Array;
|
|
18
|
+
readonly subset: TransactionSubset;
|
|
24
19
|
};
|
|
25
20
|
export declare class BuildTransactionContextTask {
|
|
26
21
|
private readonly _api;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildTransactionContextTask.d.ts","sourceRoot":"","sources":["../../../../../src/internal/app-binder/task/BuildTransactionContextTask.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAG5B,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"BuildTransactionContextTask.d.ts","sourceRoot":"","sources":["../../../../../src/internal/app-binder/task/BuildTransactionContextTask.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAG5B,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAGL,KAAK,WAAW,EAEjB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,EACL,gBAAgB,EAChB,KAAK,oBAAoB,EAC1B,MAAM,4CAA4C,CAAC;AAGpD,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,CAAC,iBAAiB,EAAE,uBAAuB,EAAE,CAAC;IACtD,QAAQ,CAAC,yBAAyB,EAAE,uBAAuB,EAAE,CAAC;IAC9D,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,wBAAwB,CAAC;IAC7C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;CACpC,CAAC;AAEF,qBAAa,2BAA2B;IAEpC,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,oBAAoB;gBAFpB,IAAI,EAAE,WAAW,EACjB,KAAK,EAAE,+BAA+B,EACtC,oBAAoB,IACnC,KAAK,WAAW,EAChB,MAAM,oBAAoB,qBACQ;IAGhC,GAAG,IAAI,OAAO,CAAC,0BAA0B,CAAC;IA2GhD,OAAO,CAAC,qBAAqB;CAS9B"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { type ClearSignContextSuccess, ClearSignContextType, type ContextModule } from "@ledgerhq/context-module";
|
|
1
|
+
import { type ClearSignContextSuccess, ClearSignContextType, type ContextModule, type TransactionSubset } from "@ledgerhq/context-module";
|
|
2
2
|
import { type DmkError, type InternalApi } from "@ledgerhq/device-management-kit";
|
|
3
3
|
import { type TypedData } from "../../../api/model/TypedData";
|
|
4
|
-
import { type TransactionMapperService } from "../../transaction/service/mapper/TransactionMapperService";
|
|
5
4
|
export type GetWeb3CheckTaskResult = {
|
|
6
5
|
readonly web3Check: ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null;
|
|
7
6
|
} | {
|
|
@@ -16,7 +15,7 @@ export type GetWeb3CheckTypedDataTaskArgs = {
|
|
|
16
15
|
export type GetWeb3CheckRawTxTaskArgs = {
|
|
17
16
|
readonly contextModule: ContextModule;
|
|
18
17
|
readonly derivationPath: string;
|
|
19
|
-
readonly
|
|
18
|
+
readonly subset: TransactionSubset;
|
|
20
19
|
readonly transaction: Uint8Array;
|
|
21
20
|
};
|
|
22
21
|
export type GetWeb3CheckTaskArgs = GetWeb3CheckTypedDataTaskArgs | GetWeb3CheckRawTxTaskArgs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GetWeb3CheckTask.d.ts","sourceRoot":"","sources":["../../../../../src/internal/app-binder/task/GetWeb3CheckTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,uBAAuB,EAC5B,oBAAoB,EACpB,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"GetWeb3CheckTask.d.ts","sourceRoot":"","sources":["../../../../../src/internal/app-binder/task/GetWeb3CheckTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,uBAAuB,EAC5B,oBAAoB,EACpB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EAEvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,WAAW,EAEjB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGtD,MAAM,MAAM,sBAAsB,GAC9B;IACE,QAAQ,CAAC,SAAS,EAAE,uBAAuB,CAAC,oBAAoB,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;CACrF,GACD;IACE,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IACzB,KAAK,EAAE,QAAQ,CAAC;CACjB,CAAC;AAEN,MAAM,MAAM,6BAA6B,GAAG;IAC1C,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;CAC1B,CAAC;AACF,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC;CAClC,CAAC;AACF,MAAM,MAAM,oBAAoB,GAC5B,6BAA6B,GAC7B,yBAAyB,CAAC;AAE9B,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBADJ,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,oBAAoB;IAGvC,GAAG,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAuD5C,OAAO,CAAC,OAAO;CAKhB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type TransactionSubset } from "@ledgerhq/context-module";
|
|
2
|
+
import { type TransactionType } from "../../../api/model/TransactionType";
|
|
3
|
+
import { type TransactionMapperService } from "../../transaction/service/mapper/TransactionMapperService";
|
|
4
|
+
export type PreBuildContextTaskResult = {
|
|
5
|
+
readonly subset: TransactionSubset;
|
|
6
|
+
readonly type: TransactionType;
|
|
7
|
+
};
|
|
8
|
+
export type PreBuildContextTaskArgs = {
|
|
9
|
+
readonly mapper: TransactionMapperService;
|
|
10
|
+
readonly transaction: Uint8Array;
|
|
11
|
+
};
|
|
12
|
+
export declare class PreBuildContextTask {
|
|
13
|
+
private readonly _args;
|
|
14
|
+
constructor(_args: PreBuildContextTaskArgs);
|
|
15
|
+
run(): PreBuildContextTaskResult;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=PreBuildContextTask.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreBuildContextTask.d.ts","sourceRoot":"","sources":["../../../../../src/internal/app-binder/task/PreBuildContextTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,+DAA+D,CAAC;AAE9G,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,MAAM,EAAE,wBAAwB,CAAC;IAC1C,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC;CAClC,CAAC;AAEF,qBAAa,mBAAmB;IAClB,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,uBAAuB;IAE3D,GAAG,IAAI,yBAAyB;CAQjC"}
|
package/lib/types/internal/transaction/service/mapper/EthersTransactionMapperService.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthersTransactionMapperService.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/transaction/service/mapper/EthersTransactionMapperService.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAe,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"EthersTransactionMapperService.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/transaction/service/mapper/EthersTransactionMapperService.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAe,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAItE,qBACa,8BACX,YAAW,wBAAwB;;IAInC,sBAAsB,CACpB,WAAW,EAAE,UAAU,GACtB,MAAM,CAAC,KAAK,EAAE,uBAAuB,CAAC;CA2B1C"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { GenericPath } from "@ledgerhq/context-module";
|
|
1
|
+
import type { GenericPath, TransactionSubset } from "@ledgerhq/context-module";
|
|
2
2
|
import { Either, Maybe } from "purify-ts";
|
|
3
3
|
export declare class TransactionParserService {
|
|
4
|
-
extractValue(
|
|
4
|
+
extractValue(subset: TransactionSubset, path: GenericPath): Either<Error, Uint8Array[]>;
|
|
5
5
|
private extractCalldataValue;
|
|
6
6
|
private extractCalldataValueAt;
|
|
7
7
|
private sliceLeaf;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionParserService.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/transaction/service/parser/TransactionParserService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,WAAW,
|
|
1
|
+
{"version":3,"file":"TransactionParserService.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/transaction/service/parser/TransactionParserService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,WAAW,EACX,iBAAiB,EAClB,MAAM,0BAA0B,CAAC;AAYlC,OAAO,EAAE,MAAM,EAAQ,KAAK,EAAS,MAAM,WAAW,CAAC;AAyDvD,qBACa,wBAAwB;IAC5B,YAAY,CACjB,MAAM,EAAE,iBAAiB,EACzB,IAAI,EAAE,WAAW,GAChB,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC;IAwC9B,OAAO,CAAC,oBAAoB;IAW5B,OAAO,CAAC,sBAAsB;IAuI9B,OAAO,CAAC,SAAS;IAuBjB,QAAQ,CACN,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC;IAU5B,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC;CAMzC"}
|