@ledgerhq/device-signer-kit-ethereum 0.0.0-signer-eth-20250122093657 → 0.0.0-try-to-fix-20250429171448
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/README.md +27 -15
- package/lib/cjs/api/SignerEthBuilder.js +1 -1
- package/lib/cjs/api/SignerEthBuilder.js.map +3 -3
- package/lib/cjs/api/SignerEthBuilder.test.js +1 -1
- package/lib/cjs/api/SignerEthBuilder.test.js.map +3 -3
- package/lib/cjs/api/app-binder/GetConfigCommandTypes.js +2 -0
- package/lib/cjs/api/app-binder/GetConfigCommandTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/SignPersonalMessageDeviceActionTypes.js +1 -1
- package/lib/cjs/api/app-binder/SignPersonalMessageDeviceActionTypes.js.map +1 -1
- package/lib/cjs/api/app-binder/SignTransactionDeviceActionTypes.js +1 -1
- package/lib/cjs/api/app-binder/SignTransactionDeviceActionTypes.js.map +3 -3
- package/lib/cjs/api/app-binder/SignTypedDataDeviceActionTypes.js +1 -1
- package/lib/cjs/api/app-binder/SignTypedDataDeviceActionTypes.js.map +3 -3
- package/lib/cjs/api/index.js +1 -1
- package/lib/cjs/api/index.js.map +3 -3
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/internal/DefaultSignerEth.test.js +1 -1
- package/lib/cjs/internal/DefaultSignerEth.test.js.map +2 -2
- package/lib/cjs/internal/address/use-case/GetAddressUseCase.test.js +1 -1
- package/lib/cjs/internal/address/use-case/GetAddressUseCase.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/EthAppBinder.js +1 -1
- package/lib/cjs/internal/app-binder/EthAppBinder.js.map +3 -3
- package/lib/cjs/internal/app-binder/EthAppBinder.test.js +1 -1
- package/lib/cjs/internal/app-binder/EthAppBinder.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/GetAddressCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetAddressCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetAppConfigurationCommand.js +2 -0
- package/lib/cjs/internal/app-binder/command/GetAppConfigurationCommand.js.map +7 -0
- package/lib/cjs/internal/app-binder/command/GetAppConfigurationCommand.test.js +2 -0
- package/lib/cjs/internal/app-binder/command/GetAppConfigurationCommand.test.js.map +7 -0
- package/lib/cjs/internal/app-binder/command/ProvideWeb3CheckCommand.js +2 -0
- package/lib/cjs/internal/app-binder/command/ProvideWeb3CheckCommand.js.map +7 -0
- package/lib/cjs/internal/app-binder/command/ProvideWeb3CheckCommand.test.js +2 -0
- package/lib/cjs/internal/app-binder/command/ProvideWeb3CheckCommand.test.js.map +7 -0
- package/lib/cjs/internal/app-binder/command/SendEIP712FilteringCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SendEIP712FilteringCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SendEIP712FilteringCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SendEIP712FilteringCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SignTransactionCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignTransactionCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/StartTransactionCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/StartTransactionCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/Web3CheckOptInCommand.js +2 -0
- package/lib/cjs/internal/app-binder/command/Web3CheckOptInCommand.js.map +7 -0
- package/lib/cjs/internal/app-binder/command/Web3CheckOptInCommand.test.js +2 -0
- package/lib/cjs/internal/app-binder/command/Web3CheckOptInCommand.test.js.map +7 -0
- package/lib/cjs/internal/app-binder/command/utils/ethAppErrors.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/utils/ethAppErrors.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/constant/plugins.js +1 -1
- package/lib/cjs/internal/app-binder/constant/plugins.js.map +2 -2
- package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/__test-utils__/makeInternalApi.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/__test-utils__/makeInternalApi.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/__test-utils__/setupOpenAppDAMock.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/__test-utils__/setupOpenAppDAMock.js.map +2 -2
- package/lib/cjs/internal/app-binder/device-action/__test-utils__/testDeviceActionStates.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/__test-utils__/testDeviceActionStates.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.js +2 -0
- package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.js.map +7 -0
- package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.test.js +2 -0
- package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.test.js.map +7 -0
- package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/ProvideTransactionGenericContextTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideTransactionGenericContextTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/ProvideTransactionGenericContextTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideTransactionGenericContextTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/SendEIP712StructImplemTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/SendEIP712StructImplemTask.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/task/SendPayloadInChunksTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/SendPayloadInChunksTask.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/task/SendSignPersonalMessageTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/SendSignPersonalMessageTask.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/task/SendSignTransactionTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/SendSignTransactionTask.test.js.map +2 -2
- package/lib/cjs/internal/message/use-case/SignMessageUseCase.test.js +1 -1
- package/lib/cjs/internal/message/use-case/SignMessageUseCase.test.js.map +2 -2
- package/lib/cjs/internal/shared/utils/ApplicationChecker.js +2 -0
- package/lib/cjs/internal/shared/utils/ApplicationChecker.js.map +7 -0
- package/lib/cjs/internal/shared/utils/ApplicationChecker.test.js +2 -0
- package/lib/cjs/internal/shared/utils/ApplicationChecker.test.js.map +7 -0
- package/lib/cjs/internal/transaction/service/mapper/TransactionMapperService.test.js +1 -1
- package/lib/cjs/internal/transaction/service/mapper/TransactionMapperService.test.js.map +2 -2
- package/lib/cjs/internal/transaction/service/parser/TransactionParserService.test.js +1 -1
- package/lib/cjs/internal/transaction/service/parser/TransactionParserService.test.js.map +2 -2
- package/lib/cjs/internal/transaction/use-case/SignTransactionUseCase.test.js +1 -1
- package/lib/cjs/internal/transaction/use-case/SignTransactionUseCase.test.js.map +2 -2
- package/lib/cjs/internal/typed-data/use-case/SignTypedDataUseCase.test.js +1 -1
- package/lib/cjs/internal/typed-data/use-case/SignTypedDataUseCase.test.js.map +2 -2
- package/lib/cjs/package.json +7 -7
- package/lib/esm/api/SignerEthBuilder.js +1 -1
- package/lib/esm/api/SignerEthBuilder.js.map +3 -3
- package/lib/esm/api/SignerEthBuilder.test.js +1 -1
- package/lib/esm/api/SignerEthBuilder.test.js.map +3 -3
- package/lib/esm/api/app-binder/GetConfigCommandTypes.js +1 -0
- package/lib/esm/api/app-binder/GetConfigCommandTypes.js.map +7 -0
- package/lib/esm/api/app-binder/SignTransactionDeviceActionTypes.js +1 -0
- package/lib/esm/api/app-binder/SignTransactionDeviceActionTypes.js.map +4 -4
- package/lib/esm/api/app-binder/SignTypedDataDeviceActionTypes.js +1 -0
- package/lib/esm/api/app-binder/SignTypedDataDeviceActionTypes.js.map +4 -4
- package/lib/esm/api/index.js +1 -1
- package/lib/esm/api/index.js.map +3 -3
- package/lib/esm/internal/DefaultSignerEth.test.js +1 -1
- package/lib/esm/internal/DefaultSignerEth.test.js.map +2 -2
- package/lib/esm/internal/address/use-case/GetAddressUseCase.test.js +1 -1
- package/lib/esm/internal/address/use-case/GetAddressUseCase.test.js.map +2 -2
- package/lib/esm/internal/app-binder/EthAppBinder.js +1 -1
- package/lib/esm/internal/app-binder/EthAppBinder.js.map +3 -3
- package/lib/esm/internal/app-binder/EthAppBinder.test.js +1 -1
- package/lib/esm/internal/app-binder/EthAppBinder.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/GetAddressCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/GetAddressCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetAppConfigurationCommand.js +2 -0
- package/lib/esm/internal/app-binder/command/GetAppConfigurationCommand.js.map +7 -0
- package/lib/esm/internal/app-binder/command/GetAppConfigurationCommand.test.js +2 -0
- package/lib/esm/internal/app-binder/command/GetAppConfigurationCommand.test.js.map +7 -0
- package/lib/esm/internal/app-binder/command/ProvideWeb3CheckCommand.js +2 -0
- package/lib/esm/internal/app-binder/command/ProvideWeb3CheckCommand.js.map +7 -0
- package/lib/esm/internal/app-binder/command/ProvideWeb3CheckCommand.test.js +2 -0
- package/lib/esm/internal/app-binder/command/ProvideWeb3CheckCommand.test.js.map +7 -0
- package/lib/esm/internal/app-binder/command/SendEIP712FilteringCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SendEIP712FilteringCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SendEIP712FilteringCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SendEIP712FilteringCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SignTransactionCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignTransactionCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/StartTransactionCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/StartTransactionCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/Web3CheckOptInCommand.js +2 -0
- package/lib/esm/internal/app-binder/command/Web3CheckOptInCommand.js.map +7 -0
- package/lib/esm/internal/app-binder/command/Web3CheckOptInCommand.test.js +2 -0
- package/lib/esm/internal/app-binder/command/Web3CheckOptInCommand.test.js.map +7 -0
- package/lib/esm/internal/app-binder/command/utils/ethAppErrors.test.js +1 -1
- package/lib/esm/internal/app-binder/command/utils/ethAppErrors.test.js.map +2 -2
- package/lib/esm/internal/app-binder/constant/plugins.js +1 -1
- package/lib/esm/internal/app-binder/constant/plugins.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/device-action/SignTypedData/SignTypedDataDeviceAction.js +1 -1
- package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js +1 -1
- package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/__test-utils__/makeInternalApi.js +1 -1
- package/lib/esm/internal/app-binder/device-action/__test-utils__/makeInternalApi.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/__test-utils__/setupOpenAppDAMock.js +1 -1
- package/lib/esm/internal/app-binder/device-action/__test-utils__/setupOpenAppDAMock.js.map +2 -2
- package/lib/esm/internal/app-binder/device-action/__test-utils__/testDeviceActionStates.js +1 -1
- package/lib/esm/internal/app-binder/device-action/__test-utils__/testDeviceActionStates.js.map +3 -3
- package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.js +2 -0
- package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.js.map +7 -0
- package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.test.js +2 -0
- package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.test.js.map +7 -0
- package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/ProvideTransactionGenericContextTask.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideTransactionGenericContextTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/ProvideTransactionGenericContextTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideTransactionGenericContextTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/SendEIP712StructImplemTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/SendEIP712StructImplemTask.test.js.map +2 -2
- package/lib/esm/internal/app-binder/task/SendPayloadInChunksTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/SendPayloadInChunksTask.test.js.map +2 -2
- package/lib/esm/internal/app-binder/task/SendSignPersonalMessageTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/SendSignPersonalMessageTask.test.js.map +2 -2
- package/lib/esm/internal/app-binder/task/SendSignTransactionTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/SendSignTransactionTask.test.js.map +2 -2
- package/lib/esm/internal/message/use-case/SignMessageUseCase.test.js +1 -1
- package/lib/esm/internal/message/use-case/SignMessageUseCase.test.js.map +2 -2
- package/lib/esm/internal/shared/utils/ApplicationChecker.js +2 -0
- package/lib/esm/internal/shared/utils/ApplicationChecker.js.map +7 -0
- package/lib/esm/internal/shared/utils/ApplicationChecker.test.js +2 -0
- package/lib/esm/internal/shared/utils/ApplicationChecker.test.js.map +7 -0
- package/lib/esm/internal/transaction/service/mapper/TransactionMapperService.test.js +1 -1
- package/lib/esm/internal/transaction/service/mapper/TransactionMapperService.test.js.map +2 -2
- package/lib/esm/internal/transaction/service/parser/TransactionParserService.test.js +1 -1
- package/lib/esm/internal/transaction/service/parser/TransactionParserService.test.js.map +2 -2
- package/lib/esm/internal/transaction/use-case/SignTransactionUseCase.test.js +1 -1
- package/lib/esm/internal/transaction/use-case/SignTransactionUseCase.test.js.map +2 -2
- package/lib/esm/internal/typed-data/use-case/SignTypedDataUseCase.test.js +1 -1
- package/lib/esm/internal/typed-data/use-case/SignTypedDataUseCase.test.js.map +2 -2
- package/lib/esm/package.json +7 -7
- package/lib/types/api/SignerEthBuilder.d.ts +4 -2
- package/lib/types/api/SignerEthBuilder.d.ts.map +1 -1
- package/lib/types/api/app-binder/GetConfigCommandTypes.d.ts +7 -0
- package/lib/types/api/app-binder/GetConfigCommandTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/SignPersonalMessageDeviceActionTypes.d.ts +1 -10
- package/lib/types/api/app-binder/SignPersonalMessageDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts +15 -3
- package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/api/app-binder/SignTypedDataDeviceActionTypes.d.ts +14 -1
- package/lib/types/api/app-binder/SignTypedDataDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/api/index.d.ts +3 -3
- package/lib/types/api/index.d.ts.map +1 -1
- package/lib/types/internal/app-binder/EthAppBinder.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetAppConfigurationCommand.d.ts +10 -0
- package/lib/types/internal/app-binder/command/GetAppConfigurationCommand.d.ts.map +1 -0
- package/lib/types/internal/app-binder/command/GetAppConfigurationCommand.test.d.ts +2 -0
- package/lib/types/internal/app-binder/command/GetAppConfigurationCommand.test.d.ts.map +1 -0
- package/lib/types/internal/app-binder/command/ProvideWeb3CheckCommand.d.ts +17 -0
- package/lib/types/internal/app-binder/command/ProvideWeb3CheckCommand.d.ts.map +1 -0
- package/lib/types/internal/app-binder/command/ProvideWeb3CheckCommand.test.d.ts +2 -0
- package/lib/types/internal/app-binder/command/ProvideWeb3CheckCommand.test.d.ts.map +1 -0
- package/lib/types/internal/app-binder/command/SendEIP712FilteringCommand.d.ts +8 -1
- package/lib/types/internal/app-binder/command/SendEIP712FilteringCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/Web3CheckOptInCommand.d.ts +15 -0
- package/lib/types/internal/app-binder/command/Web3CheckOptInCommand.d.ts.map +1 -0
- package/lib/types/internal/app-binder/command/Web3CheckOptInCommand.test.d.ts +2 -0
- package/lib/types/internal/app-binder/command/Web3CheckOptInCommand.test.d.ts.map +1 -0
- package/lib/types/internal/app-binder/constant/plugins.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts +9 -4
- package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.d.ts +7 -0
- package/lib/types/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/__test-utils__/makeInternalApi.d.ts +2 -1
- package/lib/types/internal/app-binder/device-action/__test-utils__/makeInternalApi.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/__test-utils__/setupOpenAppDAMock.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/__test-utils__/testDeviceActionStates.d.ts +5 -2
- package/lib/types/internal/app-binder/device-action/__test-utils__/testDeviceActionStates.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/BuildEIP712ContextTask.d.ts +10 -5
- package/lib/types/internal/app-binder/task/BuildEIP712ContextTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/BuildTransactionContextTask.d.ts +8 -3
- package/lib/types/internal/app-binder/task/BuildTransactionContextTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/GetWeb3CheckTask.d.ts +30 -0
- package/lib/types/internal/app-binder/task/GetWeb3CheckTask.d.ts.map +1 -0
- package/lib/types/internal/app-binder/task/GetWeb3CheckTask.test.d.ts +2 -0
- package/lib/types/internal/app-binder/task/GetWeb3CheckTask.test.d.ts.map +1 -0
- package/lib/types/internal/app-binder/task/ProvideEIP712ContextTask.d.ts +7 -2
- package/lib/types/internal/app-binder/task/ProvideEIP712ContextTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/ProvideTransactionContextTask.d.ts +3 -2
- package/lib/types/internal/app-binder/task/ProvideTransactionContextTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.d.ts +7 -0
- package/lib/types/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/ProvideTransactionGenericContextTask.d.ts +3 -1
- package/lib/types/internal/app-binder/task/ProvideTransactionGenericContextTask.d.ts.map +1 -1
- package/lib/types/internal/shared/utils/ApplicationChecker.d.ts +13 -0
- package/lib/types/internal/shared/utils/ApplicationChecker.d.ts.map +1 -0
- package/lib/types/internal/shared/utils/ApplicationChecker.test.d.ts +2 -0
- package/lib/types/internal/shared/utils/ApplicationChecker.test.d.ts.map +1 -0
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +14 -14
- package/lib/cjs/internal/app-binder/device-action/SignPersonalMessage/SignPersonalMessageDeviceAction.js +0 -2
- package/lib/cjs/internal/app-binder/device-action/SignPersonalMessage/SignPersonalMessageDeviceAction.js.map +0 -7
- package/lib/cjs/internal/app-binder/device-action/SignPersonalMessage/SignPersonalMessageDeviceAction.test.js +0 -2
- package/lib/cjs/internal/app-binder/device-action/SignPersonalMessage/SignPersonalMessageDeviceAction.test.js.map +0 -7
- package/lib/esm/internal/app-binder/device-action/SignPersonalMessage/SignPersonalMessageDeviceAction.js +0 -2
- package/lib/esm/internal/app-binder/device-action/SignPersonalMessage/SignPersonalMessageDeviceAction.js.map +0 -7
- package/lib/esm/internal/app-binder/device-action/SignPersonalMessage/SignPersonalMessageDeviceAction.test.js +0 -2
- package/lib/esm/internal/app-binder/device-action/SignPersonalMessage/SignPersonalMessageDeviceAction.test.js.map +0 -7
- package/lib/types/internal/app-binder/device-action/SignPersonalMessage/SignPersonalMessageDeviceAction.d.ts +0 -18
- package/lib/types/internal/app-binder/device-action/SignPersonalMessage/SignPersonalMessageDeviceAction.d.ts.map +0 -1
- package/lib/types/internal/app-binder/device-action/SignPersonalMessage/SignPersonalMessageDeviceAction.test.d.ts +0 -2
- package/lib/types/internal/app-binder/device-action/SignPersonalMessage/SignPersonalMessageDeviceAction.test.d.ts.map +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/internal/shared/utils/ApplicationChecker.test.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n} from \"@ledgerhq/device-management-kit\";\n\nimport type { GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\n\nimport { ApplicationChecker } from \"./ApplicationChecker\";\n\ndescribe(\"ApplicationChecker\", () => {\n function createAppConfig(version: string): GetConfigCommandResponse {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled: false,\n web3ChecksOptIn: false,\n version,\n };\n }\n\n it(\"should pass the check for exclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.13.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for exclusive version\", () => {\n // GIVEN\n const state = {\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 const config = createAppConfig(\"1.12.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check for inclusive version\", () => {\n // GIVEN\n const state = {\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 const config = createAppConfig(\"1.10.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for inclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check for excluded device\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for excluded device\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .excludeDeviceModel(DeviceModelId.FLEX)\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check for chained condition\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.11.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for chained condition\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.10.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.10.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.11.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"exchange app should not be compatible with eth features\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Exchange\", version: \"1.11.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config).check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check in plugins\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"1inch\", version: \"1.11.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check in unknexpected app\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Bitcoin\", version: \"1.13.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should reject the check in unknexpected state\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Bitcoin\", version: \"1.13.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,iBAAAA,EACA,0BAAAC,EACA,gBAAAC,MACK,kCAIP,OAAS,sBAAAC,MAA0B,uBAEnC,SAAS,qBAAsB,IAAM,CACnC,SAASC,EAAgBC,EAA2C,CAClE,MAAO,CACL,oBAAqB,GACrB,kBAAmB,GACnB,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F,EAAc,KAC7B,0BAA2B,EAC7B,EACMO,EAASH,EAAgB,QAAQ,EAEjCI,EAAS,IAAIL,EAAmBG,EAAOC,CAAM,EAChD,wBAAwB,QAAQ,EAChC,MAAM,EAET,OAAOC,CAAM,EAAE,cAAc,EAAK,CACpC,CAAC,EAED,GAAG,gDAAiD,IAAM,CAExD,MAAMF,EAAQ,CACZ,iBAAkBL,EAAuB,UACzC,aAAcC,EAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,UAAW,QAAS,WAAY,EACpD,cAAeF,EAAc,KAC7B,0BAA2B,EAC7B,EACMO,EAASH,EAAgB,QAAQ,EAEjCI,EAAS,IAAIL,EAAmBG,EAAOC,CAAM,EAChD,wBAAwB,QAAQ,EAChC,MAAM,EAET,OAAOC,CAAM,EAAE,cAAc,EAAK,CACpC,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["DeviceModelId", "DeviceSessionStateType", "DeviceStatus", "ApplicationChecker", "createAppConfig", "version", "state", "config", "result"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Just as s,Nothing as r,Right as p}from"purify-ts";import{TransactionMapperService as o}from"./TransactionMapperService";const t=a=>({map:
|
|
1
|
+
import{Just as s,Nothing as r,Right as p}from"purify-ts";import{TransactionMapperService as o}from"./TransactionMapperService";const t=a=>({map:vi.fn().mockReturnValue(a)});describe("TransactionMapperService",()=>{let a;beforeEach(()=>{vi.clearAllMocks()}),it("should return a TransactionSubset",()=>{const e=[t(s({data:"data"})),t(r)];a=new o(e);const n=a.mapTransactionToSubset(new Uint8Array(0));expect(e[0].map).toHaveBeenCalled(),expect(e[1].map).not.toHaveBeenCalled(),expect(n).toEqual(p({data:"data"}))}),it("should return a TransactionSubset for the second mapper",()=>{const e=[t(r),t(s({data:"data-2"}))];a=new o(e);const n=a.mapTransactionToSubset(new Uint8Array(0));expect(e[0].map).toHaveBeenCalled(),expect(e[1].map).toHaveBeenCalled(),expect(n).toEqual(p({data:"data-2"}))}),it("should return an error",()=>{const e=[t(r),t(r)];a=new o(e);const n=a.mapTransactionToSubset(new Uint8Array(0));expect(e[0].map).toHaveBeenCalled(),expect(e[1].map).toHaveBeenCalled(),expect(n.isLeft()).toBeTruthy()})});
|
|
2
2
|
//# sourceMappingURL=TransactionMapperService.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/transaction/service/mapper/TransactionMapperService.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { type TransactionSubset } from \"@ledgerhq/context-module\";\nimport { Just, type Maybe, Nothing, Right } from \"purify-ts\";\n\nimport { TransactionMapperService } from \"./TransactionMapperService\";\n\nconst transactionMapperBuilder = (value?: Maybe<TransactionSubset>) => {\n const map =
|
|
5
|
-
"mappings": "AACA,OAAS,QAAAA,EAAkB,WAAAC,EAAS,SAAAC,MAAa,YAEjD,OAAS,4BAAAC,MAAgC,6BAEzC,MAAMC,EAA4BC,IAEzB,CAAE,IADG,
|
|
4
|
+
"sourcesContent": ["import { type TransactionSubset } from \"@ledgerhq/context-module\";\nimport { Just, type Maybe, Nothing, Right } from \"purify-ts\";\n\nimport { TransactionMapperService } from \"./TransactionMapperService\";\n\nconst transactionMapperBuilder = (value?: Maybe<TransactionSubset>) => {\n const map = vi.fn().mockReturnValue(value);\n return { map };\n};\n\ndescribe(\"TransactionMapperService\", () => {\n let service: TransactionMapperService;\n\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n it(\"should return a TransactionSubset\", () => {\n // GIVEN\n const mappers = [\n transactionMapperBuilder(Just({ data: \"data\" } as TransactionSubset)),\n transactionMapperBuilder(Nothing),\n ];\n service = new TransactionMapperService(mappers);\n\n // WHEN\n const result = service.mapTransactionToSubset(new Uint8Array(0));\n\n // THEN\n expect(mappers[0]!.map).toHaveBeenCalled();\n expect(mappers[1]!.map).not.toHaveBeenCalled();\n expect(result).toEqual(Right({ data: \"data\" }));\n });\n\n it(\"should return a TransactionSubset for the second mapper\", () => {\n // GIVEN\n const mappers = [\n transactionMapperBuilder(Nothing),\n transactionMapperBuilder(Just({ data: \"data-2\" } as TransactionSubset)),\n ];\n service = new TransactionMapperService(mappers);\n\n // WHEN\n const result = service.mapTransactionToSubset(new Uint8Array(0));\n\n // THEN\n expect(mappers[0]!.map).toHaveBeenCalled();\n expect(mappers[1]!.map).toHaveBeenCalled();\n expect(result).toEqual(Right({ data: \"data-2\" }));\n });\n\n it(\"should return an error\", () => {\n // GIVEN\n const mappers = [\n transactionMapperBuilder(Nothing),\n transactionMapperBuilder(Nothing),\n ];\n service = new TransactionMapperService(mappers);\n\n // WHEN\n const result = service.mapTransactionToSubset(new Uint8Array(0));\n\n // THEN\n expect(mappers[0]!.map).toHaveBeenCalled();\n expect(mappers[1]!.map).toHaveBeenCalled();\n expect(result.isLeft()).toBeTruthy();\n });\n});\n"],
|
|
5
|
+
"mappings": "AACA,OAAS,QAAAA,EAAkB,WAAAC,EAAS,SAAAC,MAAa,YAEjD,OAAS,4BAAAC,MAAgC,6BAEzC,MAAMC,EAA4BC,IAEzB,CAAE,IADG,GAAG,GAAG,EAAE,gBAAgBA,CAAK,CAC5B,GAGf,SAAS,2BAA4B,IAAM,CACzC,IAAIC,EAEJ,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,GAAG,oCAAqC,IAAM,CAE5C,MAAMC,EAAU,CACdH,EAAyBJ,EAAK,CAAE,KAAM,MAAO,CAAsB,CAAC,EACpEI,EAAyBH,CAAO,CAClC,EACAK,EAAU,IAAIH,EAAyBI,CAAO,EAG9C,MAAMC,EAASF,EAAQ,uBAAuB,IAAI,WAAW,CAAC,CAAC,EAG/D,OAAOC,EAAQ,CAAC,EAAG,GAAG,EAAE,iBAAiB,EACzC,OAAOA,EAAQ,CAAC,EAAG,GAAG,EAAE,IAAI,iBAAiB,EAC7C,OAAOC,CAAM,EAAE,QAAQN,EAAM,CAAE,KAAM,MAAO,CAAC,CAAC,CAChD,CAAC,EAED,GAAG,0DAA2D,IAAM,CAElE,MAAMK,EAAU,CACdH,EAAyBH,CAAO,EAChCG,EAAyBJ,EAAK,CAAE,KAAM,QAAS,CAAsB,CAAC,CACxE,EACAM,EAAU,IAAIH,EAAyBI,CAAO,EAG9C,MAAMC,EAASF,EAAQ,uBAAuB,IAAI,WAAW,CAAC,CAAC,EAG/D,OAAOC,EAAQ,CAAC,EAAG,GAAG,EAAE,iBAAiB,EACzC,OAAOA,EAAQ,CAAC,EAAG,GAAG,EAAE,iBAAiB,EACzC,OAAOC,CAAM,EAAE,QAAQN,EAAM,CAAE,KAAM,QAAS,CAAC,CAAC,CAClD,CAAC,EAED,GAAG,yBAA0B,IAAM,CAEjC,MAAMK,EAAU,CACdH,EAAyBH,CAAO,EAChCG,EAAyBH,CAAO,CAClC,EACAK,EAAU,IAAIH,EAAyBI,CAAO,EAG9C,MAAMC,EAASF,EAAQ,uBAAuB,IAAI,WAAW,CAAC,CAAC,EAG/D,OAAOC,EAAQ,CAAC,EAAG,GAAG,EAAE,iBAAiB,EACzC,OAAOA,EAAQ,CAAC,EAAG,GAAG,EAAE,iBAAiB,EACzC,OAAOC,EAAO,OAAO,CAAC,EAAE,WAAW,CACrC,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["Just", "Nothing", "Right", "TransactionMapperService", "transactionMapperBuilder", "value", "service", "mappers", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ContainerPath as n}from"@ledgerhq/context-module";import{bufferToHexaString as s,ByteArrayBuilder as E,hexaStringToBuffer as c}from"@ledgerhq/device-management-kit";import{Transaction as o}from"ethers";import{TransactionParserService as f}from"./TransactionParserService";describe("TransactionParserService",()=>{const i=new f,l=c("0x3f32cF0B1DF94157EE1c3876c49BE3732C92a98f"),r=81818275935222000n,p=new E().add256BitUIntToData(81818275935222000n).build();beforeEach(()=>{jest.clearAllMocks()}),describe("Container paths",()=>{it("should extract TO of the container",()=>{const a=c(o.from({to:s(l),value:r,data:"0x"}).unsignedSerialized),e=i.extractValue(a,n.TO);expect(e.isRight()).toStrictEqual(!0),expect(e.unsafeCoerce()).toStrictEqual([l])}),it("should extract VALUE of the container",()=>{const a=c(o.from({to:s(l),value:r,data:"0x"}).unsignedSerialized),e=i.extractValue(a,n.VALUE);expect(e.isRight()).toStrictEqual(!0),expect(e.unsafeCoerce()).toStrictEqual([p])}),it("Unavailable container fields",()=>{const a=c(o.from({data:"0x",signature:{r:"0x73b969418389828a6328fdb96e747296226832894b8bb46d60f231a9960ec3b5",s:"0x4806aaccc52354f4a42ef9efe0d89dd8cf95210829443ad7f4a9017d6b02de07",v:1}}).unsignedSerialized),e=i.extractValue(a,n.FROM),t=i.extractValue(a,n.TO);expect(e.isRight()).toStrictEqual(!1),expect(t.isRight()).toStrictEqual(!1)}),it("invalid transaction format",()=>{const a=c("0xdeadbeef"),e=i.extractValue(a,n.FROM);expect(e.isRight()).toStrictEqual(!1)})}),describe("Data paths in a calldata with static elements",()=>{const a=c(o.from({to:s(l),value:r,data:"0xcdcd77c000000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000001"}).unsignedSerialized);it("Extract the first element",()=>{const e=[{type:"TUPLE",offset:0},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x0000000000000000000000000000000000000000000000000000000000000045")])}),it("Extract the second element",()=>{const e=[{type:"TUPLE",offset:1},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x0000000000000000000000000000000000000000000000000000000000000001")])}),it("Slice the static leaf",()=>{const e=[{type:"TUPLE",offset:0},{type:"LEAF",leafType:"STATIC_LEAF"},{type:"SLICE",start:-4}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x00000045")])}),it("Out of bounds",()=>{const e=[{type:"TUPLE",offset:2},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!1)})}),describe("Data paths in a calldata with dynamic elements",()=>{const a=c(o.from({to:s(l),value:r,data:"0x2289b18c000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000036f6e650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000374776f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000057468726565000000000000000000000000000000000000000000000000000000"}).unsignedSerialized);it("Extract all the elements of x, concatenated together",()=>{const e=[{type:"TUPLE",offset:0},{type:"REF"},{type:"ARRAY",itemSize:1},{type:"REF"},{type:"ARRAY",itemSize:1},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x0000000000000000000000000000000000000000000000000000000000000001"),c("0x0000000000000000000000000000000000000000000000000000000000000002"),c("0x0000000000000000000000000000000000000000000000000000000000000003")])}),it("Extract all the elements of x[0]",()=>{const e=[{type:"TUPLE",offset:0},{type:"REF"},{type:"ARRAY",itemSize:1,start:0,end:1},{type:"REF"},{type:"ARRAY",itemSize:1},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x0000000000000000000000000000000000000000000000000000000000000001"),c("0x0000000000000000000000000000000000000000000000000000000000000002")])}),it("Extract all the elements of x[0:-1][-1:]",()=>{const e=[{type:"TUPLE",offset:0},{type:"REF"},{type:"ARRAY",itemSize:1,start:0,end:-1},{type:"REF"},{type:"ARRAY",itemSize:1,start:-1},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x0000000000000000000000000000000000000000000000000000000000000002")])}),it("Array out of bounds",()=>{const e=[{type:"TUPLE",offset:0},{type:"REF"},{type:"ARRAY",itemSize:1,start:0,end:1},{type:"REF"},{type:"ARRAY",itemSize:1,start:2,end:3},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!1)}),it("Extract all the elements of x[1]",()=>{const e=[{type:"TUPLE",offset:1},{type:"REF"},{type:"ARRAY",itemSize:1},{type:"REF"},{type:"LEAF",leafType:"DYNAMIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x6f6e65"),c("0x74776f"),c("0x7468726565")])}),it("Extract all the elements of x[1][:2]",()=>{const e=[{type:"TUPLE",offset:1},{type:"REF"},{type:"ARRAY",itemSize:1,end:2},{type:"REF"},{type:"LEAF",leafType:"DYNAMIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x6f6e65"),c("0x74776f")])}),it("Slice the dynamic leaf with [1:-2]",()=>{const e=[{type:"TUPLE",offset:1},{type:"REF"},{type:"ARRAY",itemSize:1,start:2,end:3},{type:"REF"},{type:"LEAF",leafType:"DYNAMIC_LEAF"},{type:"SLICE",start:1,end:-2}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x6872")])}),it("Slice the dynamic leaf with [-1:]",()=>{const e=[{type:"TUPLE",offset:1},{type:"REF"},{type:"ARRAY",itemSize:1,start:2,end:3},{type:"REF"},{type:"LEAF",leafType:"DYNAMIC_LEAF"},{type:"SLICE",start:-1}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x65")])}),it("Slice the dynamic leaf with [:1]",()=>{const e=[{type:"TUPLE",offset:1},{type:"REF"},{type:"ARRAY",itemSize:1,start:2,end:3},{type:"REF"},{type:"LEAF",leafType:"DYNAMIC_LEAF"},{type:"SLICE",end:1}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x74")])}),it("Error no leaf",()=>{const e=[{type:"TUPLE",offset:1}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!1)}),it("Error slice not at the end",()=>{const e=[{type:"TUPLE",offset:1},{type:"SLICE",start:0,end:1},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!1)}),it("Error empty slice",()=>{const e=[{type:"TUPLE",offset:1},{type:"LEAF",leafType:"DYNAMIC_LEAF"},{type:"SLICE",start:0,end:0}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!1)})}),describe("Array of tuples, with bigger itemSize",()=>{const a=c(o.from({to:s(l),value:r,data:"0xcdcd77c000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000006"}).unsignedSerialized);it("Extract the first tuple element of all array elements",()=>{const e=[{type:"REF"},{type:"ARRAY",itemSize:2},{type:"TUPLE",offset:0},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x0000000000000000000000000000000000000000000000000000000000000001"),c("0x0000000000000000000000000000000000000000000000000000000000000003"),c("0x0000000000000000000000000000000000000000000000000000000000000005")])}),it("Extract the second tuple element of all array elements",()=>{const e=[{type:"REF"},{type:"ARRAY",itemSize:2},{type:"TUPLE",offset:1},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x0000000000000000000000000000000000000000000000000000000000000002"),c("0x0000000000000000000000000000000000000000000000000000000000000004"),c("0x0000000000000000000000000000000000000000000000000000000000000006")])})}),describe("Malformed calldata",()=>{const a=c(o.from({to:s(l),value:r,data:"0x2289b18c0000000000000000000000000000000000000000000000000000000000000080f000000000000000000000000000000000000000000000000000000000000140f000000000000000000000000000000000000000000000000000000000000002"}).unsignedSerialized);it("Dynamic leaf length overflow",()=>{const e=[{type:"TUPLE",offset:1},{type:"LEAF",leafType:"DYNAMIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!1)}),it("Calldata smaller than dynamic leaf",()=>{const e=[{type:"TUPLE",offset:0},{type:"LEAF",leafType:"DYNAMIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!1)}),it("Array length overflow",()=>{const e=[{type:"TUPLE",offset:1},{type:"ARRAY",itemSize:1},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!1)}),it("Calldata smaller than array length",()=>{const e=[{type:"TUPLE",offset:0},{type:"ARRAY",itemSize:1},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!1)}),it("Ref out of bounds",()=>{const e=[{type:"TUPLE",offset:1},{type:"REF"},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!1)})})});
|
|
1
|
+
import{ContainerPath as n}from"@ledgerhq/context-module";import{bufferToHexaString as s,ByteArrayBuilder as E,hexaStringToBuffer as c}from"@ledgerhq/device-management-kit";import{Transaction as o}from"ethers";import{TransactionParserService as f}from"./TransactionParserService";describe("TransactionParserService",()=>{const i=new f,l=c("0x3f32cF0B1DF94157EE1c3876c49BE3732C92a98f"),r=81818275935222000n,p=new E().add256BitUIntToData(81818275935222000n).build();beforeEach(()=>{vi.clearAllMocks()}),describe("Container paths",()=>{it("should extract TO of the container",()=>{const a=c(o.from({to:s(l),value:r,data:"0x"}).unsignedSerialized),e=i.extractValue(a,n.TO);expect(e.isRight()).toStrictEqual(!0),expect(e.unsafeCoerce()).toStrictEqual([l])}),it("should extract VALUE of the container",()=>{const a=c(o.from({to:s(l),value:r,data:"0x"}).unsignedSerialized),e=i.extractValue(a,n.VALUE);expect(e.isRight()).toStrictEqual(!0),expect(e.unsafeCoerce()).toStrictEqual([p])}),it("Unavailable container fields",()=>{const a=c(o.from({data:"0x",signature:{r:"0x73b969418389828a6328fdb96e747296226832894b8bb46d60f231a9960ec3b5",s:"0x4806aaccc52354f4a42ef9efe0d89dd8cf95210829443ad7f4a9017d6b02de07",v:1}}).unsignedSerialized),e=i.extractValue(a,n.FROM),t=i.extractValue(a,n.TO);expect(e.isRight()).toStrictEqual(!1),expect(t.isRight()).toStrictEqual(!1)}),it("invalid transaction format",()=>{const a=c("0xdeadbeef"),e=i.extractValue(a,n.FROM);expect(e.isRight()).toStrictEqual(!1)})}),describe("Data paths in a calldata with static elements",()=>{const a=c(o.from({to:s(l),value:r,data:"0xcdcd77c000000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000001"}).unsignedSerialized);it("Extract the first element",()=>{const e=[{type:"TUPLE",offset:0},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x0000000000000000000000000000000000000000000000000000000000000045")])}),it("Extract the second element",()=>{const e=[{type:"TUPLE",offset:1},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x0000000000000000000000000000000000000000000000000000000000000001")])}),it("Slice the static leaf",()=>{const e=[{type:"TUPLE",offset:0},{type:"LEAF",leafType:"STATIC_LEAF"},{type:"SLICE",start:-4}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x00000045")])}),it("Out of bounds",()=>{const e=[{type:"TUPLE",offset:2},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!1)})}),describe("Data paths in a calldata with dynamic elements",()=>{const a=c(o.from({to:s(l),value:r,data:"0x2289b18c000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000036f6e650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000374776f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000057468726565000000000000000000000000000000000000000000000000000000"}).unsignedSerialized);it("Extract all the elements of x, concatenated together",()=>{const e=[{type:"TUPLE",offset:0},{type:"REF"},{type:"ARRAY",itemSize:1},{type:"REF"},{type:"ARRAY",itemSize:1},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x0000000000000000000000000000000000000000000000000000000000000001"),c("0x0000000000000000000000000000000000000000000000000000000000000002"),c("0x0000000000000000000000000000000000000000000000000000000000000003")])}),it("Extract all the elements of x[0]",()=>{const e=[{type:"TUPLE",offset:0},{type:"REF"},{type:"ARRAY",itemSize:1,start:0,end:1},{type:"REF"},{type:"ARRAY",itemSize:1},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x0000000000000000000000000000000000000000000000000000000000000001"),c("0x0000000000000000000000000000000000000000000000000000000000000002")])}),it("Extract all the elements of x[0:-1][-1:]",()=>{const e=[{type:"TUPLE",offset:0},{type:"REF"},{type:"ARRAY",itemSize:1,start:0,end:-1},{type:"REF"},{type:"ARRAY",itemSize:1,start:-1},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x0000000000000000000000000000000000000000000000000000000000000002")])}),it("Array out of bounds",()=>{const e=[{type:"TUPLE",offset:0},{type:"REF"},{type:"ARRAY",itemSize:1,start:0,end:1},{type:"REF"},{type:"ARRAY",itemSize:1,start:2,end:3},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!1)}),it("Extract all the elements of x[1]",()=>{const e=[{type:"TUPLE",offset:1},{type:"REF"},{type:"ARRAY",itemSize:1},{type:"REF"},{type:"LEAF",leafType:"DYNAMIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x6f6e65"),c("0x74776f"),c("0x7468726565")])}),it("Extract all the elements of x[1][:2]",()=>{const e=[{type:"TUPLE",offset:1},{type:"REF"},{type:"ARRAY",itemSize:1,end:2},{type:"REF"},{type:"LEAF",leafType:"DYNAMIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x6f6e65"),c("0x74776f")])}),it("Slice the dynamic leaf with [1:-2]",()=>{const e=[{type:"TUPLE",offset:1},{type:"REF"},{type:"ARRAY",itemSize:1,start:2,end:3},{type:"REF"},{type:"LEAF",leafType:"DYNAMIC_LEAF"},{type:"SLICE",start:1,end:-2}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x6872")])}),it("Slice the dynamic leaf with [-1:]",()=>{const e=[{type:"TUPLE",offset:1},{type:"REF"},{type:"ARRAY",itemSize:1,start:2,end:3},{type:"REF"},{type:"LEAF",leafType:"DYNAMIC_LEAF"},{type:"SLICE",start:-1}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x65")])}),it("Slice the dynamic leaf with [:1]",()=>{const e=[{type:"TUPLE",offset:1},{type:"REF"},{type:"ARRAY",itemSize:1,start:2,end:3},{type:"REF"},{type:"LEAF",leafType:"DYNAMIC_LEAF"},{type:"SLICE",end:1}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x74")])}),it("Error no leaf",()=>{const e=[{type:"TUPLE",offset:1}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!1)}),it("Error slice not at the end",()=>{const e=[{type:"TUPLE",offset:1},{type:"SLICE",start:0,end:1},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!1)}),it("Error empty slice",()=>{const e=[{type:"TUPLE",offset:1},{type:"LEAF",leafType:"DYNAMIC_LEAF"},{type:"SLICE",start:0,end:0}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!1)})}),describe("Array of tuples, with bigger itemSize",()=>{const a=c(o.from({to:s(l),value:r,data:"0xcdcd77c000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000006"}).unsignedSerialized);it("Extract the first tuple element of all array elements",()=>{const e=[{type:"REF"},{type:"ARRAY",itemSize:2},{type:"TUPLE",offset:0},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x0000000000000000000000000000000000000000000000000000000000000001"),c("0x0000000000000000000000000000000000000000000000000000000000000003"),c("0x0000000000000000000000000000000000000000000000000000000000000005")])}),it("Extract the second tuple element of all array elements",()=>{const e=[{type:"REF"},{type:"ARRAY",itemSize:2},{type:"TUPLE",offset:1},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!0),expect(t.unsafeCoerce()).toStrictEqual([c("0x0000000000000000000000000000000000000000000000000000000000000002"),c("0x0000000000000000000000000000000000000000000000000000000000000004"),c("0x0000000000000000000000000000000000000000000000000000000000000006")])})}),describe("Malformed calldata",()=>{const a=c(o.from({to:s(l),value:r,data:"0x2289b18c0000000000000000000000000000000000000000000000000000000000000080f000000000000000000000000000000000000000000000000000000000000140f000000000000000000000000000000000000000000000000000000000000002"}).unsignedSerialized);it("Dynamic leaf length overflow",()=>{const e=[{type:"TUPLE",offset:1},{type:"LEAF",leafType:"DYNAMIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!1)}),it("Calldata smaller than dynamic leaf",()=>{const e=[{type:"TUPLE",offset:0},{type:"LEAF",leafType:"DYNAMIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!1)}),it("Array length overflow",()=>{const e=[{type:"TUPLE",offset:1},{type:"ARRAY",itemSize:1},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!1)}),it("Calldata smaller than array length",()=>{const e=[{type:"TUPLE",offset:0},{type:"ARRAY",itemSize:1},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!1)}),it("Ref out of bounds",()=>{const e=[{type:"TUPLE",offset:1},{type:"REF"},{type:"LEAF",leafType:"STATIC_LEAF"}],t=i.extractValue(a,e);expect(t.isRight()).toStrictEqual(!1)})})});
|
|
2
2
|
//# sourceMappingURL=TransactionParserService.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/transaction/service/parser/TransactionParserService.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { ContainerPath, type DataPathElement } from \"@ledgerhq/context-module\";\nimport {\n bufferToHexaString,\n ByteArrayBuilder,\n hexaStringToBuffer,\n} from \"@ledgerhq/device-management-kit\";\nimport { Transaction } from \"ethers\";\n\nimport { TransactionParserService } from \"./TransactionParserService\";\n\ndescribe(\"TransactionParserService\", () => {\n const parser = new TransactionParserService();\n\n const TO = hexaStringToBuffer(\"0x3f32cF0B1DF94157EE1c3876c49BE3732C92a98f\")!;\n const VALUE = 81818275935222000n;\n const VALUE_BIN = new ByteArrayBuilder()\n .add256BitUIntToData(81818275935222000n)\n .build();\n\n beforeEach(() => {\n jest.clearAllMocks();\n });\n\n describe(\"Container paths\", () => {\n it(\"should extract TO of the container\", () => {\n // GIVEN\n const transaction = hexaStringToBuffer(\n Transaction.from({\n to: bufferToHexaString(TO),\n value: VALUE,\n data: \"0x\",\n }).unsignedSerialized,\n )!;\n\n // WHEN\n const value = parser.extractValue(transaction, ContainerPath.TO);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([TO]);\n });\n\n it(\"should extract VALUE of the container\", () => {\n // GIVEN\n const transaction = hexaStringToBuffer(\n Transaction.from({\n to: bufferToHexaString(TO),\n value: VALUE,\n data: \"0x\",\n }).unsignedSerialized,\n )!;\n\n // WHEN\n const value = parser.extractValue(transaction, ContainerPath.VALUE);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([VALUE_BIN]);\n });\n\n it(\"Unavailable container fields\", () => {\n // GIVEN\n const transaction = hexaStringToBuffer(\n Transaction.from({\n data: \"0x\",\n signature: {\n r: \"0x73b969418389828a6328fdb96e747296226832894b8bb46d60f231a9960ec3b5\",\n s: \"0x4806aaccc52354f4a42ef9efe0d89dd8cf95210829443ad7f4a9017d6b02de07\",\n v: 1,\n },\n }).unsignedSerialized,\n )!;\n\n // WHEN\n const from = parser.extractValue(transaction, ContainerPath.FROM);\n const to = parser.extractValue(transaction, ContainerPath.TO);\n\n // THEN\n expect(from.isRight()).toStrictEqual(false);\n expect(to.isRight()).toStrictEqual(false);\n });\n\n it(\"invalid transaction format\", () => {\n // GIVEN\n const transaction = hexaStringToBuffer(\"0xdeadbeef\")!;\n\n // WHEN\n const from = parser.extractValue(transaction, ContainerPath.FROM);\n\n // THEN\n expect(from.isRight()).toStrictEqual(false);\n });\n });\n\n describe(\"Data paths in a calldata with static elements\", () => {\n // Example from abi specification:\n // https://docs.soliditylang.org/en/latest/abi-spec.html\n //\n // function baz(uint32 x, bool y)\n // parameters: x = 69\n // y = true\n // calldata:\n // 0xcdcd77c0\n // [0] 0x0000000000000000000000000000000000000000000000000000000000000045\n // [1] 0x0000000000000000000000000000000000000000000000000000000000000001\n const TX = hexaStringToBuffer(\n Transaction.from({\n to: bufferToHexaString(TO),\n value: VALUE,\n data: \"0xcdcd77c000000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000001\",\n }).unsignedSerialized,\n )!;\n\n it(\"Extract the first element\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000045\",\n )!,\n ]);\n });\n\n it(\"Extract the second element\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000001\",\n )!,\n ]);\n });\n\n it(\"Slice the static leaf\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n {\n type: \"SLICE\",\n start: -4,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\"0x00000045\")!,\n ]);\n });\n\n it(\"Out of bounds\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 2,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n });\n\n describe(\"Data paths in a calldata with dynamic elements\", () => {\n // Example from abi specification:\n // https://docs.soliditylang.org/en/latest/abi-spec.html\n //\n // function g(uint256[][] x, string[] x)\n // parameters: x = [[1, 2], [3]]\n // y = [\"one\", \"two\", \"three\"]\n // calldata:\n // 0x2289b18c\n // [0] 0x0000000000000000000000000000000000000000000000000000000000000040: offset of x\n // [1] 0x0000000000000000000000000000000000000000000000000000000000000140: offset of y\n // [2] 0x0000000000000000000000000000000000000000000000000000000000000002: length of x\n // [3] 0x0000000000000000000000000000000000000000000000000000000000000040: offset of x[0]\n // [4] 0x00000000000000000000000000000000000000000000000000000000000000a0: offset of x[1]\n // [5] 0x0000000000000000000000000000000000000000000000000000000000000002: length of x[0]\n // [6] 0x0000000000000000000000000000000000000000000000000000000000000001: value of x[0][0] = 1\n // [7] 0x0000000000000000000000000000000000000000000000000000000000000002: value of x[0][1] = 2\n // [8] 0x0000000000000000000000000000000000000000000000000000000000000001: length of x[1]\n // [9] 0x0000000000000000000000000000000000000000000000000000000000000003: value of x[1][0] = 3\n // [10] 0x0000000000000000000000000000000000000000000000000000000000000003: length of y\n // [11] 0x0000000000000000000000000000000000000000000000000000000000000060: offset of y[0]\n // [12] 0x00000000000000000000000000000000000000000000000000000000000000a0: offset of y[1]\n // [13] 0x00000000000000000000000000000000000000000000000000000000000000e0: offset of y[2]\n // [14] 0x0000000000000000000000000000000000000000000000000000000000000003: length of y[0]\n // [15] 0x6f6e650000000000000000000000000000000000000000000000000000000000: value of y[0] = \"one\"\n // [16] 0x0000000000000000000000000000000000000000000000000000000000000003: length of y[1]\n // [17] 0x74776f0000000000000000000000000000000000000000000000000000000000: value of y[1] = \"two\"\n // [18] 0x0000000000000000000000000000000000000000000000000000000000000005: length of y[2]\n // [19] 0x7468726565000000000000000000000000000000000000000000000000000000: value of y[2] = \"three\"\n const TX = hexaStringToBuffer(\n Transaction.from({\n to: bufferToHexaString(TO),\n value: VALUE,\n data: \"0x2289b18c000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000036f6e650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000374776f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000057468726565000000000000000000000000000000000000000000000000000000\",\n }).unsignedSerialized,\n )!;\n\n it(\"Extract all the elements of x, concatenated together\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000001\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000002\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000003\",\n )!,\n ]);\n });\n\n it(\"Extract all the elements of x[0]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 0,\n end: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000001\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000002\",\n )!,\n ]);\n });\n\n it(\"Extract all the elements of x[0:-1][-1:]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 0,\n end: -1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: -1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000002\",\n )!,\n ]);\n });\n\n it(\"Array out of bounds\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 0,\n end: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 2,\n end: 3,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Extract all the elements of x[1]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\"0x6f6e65\")!,\n hexaStringToBuffer(\"0x74776f\")!,\n hexaStringToBuffer(\"0x7468726565\")!,\n ]);\n });\n\n it(\"Extract all the elements of x[1][:2]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n end: 2,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\"0x6f6e65\")!,\n hexaStringToBuffer(\"0x74776f\")!,\n ]);\n });\n\n it(\"Slice the dynamic leaf with [1:-2]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 2,\n end: 3,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n {\n type: \"SLICE\",\n start: 1,\n end: -2,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\"0x6872\")!,\n ]);\n });\n\n it(\"Slice the dynamic leaf with [-1:]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 2,\n end: 3,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n {\n type: \"SLICE\",\n start: -1,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([hexaStringToBuffer(\"0x65\")!]);\n });\n\n it(\"Slice the dynamic leaf with [:1]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 2,\n end: 3,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n {\n type: \"SLICE\",\n end: 1,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([hexaStringToBuffer(\"0x74\")!]);\n });\n\n it(\"Error no leaf\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Error slice not at the end\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"SLICE\",\n start: 0,\n end: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Error empty slice\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n {\n type: \"SLICE\",\n start: 0,\n end: 0,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n });\n\n describe(\"Array of tuples, with bigger itemSize\", () => {\n // Example constructed with an array of tuples just for the tests\n //\n // function baz((uint32, uint32) myTuple[])\n // parameters: myTuple = [ (1, 2), (3, 4), (5, 6) ]\n // calldata:\n // 0xcdcd77c0\n // [0] 0x0000000000000000000000000000000000000000000000000000000000000020\n // [1] 0x0000000000000000000000000000000000000000000000000000000000000003\n // [2] 0x0000000000000000000000000000000000000000000000000000000000000001\n // [3] 0x0000000000000000000000000000000000000000000000000000000000000002\n // [4] 0x0000000000000000000000000000000000000000000000000000000000000003\n // [5] 0x0000000000000000000000000000000000000000000000000000000000000004\n // [6] 0x0000000000000000000000000000000000000000000000000000000000000005\n // [7] 0x0000000000000000000000000000000000000000000000000000000000000006\n const TX = hexaStringToBuffer(\n Transaction.from({\n to: bufferToHexaString(TO),\n value: VALUE,\n data: \"0xcdcd77c000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000006\",\n }).unsignedSerialized,\n )!;\n\n it(\"Extract the first tuple element of all array elements\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 2,\n },\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000001\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000003\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000005\",\n )!,\n ]);\n });\n\n it(\"Extract the second tuple element of all array elements\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 2,\n },\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000002\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000004\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000006\",\n )!,\n ]);\n });\n });\n\n describe(\"Malformed calldata\", () => {\n // Example constructed with invalid data just for the tests\n //\n // calldata:\n // 0x2289b18c\n // [0] 0x0000000000000000000000000000000000000000000000000000000000000080\n // [1] 0xf000000000000000000000000000000000000000000000000000000000000140\n // [2] 0xf000000000000000000000000000000000000000000000000000000000000002\n const TX = hexaStringToBuffer(\n Transaction.from({\n to: bufferToHexaString(TO),\n value: VALUE,\n data: \"0x2289b18c0000000000000000000000000000000000000000000000000000000000000080f000000000000000000000000000000000000000000000000000000000000140f000000000000000000000000000000000000000000000000000000000000002\",\n }).unsignedSerialized,\n )!;\n\n it(\"Dynamic leaf length overflow\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Calldata smaller than dynamic leaf\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Array length overflow\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Calldata smaller than array length\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Ref out of bounds\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,iBAAAA,MAA2C,2BACpD,OACE,sBAAAC,EACA,oBAAAC,EACA,sBAAAC,MACK,kCACP,OAAS,eAAAC,MAAmB,SAE5B,OAAS,4BAAAC,MAAgC,6BAEzC,SAAS,2BAA4B,IAAM,CACzC,MAAMC,EAAS,IAAID,EAEbE,EAAKJ,EAAmB,4CAA4C,EACpEK,EAAQ,mBACRC,EAAY,IAAIP,EAAiB,EACpC,oBAAoB,kBAAkB,EACtC,MAAM,EAET,WAAW,IAAM,CACf,
|
|
4
|
+
"sourcesContent": ["import { ContainerPath, type DataPathElement } from \"@ledgerhq/context-module\";\nimport {\n bufferToHexaString,\n ByteArrayBuilder,\n hexaStringToBuffer,\n} from \"@ledgerhq/device-management-kit\";\nimport { Transaction } from \"ethers\";\n\nimport { TransactionParserService } from \"./TransactionParserService\";\n\ndescribe(\"TransactionParserService\", () => {\n const parser = new TransactionParserService();\n\n const TO = hexaStringToBuffer(\"0x3f32cF0B1DF94157EE1c3876c49BE3732C92a98f\")!;\n const VALUE = 81818275935222000n;\n const VALUE_BIN = new ByteArrayBuilder()\n .add256BitUIntToData(81818275935222000n)\n .build();\n\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n describe(\"Container paths\", () => {\n it(\"should extract TO of the container\", () => {\n // GIVEN\n const transaction = hexaStringToBuffer(\n Transaction.from({\n to: bufferToHexaString(TO),\n value: VALUE,\n data: \"0x\",\n }).unsignedSerialized,\n )!;\n\n // WHEN\n const value = parser.extractValue(transaction, ContainerPath.TO);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([TO]);\n });\n\n it(\"should extract VALUE of the container\", () => {\n // GIVEN\n const transaction = hexaStringToBuffer(\n Transaction.from({\n to: bufferToHexaString(TO),\n value: VALUE,\n data: \"0x\",\n }).unsignedSerialized,\n )!;\n\n // WHEN\n const value = parser.extractValue(transaction, ContainerPath.VALUE);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([VALUE_BIN]);\n });\n\n it(\"Unavailable container fields\", () => {\n // GIVEN\n const transaction = hexaStringToBuffer(\n Transaction.from({\n data: \"0x\",\n signature: {\n r: \"0x73b969418389828a6328fdb96e747296226832894b8bb46d60f231a9960ec3b5\",\n s: \"0x4806aaccc52354f4a42ef9efe0d89dd8cf95210829443ad7f4a9017d6b02de07\",\n v: 1,\n },\n }).unsignedSerialized,\n )!;\n\n // WHEN\n const from = parser.extractValue(transaction, ContainerPath.FROM);\n const to = parser.extractValue(transaction, ContainerPath.TO);\n\n // THEN\n expect(from.isRight()).toStrictEqual(false);\n expect(to.isRight()).toStrictEqual(false);\n });\n\n it(\"invalid transaction format\", () => {\n // GIVEN\n const transaction = hexaStringToBuffer(\"0xdeadbeef\")!;\n\n // WHEN\n const from = parser.extractValue(transaction, ContainerPath.FROM);\n\n // THEN\n expect(from.isRight()).toStrictEqual(false);\n });\n });\n\n describe(\"Data paths in a calldata with static elements\", () => {\n // Example from abi specification:\n // https://docs.soliditylang.org/en/latest/abi-spec.html\n //\n // function baz(uint32 x, bool y)\n // parameters: x = 69\n // y = true\n // calldata:\n // 0xcdcd77c0\n // [0] 0x0000000000000000000000000000000000000000000000000000000000000045\n // [1] 0x0000000000000000000000000000000000000000000000000000000000000001\n const TX = hexaStringToBuffer(\n Transaction.from({\n to: bufferToHexaString(TO),\n value: VALUE,\n data: \"0xcdcd77c000000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000001\",\n }).unsignedSerialized,\n )!;\n\n it(\"Extract the first element\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000045\",\n )!,\n ]);\n });\n\n it(\"Extract the second element\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000001\",\n )!,\n ]);\n });\n\n it(\"Slice the static leaf\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n {\n type: \"SLICE\",\n start: -4,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\"0x00000045\")!,\n ]);\n });\n\n it(\"Out of bounds\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 2,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n });\n\n describe(\"Data paths in a calldata with dynamic elements\", () => {\n // Example from abi specification:\n // https://docs.soliditylang.org/en/latest/abi-spec.html\n //\n // function g(uint256[][] x, string[] x)\n // parameters: x = [[1, 2], [3]]\n // y = [\"one\", \"two\", \"three\"]\n // calldata:\n // 0x2289b18c\n // [0] 0x0000000000000000000000000000000000000000000000000000000000000040: offset of x\n // [1] 0x0000000000000000000000000000000000000000000000000000000000000140: offset of y\n // [2] 0x0000000000000000000000000000000000000000000000000000000000000002: length of x\n // [3] 0x0000000000000000000000000000000000000000000000000000000000000040: offset of x[0]\n // [4] 0x00000000000000000000000000000000000000000000000000000000000000a0: offset of x[1]\n // [5] 0x0000000000000000000000000000000000000000000000000000000000000002: length of x[0]\n // [6] 0x0000000000000000000000000000000000000000000000000000000000000001: value of x[0][0] = 1\n // [7] 0x0000000000000000000000000000000000000000000000000000000000000002: value of x[0][1] = 2\n // [8] 0x0000000000000000000000000000000000000000000000000000000000000001: length of x[1]\n // [9] 0x0000000000000000000000000000000000000000000000000000000000000003: value of x[1][0] = 3\n // [10] 0x0000000000000000000000000000000000000000000000000000000000000003: length of y\n // [11] 0x0000000000000000000000000000000000000000000000000000000000000060: offset of y[0]\n // [12] 0x00000000000000000000000000000000000000000000000000000000000000a0: offset of y[1]\n // [13] 0x00000000000000000000000000000000000000000000000000000000000000e0: offset of y[2]\n // [14] 0x0000000000000000000000000000000000000000000000000000000000000003: length of y[0]\n // [15] 0x6f6e650000000000000000000000000000000000000000000000000000000000: value of y[0] = \"one\"\n // [16] 0x0000000000000000000000000000000000000000000000000000000000000003: length of y[1]\n // [17] 0x74776f0000000000000000000000000000000000000000000000000000000000: value of y[1] = \"two\"\n // [18] 0x0000000000000000000000000000000000000000000000000000000000000005: length of y[2]\n // [19] 0x7468726565000000000000000000000000000000000000000000000000000000: value of y[2] = \"three\"\n const TX = hexaStringToBuffer(\n Transaction.from({\n to: bufferToHexaString(TO),\n value: VALUE,\n data: \"0x2289b18c000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000036f6e650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000374776f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000057468726565000000000000000000000000000000000000000000000000000000\",\n }).unsignedSerialized,\n )!;\n\n it(\"Extract all the elements of x, concatenated together\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000001\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000002\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000003\",\n )!,\n ]);\n });\n\n it(\"Extract all the elements of x[0]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 0,\n end: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000001\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000002\",\n )!,\n ]);\n });\n\n it(\"Extract all the elements of x[0:-1][-1:]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 0,\n end: -1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: -1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000002\",\n )!,\n ]);\n });\n\n it(\"Array out of bounds\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 0,\n end: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 2,\n end: 3,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Extract all the elements of x[1]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\"0x6f6e65\")!,\n hexaStringToBuffer(\"0x74776f\")!,\n hexaStringToBuffer(\"0x7468726565\")!,\n ]);\n });\n\n it(\"Extract all the elements of x[1][:2]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n end: 2,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\"0x6f6e65\")!,\n hexaStringToBuffer(\"0x74776f\")!,\n ]);\n });\n\n it(\"Slice the dynamic leaf with [1:-2]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 2,\n end: 3,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n {\n type: \"SLICE\",\n start: 1,\n end: -2,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\"0x6872\")!,\n ]);\n });\n\n it(\"Slice the dynamic leaf with [-1:]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 2,\n end: 3,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n {\n type: \"SLICE\",\n start: -1,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([hexaStringToBuffer(\"0x65\")!]);\n });\n\n it(\"Slice the dynamic leaf with [:1]\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n start: 2,\n end: 3,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n {\n type: \"SLICE\",\n end: 1,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([hexaStringToBuffer(\"0x74\")!]);\n });\n\n it(\"Error no leaf\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Error slice not at the end\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"SLICE\",\n start: 0,\n end: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Error empty slice\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n {\n type: \"SLICE\",\n start: 0,\n end: 0,\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n });\n\n describe(\"Array of tuples, with bigger itemSize\", () => {\n // Example constructed with an array of tuples just for the tests\n //\n // function baz((uint32, uint32) myTuple[])\n // parameters: myTuple = [ (1, 2), (3, 4), (5, 6) ]\n // calldata:\n // 0xcdcd77c0\n // [0] 0x0000000000000000000000000000000000000000000000000000000000000020\n // [1] 0x0000000000000000000000000000000000000000000000000000000000000003\n // [2] 0x0000000000000000000000000000000000000000000000000000000000000001\n // [3] 0x0000000000000000000000000000000000000000000000000000000000000002\n // [4] 0x0000000000000000000000000000000000000000000000000000000000000003\n // [5] 0x0000000000000000000000000000000000000000000000000000000000000004\n // [6] 0x0000000000000000000000000000000000000000000000000000000000000005\n // [7] 0x0000000000000000000000000000000000000000000000000000000000000006\n const TX = hexaStringToBuffer(\n Transaction.from({\n to: bufferToHexaString(TO),\n value: VALUE,\n data: \"0xcdcd77c000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000006\",\n }).unsignedSerialized,\n )!;\n\n it(\"Extract the first tuple element of all array elements\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 2,\n },\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000001\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000003\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000005\",\n )!,\n ]);\n });\n\n it(\"Extract the second tuple element of all array elements\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"REF\",\n },\n {\n type: \"ARRAY\",\n itemSize: 2,\n },\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(true);\n expect(value.unsafeCoerce()).toStrictEqual([\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000002\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000004\",\n )!,\n hexaStringToBuffer(\n \"0x0000000000000000000000000000000000000000000000000000000000000006\",\n )!,\n ]);\n });\n });\n\n describe(\"Malformed calldata\", () => {\n // Example constructed with invalid data just for the tests\n //\n // calldata:\n // 0x2289b18c\n // [0] 0x0000000000000000000000000000000000000000000000000000000000000080\n // [1] 0xf000000000000000000000000000000000000000000000000000000000000140\n // [2] 0xf000000000000000000000000000000000000000000000000000000000000002\n const TX = hexaStringToBuffer(\n Transaction.from({\n to: bufferToHexaString(TO),\n value: VALUE,\n data: \"0x2289b18c0000000000000000000000000000000000000000000000000000000000000080f000000000000000000000000000000000000000000000000000000000000140f000000000000000000000000000000000000000000000000000000000000002\",\n }).unsignedSerialized,\n )!;\n\n it(\"Dynamic leaf length overflow\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Calldata smaller than dynamic leaf\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Array length overflow\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Calldata smaller than array length\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"ARRAY\",\n itemSize: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n\n it(\"Ref out of bounds\", () => {\n // GIVEN\n const path: DataPathElement[] = [\n {\n type: \"TUPLE\",\n offset: 1,\n },\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"STATIC_LEAF\",\n },\n ];\n\n // WHEN\n const value = parser.extractValue(TX, path);\n\n // THEN\n expect(value.isRight()).toStrictEqual(false);\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,iBAAAA,MAA2C,2BAC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
|
"names": ["ContainerPath", "bufferToHexaString", "ByteArrayBuilder", "hexaStringToBuffer", "Transaction", "TransactionParserService", "parser", "TO", "VALUE", "VALUE_BIN", "transaction", "value", "from", "to", "TX", "path"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{hexaStringToBuffer as r}from"@ledgerhq/device-management-kit";import{Transaction as
|
|
1
|
+
import{hexaStringToBuffer as r}from"@ledgerhq/device-management-kit";import{Transaction as o}from"ethers";import{SignTransactionUseCase as s}from"./SignTransactionUseCase";describe("SignTransactionUseCase",()=>{it("should call signTransaction on appBinder with the correct arguments",()=>{const t="m/44'/60'/0'/0/0",n=new o;n.to="0x1234567890123456789012345678901234567890",n.value=0n,n.data="0x";const a={signTransaction:vi.fn()},i=new s(a),e=r(n.unsignedSerialized);i.execute(t,e),expect(a.signTransaction).toHaveBeenCalledWith({derivationPath:t,transaction:e})})});
|
|
2
2
|
//# sourceMappingURL=SignTransactionUseCase.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/transaction/use-case/SignTransactionUseCase.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { hexaStringToBuffer } from \"@ledgerhq/device-management-kit\";\nimport { Transaction } from \"ethers\";\n\nimport { type EthAppBinder } from \"@internal/app-binder/EthAppBinder\";\n\nimport { SignTransactionUseCase } from \"./SignTransactionUseCase\";\n\ndescribe(\"SignTransactionUseCase\", () => {\n it(\"should call signTransaction on appBinder with the correct arguments\", () => {\n // Given\n const derivationPath = \"m/44'/60'/0'/0/0\";\n const tx: Transaction = new Transaction();\n tx.to = \"0x1234567890123456789012345678901234567890\";\n tx.value = 0n;\n tx.data = \"0x\";\n const appBinder: EthAppBinder = {\n signTransaction:
|
|
5
|
-
"mappings": "AAAA,OAAS,sBAAAA,MAA0B,kCACnC,OAAS,eAAAC,MAAmB,SAI5B,OAAS,0BAAAC,MAA8B,2BAEvC,SAAS,yBAA0B,IAAM,CACvC,GAAG,sEAAuE,IAAM,CAE9E,MAAMC,EAAiB,mBACjBC,EAAkB,IAAIH,EAC5BG,EAAG,GAAK,6CACRA,EAAG,MAAQ,GACXA,EAAG,KAAO,KACV,MAAMC,EAA0B,CAC9B,gBAAiB,
|
|
4
|
+
"sourcesContent": ["import { hexaStringToBuffer } from \"@ledgerhq/device-management-kit\";\nimport { Transaction } from \"ethers\";\n\nimport { type EthAppBinder } from \"@internal/app-binder/EthAppBinder\";\n\nimport { SignTransactionUseCase } from \"./SignTransactionUseCase\";\n\ndescribe(\"SignTransactionUseCase\", () => {\n it(\"should call signTransaction on appBinder with the correct arguments\", () => {\n // Given\n const derivationPath = \"m/44'/60'/0'/0/0\";\n const tx: Transaction = new Transaction();\n tx.to = \"0x1234567890123456789012345678901234567890\";\n tx.value = 0n;\n tx.data = \"0x\";\n const appBinder: EthAppBinder = {\n signTransaction: vi.fn(),\n } as unknown as EthAppBinder;\n const useCase = new SignTransactionUseCase(appBinder);\n const transaction = hexaStringToBuffer(tx.unsignedSerialized) as Uint8Array;\n\n // When\n useCase.execute(derivationPath, transaction);\n\n // Then\n expect(appBinder.signTransaction).toHaveBeenCalledWith({\n derivationPath,\n transaction,\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,sBAAAA,MAA0B,kCACnC,OAAS,eAAAC,MAAmB,SAI5B,OAAS,0BAAAC,MAA8B,2BAEvC,SAAS,yBAA0B,IAAM,CACvC,GAAG,sEAAuE,IAAM,CAE9E,MAAMC,EAAiB,mBACjBC,EAAkB,IAAIH,EAC5BG,EAAG,GAAK,6CACRA,EAAG,MAAQ,GACXA,EAAG,KAAO,KACV,MAAMC,EAA0B,CAC9B,gBAAiB,GAAG,GAAG,CACzB,EACMC,EAAU,IAAIJ,EAAuBG,CAAS,EAC9CE,EAAcP,EAAmBI,EAAG,kBAAkB,EAG5DE,EAAQ,QAAQH,EAAgBI,CAAW,EAG3C,OAAOF,EAAU,eAAe,EAAE,qBAAqB,CACrD,eAAAF,EACA,YAAAI,CACF,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["hexaStringToBuffer", "Transaction", "SignTransactionUseCase", "derivationPath", "tx", "appBinder", "useCase", "transaction"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{SignTypedDataUseCase as s}from"./SignTypedDataUseCase";describe("SignTypedDataUseCase",()=>{it("should call signTypedData on appBinder with the correct arguments",()=>{const e="m/44'/60'/0'/0/0",a={domain:{},types:{},primaryType:"test",message:{}},t={parse:
|
|
1
|
+
import{SignTypedDataUseCase as s}from"./SignTypedDataUseCase";describe("SignTypedDataUseCase",()=>{it("should call signTypedData on appBinder with the correct arguments",()=>{const e="m/44'/60'/0'/0/0",a={domain:{},types:{},primaryType:"test",message:{}},t={parse:vi.fn()},p={signTypedData:vi.fn()};new s(p,t).execute(e,a),expect(p.signTypedData).toHaveBeenCalledWith({derivationPath:e,parser:t,data:a})})});
|
|
2
2
|
//# sourceMappingURL=SignTypedDataUseCase.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/typed-data/use-case/SignTypedDataUseCase.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { type TypedData } from \"@api/model/TypedData\";\nimport { type EthAppBinder } from \"@internal/app-binder/EthAppBinder\";\nimport { type TypedDataParserService } from \"@internal/typed-data/service/TypedDataParserService\";\n\nimport { SignTypedDataUseCase } from \"./SignTypedDataUseCase\";\n\ndescribe(\"SignTypedDataUseCase\", () => {\n it(\"should call signTypedData on appBinder with the correct arguments\", () => {\n // Given\n const derivationPath = \"m/44'/60'/0'/0/0\";\n const typedData: TypedData = {\n domain: {},\n types: {},\n primaryType: \"test\",\n message: {},\n };\n const parser: TypedDataParserService = {\n parse:
|
|
5
|
-
"mappings": "AAIA,OAAS,wBAAAA,MAA4B,yBAErC,SAAS,uBAAwB,IAAM,CACrC,GAAG,oEAAqE,IAAM,CAE5E,MAAMC,EAAiB,mBACjBC,EAAuB,CAC3B,OAAQ,CAAC,EACT,MAAO,CAAC,EACR,YAAa,OACb,QAAS,CAAC,CACZ,EACMC,EAAiC,CACrC,MAAO,
|
|
4
|
+
"sourcesContent": ["import { type TypedData } from \"@api/model/TypedData\";\nimport { type EthAppBinder } from \"@internal/app-binder/EthAppBinder\";\nimport { type TypedDataParserService } from \"@internal/typed-data/service/TypedDataParserService\";\n\nimport { SignTypedDataUseCase } from \"./SignTypedDataUseCase\";\n\ndescribe(\"SignTypedDataUseCase\", () => {\n it(\"should call signTypedData on appBinder with the correct arguments\", () => {\n // Given\n const derivationPath = \"m/44'/60'/0'/0/0\";\n const typedData: TypedData = {\n domain: {},\n types: {},\n primaryType: \"test\",\n message: {},\n };\n const parser: TypedDataParserService = {\n parse: vi.fn(),\n };\n const appBinder = {\n signTypedData: vi.fn(),\n };\n const signTypedDataUseCase = new SignTypedDataUseCase(\n appBinder as unknown as EthAppBinder,\n parser,\n );\n\n // When\n signTypedDataUseCase.execute(derivationPath, typedData);\n\n // Then\n expect(appBinder.signTypedData).toHaveBeenCalledWith({\n derivationPath,\n parser,\n data: typedData,\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAIA,OAAS,wBAAAA,MAA4B,yBAErC,SAAS,uBAAwB,IAAM,CACrC,GAAG,oEAAqE,IAAM,CAE5E,MAAMC,EAAiB,mBACjBC,EAAuB,CAC3B,OAAQ,CAAC,EACT,MAAO,CAAC,EACR,YAAa,OACb,QAAS,CAAC,CACZ,EACMC,EAAiC,CACrC,MAAO,GAAG,GAAG,CACf,EACMC,EAAY,CAChB,cAAe,GAAG,GAAG,CACvB,EAC6B,IAAIJ,EAC/BI,EACAD,CACF,EAGqB,QAAQF,EAAgBC,CAAS,EAGtD,OAAOE,EAAU,aAAa,EAAE,qBAAqB,CACnD,eAAAH,EACA,OAAAE,EACA,KAAMD,CACR,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["SignTypedDataUseCase", "derivationPath", "typedData", "parser", "appBinder"]
|
|
7
7
|
}
|
package/lib/esm/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/device-signer-kit-ethereum",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"exports": {
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
"prettier": "prettier . --check",
|
|
31
31
|
"prettier:fix": "prettier . --write",
|
|
32
32
|
"typecheck": "tsc --noEmit",
|
|
33
|
-
"test": "
|
|
34
|
-
"test:watch": "
|
|
35
|
-
"test:coverage": "
|
|
33
|
+
"test": "vitest run",
|
|
34
|
+
"test:watch": "vitest",
|
|
35
|
+
"test:coverage": "vitest run --coverage"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@ledgerhq/signer-utils": "workspace:*",
|
|
39
39
|
"ethers": "6.13.4",
|
|
40
|
-
"inversify": "^6.2.
|
|
40
|
+
"inversify": "^6.2.2",
|
|
41
41
|
"inversify-logger-middleware": "^3.1.0",
|
|
42
42
|
"purify-ts": "^2.1.0",
|
|
43
43
|
"reflect-metadata": "^0.2.2",
|
|
@@ -49,11 +49,11 @@
|
|
|
49
49
|
"@ledgerhq/device-management-kit": "workspace:*",
|
|
50
50
|
"@ledgerhq/esbuild-tools": "workspace:*",
|
|
51
51
|
"@ledgerhq/eslint-config-dsdk": "workspace:*",
|
|
52
|
-
"@ledgerhq/jest-config-dsdk": "workspace:*",
|
|
53
52
|
"@ledgerhq/prettier-config-dsdk": "workspace:*",
|
|
54
53
|
"@ledgerhq/tsconfig-dsdk": "workspace:*",
|
|
54
|
+
"@ledgerhq/vitest-config-dmk": "workspace:*",
|
|
55
55
|
"@types/semver": "^7.5.8",
|
|
56
|
-
"rxjs": "^7.8.
|
|
56
|
+
"rxjs": "^7.8.2",
|
|
57
57
|
"ts-node": "^10.9.2"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
@@ -4,6 +4,7 @@ import { DefaultSignerEth } from "../internal/DefaultSignerEth";
|
|
|
4
4
|
type SignerEthBuilderConstructorArgs = {
|
|
5
5
|
dmk: DeviceManagementKit;
|
|
6
6
|
sessionId: DeviceSessionId;
|
|
7
|
+
originToken?: string;
|
|
7
8
|
};
|
|
8
9
|
/**
|
|
9
10
|
* Builder for the `SignerEth` class.
|
|
@@ -17,8 +18,9 @@ type SignerEthBuilderConstructorArgs = {
|
|
|
17
18
|
export declare class SignerEthBuilder {
|
|
18
19
|
private _dmk;
|
|
19
20
|
private _sessionId;
|
|
20
|
-
private
|
|
21
|
-
|
|
21
|
+
private _customContextModule;
|
|
22
|
+
private _originToken;
|
|
23
|
+
constructor({ dmk, sessionId, originToken, }: SignerEthBuilderConstructorArgs);
|
|
22
24
|
/**
|
|
23
25
|
* Override the default context module
|
|
24
26
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignerEthBuilder.d.ts","sourceRoot":"","sources":["../../../src/api/SignerEthBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACrB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,KAAK,+BAA+B,GAAG;IACrC,GAAG,EAAE,mBAAmB,CAAC;IACzB,SAAS,EAAE,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"SignerEthBuilder.d.ts","sourceRoot":"","sources":["../../../src/api/SignerEthBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACrB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,KAAK,+BAA+B,GAAG;IACrC,GAAG,EAAE,mBAAmB,CAAC;IACzB,SAAS,EAAE,eAAe,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;;;GAQG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,IAAI,CAAsB;IAClC,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,oBAAoB,CAA4B;IACxD,OAAO,CAAC,YAAY,CAAqB;gBAE7B,EACV,GAAG,EACH,SAAS,EACT,WAAW,GACZ,EAAE,+BAA+B;IAMlC;;;;;OAKG;IACH,iBAAiB,CAAC,aAAa,EAAE,aAAa;IAK9C;;;;OAIG;IACI,KAAK;CAWb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GetConfigCommandTypes.d.ts","sourceRoot":"","sources":["../../../../src/api/app-binder/GetConfigCommandTypes.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC;IACtC,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC"}
|
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
import { type CommandErrorResult, type
|
|
1
|
+
import { type CommandErrorResult, type ExecuteDeviceActionReturnType, type OpenAppDAError, type OpenAppDARequiredInteraction, type UserInteractionRequired } from "@ledgerhq/device-management-kit";
|
|
2
2
|
import { type Signature } from "../model/Signature";
|
|
3
3
|
import { type EthErrorCodes } from "../../internal/app-binder/command/utils/ethAppErrors";
|
|
4
4
|
export type SignPersonalMessageDAOutput = Signature;
|
|
5
|
-
export type SignPersonalMessageDAInput = {
|
|
6
|
-
readonly derivationPath: string;
|
|
7
|
-
readonly message: string | Uint8Array;
|
|
8
|
-
};
|
|
9
5
|
export type SignPersonalMessageDAError = OpenAppDAError | CommandErrorResult<EthErrorCodes>["error"];
|
|
10
6
|
type SignPersonalMessageDARequiredInteraction = OpenAppDARequiredInteraction | UserInteractionRequired.SignPersonalMessage;
|
|
11
7
|
export type SignPersonalMessageDAIntermediateValue = {
|
|
12
8
|
requiredUserInteraction: SignPersonalMessageDARequiredInteraction;
|
|
13
9
|
};
|
|
14
|
-
export type SignPersonalMessageDAState = DeviceActionState<SignPersonalMessageDAOutput, SignPersonalMessageDAError, SignPersonalMessageDAIntermediateValue>;
|
|
15
|
-
export type SignPersonalMessageDAInternalState = {
|
|
16
|
-
readonly error: SignPersonalMessageDAError | null;
|
|
17
|
-
readonly signature: Signature | null;
|
|
18
|
-
};
|
|
19
10
|
export type SignPersonalMessageDAReturnType = ExecuteDeviceActionReturnType<SignPersonalMessageDAOutput, SignPersonalMessageDAError, SignPersonalMessageDAIntermediateValue>;
|
|
20
11
|
export {};
|
|
21
12
|
//# sourceMappingURL=SignPersonalMessageDeviceActionTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignPersonalMessageDeviceActionTypes.d.ts","sourceRoot":"","sources":["../../../../src/api/app-binder/SignPersonalMessageDeviceActionTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,
|
|
1
|
+
{"version":3,"file":"SignPersonalMessageDeviceActionTypes.d.ts","sourceRoot":"","sources":["../../../../src/api/app-binder/SignPersonalMessageDeviceActionTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACnB,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAC7B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAErF,MAAM,MAAM,2BAA2B,GAAG,SAAS,CAAC;AAEpD,MAAM,MAAM,0BAA0B,GAClC,cAAc,GACd,kBAAkB,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC;AAE/C,KAAK,wCAAwC,GACzC,4BAA4B,GAC5B,uBAAuB,CAAC,mBAAmB,CAAC;AAEhD,MAAM,MAAM,sCAAsC,GAAG;IACnD,uBAAuB,EAAE,wCAAwC,CAAC;CACnE,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG,6BAA6B,CACzE,2BAA2B,EAC3B,0BAA0B,EAC1B,sCAAsC,CACvC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type ClearSignContextSuccess, type ContextModule } from "@ledgerhq/context-module";
|
|
1
|
+
import { type ClearSignContextSuccess, type ClearSignContextType, type ContextModule } from "@ledgerhq/context-module";
|
|
2
2
|
import { type CommandErrorResult, type DeviceActionState, type ExecuteDeviceActionReturnType, type OpenAppDAError, type OpenAppDARequiredInteraction, type UserInteractionRequired } from "@ledgerhq/device-management-kit";
|
|
3
|
+
import { type GetConfigCommandResponse } from "../app-binder/GetConfigCommandTypes";
|
|
3
4
|
import { type Signature } from "../model/Signature";
|
|
4
5
|
import { type TransactionOptions } from "../model/TransactionOptions";
|
|
5
6
|
import { type TransactionType } from "../model/TransactionType";
|
|
@@ -7,6 +8,15 @@ import { type EthErrorCodes } from "../../internal/app-binder/command/utils/ethA
|
|
|
7
8
|
import { type GenericContext } from "../../internal/app-binder/task/ProvideTransactionGenericContextTask";
|
|
8
9
|
import { type TransactionMapperService } from "../../internal/transaction/service/mapper/TransactionMapperService";
|
|
9
10
|
import { type TransactionParserService } from "../../internal/transaction/service/parser/TransactionParserService";
|
|
11
|
+
export declare enum SignTransactionDAStep {
|
|
12
|
+
OPEN_APP = "signer.eth.steps.openApp",
|
|
13
|
+
GET_APP_CONFIG = "signer.eth.steps.getAppConfig",
|
|
14
|
+
WEB3_CHECKS_OPT_IN = "signer.eth.steps.web3ChecksOptIn",
|
|
15
|
+
BUILD_CONTEXT = "signer.eth.steps.buildContext",
|
|
16
|
+
PROVIDE_CONTEXT = "signer.eth.steps.provideContext",
|
|
17
|
+
PROVIDE_GENERIC_CONTEXT = "signer.eth.steps.provideGenericContext",
|
|
18
|
+
SIGN_TRANSACTION = "signer.eth.steps.signTransaction"
|
|
19
|
+
}
|
|
10
20
|
export type SignTransactionDAOutput = Signature;
|
|
11
21
|
export type SignTransactionDAInput = {
|
|
12
22
|
readonly derivationPath: string;
|
|
@@ -17,15 +27,17 @@ export type SignTransactionDAInput = {
|
|
|
17
27
|
readonly options: TransactionOptions;
|
|
18
28
|
};
|
|
19
29
|
export type SignTransactionDAError = OpenAppDAError | CommandErrorResult<EthErrorCodes>["error"];
|
|
20
|
-
type SignTransactionDARequiredInteraction = OpenAppDARequiredInteraction | UserInteractionRequired.SignTransaction;
|
|
30
|
+
type SignTransactionDARequiredInteraction = OpenAppDARequiredInteraction | UserInteractionRequired.Web3ChecksOptIn | UserInteractionRequired.SignTransaction;
|
|
21
31
|
export type SignTransactionDAIntermediateValue = {
|
|
22
32
|
requiredUserInteraction: SignTransactionDARequiredInteraction;
|
|
33
|
+
step: SignTransactionDAStep;
|
|
23
34
|
};
|
|
24
35
|
export type SignTransactionDAState = DeviceActionState<SignTransactionDAOutput, SignTransactionDAError, SignTransactionDAIntermediateValue>;
|
|
25
36
|
export type SignTransactionDAInternalState = {
|
|
26
37
|
readonly error: SignTransactionDAError | null;
|
|
27
|
-
readonly
|
|
38
|
+
readonly appConfig: GetConfigCommandResponse | null;
|
|
28
39
|
readonly clearSignContexts: ClearSignContextSuccess[] | GenericContext | null;
|
|
40
|
+
readonly web3Check: ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null;
|
|
29
41
|
readonly serializedTransaction: Uint8Array | null;
|
|
30
42
|
readonly chainId: number | null;
|
|
31
43
|
readonly transactionType: TransactionType | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignTransactionDeviceActionTypes.d.ts","sourceRoot":"","sources":["../../../../src/api/app-binder/SignTransactionDeviceActionTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACnB,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAC7B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iDAAiD,CAAC;AACrF,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gEAAgE,CAAC;AACrG,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,+DAA+D,CAAC;AAC9G,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,+DAA+D,CAAC;AAE9G,MAAM,MAAM,uBAAuB,GAAG,SAAS,CAAC;AAEhD,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,wBAAwB,CAAC;IAC1C,QAAQ,CAAC,MAAM,EAAE,wBAAwB,CAAC;IAC1C,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAC9B,cAAc,GACd,kBAAkB,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC;AAE/C,KAAK,oCAAoC,GACrC,4BAA4B,GAC5B,uBAAuB,CAAC,eAAe,CAAC;AAE5C,MAAM,MAAM,kCAAkC,GAAG;IAC/C,uBAAuB,EAAE,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"SignTransactionDeviceActionTypes.d.ts","sourceRoot":"","sources":["../../../../src/api/app-binder/SignTransactionDeviceActionTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACnB,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAC7B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iDAAiD,CAAC;AACrF,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gEAAgE,CAAC;AACrG,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,+DAA+D,CAAC;AAC9G,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,+DAA+D,CAAC;AAE9G,oBAAY,qBAAqB;IAC/B,QAAQ,6BAA6B;IACrC,cAAc,kCAAkC;IAChD,kBAAkB,qCAAqC;IACvD,aAAa,kCAAkC;IAC/C,eAAe,oCAAoC;IACnD,uBAAuB,2CAA2C;IAClE,gBAAgB,qCAAqC;CACtD;AAED,MAAM,MAAM,uBAAuB,GA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AQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,6BAA6B,CACrE,uBAAuB,EACvB,sBAAsB,EACtB,kCAAkC,CACnC,CAAC"}
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import { type ContextModule } from "@ledgerhq/context-module";
|
|
2
2
|
import { type CommandErrorResult, type DeviceActionState, type ExecuteDeviceActionReturnType, type OpenAppDAError, type OpenAppDARequiredInteraction, type UserInteractionRequired } from "@ledgerhq/device-management-kit";
|
|
3
|
+
import { type GetConfigCommandResponse } from "../app-binder/GetConfigCommandTypes";
|
|
3
4
|
import { type Signature } from "../model/Signature";
|
|
4
5
|
import { type TypedData } from "../model/TypedData";
|
|
5
6
|
import { type EthErrorCodes } from "../../internal/app-binder/command/utils/ethAppErrors";
|
|
6
7
|
import type { ProvideEIP712ContextTaskArgs } from "../../internal/app-binder/task/ProvideEIP712ContextTask";
|
|
7
8
|
import { type TypedDataParserService } from "../../internal/typed-data/service/TypedDataParserService";
|
|
9
|
+
export declare enum SignTypedDataDAStateStep {
|
|
10
|
+
OPEN_APP = "signer.eth.steps.openApp",
|
|
11
|
+
GET_APP_CONFIG = "signer.eth.steps.getAppConfig",
|
|
12
|
+
WEB3_CHECKS_OPT_IN = "signer.eth.steps.web3ChecksOptIn",
|
|
13
|
+
BUILD_CONTEXT = "signer.eth.steps.buildContext",
|
|
14
|
+
PROVIDE_CONTEXT = "signer.eth.steps.provideContext",
|
|
15
|
+
PROVIDE_GENERIC_CONTEXT = "signer.eth.steps.provideGenericContext",
|
|
16
|
+
SIGN_TYPED_DATA = "signer.eth.steps.signTypedData",
|
|
17
|
+
SIGN_TYPED_DATA_LEGACY = "signer.eth.steps.signTypedDataLegacy"
|
|
18
|
+
}
|
|
8
19
|
export type SignTypedDataDAOutput = Signature;
|
|
9
20
|
export type SignTypedDataDAInput = {
|
|
10
21
|
readonly derivationPath: string;
|
|
@@ -13,13 +24,15 @@ export type SignTypedDataDAInput = {
|
|
|
13
24
|
readonly contextModule: ContextModule;
|
|
14
25
|
};
|
|
15
26
|
export type SignTypedDataDAError = OpenAppDAError | CommandErrorResult<EthErrorCodes>["error"];
|
|
16
|
-
type SignTypedDataDARequiredInteraction = OpenAppDARequiredInteraction | UserInteractionRequired.SignTypedData;
|
|
27
|
+
type SignTypedDataDARequiredInteraction = OpenAppDARequiredInteraction | UserInteractionRequired.Web3ChecksOptIn | UserInteractionRequired.SignTypedData;
|
|
17
28
|
export type SignTypedDataDAIntermediateValue = {
|
|
18
29
|
requiredUserInteraction: SignTypedDataDARequiredInteraction;
|
|
30
|
+
step: SignTypedDataDAStateStep;
|
|
19
31
|
};
|
|
20
32
|
export type SignTypedDataDAState = DeviceActionState<SignTypedDataDAOutput, SignTypedDataDAError, SignTypedDataDAIntermediateValue>;
|
|
21
33
|
export type SignTypedDataDAInternalState = {
|
|
22
34
|
readonly error: SignTypedDataDAError | null;
|
|
35
|
+
readonly appConfig: GetConfigCommandResponse | null;
|
|
23
36
|
readonly typedDataContext: ProvideEIP712ContextTaskArgs | null;
|
|
24
37
|
readonly signature: Signature | null;
|
|
25
38
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignTypedDataDeviceActionTypes.d.ts","sourceRoot":"","sources":["../../../../src/api/app-binder/SignTypedDataDeviceActionTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACnB,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAC7B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,SAAS,EAAE,MAA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