@ledgerhq/device-signer-kit-ethereum 0.0.0-multisig-20250910160951 → 0.0.0-multisig-2-20250922093851
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/api/index.js +1 -1
- package/lib/cjs/api/index.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/task/BuildBaseContexts.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildBaseContexts.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/BuildBaseContexts.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildBaseContexts.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/task/BuildFullContextsTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildFullContextsTask.js.map +2 -2
- package/lib/cjs/internal/app-binder/task/BuildFullContextsTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildFullContextsTask.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/task/BuildSubcontextsTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildSubcontextsTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/BuildSubcontextsTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildSubcontextsTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/ProvideContextsTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideContextsTask.js.map +2 -2
- package/lib/cjs/internal/app-binder/task/ProvideContextsTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideContextsTask.test.js.map +2 -2
- 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 +2 -2
- package/lib/cjs/package.json +1 -1
- package/lib/esm/api/app-binder/SignTransactionDeviceActionTypes.js +1 -1
- package/lib/esm/api/app-binder/SignTransactionDeviceActionTypes.js.map +2 -2
- package/lib/esm/api/index.js +1 -1
- package/lib/esm/api/index.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/BuildBaseContexts.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildBaseContexts.js.map +3 -3
- package/lib/esm/internal/app-binder/task/BuildBaseContexts.test.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildBaseContexts.test.js.map +2 -2
- package/lib/esm/internal/app-binder/task/BuildFullContextsTask.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildFullContextsTask.js.map +2 -2
- package/lib/esm/internal/app-binder/task/BuildFullContextsTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildFullContextsTask.test.js.map +2 -2
- package/lib/esm/internal/app-binder/task/BuildSubcontextsTask.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildSubcontextsTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/BuildSubcontextsTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildSubcontextsTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/ProvideContextsTask.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideContextsTask.js.map +2 -2
- package/lib/esm/internal/app-binder/task/ProvideContextsTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideContextsTask.test.js.map +2 -2
- 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 +2 -2
- package/lib/esm/package.json +1 -1
- package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts +2 -1
- package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/api/index.d.ts +5 -9
- package/lib/types/api/index.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts +1 -1
- package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/BuildBaseContexts.d.ts +14 -1
- package/lib/types/internal/app-binder/task/BuildBaseContexts.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/BuildFullContextsTask.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/ProvideContextsTask.d.ts +3 -1
- package/lib/types/internal/app-binder/task/ProvideContextsTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/ProvideEIP712ContextTask.d.ts +1 -1
- package/lib/types/internal/app-binder/task/ProvideEIP712ContextTask.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/app-binder/task/BuildBaseContexts.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type ClearSignContext,\n type ClearSignContextSuccess,\n ClearSignContextType,\n type PkiCertificate,\n} from \"@ledgerhq/context-module\";\nimport {\n CommandResultFactory,\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n hexaStringToBuffer,\n UnknownDeviceExchangeError,\n} from \"@ledgerhq/device-management-kit\";\nimport { Transaction } from \"ethers\";\n\nimport type { GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\n\nimport {\n BuildBaseContexts,\n type BuildBaseContextsArgs,\n} from \"./BuildBaseContexts\";\nimport { GetWeb3CheckTask } from \"./GetWeb3CheckTask\";\n\ndescribe(\"BuildBaseContexts\", () => {\n const contextModuleMock = {\n getFieldContext: vi.fn(),\n getContexts: vi.fn(),\n getTypedDataFilters: vi.fn(),\n getWeb3Checks: vi.fn(),\n getSolanaContext: vi.fn(),\n };\n const defaultOptions = {\n domain: \"domain-name.eth\",\n };\n const defaultTransaction: Uint8Array = hexaStringToBuffer(\n Transaction.from({\n chainId: 1n,\n nonce: 0,\n data: \"0x\",\n }).unsignedSerialized,\n )!;\n const defaultCertificate: PkiCertificate = {\n keyUsageNumber: 1,\n payload: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n let defaultArgs: BuildBaseContextsArgs;\n const apiMock = makeDeviceActionInternalApiMock();\n const getWeb3ChecksFactoryMock = vi.fn();\n\n function createAppConfig(\n web3ChecksEnabled: boolean,\n ): GetConfigCommandResponse {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled,\n web3ChecksOptIn: false,\n version: \"1.13.0\",\n };\n }\n\n beforeEach(() => {\n vi.resetAllMocks();\n apiMock.sendCommand.mockResolvedValue(\n CommandResultFactory({ data: { challenge: \"challenge\" } }),\n );\n getWeb3ChecksFactoryMock.mockReturnValue({\n run: async () => Promise.resolve({ web3Check: null }),\n });\n\n defaultArgs = {\n contextModule: contextModuleMock,\n subset: { chainId: 1, to: undefined, data: \"0x\", selector: \"0x\" },\n transaction: defaultTransaction,\n options: defaultOptions,\n appConfig: createAppConfig(false),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n });\n\n it(\"should init with a default GetWeb3CheckTaskFactory\", () => {\n // GIVEN\n const task = new BuildBaseContexts(apiMock, defaultArgs);\n\n // THEN\n expect(task[\"getWeb3ChecksFactory\"]).toBeDefined();\n expect(\n task[\"getWeb3ChecksFactory\"](apiMock, {\n contextModule: defaultArgs.contextModule,\n derivationPath: defaultArgs.derivationPath,\n subset: defaultArgs.subset,\n transaction: defaultArgs.transaction!,\n }),\n ).toBeInstanceOf(GetWeb3CheckTask);\n });\n\n it(\"should build the transaction context without clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n const clearSignContextsOptional: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with web3checks\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n const clearSignContextsOptional: ClearSignContext[] = [];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [expectedWeb3Check, ...clearSignContexts],\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with web3checks and generic-parser clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n ];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n clearSignContexts[0],\n clearSignContexts[1],\n clearSignContexts[3],\n expectedWeb3Check,\n ],\n clearSignContextsOptional: [clearSignContexts[2]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with web3checks and generic-parser clear sign contexts in the correct order\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n ];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n clearSignContexts[3], // transaction info\n clearSignContexts[1], // transaction field description\n clearSignContexts[2], // transaction field description\n expectedWeb3Check, // web3 check\n ],\n clearSignContextsOptional: [clearSignContexts[0]], // enum\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with generic-parser context\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n clearSignContexts[0],\n clearSignContexts[1],\n clearSignContexts[3],\n ],\n clearSignContextsOptional: [clearSignContexts[2]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with proxy delegate call context\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: \"payload-2\",\n },\n ];\n const clearSignContextsOptional: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[0]],\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should call the web3checks factory with correct parameters\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(getWeb3ChecksFactoryMock).toHaveBeenCalledWith(apiMock, {\n contextModule: contextModuleMock,\n derivationPath: \"44'/60'/0'/0/0\",\n subset: defaultArgs.subset,\n transaction: defaultTransaction,\n });\n });\n\n it(\"should call the context module with the correct parameters\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.FLEX,\n challenge: \"challenge\",\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n });\n });\n\n it(\"should call the context module without challenge for Nano S\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.NANO_S,\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n });\n });\n\n it(\"should call the context module without context on error\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ error: new UnknownDeviceExchangeError() }),\n );\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.FLEX,\n challenge: undefined,\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n });\n });\n\n it(\"should exclude error contexts from the result\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result on old apps\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"transaction_info\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result if no transaction_info was found\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude legacy contexts from the result for generic-parser transactions\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-5\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [clearSignContexts[4]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should exclude generic-parser contexts with a nano s device\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts with an old app version\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts with a non ready device\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.NOT_CONNECTED,\n deviceModelId: DeviceModelId.FLEX,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should return no clear sign context if the transaction info certificate is missing\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.17.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should not return web3check if the transaction is undefined\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.17.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, transaction: undefined },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(getWeb3ChecksFactoryMock).not.toHaveBeenCalled();\n });\n});\n"],
|
|
5
|
-
"mappings": "aAAA,IAAAA,EAKO,oCACPC,EA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AAC,EAChB,WAAY,CAAE,KAAM,WAAY,QAAS,QAAS,EAClD,cAAe,gBAAc,KAC7B,0BAA2B,EAC7B,CAAC,EAGD,MAAMO,EAAS,MAAM,IAAI,oBACvBP,EACAD,EACAE,CACF,EAAE,IAAI,EAGN,OAAOM,CAAM,EAAE,QAAQ,CACrB,kBAAmB,CAAC,EACpB,0BAA2B,CAAC,EAC5B,iBAAkB,mBAAiB,KACrC,CAAC,CACH,CAAC,EAED,GAAG,8DAA+D,SAAY,CAE5E,MAAMF,EAAwC,CAAC,EAC/CV,EAAkB,YAAY,sBAAsBU,CAAiB,EACrEL,EAAQ,sBAAsB,oBAAoB,CAChD,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,WAAY,QAAS,QAAS,EAClD,cAAe,gBAAc,KAC7B,0BAA2B,EAC7B,CAAC,EAGD,MAAM,IAAI,oBACRA,EACA,CAAE,GAAGD,EAAa,YAAa,MAAU,EACzCE,CACF,EAAE,IAAI,EAGN,OAAOA,CAAwB,EAAE,IAAI,iBAAiB,CACxD,CAAC,CACH,CAAC",
|
|
4
|
+
"sourcesContent": ["import {\n type ClearSignContext,\n ClearSignContextType,\n type PkiCertificate,\n} from \"@ledgerhq/context-module\";\nimport {\n CommandResultFactory,\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n hexaStringToBuffer,\n UnknownDeviceExchangeError,\n} from \"@ledgerhq/device-management-kit\";\nimport { Transaction } from \"ethers\";\n\nimport type { GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\n\nimport {\n BuildBaseContexts,\n type BuildBaseContextsArgs,\n} from \"./BuildBaseContexts\";\nimport { GetWeb3CheckTask } from \"./GetWeb3CheckTask\";\n\ndescribe(\"BuildBaseContexts\", () => {\n const contextModuleMock = {\n getFieldContext: vi.fn(),\n getContexts: vi.fn(),\n getTypedDataFilters: vi.fn(),\n getWeb3Checks: vi.fn(),\n getSolanaContext: vi.fn(),\n };\n const defaultOptions = {\n domain: \"domain-name.eth\",\n };\n const defaultTransaction: Uint8Array = hexaStringToBuffer(\n Transaction.from({\n chainId: 1n,\n nonce: 0,\n data: \"0x\",\n }).unsignedSerialized,\n )!;\n const defaultCertificate: PkiCertificate = {\n keyUsageNumber: 1,\n payload: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n let defaultArgs: BuildBaseContextsArgs;\n const apiMock = makeDeviceActionInternalApiMock();\n const getWeb3ChecksFactoryMock = vi.fn();\n\n function createAppConfig(\n web3ChecksEnabled: boolean,\n ): GetConfigCommandResponse {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled,\n web3ChecksOptIn: false,\n version: \"1.13.0\",\n };\n }\n\n beforeEach(() => {\n vi.resetAllMocks();\n apiMock.sendCommand.mockResolvedValue(\n CommandResultFactory({ data: { challenge: \"challenge\" } }),\n );\n getWeb3ChecksFactoryMock.mockReturnValue({\n run: async () => Promise.resolve({ web3Check: null }),\n });\n\n defaultArgs = {\n contextModule: contextModuleMock,\n subset: { chainId: 1, to: undefined, data: \"0x\", selector: \"0x\" },\n transaction: defaultTransaction,\n options: defaultOptions,\n appConfig: createAppConfig(false),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n });\n\n it(\"should init with a default GetWeb3CheckTaskFactory\", () => {\n // GIVEN\n const task = new BuildBaseContexts(apiMock, defaultArgs);\n\n // THEN\n expect(task[\"getWeb3ChecksFactory\"]).toBeDefined();\n expect(\n task[\"getWeb3ChecksFactory\"](apiMock, {\n contextModule: defaultArgs.contextModule,\n derivationPath: defaultArgs.derivationPath,\n subset: defaultArgs.subset,\n transaction: defaultArgs.transaction!,\n }),\n ).toBeInstanceOf(GetWeb3CheckTask);\n });\n\n it(\"should build the transaction context without clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n const clearSignContextsOptional: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with web3checks\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n const clearSignContextsOptional: ClearSignContext[] = [];\n const expectedWeb3Check = {\n type: ClearSignContextType.WEB3_CHECK,\n payload: \"web3Check\",\n };\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce([...clearSignContexts]);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [expectedWeb3Check, ...clearSignContexts],\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with web3checks and generic-parser clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n ];\n const expectedWeb3Check = {\n type: ClearSignContextType.WEB3_CHECK,\n payload: \"web3Check\",\n };\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce([...clearSignContexts]);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n expectedWeb3Check,\n clearSignContexts[0],\n clearSignContexts[1],\n clearSignContexts[3],\n ],\n clearSignContextsOptional: [clearSignContexts[2]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with web3checks and generic-parser clear sign contexts in the correct order\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n ];\n const expectedWeb3Check = {\n type: ClearSignContextType.WEB3_CHECK,\n payload: \"web3Check\",\n };\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce([...clearSignContexts]);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n expectedWeb3Check, // web3 check\n clearSignContexts[3], // transaction info\n clearSignContexts[1], // transaction field description\n clearSignContexts[2], // transaction field description\n ],\n clearSignContextsOptional: [clearSignContexts[0]], // enum\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n const expectedWeb3Check = {\n type: ClearSignContextType.WEB3_CHECK,\n payload: \"web3Check\",\n };\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with generic-parser context\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n clearSignContexts[0],\n clearSignContexts[1],\n clearSignContexts[3],\n ],\n clearSignContextsOptional: [clearSignContexts[2]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with proxy delegate call context\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.PROXY_INFO,\n payload: \"payload-2\",\n },\n ];\n const clearSignContextsOptional: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[0]],\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should call the web3checks factory with correct parameters\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(getWeb3ChecksFactoryMock).toHaveBeenCalledWith(apiMock, {\n contextModule: contextModuleMock,\n derivationPath: \"44'/60'/0'/0/0\",\n subset: defaultArgs.subset,\n transaction: defaultTransaction,\n });\n });\n\n it(\"should call the context module with the correct parameters\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.FLEX,\n challenge: \"challenge\",\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n });\n });\n\n it(\"should call the context module without challenge for Nano S\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.NANO_S,\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n });\n });\n\n it(\"should call the context module without context on error\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ error: new UnknownDeviceExchangeError() }),\n );\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.FLEX,\n challenge: undefined,\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n });\n });\n\n it(\"should exclude error contexts from the result\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result on old apps\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"transaction_info\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result if no transaction_info was found\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude legacy contexts from the result for generic-parser transactions\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-5\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [clearSignContexts[4]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should exclude generic-parser contexts with a nano s device\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts with an old app version\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts with a non ready device\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.NOT_CONNECTED,\n deviceModelId: DeviceModelId.FLEX,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should return no clear sign context if the transaction info certificate is missing\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.17.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should not return web3check if the transaction is undefined\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.17.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, transaction: undefined },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(getWeb3ChecksFactoryMock).not.toHaveBeenCalled();\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAIO,oCACPC,EAOO,2CACPC,EAA4B,kBAG5BC,EAAiC,uCACjCC,EAAgD,6EAEhDC,EAGO,+BACPC,EAAiC,8BAEjC,SAAS,oBAAqB,IAAM,CAClC,MAAMC,EAAoB,CACxB,gBAAiB,GAAG,GAAG,EACvB,YAAa,GAAG,GAAG,EACnB,oBAAqB,GAAG,GAAG,EAC3B,cAAe,GAAG,GAAG,EACrB,iBAAkB,GAAG,GAAG,CAC1B,EACMC,EAAiB,CACrB,OAAQ,iBACV,EACMC,KAAiC,sBACrC,cAAY,KAAK,CACf,QAAS,GACT,MAAO,EACP,KAAM,IACR,CAAC,EAAE,kBACL,EACMC,EAAqC,CACzC,eAAgB,EAChB,QAAS,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,CAC5C,EAEA,IAAIC,EACJ,MAAMC,KAAU,mCAAgC,EAC1CC,EAA2B,GAAG,GAAG,EAEvC,SAASC,EACPC,EAC0B,CAC1B,MAAO,CACL,oBAAqB,GACrB,kBAAAA,EACA,gBAAiB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CAChD,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,WAAY,QAAS,QAAS,EAClD,cAAe,gBAAc,KAC7B,0BAA2B,EAC7B,CAAC,EAGD,MAAM,IAAI,oBACRA,EACA,CAAE,GAAGD,EAAa,YAAa,MAAU,EACzCE,CACF,EAAE,IAAI,EAGN,OAAOA,CAAwB,EAAE,IAAI,iBAAiB,CACxD,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_context_module", "import_device_management_kit", "import_ethers", "import_ClearSigningType", "import_makeInternalApi", "import_BuildBaseContexts", "import_GetWeb3CheckTask", "contextModuleMock", "defaultOptions", "defaultTransaction", "defaultCertificate", "defaultArgs", "apiMock", "getWeb3ChecksFactoryMock", "createAppConfig", "web3ChecksEnabled", "task", "clearSignContexts", "clearSignContextsOptional", "result", "expectedWeb3Check"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var c=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var b=(n,e)=>{for(var
|
|
1
|
+
"use strict";var c=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var b=(n,e)=>{for(var o in e)c(n,o,{get:e[o],enumerable:!0})},m=(n,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of T(e))!S.call(n,s)&&s!==o&&c(n,s,{get:()=>e[s],enumerable:!(r=g(e,s))||r.enumerable});return n};var h=n=>m(c({},"__esModule",{value:!0}),n);var _={};b(_,{BuildFullContextsTask:()=>p});module.exports=h(_);var l=require("@ledgerhq/context-module"),u=require("./BuildBaseContexts"),d=require("./BuildSubcontextsTask"),x=require("./ParseNestedTransactionTask");class p{constructor(e,o,r=(t,a)=>new d.BuildSubcontextsTask(t,a),s=(t,a)=>new u.BuildBaseContexts(t,a),i=t=>new x.ParseNestedTransactionTask(t)){this._api=e;this._args=o;this._buildSubcontextsTaskFactory=r;this._buildBaseContextsTaskFactory=s;this._preBuildNestedCallDataTaskFactory=i}async run(){const{clearSignContexts:e,clearSigningType:o,clearSignContextsOptional:r}=await this._buildBaseContextsTaskFactory(this._api,this._args).run(),s=e.map(t=>{const{subcontextCallbacks:a}=this._buildSubcontextsTaskFactory(this._api,{context:t,contextOptional:r,contextModule:this._args.contextModule,subset:this._args.subset,transactionParser:this._args.parser,deviceModelId:this._args.deviceModelId}).run();return{context:t,subcontextCallbacks:a}}),i=[];for(const t of s)if(i.push(t),t.context.type===l.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION&&t.context.reference?.type===l.ClearSignContextReferenceType.CALLDATA){const{subsets:a}=this._preBuildNestedCallDataTaskFactory({parser:this._args.parser,subset:this._args.subset,context:t.context}).run();for(const C of a){const{clearSignContexts:y}=await new p(this._api,{...this._args,subset:C},this._buildSubcontextsTaskFactory,this._buildBaseContextsTaskFactory,this._preBuildNestedCallDataTaskFactory).run();i.push(...y)}}return{clearSignContexts:i,clearSigningType:o}}}0&&(module.exports={BuildFullContextsTask});
|
|
2
2
|
//# sourceMappingURL=BuildFullContextsTask.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/task/BuildFullContextsTask.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type ClearSignContext,\n ClearSignContextReferenceType,\n type ClearSignContextSuccess,\n ClearSignContextType,\n type ContextModule,\n type TransactionSubset,\n} from \"@ledgerhq/context-module\";\nimport {\n type DeviceModelId,\n type InternalApi,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { type ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { type TransactionOptions } from \"@api/model/TransactionOptions\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nimport {\n BuildBaseContexts,\n type BuildBaseContextsArgs,\n} from \"./BuildBaseContexts\";\nimport {\n BuildSubcontextsTask,\n type BuildSubcontextsTaskArgs,\n} from \"./BuildSubcontextsTask\";\nimport {\n ParseNestedTransactionTask,\n type ParseNestedTransactionTaskArgs,\n} from \"./ParseNestedTransactionTask\";\n\nexport type BuildFullContextsTaskResult = {\n readonly clearSignContexts: ContextWithSubContexts[];\n readonly clearSigningType: ClearSigningType;\n};\n\nexport type BuildFullContextsTaskArgs = {\n readonly contextModule: ContextModule;\n readonly mapper: TransactionMapperService;\n readonly parser: TransactionParserService;\n readonly options: TransactionOptions;\n readonly appConfig: GetConfigCommandResponse;\n readonly derivationPath: string;\n readonly subset: TransactionSubset;\n readonly deviceModelId: DeviceModelId;\n readonly transaction?: Uint8Array;\n};\n\nexport type ContextWithSubContexts = {\n context: ClearSignContextSuccess;\n subcontextCallbacks: (() => Promise<ClearSignContext>)[];\n};\n\nexport class BuildFullContextsTask {\n constructor(\n private readonly _api: InternalApi,\n private readonly _args: BuildFullContextsTaskArgs,\n private readonly _buildSubcontextsTaskFactory = (\n api: InternalApi,\n args: BuildSubcontextsTaskArgs,\n ) => new BuildSubcontextsTask(api, args),\n private readonly _buildBaseContextsTaskFactory = (\n api: InternalApi,\n args: BuildBaseContextsArgs,\n ) => new BuildBaseContexts(api, args),\n private readonly _preBuildNestedCallDataTaskFactory = (\n args: ParseNestedTransactionTaskArgs,\n ) => new ParseNestedTransactionTask(args),\n ) {}\n\n async run(): Promise<BuildFullContextsTaskResult> {\n // get the base contexts\n const { clearSignContexts, clearSigningType, clearSignContextsOptional } =\n await this._buildBaseContextsTaskFactory(this._api, this._args).run();\n\n // for each context, build the subcontexts\n const contextsWithSubContexts: ContextWithSubContexts[] =\n clearSignContexts.map((context: ClearSignContextSuccess) => {\n const { subcontextCallbacks } = this._buildSubcontextsTaskFactory(\n this._api,\n {\n context,\n contextOptional: clearSignContextsOptional,\n contextModule: this._args.contextModule,\n subset: this._args.subset,\n transactionParser: this._args.parser,\n deviceModelId: this._args.deviceModelId,\n },\n ).run();\n\n return {\n context,\n subcontextCallbacks,\n };\n });\n\n // recursively build the nested contexts\n
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,2BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAOO,oCAYPC,EAGO,+BACPC,EAGO,kCACPC,EAGO,wCAwBA,MAAML,CAAsB,CACjC,YACmBM,EACAC,EACAC,EAA+B,CAC9CC,EACAC,IACG,IAAI,uBAAqBD,EAAKC,CAAI,EACtBC,EAAgC,CAC/CF,EACAC,IACG,IAAI,oBAAkBD,EAAKC,CAAI,EACnBE,EACfF,GACG,IAAI,6BAA2BA,CAAI,EACxC,CAbiB,UAAAJ,EACA,WAAAC,EACA,kCAAAC,EAIA,mCAAAG,EAIA,wCAAAC,CAGhB,CAEH,MAAM,KAA4C,CAEhD,KAAM,CAAE,kBAAAC,EAAmB,iBAAAC,EAAkB,0BAAAC,CAA0B,EACrE,MAAM,KAAK,8BAA8B,KAAK,KAAM,KAAK,KAAK,EAAE,IAAI,EAGhEC,EACJH,EAAkB,IAAKI,GAAqC,CAC1D,KAAM,CAAE,oBAAAC,CAAoB,EAAI,KAAK,6BACnC,KAAK,KACL,CACE,QAAAD,EACA,gBAAiBF,EACjB,cAAe,KAAK,MAAM,cAC1B,OAAQ,KAAK,MAAM,OACnB,kBAAmB,KAAK,MAAM,OAC9B,cAAe,KAAK,MAAM,aAC5B,CACF,EAAE,IAAI,EAEN,MAAO,CACL,QAAAE,EACA,oBAAAC,CACF,CACF,CAAC,
|
|
4
|
+
"sourcesContent": ["import {\n type ClearSignContext,\n ClearSignContextReferenceType,\n type ClearSignContextSuccess,\n ClearSignContextType,\n type ContextModule,\n type TransactionSubset,\n} from \"@ledgerhq/context-module\";\nimport {\n type DeviceModelId,\n type InternalApi,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { type ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { type TransactionOptions } from \"@api/model/TransactionOptions\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nimport {\n BuildBaseContexts,\n type BuildBaseContextsArgs,\n} from \"./BuildBaseContexts\";\nimport {\n BuildSubcontextsTask,\n type BuildSubcontextsTaskArgs,\n} from \"./BuildSubcontextsTask\";\nimport {\n ParseNestedTransactionTask,\n type ParseNestedTransactionTaskArgs,\n} from \"./ParseNestedTransactionTask\";\n\nexport type BuildFullContextsTaskResult = {\n readonly clearSignContexts: ContextWithSubContexts[];\n readonly clearSigningType: ClearSigningType;\n};\n\nexport type BuildFullContextsTaskArgs = {\n readonly contextModule: ContextModule;\n readonly mapper: TransactionMapperService;\n readonly parser: TransactionParserService;\n readonly options: TransactionOptions;\n readonly appConfig: GetConfigCommandResponse;\n readonly derivationPath: string;\n readonly subset: TransactionSubset;\n readonly deviceModelId: DeviceModelId;\n readonly transaction?: Uint8Array;\n};\n\nexport type ContextWithSubContexts = {\n context: ClearSignContextSuccess;\n subcontextCallbacks: (() => Promise<ClearSignContext>)[];\n};\n\nexport class BuildFullContextsTask {\n constructor(\n private readonly _api: InternalApi,\n private readonly _args: BuildFullContextsTaskArgs,\n private readonly _buildSubcontextsTaskFactory = (\n api: InternalApi,\n args: BuildSubcontextsTaskArgs,\n ) => new BuildSubcontextsTask(api, args),\n private readonly _buildBaseContextsTaskFactory = (\n api: InternalApi,\n args: BuildBaseContextsArgs,\n ) => new BuildBaseContexts(api, args),\n private readonly _preBuildNestedCallDataTaskFactory = (\n args: ParseNestedTransactionTaskArgs,\n ) => new ParseNestedTransactionTask(args),\n ) {}\n\n async run(): Promise<BuildFullContextsTaskResult> {\n // get the base contexts\n const { clearSignContexts, clearSigningType, clearSignContextsOptional } =\n await this._buildBaseContextsTaskFactory(this._api, this._args).run();\n\n // for each context, build the subcontexts\n const contextsWithSubContexts: ContextWithSubContexts[] =\n clearSignContexts.map((context: ClearSignContextSuccess) => {\n const { subcontextCallbacks } = this._buildSubcontextsTaskFactory(\n this._api,\n {\n context,\n contextOptional: clearSignContextsOptional,\n contextModule: this._args.contextModule,\n subset: this._args.subset,\n transactionParser: this._args.parser,\n deviceModelId: this._args.deviceModelId,\n },\n ).run();\n\n return {\n context,\n subcontextCallbacks,\n };\n });\n\n // recursively build the nested contexts\n const contextWithNestedContexts: ContextWithSubContexts[] = [];\n for (const context of contextsWithSubContexts) {\n contextWithNestedContexts.push(context);\n\n if (\n context.context.type ===\n ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION &&\n context.context.reference?.type ===\n ClearSignContextReferenceType.CALLDATA\n ) {\n const { subsets } = this._preBuildNestedCallDataTaskFactory({\n parser: this._args.parser,\n subset: this._args.subset,\n context: context.context,\n }).run();\n\n for (const subset of subsets) {\n const { clearSignContexts: nestedContexts } =\n await new BuildFullContextsTask(\n this._api,\n {\n ...this._args,\n subset,\n },\n // inject the factories for testing\n this._buildSubcontextsTaskFactory,\n this._buildBaseContextsTaskFactory,\n this._preBuildNestedCallDataTaskFactory,\n ).run();\n\n // Contexts order as expected by the Ethereum application:\n // * previous contexts\n // * calldata field from the parent\n // * list of nested transactions infos and nested fields\n contextWithNestedContexts.push(...nestedContexts);\n }\n }\n }\n\n return {\n clearSignContexts: contextWithNestedContexts,\n clearSigningType,\n };\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,2BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAOO,oCAYPC,EAGO,+BACPC,EAGO,kCACPC,EAGO,wCAwBA,MAAML,CAAsB,CACjC,YACmBM,EACAC,EACAC,EAA+B,CAC9CC,EACAC,IACG,IAAI,uBAAqBD,EAA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F,CACF,CACF",
|
|
6
6
|
"names": ["BuildFullContextsTask_exports", "__export", "BuildFullContextsTask", "__toCommonJS", "import_context_module", "import_BuildBaseContexts", "import_BuildSubcontextsTask", "import_ParseNestedTransactionTask", "_api", "_args", "_buildSubcontextsTaskFactory", "api", "args", "_buildBaseContextsTaskFactory", "_preBuildNestedCallDataTaskFactory", "clearSignContexts", "clearSigningType", "clearSignContextsOptional", "contextsWithSubContexts", "context", "subcontextCallbacks", "contextWithNestedContexts", "subsets", "subset", "nestedContexts"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("@ledgerhq/context-module"),c=require("@ledgerhq/device-management-kit"),o=require("../../../api/model/ClearSigningType"),b=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),A=require("./BuildBaseContexts"),l=require("./BuildFullContextsTask"),N=require("./BuildSubcontextsTask"),g=require("./ParseNestedTransactionTask");describe("BuildFullContextsTask",()=>{const n=(0,b.makeDeviceActionInternalApiMock)(),p={},i={},r={},d={blindSigningEnabled:!1,web3ChecksEnabled:!1,web3ChecksOptIn:!1,version:"1.0.0"},u={},y={chainId:1,data:"0x",selector:"0x"},x="44'/60'/0'/0/0",T=vi.fn(),C=(a,t)=>({run:T}),s=vi.fn(),S=(a,t)=>({run:s}),k=vi.fn(),I=a=>({run:k});describe("Init",()=>{it("should init with defaults tasks",()=>{const a=new l.BuildFullContextsTask(n,{contextModule:p,mapper:i,parser:r,options:u,appConfig:d,derivationPath:x,subset:y,deviceModelId:c.DeviceModelId.STAX});expect(a).toBeDefined(),expect(a._buildSubcontextsTaskFactory(n,{})).toBeInstanceOf(N.BuildSubcontextsTask),expect(a._buildBaseContextsTaskFactory(n,{})).toBeInstanceOf(A.BuildBaseContexts),expect(a._preBuildNestedCallDataTaskFactory({})).toBeInstanceOf(g.ParseNestedTransactionTask)})}),describe("Happy path",()=>{beforeEach(()=>{vi.resetAllMocks()}),it("should build with no context",async()=>{s.mockReturnValue({clearSignContexts:[],clearSignContextsOptional:[],clearSigningType:o.ClearSigningType.BASIC});const t=await new l.BuildFullContextsTask(n,{contextModule:p,mapper:i,parser:r,options:u,appConfig:d,derivationPath:x,subset:y,deviceModelId:c.DeviceModelId.STAX},C,S,I).run();expect(t).toEqual({clearSignContexts:[],clearSigningType:o.ClearSigningType.BASIC})}),it("should build with multiple contexts and no subcontexts",async()=>{s.mockReturnValueOnce({clearSignContexts:[{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"}],clearSigningType:o.ClearSigningType.EIP7730}),T.mockReturnValue({subcontextCallbacks:[]});const t=await new l.BuildFullContextsTask(n,{contextModule:p,mapper:i,parser:r,options:u,appConfig:d,derivationPath:x,subset:y,deviceModelId:c.DeviceModelId.STAX},C,S,I).run();expect(t).toEqual({clearSignContexts:[{context:{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},subcontextCallbacks:[]},{context:{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},subcontextCallbacks:[]},{context:{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},subcontextCallbacks:[]}],clearSigningType:o.ClearSigningType.EIP7730})}),it("should build with multiple contexts and subcontexts",async()=>{s.mockReturnValueOnce({clearSignContexts:[{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"}],clearSignContextsOptional:[],clearSigningType:o.ClearSigningType.EIP7730}),T.mockReturnValueOnce({subcontextCallbacks:[]}),T.mockReturnValueOnce({subcontextCallbacks:[()=>Promise.resolve({type:e.ClearSignContextType.TOKEN,payload:"payload-3"}),()=>Promise.resolve({type:e.ClearSignContextType.TOKEN,payload:"payload-4"})]});const t=await new l.BuildFullContextsTask(n,{contextModule:p,mapper:i,parser:r,options:u,appConfig:d,derivationPath:x,subset:y,deviceModelId:c.DeviceModelId.STAX},C,S,I).run();expect(t.clearSignContexts[0]).toEqual({context:{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},subcontextCallbacks:[]}),expect(t.clearSignContexts[1]).toEqual({context:{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},subcontextCallbacks:[expect.any(Function),expect.any(Function)]}),await expect(t.clearSignContexts[1].subcontextCallbacks[0]()).resolves.toEqual({type:e.ClearSignContextType.TOKEN,payload:"payload-3"}),await expect(t.clearSignContexts[1].subcontextCallbacks[1]()).resolves.toEqual({type:e.ClearSignContextType.TOKEN,payload:"payload-4"})}),it("should build with nested contexts",async()=>{s.mockReturnValueOnce({clearSignContexts:[{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2",reference:{type:e.ClearSignContextReferenceType.CALLDATA,subset:{chainId:1,data:"0x",selector:"0x"}}}],clearSigningType:o.ClearSigningType.EIP7730}),s.mockReturnValueOnce({clearSignContexts:[{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"payload-3"},{type:e.ClearSignContextType.TOKEN,payload:"payload-4"}],clearSignContextsOptional:[],clearSigningType:o.ClearSigningType.EIP7730}),T.mockReturnValue({subcontextCallbacks:[]}),k.mockReturnValue({subsets:[{chainId:1,data:"0x",selector:"0x"}]});const t=await new l.BuildFullContextsTask(n,{contextModule:p,mapper:i,parser:r,options:u,appConfig:d,derivationPath:x,subset:y,deviceModelId:c.DeviceModelId.STAX},C,S,I).run();expect(t).toEqual({clearSignContexts:expect.any(Array),clearSigningType:o.ClearSigningType.EIP7730}),expect(t.clearSignContexts[0]).toEqual({context:{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},subcontextCallbacks:[]}),expect(t.clearSignContexts[1]).toEqual({context:{type:e.ClearSignContextType.
|
|
1
|
+
"use strict";var e=require("@ledgerhq/context-module"),c=require("@ledgerhq/device-management-kit"),o=require("../../../api/model/ClearSigningType"),b=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),A=require("./BuildBaseContexts"),l=require("./BuildFullContextsTask"),N=require("./BuildSubcontextsTask"),g=require("./ParseNestedTransactionTask");describe("BuildFullContextsTask",()=>{const n=(0,b.makeDeviceActionInternalApiMock)(),p={},i={},r={},d={blindSigningEnabled:!1,web3ChecksEnabled:!1,web3ChecksOptIn:!1,version:"1.0.0"},u={},y={chainId:1,data:"0x",selector:"0x"},x="44'/60'/0'/0/0",T=vi.fn(),C=(a,t)=>({run:T}),s=vi.fn(),S=(a,t)=>({run:s}),k=vi.fn(),I=a=>({run:k});describe("Init",()=>{it("should init with defaults tasks",()=>{const a=new l.BuildFullContextsTask(n,{contextModule:p,mapper:i,parser:r,options:u,appConfig:d,derivationPath:x,subset:y,deviceModelId:c.DeviceModelId.STAX});expect(a).toBeDefined(),expect(a._buildSubcontextsTaskFactory(n,{})).toBeInstanceOf(N.BuildSubcontextsTask),expect(a._buildBaseContextsTaskFactory(n,{})).toBeInstanceOf(A.BuildBaseContexts),expect(a._preBuildNestedCallDataTaskFactory({})).toBeInstanceOf(g.ParseNestedTransactionTask)})}),describe("Happy path",()=>{beforeEach(()=>{vi.resetAllMocks()}),it("should build with no context",async()=>{s.mockReturnValue({clearSignContexts:[],clearSignContextsOptional:[],clearSigningType:o.ClearSigningType.BASIC});const t=await new l.BuildFullContextsTask(n,{contextModule:p,mapper:i,parser:r,options:u,appConfig:d,derivationPath:x,subset:y,deviceModelId:c.DeviceModelId.STAX},C,S,I).run();expect(t).toEqual({clearSignContexts:[],clearSigningType:o.ClearSigningType.BASIC})}),it("should build with multiple contexts and no subcontexts",async()=>{s.mockReturnValueOnce({clearSignContexts:[{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"}],clearSigningType:o.ClearSigningType.EIP7730}),T.mockReturnValue({subcontextCallbacks:[]});const t=await new l.BuildFullContextsTask(n,{contextModule:p,mapper:i,parser:r,options:u,appConfig:d,derivationPath:x,subset:y,deviceModelId:c.DeviceModelId.STAX},C,S,I).run();expect(t).toEqual({clearSignContexts:[{context:{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},subcontextCallbacks:[]},{context:{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},subcontextCallbacks:[]},{context:{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},subcontextCallbacks:[]}],clearSigningType:o.ClearSigningType.EIP7730})}),it("should build with multiple contexts and subcontexts",async()=>{s.mockReturnValueOnce({clearSignContexts:[{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"}],clearSignContextsOptional:[],clearSigningType:o.ClearSigningType.EIP7730}),T.mockReturnValueOnce({subcontextCallbacks:[]}),T.mockReturnValueOnce({subcontextCallbacks:[()=>Promise.resolve({type:e.ClearSignContextType.TOKEN,payload:"payload-3"}),()=>Promise.resolve({type:e.ClearSignContextType.TOKEN,payload:"payload-4"})]});const t=await new l.BuildFullContextsTask(n,{contextModule:p,mapper:i,parser:r,options:u,appConfig:d,derivationPath:x,subset:y,deviceModelId:c.DeviceModelId.STAX},C,S,I).run();expect(t.clearSignContexts[0]).toEqual({context:{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},subcontextCallbacks:[]}),expect(t.clearSignContexts[1]).toEqual({context:{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},subcontextCallbacks:[expect.any(Function),expect.any(Function)]}),await expect(t.clearSignContexts[1].subcontextCallbacks[0]()).resolves.toEqual({type:e.ClearSignContextType.TOKEN,payload:"payload-3"}),await expect(t.clearSignContexts[1].subcontextCallbacks[1]()).resolves.toEqual({type:e.ClearSignContextType.TOKEN,payload:"payload-4"})}),it("should build with nested contexts",async()=>{s.mockReturnValueOnce({clearSignContexts:[{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2",reference:{type:e.ClearSignContextReferenceType.CALLDATA,subset:{chainId:1,data:"0x",selector:"0x"}}}],clearSigningType:o.ClearSigningType.EIP7730}),s.mockReturnValueOnce({clearSignContexts:[{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"payload-3"},{type:e.ClearSignContextType.TOKEN,payload:"payload-4"}],clearSignContextsOptional:[],clearSigningType:o.ClearSigningType.EIP7730}),T.mockReturnValue({subcontextCallbacks:[]}),k.mockReturnValue({subsets:[{chainId:1,data:"0x",selector:"0x"}]});const t=await new l.BuildFullContextsTask(n,{contextModule:p,mapper:i,parser:r,options:u,appConfig:d,derivationPath:x,subset:y,deviceModelId:c.DeviceModelId.STAX},C,S,I).run();expect(t).toEqual({clearSignContexts:expect.any(Array),clearSigningType:o.ClearSigningType.EIP7730}),expect(t.clearSignContexts[0]).toEqual({context:{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},subcontextCallbacks:[]}),expect(t.clearSignContexts[1]).toEqual({context:{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2",reference:{type:e.ClearSignContextReferenceType.CALLDATA,subset:{chainId:1,data:"0x",selector:"0x"}}},subcontextCallbacks:[]}),expect(t.clearSignContexts[2]).toEqual({context:{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"payload-3"},subcontextCallbacks:[]}),expect(t.clearSignContexts[3]).toEqual({context:{type:e.ClearSignContextType.TOKEN,payload:"payload-4"},subcontextCallbacks:[]})})})});
|
|
2
2
|
//# sourceMappingURL=BuildFullContextsTask.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/task/BuildFullContextsTask.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ClearSignContextReferenceType,\n ClearSignContextType,\n type ContextModule,\n type TransactionSubset,\n} from \"@ledgerhq/context-module\";\nimport {\n DeviceModelId,\n type InternalApi,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { type TransactionOptions } from \"@api/index\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nimport {\n BuildBaseContexts,\n type BuildBaseContextsArgs,\n} from \"./BuildBaseContexts\";\nimport { BuildFullContextsTask } from \"./BuildFullContextsTask\";\nimport {\n BuildSubcontextsTask,\n type BuildSubcontextsTaskArgs,\n} from \"./BuildSubcontextsTask\";\nimport {\n ParseNestedTransactionTask,\n type ParseNestedTransactionTaskArgs,\n} from \"./ParseNestedTransactionTask\";\n\ndescribe(\"BuildFullContextsTask\", () => {\n const apiMock = makeDeviceActionInternalApiMock();\n const contextModuleMock = {} as ContextModule;\n const mapperMock = {} as TransactionMapperService;\n const parserMock = {} as TransactionParserService;\n\n const defaultAppConfig: GetConfigCommandResponse = {\n blindSigningEnabled: false,\n web3ChecksEnabled: false,\n web3ChecksOptIn: false,\n version: \"1.0.0\",\n };\n const defaultOptions: TransactionOptions = {};\n const defaultSubset: TransactionSubset = {\n chainId: 1,\n data: \"0x\",\n selector: \"0x\",\n };\n const defaultDerivationPath = \"44'/60'/0'/0/0\";\n\n const buildSubContextTaskRunMock = vi.fn();\n const buildSubcontextsTaskFactory = (\n _api: InternalApi,\n _args: BuildSubcontextsTaskArgs,\n ) =>\n ({\n run: buildSubContextTaskRunMock,\n }) as unknown as BuildSubcontextsTask;\n\n const buildBaseContextsTaskRunMock = vi.fn();\n const buildBaseContextsTaskFactory = (\n _api: InternalApi,\n _args: BuildBaseContextsArgs,\n ) =>\n ({\n run: buildBaseContextsTaskRunMock,\n }) as unknown as BuildBaseContexts;\n\n const parseNestedTransactionTaskRunMock = vi.fn();\n const parseNestedTransactionTaskFactory = (\n _args: ParseNestedTransactionTaskArgs,\n ) =>\n ({\n run: parseNestedTransactionTaskRunMock,\n }) as unknown as ParseNestedTransactionTask;\n\n describe(\"Init\", () => {\n it(\"should init with defaults tasks\", () => {\n const task = new BuildFullContextsTask(apiMock, {\n contextModule: contextModuleMock,\n mapper: mapperMock,\n parser: parserMock,\n options: defaultOptions,\n appConfig: defaultAppConfig,\n derivationPath: defaultDerivationPath,\n subset: defaultSubset,\n deviceModelId: DeviceModelId.STAX,\n });\n\n expect(task).toBeDefined();\n expect(\n task[\"_buildSubcontextsTaskFactory\"](\n apiMock,\n {} as BuildSubcontextsTaskArgs,\n ),\n ).toBeInstanceOf(BuildSubcontextsTask);\n expect(\n task[\"_buildBaseContextsTaskFactory\"](\n apiMock,\n {} as BuildBaseContextsArgs,\n ),\n ).toBeInstanceOf(BuildBaseContexts);\n expect(\n task[\"_preBuildNestedCallDataTaskFactory\"](\n {} as ParseNestedTransactionTaskArgs,\n ),\n ).toBeInstanceOf(ParseNestedTransactionTask);\n });\n });\n\n describe(\"Happy path\", () => {\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should build with no context\", async () => {\n // GIVEN\n buildBaseContextsTaskRunMock.mockReturnValue({\n clearSignContexts: [],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n\n const task = new BuildFullContextsTask(\n apiMock,\n {\n contextModule: contextModuleMock,\n mapper: mapperMock,\n parser: parserMock,\n options: defaultOptions,\n appConfig: defaultAppConfig,\n derivationPath: defaultDerivationPath,\n subset: defaultSubset,\n deviceModelId: DeviceModelId.STAX,\n },\n buildSubcontextsTaskFactory,\n buildBaseContextsTaskFactory,\n parseNestedTransactionTaskFactory,\n );\n\n // WHEN\n const result = await task.run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build with multiple contexts and no subcontexts\", async () => {\n // GIVEN\n buildBaseContextsTaskRunMock.mockReturnValueOnce({\n clearSignContexts: [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n ],\n clearSigningType: ClearSigningType.EIP7730,\n });\n buildSubContextTaskRunMock.mockReturnValue({\n subcontextCallbacks: [],\n });\n\n const task = new BuildFullContextsTask(\n apiMock,\n {\n contextModule: contextModuleMock,\n mapper: mapperMock,\n parser: parserMock,\n options: defaultOptions,\n appConfig: defaultAppConfig,\n derivationPath: defaultDerivationPath,\n subset: defaultSubset,\n deviceModelId: DeviceModelId.STAX,\n },\n buildSubcontextsTaskFactory,\n buildBaseContextsTaskFactory,\n parseNestedTransactionTaskFactory,\n );\n\n // WHEN\n const result = await task.run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n {\n context: {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n subcontextCallbacks: [],\n },\n {\n context: {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n subcontextCallbacks: [],\n },\n {\n context: {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n subcontextCallbacks: [],\n },\n ],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build with multiple contexts and subcontexts\", async () => {\n // GIVEN\n buildBaseContextsTaskRunMock.mockReturnValueOnce({\n clearSignContexts: [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n ],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.EIP7730,\n });\n buildSubContextTaskRunMock.mockReturnValueOnce({\n subcontextCallbacks: [],\n });\n buildSubContextTaskRunMock.mockReturnValueOnce({\n subcontextCallbacks: [\n () =>\n Promise.resolve({\n type: ClearSignContextType.TOKEN,\n payload: \"payload-3\",\n }),\n () =>\n Promise.resolve({\n type: ClearSignContextType.TOKEN,\n payload: \"payload-4\",\n }),\n ],\n });\n\n const task = new BuildFullContextsTask(\n apiMock,\n {\n contextModule: contextModuleMock,\n mapper: mapperMock,\n parser: parserMock,\n options: defaultOptions,\n appConfig: defaultAppConfig,\n derivationPath: defaultDerivationPath,\n subset: defaultSubset,\n deviceModelId: DeviceModelId.STAX,\n },\n buildSubcontextsTaskFactory,\n buildBaseContextsTaskFactory,\n parseNestedTransactionTaskFactory,\n );\n\n // WHEN\n const result = await task.run();\n\n // THEN\n expect(result.clearSignContexts[0]).toEqual({\n context: {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n subcontextCallbacks: [],\n });\n expect(result.clearSignContexts[1]).toEqual({\n context: {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n subcontextCallbacks: [expect.any(Function), expect.any(Function)],\n });\n await expect(\n result.clearSignContexts[1]!.subcontextCallbacks[0]!(),\n ).resolves.toEqual({\n type: ClearSignContextType.TOKEN,\n payload: \"payload-3\",\n });\n await expect(\n result.clearSignContexts[1]!.subcontextCallbacks[1]!(),\n ).resolves.toEqual({\n type: ClearSignContextType.TOKEN,\n payload: \"payload-4\",\n });\n });\n\n it(\"should build with nested contexts\", async () => {\n // GIVEN\n buildBaseContextsTaskRunMock.mockReturnValueOnce({\n clearSignContexts: [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n reference: {\n type: ClearSignContextReferenceType.CALLDATA,\n subset: {\n chainId: 1,\n data: \"0x\",\n selector: \"0x\",\n },\n },\n },\n ],\n clearSigningType: ClearSigningType.EIP7730,\n });\n // nested context\n buildBaseContextsTaskRunMock.mockReturnValueOnce({\n clearSignContexts: [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-4\",\n },\n ],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.EIP7730,\n });\n buildSubContextTaskRunMock.mockReturnValue({\n subcontextCallbacks: [],\n });\n parseNestedTransactionTaskRunMock.mockReturnValue({\n subsets: [\n {\n chainId: 1,\n data: \"0x\",\n selector: \"0x\",\n },\n ],\n });\n\n const task = new BuildFullContextsTask(\n apiMock,\n {\n contextModule: contextModuleMock,\n mapper: mapperMock,\n parser: parserMock,\n options: defaultOptions,\n appConfig: defaultAppConfig,\n derivationPath: defaultDerivationPath,\n subset: defaultSubset,\n deviceModelId: DeviceModelId.STAX,\n },\n buildSubcontextsTaskFactory,\n buildBaseContextsTaskFactory,\n parseNestedTransactionTaskFactory,\n );\n\n // WHEN\n const result = await task.run();\n\n // THEN\n expect(result).toEqual({\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n clearSignContexts: expect.any(Array),\n clearSigningType: ClearSigningType.EIP7730,\n });\n expect(result.clearSignContexts[0]).toEqual({\n context: {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n subcontextCallbacks: [],\n });\n expect(result.clearSignContexts[1]).toEqual({\n context: {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-3\",\n },\n subcontextCallbacks: [],\n });\n expect(result.clearSignContexts[2]).toEqual({\n context: {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-4\",\n },\n subcontextCallbacks: [],\n });\n expect(result.clearSignContexts[3]).toEqual({\n context: {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n reference: {\n type: ClearSignContextReferenceType.CALLDATA,\n subset: {\n chainId: 1,\n data: \"0x\",\n selector: \"0x\",\n },\n },\n },\n subcontextCallbacks: [],\n });\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "aAAA,IAAAA,EAKO,oCACPC,EAGO,2CAIPC,EAAiC,uCACjCC,EAAgD,6EAIhDC,EAGO,+BACPC,EAAsC,mCACtCC,EAGO,kCACPC,EAGO,wCAEP,SAAS,wBAAyB,IAAM,CACtC,MAAMC,KAAU,mCAAgC,EAC1CC,EAAoB,CAAC,EACrBC,EAAa,CAAC,EACdC,EAAa,CAAC,EAEdC,EAA6C,CACjD,oBAAqB,GACrB,kBAAmB,GACnB,gBAAiB,GACjB,QAAS,OACX,EACMC,EAAqC,CAAC,EACtCC,EAAmC,CACvC,QAAS,EACT,KAAM,KACN,SAAU,IACZ,EACMC,EAAwB,iBAExBC,EAA6B,GAAG,GAAG,EACnCC,EAA8B,CAClCC,EACAC,KAEC,CACC,IAAKH,CACP,GAEII,EAA+B,GAAG,GAAG,EACrCC,EAA+B,CACnCH,EACAC,KAEC,CACC,IAAKC,CACP,GAEIE,EAAoC,GAAG,GAAG,EAC1CC,EACJJ,IAEC,CACC,IAAKG,CACP,GAEF,SAAS,OAAQ,IAAM,CACrB,GAAG,kCAAmC,IAAM,CAC1C,MAAME,EAAO,IAAI,wBAAsBhB,EAAS,CAC9C,cAAeC,EACf,OAAQC,EACR,OAAQC,EACR,QAASE,EACT,UAAWD,EACX,eAAgBG,EAChB,OAAQD,EACR,cAAe,gBAAc,IAC/B,CAAC,EAED,OAAOU,CAAI,EAAE,YAAY,EACzB,OACEA,EAAK,6BACHhB,EACA,CAAC,CACH,CACF,EAAE,eAAe,sBAAoB,EACrC,OACEgB,EAAK,8BACHhB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,WACX,EACA,oBAAqB,CAAC,CACxB,CAAC,EACD,OAAOA,EAAO,kBAAkB,CAAC,CAAC,EAAE,QAAQ,CAC1C,QAAS,CACP,KAAM,uBAAqB,
|
|
4
|
+
"sourcesContent": ["import {\n ClearSignContextReferenceType,\n ClearSignContextType,\n type ContextModule,\n type TransactionSubset,\n} from \"@ledgerhq/context-module\";\nimport {\n DeviceModelId,\n type InternalApi,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { type TransactionOptions } from \"@api/index\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nimport {\n BuildBaseContexts,\n type BuildBaseContextsArgs,\n} from \"./BuildBaseContexts\";\nimport { BuildFullContextsTask } from \"./BuildFullContextsTask\";\nimport {\n BuildSubcontextsTask,\n type BuildSubcontextsTaskArgs,\n} from \"./BuildSubcontextsTask\";\nimport {\n ParseNestedTransactionTask,\n type ParseNestedTransactionTaskArgs,\n} from \"./ParseNestedTransactionTask\";\n\ndescribe(\"BuildFullContextsTask\", () => {\n const apiMock = makeDeviceActionInternalApiMock();\n const contextModuleMock = {} as ContextModule;\n const mapperMock = {} as TransactionMapperService;\n const parserMock = {} as TransactionParserService;\n\n const defaultAppConfig: GetConfigCommandResponse = {\n blindSigningEnabled: false,\n web3ChecksEnabled: false,\n web3ChecksOptIn: false,\n version: \"1.0.0\",\n };\n const defaultOptions: TransactionOptions = {};\n const defaultSubset: TransactionSubset = {\n chainId: 1,\n data: \"0x\",\n selector: \"0x\",\n };\n const defaultDerivationPath = \"44'/60'/0'/0/0\";\n\n const buildSubContextTaskRunMock = vi.fn();\n const buildSubcontextsTaskFactory = (\n _api: InternalApi,\n _args: BuildSubcontextsTaskArgs,\n ) =>\n ({\n run: buildSubContextTaskRunMock,\n }) as unknown as BuildSubcontextsTask;\n\n const buildBaseContextsTaskRunMock = vi.fn();\n const buildBaseContextsTaskFactory = (\n _api: InternalApi,\n _args: BuildBaseContextsArgs,\n ) =>\n ({\n run: buildBaseContextsTaskRunMock,\n }) as unknown as BuildBaseContexts;\n\n const parseNestedTransactionTaskRunMock = vi.fn();\n const parseNestedTransactionTaskFactory = (\n _args: ParseNestedTransactionTaskArgs,\n ) =>\n ({\n run: parseNestedTransactionTaskRunMock,\n }) as unknown as ParseNestedTransactionTask;\n\n describe(\"Init\", () => {\n it(\"should init with defaults tasks\", () => {\n const task = new BuildFullContextsTask(apiMock, {\n contextModule: contextModuleMock,\n mapper: mapperMock,\n parser: parserMock,\n options: defaultOptions,\n appConfig: defaultAppConfig,\n derivationPath: defaultDerivationPath,\n subset: defaultSubset,\n deviceModelId: DeviceModelId.STAX,\n });\n\n expect(task).toBeDefined();\n expect(\n task[\"_buildSubcontextsTaskFactory\"](\n apiMock,\n {} as BuildSubcontextsTaskArgs,\n ),\n ).toBeInstanceOf(BuildSubcontextsTask);\n expect(\n task[\"_buildBaseContextsTaskFactory\"](\n apiMock,\n {} as BuildBaseContextsArgs,\n ),\n ).toBeInstanceOf(BuildBaseContexts);\n expect(\n task[\"_preBuildNestedCallDataTaskFactory\"](\n {} as ParseNestedTransactionTaskArgs,\n ),\n ).toBeInstanceOf(ParseNestedTransactionTask);\n });\n });\n\n describe(\"Happy path\", () => {\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should build with no context\", async () => {\n // GIVEN\n buildBaseContextsTaskRunMock.mockReturnValue({\n clearSignContexts: [],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n\n const task = new BuildFullContextsTask(\n apiMock,\n {\n contextModule: contextModuleMock,\n mapper: mapperMock,\n parser: parserMock,\n options: defaultOptions,\n appConfig: defaultAppConfig,\n derivationPath: defaultDerivationPath,\n subset: defaultSubset,\n deviceModelId: DeviceModelId.STAX,\n },\n buildSubcontextsTaskFactory,\n buildBaseContextsTaskFactory,\n parseNestedTransactionTaskFactory,\n );\n\n // WHEN\n const result = await task.run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build with multiple contexts and no subcontexts\", async () => {\n // GIVEN\n buildBaseContextsTaskRunMock.mockReturnValueOnce({\n clearSignContexts: [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n ],\n clearSigningType: ClearSigningType.EIP7730,\n });\n buildSubContextTaskRunMock.mockReturnValue({\n subcontextCallbacks: [],\n });\n\n const task = new BuildFullContextsTask(\n apiMock,\n {\n contextModule: contextModuleMock,\n mapper: mapperMock,\n parser: parserMock,\n options: defaultOptions,\n appConfig: defaultAppConfig,\n derivationPath: defaultDerivationPath,\n subset: defaultSubset,\n deviceModelId: DeviceModelId.STAX,\n },\n buildSubcontextsTaskFactory,\n buildBaseContextsTaskFactory,\n parseNestedTransactionTaskFactory,\n );\n\n // WHEN\n const result = await task.run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n {\n context: {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n subcontextCallbacks: [],\n },\n {\n context: {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n subcontextCallbacks: [],\n },\n {\n context: {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n subcontextCallbacks: [],\n },\n ],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build with multiple contexts and subcontexts\", async () => {\n // GIVEN\n buildBaseContextsTaskRunMock.mockReturnValueOnce({\n clearSignContexts: [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n ],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.EIP7730,\n });\n buildSubContextTaskRunMock.mockReturnValueOnce({\n subcontextCallbacks: [],\n });\n buildSubContextTaskRunMock.mockReturnValueOnce({\n subcontextCallbacks: [\n () =>\n Promise.resolve({\n type: ClearSignContextType.TOKEN,\n payload: \"payload-3\",\n }),\n () =>\n Promise.resolve({\n type: ClearSignContextType.TOKEN,\n payload: \"payload-4\",\n }),\n ],\n });\n\n const task = new BuildFullContextsTask(\n apiMock,\n {\n contextModule: contextModuleMock,\n mapper: mapperMock,\n parser: parserMock,\n options: defaultOptions,\n appConfig: defaultAppConfig,\n derivationPath: defaultDerivationPath,\n subset: defaultSubset,\n deviceModelId: DeviceModelId.STAX,\n },\n buildSubcontextsTaskFactory,\n buildBaseContextsTaskFactory,\n parseNestedTransactionTaskFactory,\n );\n\n // WHEN\n const result = await task.run();\n\n // THEN\n expect(result.clearSignContexts[0]).toEqual({\n context: {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n subcontextCallbacks: [],\n });\n expect(result.clearSignContexts[1]).toEqual({\n context: {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n subcontextCallbacks: [expect.any(Function), expect.any(Function)],\n });\n await expect(\n result.clearSignContexts[1]!.subcontextCallbacks[0]!(),\n ).resolves.toEqual({\n type: ClearSignContextType.TOKEN,\n payload: \"payload-3\",\n });\n await expect(\n result.clearSignContexts[1]!.subcontextCallbacks[1]!(),\n ).resolves.toEqual({\n type: ClearSignContextType.TOKEN,\n payload: \"payload-4\",\n });\n });\n\n it(\"should build with nested contexts\", async () => {\n // GIVEN\n buildBaseContextsTaskRunMock.mockReturnValueOnce({\n clearSignContexts: [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n reference: {\n type: ClearSignContextReferenceType.CALLDATA,\n subset: {\n chainId: 1,\n data: \"0x\",\n selector: \"0x\",\n },\n },\n },\n ],\n clearSigningType: ClearSigningType.EIP7730,\n });\n // nested context\n buildBaseContextsTaskRunMock.mockReturnValueOnce({\n clearSignContexts: [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-4\",\n },\n ],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.EIP7730,\n });\n buildSubContextTaskRunMock.mockReturnValue({\n subcontextCallbacks: [],\n });\n parseNestedTransactionTaskRunMock.mockReturnValue({\n subsets: [\n {\n chainId: 1,\n data: \"0x\",\n selector: \"0x\",\n },\n ],\n });\n\n const task = new BuildFullContextsTask(\n apiMock,\n {\n contextModule: contextModuleMock,\n mapper: mapperMock,\n parser: parserMock,\n options: defaultOptions,\n appConfig: defaultAppConfig,\n derivationPath: defaultDerivationPath,\n subset: defaultSubset,\n deviceModelId: DeviceModelId.STAX,\n },\n buildSubcontextsTaskFactory,\n buildBaseContextsTaskFactory,\n parseNestedTransactionTaskFactory,\n );\n\n // WHEN\n const result = await task.run();\n\n // THEN\n expect(result).toEqual({\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n clearSignContexts: expect.any(Array),\n clearSigningType: ClearSigningType.EIP7730,\n });\n expect(result.clearSignContexts[0]).toEqual({\n context: {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n subcontextCallbacks: [],\n });\n expect(result.clearSignContexts[1]).toEqual({\n context: {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n reference: {\n type: ClearSignContextReferenceType.CALLDATA,\n subset: {\n chainId: 1,\n data: \"0x\",\n selector: \"0x\",\n },\n },\n },\n subcontextCallbacks: [],\n });\n expect(result.clearSignContexts[2]).toEqual({\n context: {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-3\",\n },\n subcontextCallbacks: [],\n });\n expect(result.clearSignContexts[3]).toEqual({\n context: {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-4\",\n },\n subcontextCallbacks: [],\n });\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAKO,oCACPC,EAGO,2CAIPC,EAAiC,uCACjCC,EAAgD,6EAIhDC,EAGO,+BACPC,EAAsC,mCACtCC,EAGO,kCACPC,EAGO,wCAEP,SAAS,wBAAyB,IAAM,CACtC,MAAMC,KAAU,mCAAgC,EAC1CC,EAAoB,CAAC,EACrBC,EAAa,CAAC,EACdC,EAAa,CAAC,EAEdC,EAA6C,CACjD,oBAAqB,GACrB,kBAAmB,GACnB,gBAAiB,GACjB,QAAS,OACX,EACMC,EAAqC,CAAC,EACtCC,EAAmC,CACvC,QAAS,EACT,KAAM,KACN,SAAU,IACZ,EACMC,EAAwB,iBAExBC,EAA6B,GAAG,GAAG,EACnCC,EAA8B,CAClCC,EACAC,KAEC,CACC,IAAKH,CACP,GAEII,EAA+B,GAAG,GAAG,EACrCC,EAA+B,CACnCH,EACAC,KAEC,CACC,IAAKC,CACP,GAEIE,EAAoC,GAAG,GAAG,EAC1CC,EACJJ,IAEC,CACC,IAAKG,CACP,GAEF,SAAS,OAAQ,IAAM,CACrB,GAAG,kCAAmC,IAAM,CAC1C,MAAME,EAAO,IAAI,wBAAsBhB,EAAS,CAC9C,cAAeC,EACf,OAAQC,EACR,OAAQC,EACR,QAASE,EACT,UAAWD,EACX,eAAgBG,EAChB,OAAQD,EACR,cAAe,gBAAc,IAC/B,CAAC,EAED,OAAOU,CAAI,EAAE,YAAY,EACzB,OACEA,EAAK,6BACHhB,EACA,CAAC,CACH,CACF,EAAE,eAAe,sBAAoB,EACrC,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BAAqB,iBAC3B,QAAS,WACX,EACA,oBAAqB,CAAC,CACxB,CAAC,EACD,OAAOA,EAAO,kBAAkB,CAAC,CAAC,EAAE,QAAQ,CAC1C,QAAS,CACP,KAAM,uBAAqB,8BAC3B,QAAS,YACT,UAAW,CACT,KAAM,gCAA8B,SACpC,OAAQ,CACN,QAAS,EACT,KAAM,KACN,SAAU,IACZ,CACF,CACF,EACA,oBAAqB,CAAC,CACxB,CAAC,EACD,OAAOA,EAAO,kBAAkB,CAAC,CAAC,EAAE,QAAQ,CAC1C,QAAS,CACP,KAAM,uBAAqB,iBAC3B,QAAS,WACX,EACA,oBAAqB,CAAC,CACxB,CAAC,EACD,OAAOA,EAAO,kBAAkB,CAAC,CAAC,EAAE,QAAQ,CAC1C,QAAS,CACP,KAAM,uBAAqB,MAC3B,QAAS,WACX,EACA,oBAAqB,CAAC,CACxB,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_context_module", "import_device_management_kit", "import_ClearSigningType", "import_makeInternalApi", "import_BuildBaseContexts", "import_BuildFullContextsTask", "import_BuildSubcontextsTask", "import_ParseNestedTransactionTask", "apiMock", "contextModuleMock", "mapperMock", "parserMock", "defaultAppConfig", "defaultOptions", "defaultSubset", "defaultDerivationPath", "buildSubContextTaskRunMock", "buildSubcontextsTaskFactory", "_api", "_args", "buildBaseContextsTaskRunMock", "buildBaseContextsTaskFactory", "parseNestedTransactionTaskRunMock", "parseNestedTransactionTaskFactory", "task", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var p=(r,e)=>{for(var n in e)d(r,n,{get:e[n],enumerable:!0})},h=(r,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of g(e))!b.call(r,a)&&a!==n&&d(r,a,{get:()=>e[a],enumerable:!(s=C(e,a))||s.enumerable});return r};var S=r=>h(d({},"__esModule",{value:!0}),r);var y={};p(y,{BuildSubcontextsTask:()=>T});module.exports=S(y);var t=require("@ledgerhq/context-module"),c=require("@ledgerhq/device-management-kit"),x=require("../../app-binder/command/GetChallengeCommand");class T{constructor(e,n){this.api=e;this.args=n}run(){const e=this.args.context,n=e.type;switch(n){case t.ClearSignContextType.TRANSACTION_INFO:case t.ClearSignContextType.WEB3_CHECK:case t.ClearSignContextType.PLUGIN:case t.ClearSignContextType.EXTERNAL_PLUGIN:case t.ClearSignContextType.DYNAMIC_NETWORK:case t.ClearSignContextType.DYNAMIC_NETWORK_ICON:case t.ClearSignContextType.ENUM:case t.ClearSignContextType.TRUSTED_NAME:case t.ClearSignContextType.TOKEN:case t.ClearSignContextType.NFT:return{subcontextCallbacks:[]};case t.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:return{subcontextCallbacks:e.reference?this._getSubcontextsFromReference(e.reference):[]};case t.ClearSignContextType.PROXY_INFO:return{subcontextCallbacks:this._getSubcontextFromProxy(e)};default:{const s=n;throw new Error(`Uncovered type: ${s}`)}}}_getSubcontextsFromReference(e){const n=e.type;switch(n){case t.ClearSignContextReferenceType.TOKEN:case t.ClearSignContextReferenceType.NFT:return this._getSubcontextsFromTokenOrNftReference(e);case t.ClearSignContextReferenceType.ENUM:return this._getSubcontextsFromEnumReference(e);case t.ClearSignContextReferenceType.TRUSTED_NAME:return this._getSubcontextsFromTrustedNameReference(e);case t.ClearSignContextReferenceType.CALLDATA:return[];default:{const s=n;throw new Error(`Uncovered reference type: ${s}`)}}}_getSubcontextsFromTokenOrNftReference(e){if(e.value!==void 0){const s={chainId:this.args.subset.chainId,address:e.value},a=e.type===t.ClearSignContextReferenceType.TOKEN?t.ClearSignContextType.TOKEN:t.ClearSignContextType.NFT;return[()=>this.args.contextModule.getFieldContext(s,a)]}const n=[];if(e.valuePath!==void 0){const s=this.args.transactionParser.extractValue(this.args.subset,e.valuePath).orDefault([]);for(const a of s){const o=(0,c.bufferToHexaString)(a.slice(Math.max(0,a.length-20))),l=e.type===t.ClearSignContextReferenceType.TOKEN?t.ClearSignContextType.TOKEN:t.ClearSignContextType.NFT;n.push(()=>this.args.contextModule.getFieldContext({chainId:this.args.subset.chainId,address:o},l))}}return n}_getSubcontextsFromEnumReference(e){const n=[];if(!e.valuePath)return n;const s=this.args.transactionParser.extractValue(this.args.subset,e.valuePath).orDefault([]);for(const a of s){const o=a[a.length-1];if(o===void 0)continue;const i=this.args.contextOptional.filter(u=>u.type===t.ClearSignContextType.ENUM).find(u=>u.value===o&&u.id===e.id);i&&n.push(()=>Promise.resolve(i))}return n}_getSubcontextsFromTrustedNameReference(e){const n=[];if(!e.valuePath)return n;const s=this.args.transactionParser.extractValue(this.args.subset,e.valuePath).orDefault([]);for(const a of s)n.push(async()=>{const o=(0,c.bufferToHexaString)(a.slice(Math.max(0,a.length-20))),l=await this.api.sendCommand(new x.GetChallengeCommand);return(0,c.isSuccessCommandResult)(l)?await this.args.contextModule.getFieldContext({chainId:this.args.subset.chainId,address:o,challenge:l.data.challenge,types:e.types,sources:e.sources},t.ClearSignContextType.TRUSTED_NAME):{type:t.ClearSignContextType.ERROR,error:new Error("Failed to get challenge")}});return n}_getSubcontextFromProxy(e){return[async()=>{const n=await this.api.sendCommand(new x.GetChallengeCommand);return(0,c.isSuccessCommandResult)(n)?this.args.subset.to===void 0?{type:t.ClearSignContextType.ERROR,error:new Error("Failed to get proxy address")}:await this.args.contextModule.getFieldContext({chainId:this.args.subset.chainId,proxyAddress:this.args.subset.to,calldata:this.args.subset.data,deviceModelId:this.args.deviceModelId,challenge:n.data.challenge},t.ClearSignContextType.PROXY_INFO):{type:t.ClearSignContextType.ERROR,error:new Error("Failed to get challenge")}}]}}0&&(module.exports={BuildSubcontextsTask});
|
|
2
2
|
//# sourceMappingURL=BuildSubcontextsTask.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/task/BuildSubcontextsTask.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type ClearSignContext,\n type ClearSignContextReference,\n ClearSignContextReferenceType,\n type ClearSignContextSuccess,\n ClearSignContextType,\n type ContextModule,\n type
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,
|
|
6
|
-
"names": ["BuildSubcontextsTask_exports", "__export", "BuildSubcontextsTask", "__toCommonJS", "import_context_module", "
|
|
4
|
+
"sourcesContent": ["import {\n type ClearSignContext,\n type ClearSignContextReference,\n ClearSignContextReferenceType,\n type ClearSignContextSuccess,\n ClearSignContextType,\n type ContextModule,\n type TransactionSubset,\n} from \"@ledgerhq/context-module\";\nimport {\n bufferToHexaString,\n type DeviceModelId,\n type InternalApi,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { GetChallengeCommand } from \"@internal/app-binder/command/GetChallengeCommand\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nexport type BuildSubcontextsTaskArgs = {\n readonly context: ClearSignContextSuccess;\n readonly contextOptional: ClearSignContextSuccess[];\n readonly transactionParser: TransactionParserService;\n readonly subset: TransactionSubset;\n readonly deviceModelId: DeviceModelId;\n readonly contextModule: ContextModule;\n};\n\ntype SubcontextCallback = () => Promise<ClearSignContext>;\n\nexport type BuildSubcontextsTaskResult = {\n subcontextCallbacks: SubcontextCallback[];\n};\n\nexport class BuildSubcontextsTask {\n constructor(\n private readonly api: InternalApi,\n private readonly args: BuildSubcontextsTaskArgs,\n ) {}\n\n run(): BuildSubcontextsTaskResult {\n const context = this.args.context;\n const type = context.type;\n\n switch (type) {\n case ClearSignContextType.TRANSACTION_INFO:\n case ClearSignContextType.WEB3_CHECK:\n case ClearSignContextType.PLUGIN:\n case ClearSignContextType.EXTERNAL_PLUGIN:\n case ClearSignContextType.DYNAMIC_NETWORK:\n case ClearSignContextType.DYNAMIC_NETWORK_ICON:\n case ClearSignContextType.ENUM:\n case ClearSignContextType.TRUSTED_NAME:\n case ClearSignContextType.TOKEN:\n case ClearSignContextType.NFT:\n return {\n subcontextCallbacks: [],\n };\n case ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:\n return {\n subcontextCallbacks: context.reference\n ? this._getSubcontextsFromReference(context.reference)\n : [],\n };\n case ClearSignContextType.PROXY_INFO:\n return {\n subcontextCallbacks: this._getSubcontextFromProxy(context),\n };\n default: {\n const uncoveredType: never = type;\n throw new Error(`Uncovered type: ${uncoveredType}`);\n }\n }\n }\n\n private _getSubcontextsFromReference(\n reference: ClearSignContextReference,\n ): SubcontextCallback[] {\n const referenceType = reference.type;\n\n switch (referenceType) {\n case ClearSignContextReferenceType.TOKEN:\n case ClearSignContextReferenceType.NFT:\n return this._getSubcontextsFromTokenOrNftReference(reference);\n case ClearSignContextReferenceType.ENUM:\n return this._getSubcontextsFromEnumReference(reference);\n case ClearSignContextReferenceType.TRUSTED_NAME:\n return this._getSubcontextsFromTrustedNameReference(reference);\n case ClearSignContextReferenceType.CALLDATA:\n // calldata reference is handled by the BuildFullContextsTask and ParseNestedTransactionTask\n return [];\n default: {\n const uncoveredReferenceType: never = referenceType;\n throw new Error(`Uncovered reference type: ${uncoveredReferenceType}`);\n }\n }\n }\n\n private _getSubcontextsFromTokenOrNftReference(\n reference: ClearSignContextReference<\n ClearSignContextReferenceType.TOKEN | ClearSignContextReferenceType.NFT\n >,\n ): SubcontextCallback[] {\n // if the reference is a string, it means it is a direct address\n // and we don't need to extract the value from the transaction\n // as it is already provided in the reference\n if (reference.value !== undefined) {\n const transactionFieldContext = {\n chainId: this.args.subset.chainId,\n address: reference.value,\n };\n\n const expectedType =\n reference.type === ClearSignContextReferenceType.TOKEN\n ? ClearSignContextType.TOKEN\n : ClearSignContextType.NFT;\n\n return [\n () =>\n this.args.contextModule.getFieldContext(\n transactionFieldContext,\n expectedType,\n ),\n ];\n }\n\n const subcontextCallbacks: SubcontextCallback[] = [];\n\n // if the reference is a path, it means we need to extract the value\n // from the transaction and provide it to the device\n if (reference.valuePath !== undefined) {\n const referenceValues = this.args.transactionParser\n .extractValue(this.args.subset, reference.valuePath)\n .orDefault([]);\n\n for (const value of referenceValues) {\n const address = bufferToHexaString(\n value.slice(Math.max(0, value.length - 20)),\n );\n\n const expectedType =\n reference.type === ClearSignContextReferenceType.TOKEN\n ? ClearSignContextType.TOKEN\n : ClearSignContextType.NFT;\n\n subcontextCallbacks.push(() =>\n this.args.contextModule.getFieldContext(\n {\n chainId: this.args.subset.chainId,\n address,\n },\n expectedType,\n ),\n );\n }\n }\n\n return subcontextCallbacks;\n }\n\n private _getSubcontextsFromEnumReference(\n reference: ClearSignContextReference<ClearSignContextReferenceType.ENUM>,\n ): SubcontextCallback[] {\n const subcontextCallbacks: SubcontextCallback[] = [];\n\n if (!reference.valuePath) {\n return subcontextCallbacks;\n }\n\n const referenceValues = this.args.transactionParser\n .extractValue(this.args.subset, reference.valuePath)\n .orDefault([]);\n\n for (const value of referenceValues) {\n const enumValue = value[value.length - 1];\n if (enumValue === undefined) {\n continue;\n }\n\n const enumsContext = this.args.contextOptional.filter(\n (c) => c.type === ClearSignContextType.ENUM,\n );\n\n const subcontext = enumsContext.find(\n (enumContext) =>\n enumContext.value === enumValue && enumContext.id === reference.id,\n );\n\n if (subcontext) {\n subcontextCallbacks.push(() => Promise.resolve(subcontext));\n }\n }\n return subcontextCallbacks;\n }\n\n private _getSubcontextsFromTrustedNameReference(\n reference: ClearSignContextReference<ClearSignContextReferenceType.TRUSTED_NAME>,\n ): SubcontextCallback[] {\n const subcontextCallbacks: SubcontextCallback[] = [];\n\n if (!reference.valuePath) {\n return subcontextCallbacks;\n }\n\n const referenceValues = this.args.transactionParser\n .extractValue(this.args.subset, reference.valuePath)\n .orDefault([]);\n\n for (const value of referenceValues) {\n {\n subcontextCallbacks.push(async () => {\n const address = bufferToHexaString(\n value.slice(Math.max(0, value.length - 20)),\n );\n\n const getChallengeResult = await this.api.sendCommand(\n new GetChallengeCommand(),\n );\n if (!isSuccessCommandResult(getChallengeResult)) {\n return {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Failed to get challenge\"),\n };\n }\n\n const subcontext = await this.args.contextModule.getFieldContext(\n {\n chainId: this.args.subset.chainId,\n address,\n challenge: getChallengeResult.data.challenge,\n types: reference.types,\n sources: reference.sources,\n },\n ClearSignContextType.TRUSTED_NAME,\n );\n\n return subcontext;\n });\n }\n }\n\n return subcontextCallbacks;\n }\n\n private _getSubcontextFromProxy(\n _context: ClearSignContextSuccess<ClearSignContextType.PROXY_INFO>,\n ): SubcontextCallback[] {\n return [\n async () => {\n const getChallengeResult = await this.api.sendCommand(\n new GetChallengeCommand(),\n );\n if (!isSuccessCommandResult(getChallengeResult)) {\n return {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Failed to get challenge\"),\n };\n }\n\n if (this.args.subset.to === undefined) {\n return {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Failed to get proxy address\"),\n };\n }\n\n const subcontext = await this.args.contextModule.getFieldContext(\n {\n chainId: this.args.subset.chainId,\n proxyAddress: this.args.subset.to,\n calldata: this.args.subset.data,\n deviceModelId: this.args.deviceModelId,\n challenge: getChallengeResult.data.challenge,\n },\n ClearSignContextType.PROXY_INFO,\n );\n\n return subcontext;\n },\n ];\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAQO,oCACPC,EAKO,2CAEPC,EAAoC,4DAkB7B,MAAMJ,CAAqB,CAChC,YACmBK,EACAC,EACjB,CAFiB,SAAAD,EACA,UAAAC,CAChB,CAEH,KAAkC,CAChC,MAAMC,EAAU,KAAK,KAAK,QACpBC,EAAOD,EAAQ,KAErB,OAAQC,EAAM,CACZ,KAAK,uBAAqB,iBAC1B,KAAK,uBAAqB,W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EMM,EAAqB,MAAM,KAAK,IAAI,YACxC,IAAI,qBACN,EACA,SAAK,0BAAuBA,CAAkB,EAO3B,MAAM,KAAK,KAAK,cAAc,gBAC/C,CACE,QAAS,KAAK,KAAK,OAAO,QAC1B,QAAAL,EACA,UAAWK,EAAmB,KAAK,UACnC,MAAOb,EAAU,MACjB,QAASA,EAAU,OACrB,EACA,uBAAqB,YACvB,EAfS,CACL,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,yBAAyB,CAC5C,CAeJ,CAAC,EAIL,OAAOK,CACT,CAEQ,wBACNS,EACsB,CACtB,MAAO,CACL,SAAY,CACV,MAAMD,EAAqB,MAAM,KAAK,IAAI,YACxC,IAAI,qBACN,EACA,SAAK,0BAAuBA,CAAkB,EAO1C,KAAK,KAAK,OAAO,KAAO,OACnB,CACL,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,6BAA6B,CAChD,EAGiB,MAAM,KAAK,KAAK,cAAc,gBAC/C,CACE,QAAS,KAAK,KAAK,OAAO,QAC1B,aAAc,KAAK,KAAK,OAAO,GAC/B,SAAU,KAAK,KAAK,OAAO,KAC3B,cAAe,KAAK,KAAK,cACzB,UAAWA,EAAmB,KAAK,SACrC,EACA,uBAAqB,UACvB,EAtBS,CACL,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,yBAAyB,CAC5C,CAsBJ,CACF,CACF,CACF",
|
|
6
|
+
"names": ["BuildSubcontextsTask_exports", "__export", "BuildSubcontextsTask", "__toCommonJS", "import_context_module", "import_device_management_kit", "import_GetChallengeCommand", "api", "args", "context", "type", "uncoveredType", "reference", "referenceType", "uncoveredReferenceType", "transactionFieldContext", "expectedType", "subcontextCallbacks", "referenceValues", "value", "address", "enumValue", "subcontext", "c", "enumContext", "getChallengeResult", "_context"]
|
|
7
7
|
}
|