@ledgerhq/device-signer-kit-ethereum 1.9.1 → 1.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/internal/app-binder/command/GetAddressCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetAddressCommand.js.map +2 -2
- 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 +1 -1
- package/lib/cjs/internal/app-binder/command/GetAppConfigurationCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetAppConfigurationCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetAppConfigurationCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetChallengeCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetChallengeCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetChallengeCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetChallengeCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideEnumCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideEnumCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideEnumCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideEnumCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/ProvideNFTInformationCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideNFTInformationCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideNFTInformationCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideNFTInformationCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/ProvideNetworkConfigurationCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideNetworkConfigurationCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/ProvideProxyInfoCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideProxyInfoCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideProxyInfoCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideProxyInfoCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/ProvideSafeAccountCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideSafeAccountCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideSafeAccountCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideSafeAccountCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/ProvideTokenInformationCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideTokenInformationCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideTokenInformationCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideTokenInformationCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideTransactionFieldDescriptionCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideTransactionFieldDescriptionCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideTransactionFieldDescriptionCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideTransactionFieldDescriptionCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/ProvideTransactionInformationCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideTransactionInformationCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideTransactionInformationCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideTransactionInformationCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/ProvideTrustedNameCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideTrustedNameCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideTrustedNameCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideTrustedNameCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/ProvideWeb3CheckCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideWeb3CheckCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideWeb3CheckCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideWeb3CheckCommand.test.js.map +3 -3
- 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/SendEIP712StructDefinitionCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SendEIP712StructDefinitionCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SendEIP712StructDefinitionCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SendEIP712StructDefinitionCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SendEIP712StructImplemCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SendEIP712StructImplemCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SendEIP712StructImplemCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SendEIP712StructImplemCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SetExternalPluginCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SetExternalPluginCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SetExternalPluginCommand.test.js +2 -2
- package/lib/cjs/internal/app-binder/command/SetExternalPluginCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SetPluginCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SetPluginCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SetPluginCommand.test.js +2 -2
- package/lib/cjs/internal/app-binder/command/SetPluginCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SignAuthorizationDelegationCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignAuthorizationDelegationCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignAuthorizationDelegationCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignAuthorizationDelegationCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SignEIP712Command.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignEIP712Command.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SignEIP712Command.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignEIP712Command.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignPersonalMessageCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignPersonalMessageCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignPersonalMessageCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignPersonalMessageCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SignTransactionCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignTransactionCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignTransactionCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignTransactionCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/StartTransactionCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/StartTransactionCommand.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 +3 -3
- package/lib/cjs/internal/app-binder/command/StoreTransactionCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/StoreTransactionCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/StoreTransactionCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/StoreTransactionCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/Web3CheckOptInCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/Web3CheckOptInCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/Web3CheckOptInCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/Web3CheckOptInCommand.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 +2 -2
- 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 +2 -2
- package/lib/cjs/package.json +1 -1
- package/lib/esm/internal/app-binder/command/GetAddressCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/GetAddressCommand.js.map +2 -2
- 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 +1 -1
- package/lib/esm/internal/app-binder/command/GetAppConfigurationCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetAppConfigurationCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/GetAppConfigurationCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetChallengeCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/GetChallengeCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetChallengeCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/GetChallengeCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideEnumCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideEnumCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideEnumCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideEnumCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/ProvideNFTInformationCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideNFTInformationCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideNFTInformationCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideNFTInformationCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/ProvideNetworkConfigurationCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideNetworkConfigurationCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/ProvideProxyInfoCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideProxyInfoCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideProxyInfoCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideProxyInfoCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/ProvideSafeAccountCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideSafeAccountCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideSafeAccountCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideSafeAccountCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/ProvideTokenInformationCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideTokenInformationCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideTokenInformationCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideTokenInformationCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideTransactionFieldDescriptionCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideTransactionFieldDescriptionCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideTransactionFieldDescriptionCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideTransactionFieldDescriptionCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/ProvideTransactionInformationCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideTransactionInformationCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideTransactionInformationCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideTransactionInformationCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/ProvideTrustedNameCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideTrustedNameCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideTrustedNameCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideTrustedNameCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/ProvideWeb3CheckCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideWeb3CheckCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideWeb3CheckCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideWeb3CheckCommand.test.js.map +3 -3
- 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/SendEIP712StructDefinitionCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SendEIP712StructDefinitionCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SendEIP712StructDefinitionCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SendEIP712StructDefinitionCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SendEIP712StructImplemCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SendEIP712StructImplemCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SendEIP712StructImplemCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SendEIP712StructImplemCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SetExternalPluginCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SetExternalPluginCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SetExternalPluginCommand.test.js +2 -2
- package/lib/esm/internal/app-binder/command/SetExternalPluginCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SetPluginCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SetPluginCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SetPluginCommand.test.js +2 -2
- package/lib/esm/internal/app-binder/command/SetPluginCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SignAuthorizationDelegationCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SignAuthorizationDelegationCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignAuthorizationDelegationCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignAuthorizationDelegationCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SignEIP712Command.js +1 -1
- package/lib/esm/internal/app-binder/command/SignEIP712Command.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignEIP712Command.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignEIP712Command.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignPersonalMessageCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SignPersonalMessageCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignPersonalMessageCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignPersonalMessageCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SignTransactionCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SignTransactionCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignTransactionCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignTransactionCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/StartTransactionCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/StartTransactionCommand.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 +3 -3
- package/lib/esm/internal/app-binder/command/StoreTransactionCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/StoreTransactionCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/StoreTransactionCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/StoreTransactionCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/Web3CheckOptInCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/Web3CheckOptInCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/Web3CheckOptInCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/Web3CheckOptInCommand.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 +2 -2
- 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/package.json +1 -1
- package/lib/types/internal/app-binder/command/GetAddressCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/GetAddressCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetAppConfigurationCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/GetAppConfigurationCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetChallengeCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/GetChallengeCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ProvideEnumCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/ProvideEnumCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ProvideNFTInformationCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/ProvideNFTInformationCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ProvideNetworkConfigurationCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/ProvideNetworkConfigurationCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ProvideProxyInfoCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/ProvideProxyInfoCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ProvideSafeAccountCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/ProvideSafeAccountCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ProvideTokenInformationCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/ProvideTokenInformationCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ProvideTransactionFieldDescriptionCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/ProvideTransactionFieldDescriptionCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ProvideTransactionInformationCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/ProvideTransactionInformationCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ProvideTrustedNameCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/ProvideTrustedNameCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ProvideWeb3CheckCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/ProvideWeb3CheckCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SendEIP712FilteringCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/SendEIP712FilteringCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SendEIP712StructDefinitionCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/SendEIP712StructDefinitionCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SendEIP712StructImplemCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/SendEIP712StructImplemCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SetExternalPluginCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/SetExternalPluginCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SetPluginCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/SetPluginCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignAuthorizationDelegationCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/SignAuthorizationDelegationCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignEIP712Command.d.ts +1 -0
- package/lib/types/internal/app-binder/command/SignEIP712Command.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignPersonalMessageCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/SignPersonalMessageCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignTransactionCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/SignTransactionCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/StartTransactionCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/StartTransactionCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/StoreTransactionCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/StoreTransactionCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/Web3CheckOptInCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/Web3CheckOptInCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +5 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SendEIP712FilteringCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type ApduResponse,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {\n CalldataParamPresence,\n Eip712FilterType,\n SendEIP712FilteringCommand,\n type SendEIP712FilteringCommandArgs,\n} from \"./SendEIP712FilteringCommand\";\n\nconst ACTIVATE_APDU = Uint8Array.from([0xe0, 0x1e, 0x00, 0x00, 0x00]);\nconst MESSAGE_INFO_APDU = Uint8Array.from([\n 0xe0, 0x1e, 0x00, 0x0f, 0x54, 0x0b, 0x31, 0x69, 0x6e, 0x63, 0x68, 0x20, 0x4f,\n 0x72, 0x64, 0x65, 0x72, 0x06, 0x46, 0x30, 0x44, 0x02, 0x20, 0x29, 0x5e, 0x0a,\n 0xeb, 0x17, 0xca, 0x09, 0x29, 0xb2, 0xa9, 0x4c, 0x32, 0x4d, 0x67, 0xd0, 0xb5,\n 0x52, 0x8a, 0xba, 0x26, 0x81, 0x77, 0xf3, 0xac, 0x29, 0x7b, 0x56, 0x31, 0x41,\n 0xe0, 0x00, 0x27, 0x02, 0x20, 0x3a, 0xc3, 0x60, 0xd9, 0xfd, 0x0c, 0x9c, 0x0c,\n 0x12, 0x27, 0x9d, 0x1e, 0x73, 0xbe, 0xa5, 0xd5, 0x49, 0xa1, 0xe8, 0x14, 0x1f,\n 0x45, 0x4d, 0x88, 0xfb, 0xe1, 0xe8, 0xef, 0x97, 0x0e, 0x68, 0x02,\n]);\nconst RAW_APDU = Uint8Array.from([\n 0xe0, 0x1e, 0x00, 0xff, 0x4d, 0x04, 0x46, 0x72, 0x6f, 0x6d, 0x47, 0x30, 0x45,\n 0x02, 0x21, 0x00, 0xb8, 0x20, 0xe4, 0xdf, 0xb1, 0xa0, 0xcd, 0xe6, 0xdc, 0x97,\n 0xd9, 0xa3, 0x4e, 0xeb, 0xb1, 0xa4, 0xee, 0xf0, 0xb2, 0x26, 0x26, 0x2e, 0x67,\n 0x88, 0x11, 0x8a, 0xb3, 0xc7, 0xfb, 0x79, 0xfe, 0x35, 0x02, 0x20, 0x2d, 0x42,\n 0x6a, 0x38, 0x8b, 0x4c, 0x3a, 0x80, 0x96, 0xb3, 0xf8, 0x44, 0x12, 0xa7, 0x02,\n 0xea, 0x53, 0x77, 0x70, 0xe6, 0x1e, 0xe0, 0x72, 0x7e, 0xc1, 0xb7, 0x10, 0xc1,\n 0xda, 0x52, 0x0c, 0x44,\n]);\nconst CALLDATA_INFO_APDU = Uint8Array.from([\n 0xe0, 0x1e, 0x00, 0xfa, 0x4f, 0x03, 0x01, 0x01, 0x00, 0x01, 0x00, 0x02, 0x47,\n 0x30, 0x45, 0x02, 0x21, 0x00, 0xff, 0x72, 0x78, 0x47, 0x44, 0x54, 0x31, 0xe5,\n 0x71, 0xcd, 0x2a, 0x0d, 0x9d, 0xb4, 0x2a, 0x7e, 0xb6, 0x2e, 0x37, 0x87, 0x7b,\n 0x9b, 0xf2, 0x0e, 0x6a, 0x96, 0x58, 0x42, 0x55, 0x34, 0x7e, 0x19, 0x02, 0x20,\n 0x0a, 0x6e, 0x95, 0xb7, 0xf8, 0xe6, 0x3b, 0x2f, 0xab, 0x0b, 0xef, 0x88, 0xc7,\n 0x47, 0xde, 0x6a, 0x38, 0x7d, 0x06, 0x35, 0x1b, 0xe5, 0xbd, 0xc3, 0x4b, 0x2c,\n 0x1f, 0x9a, 0xea, 0x6f, 0xdd, 0x28,\n]);\nconst CALLDATA_VALUE_APDU = Uint8Array.from([\n 0xe0, 0x1e, 0x00, 0xf9, 0x49, 0x07, 0x47, 0x30, 0x45, 0x02, 0x21, 0x00, 0xff,\n 0x72, 0x78, 0x47, 0x44, 0x54, 0x31, 0xe5, 0x71, 0xcd, 0x2a, 0x0d, 0x9d, 0xb4,\n 0x2a, 0x7e, 0xb6, 0x2e, 0x37, 0x87, 0x7b, 0x9b, 0xf2, 0x0e, 0x6a, 0x96, 0x58,\n 0x42, 0x55, 0x34, 0x7e, 0x19, 0x02, 0x20, 0x0a, 0x6e, 0x95, 0xb7, 0xf8, 0xe6,\n 0x3b, 0x2f, 0xab, 0x0b, 0xef, 0x88, 0xc7, 0x47, 0xde, 0x6a, 0x38, 0x7d, 0x06,\n 0x35, 0x1b, 0xe5, 0xbd, 0xc3, 0x4b, 0x2c, 0x1f, 0x9a, 0xea, 0x6f, 0xdd, 0x28,\n]);\nconst TOKEN_APDU = Uint8Array.from([\n 0xe0, 0x1e, 0x00, 0xfd, 0x49, 0x01, 0x47, 0x30, 0x45, 0x02, 0x21, 0x00, 0xff,\n 0x72, 0x78, 0x47, 0x44, 0x54, 0x31, 0xe5, 0x71, 0xcd, 0x2a, 0x0d, 0x9d, 0xb4,\n 0x2a, 0x7e, 0xb6, 0x2e, 0x37, 0x87, 0x7b, 0x9b, 0xf2, 0x0e, 0x6a, 0x96, 0x58,\n 0x42, 0x55, 0x34, 0x7e, 0x19, 0x02, 0x20, 0x0a, 0x6e, 0x95, 0xb7, 0xf8, 0xe6,\n 0x3b, 0x2f, 0xab, 0x0b, 0xef, 0x88, 0xc7, 0x47, 0xde, 0x6a, 0x38, 0x7d, 0x06,\n 0x35, 0x1b, 0xe5, 0xbd, 0xc3, 0x4b, 0x2c, 0x1f, 0x9a, 0xea, 0x6f, 0xdd, 0x28,\n]);\nconst AMOUNT_APDU = Uint8Array.from([\n 0xe0, 0x1e, 0x00, 0xfe, 0x59, 0x0f, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65,\n 0x20, 0x6d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x01, 0x47, 0x30, 0x45, 0x02,\n 0x21, 0x00, 0xa5, 0x9d, 0xc4, 0x79, 0xa8, 0x38, 0xa8, 0x13, 0x90, 0x9c, 0x14,\n 0x0a, 0x15, 0xe6, 0xb6, 0x5b, 0xc5, 0x8c, 0x56, 0x33, 0x28, 0x4b, 0xf9, 0x73,\n 0xc4, 0x36, 0xde, 0x5a, 0x59, 0x26, 0x34, 0xe2, 0x02, 0x20, 0x1e, 0x03, 0x8f,\n 0xc7, 0x99, 0x5d, 0x93, 0x9f, 0xcc, 0xd5, 0x46, 0xe4, 0xc8, 0x5e, 0x79, 0x3c,\n 0x0a, 0xd4, 0x51, 0x21, 0x6e, 0x36, 0xa4, 0xed, 0xfc, 0x7b, 0xce, 0x5b, 0xe2,\n 0x78, 0x08, 0xcb,\n]);\nconst TRUSTED_NAME_APDU = Uint8Array.from([\n 0xe0, 0x1e, 0x00, 0xfb, 0x56, 0x07, 0x53, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x72,\n 0x01, 0x02, 0x03, 0x01, 0x00, 0x02, 0x47, 0x30, 0x45, 0x02, 0x21, 0x00, 0xe8,\n 0x47, 0x16, 0x6e, 0x60, 0xf8, 0x51, 0xe3, 0xc8, 0xd1, 0xf4, 0x41, 0x39, 0x81,\n 0x18, 0x98, 0xcc, 0xd0, 0xd3, 0xa0, 0x3a, 0xed, 0x6c, 0x77, 0xf8, 0xc3, 0x99,\n 0x38, 0x13, 0xf4, 0x79, 0xd2, 0x02, 0x20, 0x31, 0xfe, 0x6b, 0x6a, 0x57, 0x4b,\n 0x56, 0xc5, 0x10, 0x40, 0x03, 0xcf, 0x07, 0x90, 0x0d, 0x11, 0xff, 0xaf, 0x30,\n 0x3d, 0xc0, 0x16, 0xda, 0x4c, 0x1c, 0x3d, 0x18, 0x46, 0x63, 0xda, 0x8f, 0x6a,\n]);\nconst DATE_TIME_APDU = Uint8Array.from([\n 0xe0, 0x1e, 0x00, 0xfc, 0x58, 0x0f, 0x41, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x61,\n 0x6c, 0x20, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x47, 0x30, 0x45, 0x02, 0x21,\n 0x00, 0xe8, 0x47, 0x16, 0x6e, 0x60, 0xf8, 0x51, 0xe3, 0xc8, 0xd1, 0xf4, 0x41,\n 0x39, 0x81, 0x18, 0x98, 0xcc, 0xd0, 0xd3, 0xa0, 0x3a, 0xed, 0x6c, 0x77, 0xf8,\n 0xc3, 0x99, 0x38, 0x13, 0xf4, 0x79, 0xd2, 0x02, 0x20, 0x31, 0xfe, 0x6b, 0x6a,\n 0x57, 0x4b, 0x56, 0xc5, 0x10, 0x40, 0x03, 0xcf, 0x07, 0x90, 0x0d, 0x11, 0xff,\n 0xaf, 0x30, 0x3d, 0xc0, 0x16, 0xda, 0x4c, 0x1c, 0x3d, 0x18, 0x46, 0x63, 0xda,\n 0x8f, 0x6a,\n]);\nconst DISCARDED_PATH_APDU = Uint8Array.from([\n 0xe0, 0x1e, 0x00, 0x01, 0x11, 0x10, 0x74, 0x6f, 0x2e, 0x5b, 0x5d, 0x2e, 0x77,\n 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x73, 0x2e, 0x5b, 0x5d,\n]);\n\ndescribe(\"SendEIP712FilteringCommand\", () => {\n describe(\"getApdu\", () => {\n it(\"Activate APDU\", () => {\n // GIVEN\n const args: SendEIP712FilteringCommandArgs = {\n type: Eip712FilterType.Activation,\n };\n // WHEN\n const command = new SendEIP712FilteringCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(ACTIVATE_APDU);\n });\n\n it(\"Discarded path APDU\", () => {\n // GIVEN\n const args: SendEIP712FilteringCommandArgs = {\n type: Eip712FilterType.DiscardedPath,\n path: \"to.[].wallets.[]\",\n };\n // WHEN\n const command = new SendEIP712FilteringCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(DISCARDED_PATH_APDU);\n });\n\n it(\"Message info APDU\", () => {\n // GIVEN\n const args: SendEIP712FilteringCommandArgs = {\n type: Eip712FilterType.MessageInfo,\n displayName: \"1inch Order\",\n filtersCount: 6,\n signature:\n \"30440220295e0aeb17ca0929b2a94c324d67d0b5528aba268177f3ac297b563141e0002702203ac360d9fd0c9c0c12279d1e73bea5d549a1e8141f454d88fbe1e8ef970e6802\",\n };\n // WHEN\n const command = new SendEIP712FilteringCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(MESSAGE_INFO_APDU);\n });\n\n it(\"Raw APDU\", () => {\n // GIVEN\n const args: SendEIP712FilteringCommandArgs = {\n type: Eip712FilterType.Raw,\n discarded: false,\n displayName: \"From\",\n signature:\n \"3045022100b820e4dfb1a0cde6dc97d9a34eebb1a4eef0b226262e6788118ab3c7fb79fe3502202d426a388b4c3a8096b3f84412a702ea537770e61ee0727ec1b710c1da520c44\",\n };\n // WHEN\n const command = new SendEIP712FilteringCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(RAW_APDU);\n });\n\n it(\"Calldata info APDU\", () => {\n // GIVEN\n const args: SendEIP712FilteringCommandArgs = {\n type: Eip712FilterType.CalldataInfo,\n discarded: false,\n calldataIndex: 3,\n valueFlag: true,\n calleeFlag: CalldataParamPresence.Present,\n chainIdFlag: false,\n selectorFlag: true,\n amountFlag: false,\n spenderFlag: CalldataParamPresence.VerifyingContract,\n signature:\n \"3045022100ff727847445431e571cd2a0d9db42a7eb62e37877b9bf20e6a96584255347e1902200a6e95b7f8e63b2fab0bef88c747de6a387d06351be5bdc34b2c1f9aea6fdd28\",\n };\n // WHEN\n const command = new SendEIP712FilteringCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(CALLDATA_INFO_APDU);\n });\n\n it.each([\n { name: \"spender\", type: Eip712FilterType.CalldataSpender, cmd: 0xf4 },\n { name: \"amount\", type: Eip712FilterType.CalldataAmount, cmd: 0xf5 },\n { name: \"selector\", type: Eip712FilterType.CalldataSelector, cmd: 0xf6 },\n { name: \"chainId\", type: Eip712FilterType.CalldataChainId, cmd: 0xf7 },\n { name: \"callee\", type: Eip712FilterType.CalldataCallee, cmd: 0xf8 },\n { name: \"value\", type: Eip712FilterType.CalldataValue, cmd: 0xf9 },\n ])(\"Calldata APDU $name\", ({ type, cmd }) => {\n // GIVEN\n const args: SendEIP712FilteringCommandArgs = {\n type,\n discarded: false,\n calldataIndex: 7,\n signature:\n \"3045022100ff727847445431e571cd2a0d9db42a7eb62e37877b9bf20e6a96584255347e1902200a6e95b7f8e63b2fab0bef88c747de6a387d06351be5bdc34b2c1f9aea6fdd28\",\n } as SendEIP712FilteringCommandArgs;\n const expectedApdu = Uint8Array.from(CALLDATA_VALUE_APDU);\n expectedApdu[3] = cmd;\n // WHEN\n const command = new SendEIP712FilteringCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(expectedApdu);\n });\n\n it(\"Token APDU\", () => {\n // GIVEN\n const args: SendEIP712FilteringCommandArgs = {\n type: Eip712FilterType.Token,\n discarded: false,\n tokenIndex: 1,\n signature:\n \"3045022100ff727847445431e571cd2a0d9db42a7eb62e37877b9bf20e6a96584255347e1902200a6e95b7f8e63b2fab0bef88c747de6a387d06351be5bdc34b2c1f9aea6fdd28\",\n };\n // WHEN\n const command = new SendEIP712FilteringCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(TOKEN_APDU);\n });\n\n it(\"Amount APDU\", () => {\n // GIVEN\n const args: SendEIP712FilteringCommandArgs = {\n type: Eip712FilterType.Amount,\n discarded: false,\n displayName: \"Receive minimum\",\n tokenIndex: 1,\n signature:\n \"3045022100a59dc479a838a813909c140a15e6b65bc58c5633284bf973c436de5a592634e202201e038fc7995d939fccd546e4c85e793c0ad451216e36a4edfc7bce5be27808cb\",\n };\n // WHEN\n const command = new SendEIP712FilteringCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(AMOUNT_APDU);\n });\n\n it(\"Date-time APDU\", () => {\n // GIVEN\n const args: SendEIP712FilteringCommandArgs = {\n type: Eip712FilterType.Datetime,\n discarded: false,\n displayName: \"Approval expire\",\n signature:\n \"3045022100e847166e60f851e3c8d1f44139811898ccd0d3a03aed6c77f8c3993813f479d2022031fe6b6a574b56c5104003cf07900d11ffaf303dc016da4c1c3d184663da8f6a\",\n };\n // WHEN\n const command = new SendEIP712FilteringCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(DATE_TIME_APDU);\n });\n\n it(\"Trusted name APDU\", () => {\n // GIVEN\n const args: SendEIP712FilteringCommandArgs = {\n type: Eip712FilterType.TrustedName,\n discarded: false,\n displayName: \"Spender\",\n typesAndSourcesPayload: \"010203010002\",\n signature:\n \"3045022100e847166e60f851e3c8d1f44139811898ccd0d3a03aed6c77f8c3993813f479d2022031fe6b6a574b56c5104003cf07900d11ffaf303dc016da4c1c3d184663da8f6a\",\n };\n // WHEN\n const command = new SendEIP712FilteringCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(TRUSTED_NAME_APDU);\n });\n\n it(\"Discarded filter\", () => {\n // GIVEN\n const args: SendEIP712FilteringCommandArgs = {\n type: Eip712FilterType.Raw,\n discarded: true,\n displayName: \"From\",\n signature:\n \"3045022100b820e4dfb1a0cde6dc97d9a34eebb1a4eef0b226262e6788118ab3c7fb79fe3502202d426a388b4c3a8096b3f84412a702ea537770e61ee0727ec1b710c1da520c44\",\n };\n // WHEN\n const command = new SendEIP712FilteringCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(\n Uint8Array.from([...RAW_APDU.slice(0, 2), 0x01, ...RAW_APDU.slice(3)]),\n );\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return an error if the response status code is invalid\", () => {\n // GIVEN\n const response: ApduResponse = {\n statusCode: Buffer.from([0x6a, 0x80]), // Invalid status code\n data: Buffer.from([]),\n };\n // WHEN\n const command = new SendEIP712FilteringCommand({\n type: Eip712FilterType.Activation,\n });\n // THEN\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n\n it(\"should parse the response\", () => {\n // GIVEN\n const response: ApduResponse = {\n statusCode: Buffer.from([0x90, 0x00]), // Success status code\n data: Buffer.from([]),\n };\n // WHEN\n const command = new SendEIP712FilteringCommand({\n type: Eip712FilterType.Activation,\n });\n // THEN\n expect(command.parseRes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BAAiB,IAAM,CAExB,MAAMC,EAAuC,CAC3C,
|
|
6
|
-
"names": ["CommandResultFactory", "isSuccessCommandResult", "CalldataParamPresence", "Eip712FilterType", "SendEIP712FilteringCommand", "ACTIVATE_APDU", "MESSAGE_INFO_APDU", "RAW_APDU", "CALLDATA_INFO_APDU", "CALLDATA_VALUE_APDU", "TOKEN_APDU", "AMOUNT_APDU", "TRUSTED_NAME_APDU", "DATE_TIME_APDU", "DISCARDED_PATH_APDU", "args", "apdu", "type", "cmd", "expectedApdu", "response", "result"
|
|
4
|
+
"sourcesContent": ["import {\n type ApduResponse,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {\n CalldataParamPresence,\n Eip712FilterType,\n SendEIP712FilteringCommand,\n type SendEIP712FilteringCommandArgs,\n} from \"./SendEIP712FilteringCommand\";\n\nconst ACTIVATE_APDU = Uint8Array.from([0xe0, 0x1e, 0x00, 0x00, 0x00]);\nconst MESSAGE_INFO_APDU = Uint8Array.from([\n 0xe0, 0x1e, 0x00, 0x0f, 0x54, 0x0b, 0x31, 0x69, 0x6e, 0x63, 0x68, 0x20, 0x4f,\n 0x72, 0x64, 0x65, 0x72, 0x06, 0x46, 0x30, 0x44, 0x02, 0x20, 0x29, 0x5e, 0x0a,\n 0xeb, 0x17, 0xca, 0x09, 0x29, 0xb2, 0xa9, 0x4c, 0x32, 0x4d, 0x67, 0xd0, 0xb5,\n 0x52, 0x8a, 0xba, 0x26, 0x81, 0x77, 0xf3, 0xac, 0x29, 0x7b, 0x56, 0x31, 0x41,\n 0xe0, 0x00, 0x27, 0x02, 0x20, 0x3a, 0xc3, 0x60, 0xd9, 0xfd, 0x0c, 0x9c, 0x0c,\n 0x12, 0x27, 0x9d, 0x1e, 0x73, 0xbe, 0xa5, 0xd5, 0x49, 0xa1, 0xe8, 0x14, 0x1f,\n 0x45, 0x4d, 0x88, 0xfb, 0xe1, 0xe8, 0xef, 0x97, 0x0e, 0x68, 0x02,\n]);\nconst RAW_APDU = Uint8Array.from([\n 0xe0, 0x1e, 0x00, 0xff, 0x4d, 0x04, 0x46, 0x72, 0x6f, 0x6d, 0x47, 0x30, 0x45,\n 0x02, 0x21, 0x00, 0xb8, 0x20, 0xe4, 0xdf, 0xb1, 0xa0, 0xcd, 0xe6, 0xdc, 0x97,\n 0xd9, 0xa3, 0x4e, 0xeb, 0xb1, 0xa4, 0xee, 0xf0, 0xb2, 0x26, 0x26, 0x2e, 0x67,\n 0x88, 0x11, 0x8a, 0xb3, 0xc7, 0xfb, 0x79, 0xfe, 0x35, 0x02, 0x20, 0x2d, 0x42,\n 0x6a, 0x38, 0x8b, 0x4c, 0x3a, 0x80, 0x96, 0xb3, 0xf8, 0x44, 0x12, 0xa7, 0x02,\n 0xea, 0x53, 0x77, 0x70, 0xe6, 0x1e, 0xe0, 0x72, 0x7e, 0xc1, 0xb7, 0x10, 0xc1,\n 0xda, 0x52, 0x0c, 0x44,\n]);\nconst CALLDATA_INFO_APDU = Uint8Array.from([\n 0xe0, 0x1e, 0x00, 0xfa, 0x4f, 0x03, 0x01, 0x01, 0x00, 0x01, 0x00, 0x02, 0x47,\n 0x30, 0x45, 0x02, 0x21, 0x00, 0xff, 0x72, 0x78, 0x47, 0x44, 0x54, 0x31, 0xe5,\n 0x71, 0xcd, 0x2a, 0x0d, 0x9d, 0xb4, 0x2a, 0x7e, 0xb6, 0x2e, 0x37, 0x87, 0x7b,\n 0x9b, 0xf2, 0x0e, 0x6a, 0x96, 0x58, 0x42, 0x55, 0x34, 0x7e, 0x19, 0x02, 0x20,\n 0x0a, 0x6e, 0x95, 0xb7, 0xf8, 0xe6, 0x3b, 0x2f, 0xab, 0x0b, 0xef, 0x88, 0xc7,\n 0x47, 0xde, 0x6a, 0x38, 0x7d, 0x06, 0x35, 0x1b, 0xe5, 0xbd, 0xc3, 0x4b, 0x2c,\n 0x1f, 0x9a, 0xea, 0x6f, 0xdd, 0x28,\n]);\nconst CALLDATA_VALUE_APDU = Uint8Array.from([\n 0xe0, 0x1e, 0x00, 0xf9, 0x49, 0x07, 0x47, 0x30, 0x45, 0x02, 0x21, 0x00, 0xff,\n 0x72, 0x78, 0x47, 0x44, 0x54, 0x31, 0xe5, 0x71, 0xcd, 0x2a, 0x0d, 0x9d, 0xb4,\n 0x2a, 0x7e, 0xb6, 0x2e, 0x37, 0x87, 0x7b, 0x9b, 0xf2, 0x0e, 0x6a, 0x96, 0x58,\n 0x42, 0x55, 0x34, 0x7e, 0x19, 0x02, 0x20, 0x0a, 0x6e, 0x95, 0xb7, 0xf8, 0xe6,\n 0x3b, 0x2f, 0xab, 0x0b, 0xef, 0x88, 0xc7, 0x47, 0xde, 0x6a, 0x38, 0x7d, 0x06,\n 0x35, 0x1b, 0xe5, 0xbd, 0xc3, 0x4b, 0x2c, 0x1f, 0x9a, 0xea, 0x6f, 0xdd, 0x28,\n]);\nconst TOKEN_APDU = Uint8Array.from([\n 0xe0, 0x1e, 0x00, 0xfd, 0x49, 0x01, 0x47, 0x30, 0x45, 0x02, 0x21, 0x00, 0xff,\n 0x72, 0x78, 0x47, 0x44, 0x54, 0x31, 0xe5, 0x71, 0xcd, 0x2a, 0x0d, 0x9d, 0xb4,\n 0x2a, 0x7e, 0xb6, 0x2e, 0x37, 0x87, 0x7b, 0x9b, 0xf2, 0x0e, 0x6a, 0x96, 0x58,\n 0x42, 0x55, 0x34, 0x7e, 0x19, 0x02, 0x20, 0x0a, 0x6e, 0x95, 0xb7, 0xf8, 0xe6,\n 0x3b, 0x2f, 0xab, 0x0b, 0xef, 0x88, 0xc7, 0x47, 0xde, 0x6a, 0x38, 0x7d, 0x06,\n 0x35, 0x1b, 0xe5, 0xbd, 0xc3, 0x4b, 0x2c, 0x1f, 0x9a, 0xea, 0x6f, 0xdd, 0x28,\n]);\nconst AMOUNT_APDU = Uint8Array.from([\n 0xe0, 0x1e, 0x00, 0xfe, 0x59, 0x0f, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65,\n 0x20, 0x6d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x01, 0x47, 0x30, 0x45, 0x02,\n 0x21, 0x00, 0xa5, 0x9d, 0xc4, 0x79, 0xa8, 0x38, 0xa8, 0x13, 0x90, 0x9c, 0x14,\n 0x0a, 0x15, 0xe6, 0xb6, 0x5b, 0xc5, 0x8c, 0x56, 0x33, 0x28, 0x4b, 0xf9, 0x73,\n 0xc4, 0x36, 0xde, 0x5a, 0x59, 0x26, 0x34, 0xe2, 0x02, 0x20, 0x1e, 0x03, 0x8f,\n 0xc7, 0x99, 0x5d, 0x93, 0x9f, 0xcc, 0xd5, 0x46, 0xe4, 0xc8, 0x5e, 0x79, 0x3c,\n 0x0a, 0xd4, 0x51, 0x21, 0x6e, 0x36, 0xa4, 0xed, 0xfc, 0x7b, 0xce, 0x5b, 0xe2,\n 0x78, 0x08, 0xcb,\n]);\nconst TRUSTED_NAME_APDU = Uint8Array.from([\n 0xe0, 0x1e, 0x00, 0xfb, 0x56, 0x07, 0x53, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x72,\n 0x01, 0x02, 0x03, 0x01, 0x00, 0x02, 0x47, 0x30, 0x45, 0x02, 0x21, 0x00, 0xe8,\n 0x47, 0x16, 0x6e, 0x60, 0xf8, 0x51, 0xe3, 0xc8, 0xd1, 0xf4, 0x41, 0x39, 0x81,\n 0x18, 0x98, 0xcc, 0xd0, 0xd3, 0xa0, 0x3a, 0xed, 0x6c, 0x77, 0xf8, 0xc3, 0x99,\n 0x38, 0x13, 0xf4, 0x79, 0xd2, 0x02, 0x20, 0x31, 0xfe, 0x6b, 0x6a, 0x57, 0x4b,\n 0x56, 0xc5, 0x10, 0x40, 0x03, 0xcf, 0x07, 0x90, 0x0d, 0x11, 0xff, 0xaf, 0x30,\n 0x3d, 0xc0, 0x16, 0xda, 0x4c, 0x1c, 0x3d, 0x18, 0x46, 0x63, 0xda, 0x8f, 0x6a,\n]);\nconst DATE_TIME_APDU = Uint8Array.from([\n 0xe0, 0x1e, 0x00, 0xfc, 0x58, 0x0f, 0x41, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x61,\n 0x6c, 0x20, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x47, 0x30, 0x45, 0x02, 0x21,\n 0x00, 0xe8, 0x47, 0x16, 0x6e, 0x60, 0xf8, 0x51, 0xe3, 0xc8, 0xd1, 0xf4, 0x41,\n 0x39, 0x81, 0x18, 0x98, 0xcc, 0xd0, 0xd3, 0xa0, 0x3a, 0xed, 0x6c, 0x77, 0xf8,\n 0xc3, 0x99, 0x38, 0x13, 0xf4, 0x79, 0xd2, 0x02, 0x20, 0x31, 0xfe, 0x6b, 0x6a,\n 0x57, 0x4b, 0x56, 0xc5, 0x10, 0x40, 0x03, 0xcf, 0x07, 0x90, 0x0d, 0x11, 0xff,\n 0xaf, 0x30, 0x3d, 0xc0, 0x16, 0xda, 0x4c, 0x1c, 0x3d, 0x18, 0x46, 0x63, 0xda,\n 0x8f, 0x6a,\n]);\nconst DISCARDED_PATH_APDU = Uint8Array.from([\n 0xe0, 0x1e, 0x00, 0x01, 0x11, 0x10, 0x74, 0x6f, 0x2e, 0x5b, 0x5d, 0x2e, 0x77,\n 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x73, 0x2e, 0x5b, 0x5d,\n]);\n\ndescribe(\"SendEIP712FilteringCommand\", () => {\n describe(\"name\", () => {\n it(\"should be 'sendEIP712Filtering'\", () => {\n const command = new SendEIP712FilteringCommand({\n type: Eip712FilterType.Activation,\n });\n expect(command.name).toBe(\"sendEIP712Filtering\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"Activate APDU\", () => {\n // GIVEN\n const args: SendEIP712FilteringCommandArgs = {\n type: Eip712FilterType.Activation,\n };\n // WHEN\n const command = new SendEIP712FilteringCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(ACTIVATE_APDU);\n });\n\n it(\"Discarded path APDU\", () => {\n // GIVEN\n const args: SendEIP712FilteringCommandArgs = {\n type: Eip712FilterType.DiscardedPath,\n path: \"to.[].wallets.[]\",\n };\n // WHEN\n const command = new SendEIP712FilteringCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(DISCARDED_PATH_APDU);\n });\n\n it(\"Message info APDU\", () => {\n // GIVEN\n const args: SendEIP712FilteringCommandArgs = {\n type: Eip712FilterType.MessageInfo,\n displayName: \"1inch Order\",\n filtersCount: 6,\n signature:\n \"30440220295e0aeb17ca0929b2a94c324d67d0b5528aba268177f3ac297b563141e0002702203ac360d9fd0c9c0c12279d1e73bea5d549a1e8141f454d88fbe1e8ef970e6802\",\n };\n // WHEN\n const command = new SendEIP712FilteringCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(MESSAGE_INFO_APDU);\n });\n\n it(\"Raw APDU\", () => {\n // GIVEN\n const args: SendEIP712FilteringCommandArgs = {\n type: Eip712FilterType.Raw,\n discarded: false,\n displayName: \"From\",\n signature:\n \"3045022100b820e4dfb1a0cde6dc97d9a34eebb1a4eef0b226262e6788118ab3c7fb79fe3502202d426a388b4c3a8096b3f84412a702ea537770e61ee0727ec1b710c1da520c44\",\n };\n // WHEN\n const command = new SendEIP712FilteringCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(RAW_APDU);\n });\n\n it(\"Calldata info APDU\", () => {\n // GIVEN\n const args: SendEIP712FilteringCommandArgs = {\n type: Eip712FilterType.CalldataInfo,\n discarded: false,\n calldataIndex: 3,\n valueFlag: true,\n calleeFlag: CalldataParamPresence.Present,\n chainIdFlag: false,\n selectorFlag: true,\n amountFlag: false,\n spenderFlag: CalldataParamPresence.VerifyingContract,\n signature:\n \"3045022100ff727847445431e571cd2a0d9db42a7eb62e37877b9bf20e6a96584255347e1902200a6e95b7f8e63b2fab0bef88c747de6a387d06351be5bdc34b2c1f9aea6fdd28\",\n };\n // WHEN\n const command = new SendEIP712FilteringCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(CALLDATA_INFO_APDU);\n });\n\n it.each([\n { name: \"spender\", type: Eip712FilterType.CalldataSpender, cmd: 0xf4 },\n { name: \"amount\", type: Eip712FilterType.CalldataAmount, cmd: 0xf5 },\n { name: \"selector\", type: Eip712FilterType.CalldataSelector, cmd: 0xf6 },\n { name: \"chainId\", type: Eip712FilterType.CalldataChainId, cmd: 0xf7 },\n { name: \"callee\", type: Eip712FilterType.CalldataCallee, cmd: 0xf8 },\n { name: \"value\", type: Eip712FilterType.CalldataValue, cmd: 0xf9 },\n ])(\"Calldata APDU $name\", ({ type, cmd }) => {\n // GIVEN\n const args: SendEIP712FilteringCommandArgs = {\n type,\n discarded: false,\n calldataIndex: 7,\n signature:\n \"3045022100ff727847445431e571cd2a0d9db42a7eb62e37877b9bf20e6a96584255347e1902200a6e95b7f8e63b2fab0bef88c747de6a387d06351be5bdc34b2c1f9aea6fdd28\",\n } as SendEIP712FilteringCommandArgs;\n const expectedApdu = Uint8Array.from(CALLDATA_VALUE_APDU);\n expectedApdu[3] = cmd;\n // WHEN\n const command = new SendEIP712FilteringCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(expectedApdu);\n });\n\n it(\"Token APDU\", () => {\n // GIVEN\n const args: SendEIP712FilteringCommandArgs = {\n type: Eip712FilterType.Token,\n discarded: false,\n tokenIndex: 1,\n signature:\n \"3045022100ff727847445431e571cd2a0d9db42a7eb62e37877b9bf20e6a96584255347e1902200a6e95b7f8e63b2fab0bef88c747de6a387d06351be5bdc34b2c1f9aea6fdd28\",\n };\n // WHEN\n const command = new SendEIP712FilteringCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(TOKEN_APDU);\n });\n\n it(\"Amount APDU\", () => {\n // GIVEN\n const args: SendEIP712FilteringCommandArgs = {\n type: Eip712FilterType.Amount,\n discarded: false,\n displayName: \"Receive minimum\",\n tokenIndex: 1,\n signature:\n \"3045022100a59dc479a838a813909c140a15e6b65bc58c5633284bf973c436de5a592634e202201e038fc7995d939fccd546e4c85e793c0ad451216e36a4edfc7bce5be27808cb\",\n };\n // WHEN\n const command = new SendEIP712FilteringCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(AMOUNT_APDU);\n });\n\n it(\"Date-time APDU\", () => {\n // GIVEN\n const args: SendEIP712FilteringCommandArgs = {\n type: Eip712FilterType.Datetime,\n discarded: false,\n displayName: \"Approval expire\",\n signature:\n \"3045022100e847166e60f851e3c8d1f44139811898ccd0d3a03aed6c77f8c3993813f479d2022031fe6b6a574b56c5104003cf07900d11ffaf303dc016da4c1c3d184663da8f6a\",\n };\n // WHEN\n const command = new SendEIP712FilteringCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(DATE_TIME_APDU);\n });\n\n it(\"Trusted name APDU\", () => {\n // GIVEN\n const args: SendEIP712FilteringCommandArgs = {\n type: Eip712FilterType.TrustedName,\n discarded: false,\n displayName: \"Spender\",\n typesAndSourcesPayload: \"010203010002\",\n signature:\n \"3045022100e847166e60f851e3c8d1f44139811898ccd0d3a03aed6c77f8c3993813f479d2022031fe6b6a574b56c5104003cf07900d11ffaf303dc016da4c1c3d184663da8f6a\",\n };\n // WHEN\n const command = new SendEIP712FilteringCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(TRUSTED_NAME_APDU);\n });\n\n it(\"Discarded filter\", () => {\n // GIVEN\n const args: SendEIP712FilteringCommandArgs = {\n type: Eip712FilterType.Raw,\n discarded: true,\n displayName: \"From\",\n signature:\n \"3045022100b820e4dfb1a0cde6dc97d9a34eebb1a4eef0b226262e6788118ab3c7fb79fe3502202d426a388b4c3a8096b3f84412a702ea537770e61ee0727ec1b710c1da520c44\",\n };\n // WHEN\n const command = new SendEIP712FilteringCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(\n Uint8Array.from([...RAW_APDU.slice(0, 2), 0x01, ...RAW_APDU.slice(3)]),\n );\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return an error if the response status code is invalid\", () => {\n // GIVEN\n const response: ApduResponse = {\n statusCode: Buffer.from([0x6a, 0x80]), // Invalid status code\n data: Buffer.from([]),\n };\n // WHEN\n const command = new SendEIP712FilteringCommand({\n type: Eip712FilterType.Activation,\n });\n // THEN\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n\n it(\"should parse the response\", () => {\n // GIVEN\n const response: ApduResponse = {\n statusCode: Buffer.from([0x90, 0x00]), // Success status code\n data: Buffer.from([]),\n };\n // WHEN\n const command = new SendEIP712FilteringCommand({\n type: Eip712FilterType.Activation,\n });\n // THEN\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({ data: undefined }),\n );\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAEE,wBAAAA,EACA,0BAAAC,MACK,kCAEP,OACE,yBAAAC,EACA,oBAAAC,EACA,8BAAAC,MAEK,+BAEP,MAAMC,EAAgB,WAAW,KAAK,CAAC,IAAM,GAAM,EAAM,EAAM,CAAI,CAAC,EAC9DC,EAAoB,WAAW,KAAK,CACxC,IAAM,GAAM,EAAM,GAAM,GAAM,GAAM,GAAM,IAAM,IAAM,GAAM,IAAM,GAAM,GACxE,IAAM,IAAM,IAAM,IAAM,EAAM,GAAM,GAAM,GAAM,EAAM,GAAM,GAAM,GAAM,GACxE,IAAM,GAAM,IAAM,EAAM,GAAM,IAAM,IAAM,GAAM,GAAM,GAAM,IAAM,IAAM,IACxE,GAAM,IAAM,IAAM,GAAM,IAAM,IAAM,IAAM,IAAM,GAAM,IAAM,GAAM,GAAM,GACxE,IAAM,EAAM,GAAM,EAAM,GAAM,GAAM,IAAM,GAAM,IAAM,IAAM,GAAM,IAAM,GACxE,GAA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MAAM,EAAG,CAAC,EAAG,EAAM,GAAGA,EAAS,MAAM,CAAC,CAAC,CAAC,CACvE,CACF,CAAC,CACH,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,GAAG,gEAAiE,IAAM,CAExE,MAAMc,EAAyB,CAC7B,WAAY,OAAO,KAAK,CAAC,IAAM,GAAI,CAAC,EACpC,KAAM,OAAO,KAAK,CAAC,CAAC,CACtB,EAMMC,EAJU,IAAIlB,EAA2B,CAC7C,KAAMD,EAAiB,UACzB,CAAC,EAEsB,cAAckB,CAAQ,EAC7C,OAAOpB,EAAuBqB,CAAM,CAAC,EAAE,KAAK,EAAK,CACnD,CAAC,EAED,GAAG,4BAA6B,IAAM,CAEpC,MAAMD,EAAyB,CAC7B,WAAY,OAAO,KAAK,CAAC,IAAM,CAAI,CAAC,EACpC,KAAM,OAAO,KAAK,CAAC,CAAC,CACtB,EAEMN,EAAU,IAAIX,EAA2B,CAC7C,KAAMD,EAAiB,UACzB,CAAC,EAED,OAAOY,EAAQ,cAAcM,CAAQ,CAAC,EAAE,cACtCrB,EAAqB,CAAE,KAAM,MAAU,CAAC,CAC1C,CACF,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["CommandResultFactory", "isSuccessCommandResult", "CalldataParamPresence", "Eip712FilterType", "SendEIP712FilteringCommand", "ACTIVATE_APDU", "MESSAGE_INFO_APDU", "RAW_APDU", "CALLDATA_INFO_APDU", "CALLDATA_VALUE_APDU", "TOKEN_APDU", "AMOUNT_APDU", "TRUSTED_NAME_APDU", "DATE_TIME_APDU", "DISCARDED_PATH_APDU", "command", "args", "apdu", "type", "cmd", "expectedApdu", "response", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduBuilder as o,CommandResultFactory as m}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as u}from"@ledgerhq/signer-utils";import{Just as p,Maybe as c,Nothing as a}from"purify-ts";import{ArrayType as
|
|
1
|
+
import{ApduBuilder as o,CommandResultFactory as m}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as u}from"@ledgerhq/signer-utils";import{Just as p,Maybe as c,Nothing as a}from"purify-ts";import{ArrayType as r,PrimitiveType as y,StructType as d}from"../../typed-data/model/Types";import{ETH_APP_ERRORS as l,EthAppCommandErrorFactory as g}from"./utils/ethAppErrors";var f=(t=>(t[t.Name=0]="Name",t[t.Field=255]="Field",t))(f||{});class E{constructor(e){this.args=e}name="sendEIP712StructDefinition";errorHelper=new u(l,g);getApdu(){const e={cla:224,ins:26,p1:0,p2:this.args.command};if(this.args.command===0)return new o(e).addAsciiStringToData(this.args.name).build();const t=new o(e),n=this.constructTypeDescByte(this.args.type);if(t.add8BitUIntToData(n),this.getTypeCustomName(this.args.type).ifJust(i=>{t.encodeInLVFromAscii(i)}),this.getTypeSize(this.args.type).ifJust(i=>{t.add8BitUIntToData(i)}),this.args.type instanceof r){t.add8BitUIntToData(this.args.type.levels.length);for(const i of this.args.type.levels)i.caseOf({Just:s=>{t.add8BitUIntToData(1).add8BitUIntToData(s)},Nothing:()=>{t.add8BitUIntToData(0)}})}return t.encodeInLVFromAscii(this.args.name).build()}parseResponse(e){return c.fromNullable(this.errorHelper.getError(e)).orDefault(m({data:void 0}))}constructTypeDescByte(e){const t=e instanceof r?1:0,n=this.getTypeSize(e).isJust()?1:0,i=this.getType(e);return t<<7|n<<6|i}getTypeSize(e){return e instanceof r?this.getTypeSize(e.rootType):e instanceof y?e.size:a}getTypeCustomName(e){return e instanceof r?this.getTypeCustomName(e.rootType):e instanceof d?p(e.typeName):a}getType(e){if(e instanceof r)return this.getType(e.rootType);if(e instanceof d)return 0;switch(e.name){case"int":return 1;case"uint":return 2;case"address":return 3;case"bool":return 4;case"string":return 5;case"bytes":return e.size.isJust()?6:7}}}export{E as SendEIP712StructDefinitionCommand,f as StructDefinitionCommand};
|
|
2
2
|
//# sourceMappingURL=SendEIP712StructDefinitionCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SendEIP712StructDefinitionCommand.ts"],
|
|
4
|
-
"sourcesContent": ["// https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#eip712-send-struct-definition\nimport {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Just, Maybe, Nothing } from \"purify-ts\";\n\nimport {\n ArrayType,\n type FieldName,\n type FieldType,\n PrimitiveType,\n StructType,\n} from \"@internal/typed-data/model/Types\";\n\nimport {\n ETH_APP_ERRORS,\n EthAppCommandErrorFactory,\n type EthErrorCodes,\n} from \"./utils/ethAppErrors\";\n\nexport enum StructDefinitionCommand {\n Name = 0,\n Field = 255,\n}\n\nexport type SendEIP712StructDefinitionCommandArgs =\n | { command: StructDefinitionCommand.Name; name: string }\n | {\n command: StructDefinitionCommand.Field;\n name: FieldName;\n type: FieldType;\n };\n\nenum ArraySize {\n Dynamic,\n Fixed,\n}\n\nenum Type {\n Custom,\n Int,\n Uint,\n Address,\n Bool,\n String,\n FixedSizedBytes,\n DynamicSizedBytes,\n}\n\nexport class SendEIP712StructDefinitionCommand\n implements Command<void, SendEIP712StructDefinitionCommandArgs, EthErrorCodes>\n{\n private readonly errorHelper = new CommandErrorHelper<void, EthErrorCodes>(\n ETH_APP_ERRORS,\n EthAppCommandErrorFactory,\n );\n\n constructor(private args: SendEIP712StructDefinitionCommandArgs) {}\n\n getApdu(): Apdu {\n const SendEIP712StructDefinitionArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x1a,\n p1: 0x00,\n p2: this.args.command,\n };\n\n // Struct name\n if (this.args.command === StructDefinitionCommand.Name) {\n return new ApduBuilder(SendEIP712StructDefinitionArgs)\n .addAsciiStringToData(this.args.name)\n .build();\n }\n\n // Struct field\n const builder = new ApduBuilder(SendEIP712StructDefinitionArgs);\n\n const typeDesc = this.constructTypeDescByte(this.args.type);\n\n // Add type descriptor\n builder.add8BitUIntToData(typeDesc);\n\n // Add struct name if this is a custom type\n this.getTypeCustomName(this.args.type).ifJust((customName) => {\n builder.encodeInLVFromAscii(customName);\n });\n\n // Add type size, if applicable\n this.getTypeSize(this.args.type).ifJust((size) => {\n builder.add8BitUIntToData(size);\n });\n\n // Add array levels, if it is an array\n if (this.args.type instanceof ArrayType) {\n builder.add8BitUIntToData(this.args.type.levels.length);\n for (const level of this.args.type.levels) {\n level.caseOf({\n Just: (l) => {\n builder.add8BitUIntToData(ArraySize.Fixed).add8BitUIntToData(l);\n },\n Nothing: () => {\n builder.add8BitUIntToData(ArraySize.Dynamic);\n },\n });\n }\n }\n\n // Add field name\n return builder.encodeInLVFromAscii(this.args.name).build();\n }\n\n parseResponse(response: ApduResponse): CommandResult<void, EthErrorCodes> {\n return Maybe.fromNullable(this.errorHelper.getError(response)).orDefault(\n CommandResultFactory({ data: undefined }),\n );\n }\n\n private constructTypeDescByte(type: FieldType): number {\n const isArrayBit = type instanceof ArrayType ? 1 : 0;\n const hasTypeSize = this.getTypeSize(type).isJust() ? 1 : 0;\n const typeBits = this.getType(type);\n\n // Combine the bits using bitwise operations\n const combinedBits = (isArrayBit << 7) | (hasTypeSize << 6) | typeBits;\n return combinedBits;\n }\n\n private getTypeSize(type: FieldType): Maybe<number> {\n if (type instanceof ArrayType) {\n return this.getTypeSize(type.rootType);\n }\n return type instanceof PrimitiveType ? type.size : Nothing;\n }\n\n private getTypeCustomName(type: FieldType): Maybe<string> {\n if (type instanceof ArrayType) {\n return this.getTypeCustomName(type.rootType);\n }\n return type instanceof StructType ? Just(type.typeName) : Nothing;\n }\n\n private getType(type: FieldType): Type {\n if (type instanceof ArrayType) {\n return this.getType(type.rootType);\n } else if (type instanceof StructType) {\n return Type.Custom;\n }\n switch (type.name) {\n case \"int\":\n return Type.Int;\n case \"uint\":\n return Type.Uint;\n case \"address\":\n return Type.Address;\n case \"bool\":\n return Type.Bool;\n case \"string\":\n return Type.String;\n case \"bytes\":\n return type.size.isJust()\n ? Type.FixedSizedBytes\n : Type.DynamicSizedBytes;\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AACA,OAEE,eAAAA,EAKA,wBAAAC,MACK,kCACP,OAAS,sBAAAC,MAA0B,yBACnC,OAAS,QAAAC,EAAM,SAAAC,EAAO,WAAAC,MAAe,YAErC,OACE,aAAAC,EAGA,iBAAAC,EACA,cAAAC,MACK,mCAEP,OACE,kBAAAC,EACA,6BAAAC,MAEK,uBAEA,IAAKC,OACVA,IAAA,KAAO,GAAP,OACAA,IAAA,MAAQ,KAAR,QAFUA,OAAA,IA6BL,MAAMC,CAEb,
|
|
4
|
+
"sourcesContent": ["// https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#eip712-send-struct-definition\nimport {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Just, Maybe, Nothing } from \"purify-ts\";\n\nimport {\n ArrayType,\n type FieldName,\n type FieldType,\n PrimitiveType,\n StructType,\n} from \"@internal/typed-data/model/Types\";\n\nimport {\n ETH_APP_ERRORS,\n EthAppCommandErrorFactory,\n type EthErrorCodes,\n} from \"./utils/ethAppErrors\";\n\nexport enum StructDefinitionCommand {\n Name = 0,\n Field = 255,\n}\n\nexport type SendEIP712StructDefinitionCommandArgs =\n | { command: StructDefinitionCommand.Name; name: string }\n | {\n command: StructDefinitionCommand.Field;\n name: FieldName;\n type: FieldType;\n };\n\nenum ArraySize {\n Dynamic,\n Fixed,\n}\n\nenum Type {\n Custom,\n Int,\n Uint,\n Address,\n Bool,\n String,\n FixedSizedBytes,\n DynamicSizedBytes,\n}\n\nexport class SendEIP712StructDefinitionCommand\n implements Command<void, SendEIP712StructDefinitionCommandArgs, EthErrorCodes>\n{\n readonly name = \"sendEIP712StructDefinition\";\n private readonly errorHelper = new CommandErrorHelper<void, EthErrorCodes>(\n ETH_APP_ERRORS,\n EthAppCommandErrorFactory,\n );\n\n constructor(private args: SendEIP712StructDefinitionCommandArgs) {}\n\n getApdu(): Apdu {\n const SendEIP712StructDefinitionArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x1a,\n p1: 0x00,\n p2: this.args.command,\n };\n\n // Struct name\n if (this.args.command === StructDefinitionCommand.Name) {\n return new ApduBuilder(SendEIP712StructDefinitionArgs)\n .addAsciiStringToData(this.args.name)\n .build();\n }\n\n // Struct field\n const builder = new ApduBuilder(SendEIP712StructDefinitionArgs);\n\n const typeDesc = this.constructTypeDescByte(this.args.type);\n\n // Add type descriptor\n builder.add8BitUIntToData(typeDesc);\n\n // Add struct name if this is a custom type\n this.getTypeCustomName(this.args.type).ifJust((customName) => {\n builder.encodeInLVFromAscii(customName);\n });\n\n // Add type size, if applicable\n this.getTypeSize(this.args.type).ifJust((size) => {\n builder.add8BitUIntToData(size);\n });\n\n // Add array levels, if it is an array\n if (this.args.type instanceof ArrayType) {\n builder.add8BitUIntToData(this.args.type.levels.length);\n for (const level of this.args.type.levels) {\n level.caseOf({\n Just: (l) => {\n builder.add8BitUIntToData(ArraySize.Fixed).add8BitUIntToData(l);\n },\n Nothing: () => {\n builder.add8BitUIntToData(ArraySize.Dynamic);\n },\n });\n }\n }\n\n // Add field name\n return builder.encodeInLVFromAscii(this.args.name).build();\n }\n\n parseResponse(response: ApduResponse): CommandResult<void, EthErrorCodes> {\n return Maybe.fromNullable(this.errorHelper.getError(response)).orDefault(\n CommandResultFactory({ data: undefined }),\n );\n }\n\n private constructTypeDescByte(type: FieldType): number {\n const isArrayBit = type instanceof ArrayType ? 1 : 0;\n const hasTypeSize = this.getTypeSize(type).isJust() ? 1 : 0;\n const typeBits = this.getType(type);\n\n // Combine the bits using bitwise operations\n const combinedBits = (isArrayBit << 7) | (hasTypeSize << 6) | typeBits;\n return combinedBits;\n }\n\n private getTypeSize(type: FieldType): Maybe<number> {\n if (type instanceof ArrayType) {\n return this.getTypeSize(type.rootType);\n }\n return type instanceof PrimitiveType ? type.size : Nothing;\n }\n\n private getTypeCustomName(type: FieldType): Maybe<string> {\n if (type instanceof ArrayType) {\n return this.getTypeCustomName(type.rootType);\n }\n return type instanceof StructType ? Just(type.typeName) : Nothing;\n }\n\n private getType(type: FieldType): Type {\n if (type instanceof ArrayType) {\n return this.getType(type.rootType);\n } else if (type instanceof StructType) {\n return Type.Custom;\n }\n switch (type.name) {\n case \"int\":\n return Type.Int;\n case \"uint\":\n return Type.Uint;\n case \"address\":\n return Type.Address;\n case \"bool\":\n return Type.Bool;\n case \"string\":\n return Type.String;\n case \"bytes\":\n return type.size.isJust()\n ? Type.FixedSizedBytes\n : Type.DynamicSizedBytes;\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,OAEE,eAAAA,EAKA,wBAAAC,MACK,kCACP,OAAS,sBAAAC,MAA0B,yBACnC,OAAS,QAAAC,EAAM,SAAAC,EAAO,WAAAC,MAAe,YAErC,OACE,aAAAC,EAGA,iBAAAC,EACA,cAAAC,MACK,mCAEP,OACE,kBAAAC,EACA,6BAAAC,MAEK,uBAEA,IAAKC,OACVA,IAAA,KAAO,GAAP,OACAA,IAAA,MAAQ,KAAR,QAFUA,OAAA,IA6BL,MAAMC,CAEb,CAOE,YAAoBC,EAA6C,CAA7C,UAAAA,CAA8C,CANzD,KAAO,6BACC,YAAc,IAAIC,EACjCC,EACAC,CACF,EAIA,SAAgB,CACd,MAAMC,EAAkD,CACtD,IAAK,IACL,IAAK,GACL,GAAI,EACJ,GAAI,KAAK,KAAK,OAChB,EAGA,GAAI,KAAK,KAAK,UAAY,EACxB,OAAO,IAAIC,EAAYD,CAA8B,EAClD,qBAAqB,KAAK,KAAK,IAAI,EACnC,MAAM,EAIX,MAAME,EAAU,IAAID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AAQ,EAAIK,CAC5D,CAEQ,QAAQL,EAAuB,CACrC,GAAIA,aAAgBN,EAClB,OAAO,KAAK,QAAQM,EAAK,QAAQ,EAC5B,GAAIA,aAAgBM,EACzB,MAAO,GAET,OAAQN,EAAK,KAAM,CACjB,IAAK,MACH,MAAO,GACT,IAAK,OACH,MAAO,GACT,IAAK,UACH,MAAO,GACT,IAAK,OACH,MAAO,GACT,IAAK,SACH,MAAO,GACT,IAAK,QACH,OAAOA,EAAK,KAAK,OAAO,EACpB,EACA,CACR,CACF,CACF",
|
|
6
6
|
"names": ["ApduBuilder", "CommandResultFactory", "CommandErrorHelper", "Just", "Maybe", "Nothing", "ArrayType", "PrimitiveType", "StructType", "ETH_APP_ERRORS", "EthAppCommandErrorFactory", "StructDefinitionCommand", "SendEIP712StructDefinitionCommand", "args", "CommandErrorHelper", "ETH_APP_ERRORS", "EthAppCommandErrorFactory", "SendEIP712StructDefinitionArgs", "ApduBuilder", "builder", "typeDesc", "customName", "size", "ArrayType", "level", "l", "response", "Maybe", "CommandResultFactory", "type", "isArrayBit", "hasTypeSize", "typeBits", "PrimitiveType", "Nothing", "StructType", "Just"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{CommandResultFactory as u,isSuccessCommandResult as p}from"@ledgerhq/device-management-kit";import{Just as a,Nothing as x}from"purify-ts";import{ArrayType as d,PrimitiveType as o,StructType as i}from"../../typed-data/model/Types";import{SendEIP712StructDefinitionCommand as n,StructDefinitionCommand as r}from"./SendEIP712StructDefinitionCommand";const c=Uint8Array.from([224,26,0,0,12,69,73,80,55,49,50,68,111,109,97,105,110]),m=Uint8Array.from([224,26,0,0,5,71,114,111,117,112]),f=Uint8Array.from([224,26,0,255,6,5,4,110,97,109,101]),E=Uint8Array.from([224,26,0,255,9,5,7,118,101,114,115,105,111,110]),A=Uint8Array.from([224,26,0,255,10,66,32,7,99,104,97,105,110,73,100]),y=Uint8Array.from([224,26,0,255,19,3,17,118,101,114,105,102,121,105,110,103,67,111,110,116,114,97,99,116]),l=Uint8Array.from([224,26,0,255,18,128,6,80,101,114,115,111,110,1,0,7,109,101,109,98,101,114,115]),_=Uint8Array.from([224,26,0,255,13,0,6,80,101,114,115,111,110,4,102,114,111,109]),w=Uint8Array.from([224,26,0,255,11,131,1,0,7,119,97,108,108,101,116,115]),I=Uint8Array.from([224,26,0,255,17,7,15,115,116,97,116,105,99,69,120,116,114,97,100,97,116,97]),g=Uint8Array.from([224,26,0,255,20,7,18,114,101,112,108,97,99,101,109,101,110,116,80,97,116,116,101,114,110]),D=Uint8Array.from([224,26,0,255,11,70,4,8,100,97,116,97,84,121,112,101]),S=Uint8Array.from([224,26,0,255,14,133,2,1,3,0,8,100,111,99,117,109,101,110,116]),
|
|
1
|
+
import{CommandResultFactory as u,isSuccessCommandResult as p}from"@ledgerhq/device-management-kit";import{Just as a,Nothing as x}from"purify-ts";import{ArrayType as d,PrimitiveType as o,StructType as i}from"../../typed-data/model/Types";import{SendEIP712StructDefinitionCommand as n,StructDefinitionCommand as r}from"./SendEIP712StructDefinitionCommand";const c=Uint8Array.from([224,26,0,0,12,69,73,80,55,49,50,68,111,109,97,105,110]),m=Uint8Array.from([224,26,0,0,5,71,114,111,117,112]),f=Uint8Array.from([224,26,0,255,6,5,4,110,97,109,101]),E=Uint8Array.from([224,26,0,255,9,5,7,118,101,114,115,105,111,110]),A=Uint8Array.from([224,26,0,255,10,66,32,7,99,104,97,105,110,73,100]),y=Uint8Array.from([224,26,0,255,19,3,17,118,101,114,105,102,121,105,110,103,67,111,110,116,114,97,99,116]),l=Uint8Array.from([224,26,0,255,18,128,6,80,101,114,115,111,110,1,0,7,109,101,109,98,101,114,115]),_=Uint8Array.from([224,26,0,255,13,0,6,80,101,114,115,111,110,4,102,114,111,109]),w=Uint8Array.from([224,26,0,255,11,131,1,0,7,119,97,108,108,101,116,115]),I=Uint8Array.from([224,26,0,255,17,7,15,115,116,97,116,105,99,69,120,116,114,97,100,97,116,97]),g=Uint8Array.from([224,26,0,255,20,7,18,114,101,112,108,97,99,101,109,101,110,116,80,97,116,116,101,114,110]),D=Uint8Array.from([224,26,0,255,11,70,4,8,100,97,116,97,84,121,112,101]),S=Uint8Array.from([224,26,0,255,14,133,2,1,3,0,8,100,111,99,117,109,101,110,116]),h=Uint8Array.from([224,26,0,255,14,194,1,4,0,0,0,0,6,100,101,112,116,104,121]);describe("SendEIP712StructDefinitionCommand",()=>{let t;describe("name",()=>{it("should be 'sendEIP712StructDefinition'",()=>{const e=new n({command:r.Name,name:"test"});expect(e.name).toBe("sendEIP712StructDefinition")})}),describe("getApdu",()=>{it("should return the apdu for 'EIP712Domain' name definition",()=>{t=new n({command:r.Name,name:"EIP712Domain"});const e=t.getApdu();expect(e.getRawApdu()).toStrictEqual(c)}),it("should return the apdu for 'Group' name definition",()=>{t=new n({command:r.Name,name:"Group"});const e=t.getApdu();expect(e.getRawApdu()).toStrictEqual(m)}),it("should return the apdu for 'name' of type 'string'",()=>{t=new n({command:r.Field,name:"name",type:new o("string","string",x)});const e=t.getApdu();expect(e.getRawApdu()).toStrictEqual(f)}),it("should return the apdu for 'version' of type 'string'",()=>{t=new n({command:r.Field,name:"version",type:new o("string","string",x)});const e=t.getApdu();expect(e.getRawApdu()).toStrictEqual(E)}),it("should return the apdu for 'chainId' of type 'uint256'",()=>{t=new n({command:r.Field,name:"chainId",type:new o("uint256","uint",a(32))});const e=t.getApdu();expect(e.getRawApdu()).toStrictEqual(A)}),it("should return the apdu for 'verifyingContract' of type 'address'",()=>{t=new n({command:r.Field,name:"verifyingContract",type:new o("address","address",x)});const e=t.getApdu();expect(e.getRawApdu()).toStrictEqual(y)}),it("should return the apdu for 'members' of type 'Person[]'",()=>{t=new n({command:r.Field,name:"members",type:new d("Person[]",new i("Person"),"Person",x,[x])});const e=t.getApdu();expect(e.getRawApdu()).toStrictEqual(l)}),it("should return the apdu for 'from' of type 'Person'",()=>{t=new n({command:r.Field,name:"from",type:new i("Person")});const e=t.getApdu();expect(e.getRawApdu()).toStrictEqual(_)}),it("should return the apdu for 'wallets' of type 'address[]'",()=>{t=new n({command:r.Field,name:"wallets",type:new d("address[]",new o("address","address",x),"address",x,[x])});const e=t.getApdu();expect(e.getRawApdu()).toStrictEqual(w)}),it("should return the apdu for 'staticExtradata' of type 'bytes'",()=>{t=new n({command:r.Field,name:"staticExtradata",type:new o("bytes","bytes",x)});const e=t.getApdu();expect(e.getRawApdu()).toStrictEqual(I)}),it("should return the apdu for 'replacementPattern' of type 'bytes'",()=>{t=new n({command:r.Field,name:"replacementPattern",type:new o("bytes","bytes",x)});const e=t.getApdu();expect(e.getRawApdu()).toStrictEqual(g)}),it("should return the apdu for 'dataType' of type 'bytes4'",()=>{t=new n({command:r.Field,name:"dataType",type:new o("bytes4","bytes",a(4))});const e=t.getApdu();expect(e.getRawApdu()).toStrictEqual(D)}),it("should return the apdu for 'document' of type 'string[3][]'",()=>{t=new n({command:r.Field,name:"document",type:new d("string[3][]",new o("string","string",x),"string[3]",x,[a(3),x])});const e=t.getApdu();expect(e.getRawApdu()).toStrictEqual(S)}),it("should return the apdu for 'depthy' of type 'uint8[][][][]'",()=>{t=new n({command:r.Field,name:"depthy",type:new d("uint8[][][][]",new o("uint8","uint",a(1)),"uint8[][][]",x,[x,x,x,x])});const e=t.getApdu();expect(e.getRawApdu()).toStrictEqual(h)})}),describe("parseResponse",()=>{it("should parse the response",()=>{const e={statusCode:Uint8Array.from([144,0]),data:new Uint8Array},s=t.parseResponse(e);expect(s).toStrictEqual(u({data:void 0}))}),it("should throw an error if the response is not successful",()=>{const e={statusCode:Uint8Array.from([85,21]),data:new Uint8Array},s=t.parseResponse(e);expect(p(s)).toBe(!1)})})});
|
|
2
2
|
//# sourceMappingURL=SendEIP712StructDefinitionCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SendEIP712StructDefinitionCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type Command,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, Nothing } from \"purify-ts\";\n\nimport {\n ArrayType,\n PrimitiveType,\n StructType,\n} from \"@internal/typed-data/model/Types\";\n\nimport { type EthErrorCodes } from \"./utils/ethAppErrors\";\nimport {\n SendEIP712StructDefinitionCommand,\n type SendEIP712StructDefinitionCommandArgs,\n StructDefinitionCommand,\n} from \"./SendEIP712StructDefinitionCommand\";\n\nconst EIP712_DEF_NAME_EIP712DOMAIN = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0x00, 0x0c, 0x45, 0x49, 0x50, 0x37, 0x31, 0x32, 0x44, 0x6f,\n 0x6d, 0x61, 0x69, 0x6e,\n]);\n\nconst EIP712_DEF_NAME_GROUP = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0x00, 0x05, 0x47, 0x72, 0x6f, 0x75, 0x70,\n]);\n\n// name string\nconst EIP712_DEF_FIELD_NAME_STRING = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x06, 0x05, 0x04, 0x6e, 0x61, 0x6d, 0x65,\n]);\n\n// version string\nconst EIP712_DEF_FIELD_VERSION_STRING = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x09, 0x05, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f,\n 0x6e,\n]);\n\n// chainId uint256\nconst EIP712_DEF_FIELD_CHAINID_UINT256 = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x0a, 0x42, 0x20, 0x07, 0x63, 0x68, 0x61, 0x69, 0x6e,\n 0x49, 0x64,\n]);\n\n// verifyingContract address\nconst EIP712_DEF_FIELD_VERIFYINGCONTRACT_ADDRESS = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x13, 0x03, 0x11, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79,\n 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74,\n]);\n\n// members Person[]\nconst EIP712_DEF_FIELD_MEMBERS_PERSON = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x12, 0x80, 0x06, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e,\n 0x01, 0x00, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73,\n]);\n\n// from Person\nconst EIP712_DEF_FIELD_FROM_PERSON = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x0d, 0x00, 0x06, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e,\n 0x04, 0x66, 0x72, 0x6f, 0x6d,\n]);\n\n// wallets address[]\nconst EIP712_DEF_FIELD_WALLETS_ADDRESS = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x0b, 0x83, 0x01, 0x00, 0x07, 0x77, 0x61, 0x6c, 0x6c,\n 0x65, 0x74, 0x73,\n]);\n\n// staticExtradata bytes\nconst EIP712_DEF_FIELD_STATICEXTRADATA_BYTES = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x11, 0x07, 0x0f, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63,\n 0x45, 0x78, 0x74, 0x72, 0x61, 0x64, 0x61, 0x74, 0x61,\n]);\n\n// replacementPattern bytes\nconst EIP712_DEF_FIELD_REPLACEMENTPATTERN_BYTES = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x14, 0x07, 0x12, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63,\n 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e,\n]);\n\n// dataType bytes4\nconst EIP712_DEF_FIELD_DATA_TYPE_BYTES4 = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x0b, 0x46, 0x04, 0x08, 0x64, 0x61, 0x74, 0x61, 0x54,\n 0x79, 0x70, 0x65,\n]);\n\n// document string[3][]\nconst EIP712_DEF_FIELD_DOCUMENT_STRING = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x0e, 0x85, 0x02, 0x01, 0x03, 0x00, 0x08, 0x64, 0x6f,\n 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74,\n]);\n\n// depthy uint8[][][][]\nconst EIP712_DEF_FIELD_DEPTHY_UINT8 = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x0e, 0xc2, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x06,\n 0x64, 0x65, 0x70, 0x74, 0x68, 0x79,\n]);\n\n// TODO: find examples for bool and int types.\n\ndescribe(\"SendEIP712StructDefinitionCommand\", () => {\n let command: Command<\n void,\n SendEIP712StructDefinitionCommandArgs,\n EthErrorCodes\n >;\n\n describe(\"getApdu\", () => {\n it(\"should return the apdu for 'EIP712Domain' name definition\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Name,\n name: \"EIP712Domain\",\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(EIP712_DEF_NAME_EIP712DOMAIN);\n });\n\n it(\"should return the apdu for 'Group' name definition\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Name,\n name: \"Group\",\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(EIP712_DEF_NAME_GROUP);\n });\n\n it(\"should return the apdu for 'name' of type 'string'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"name\",\n type: new PrimitiveType(\"string\", \"string\", Nothing),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(EIP712_DEF_FIELD_NAME_STRING);\n });\n\n it(\"should return the apdu for 'version' of type 'string'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"version\",\n type: new PrimitiveType(\"string\", \"string\", Nothing),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(EIP712_DEF_FIELD_VERSION_STRING);\n });\n\n it(\"should return the apdu for 'chainId' of type 'uint256'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"chainId\",\n type: new PrimitiveType(\"uint256\", \"uint\", Just(32)),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(EIP712_DEF_FIELD_CHAINID_UINT256);\n });\n\n it(\"should return the apdu for 'verifyingContract' of type 'address'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"verifyingContract\",\n type: new PrimitiveType(\"address\", \"address\", Nothing),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(\n EIP712_DEF_FIELD_VERIFYINGCONTRACT_ADDRESS,\n );\n });\n\n it(\"should return the apdu for 'members' of type 'Person[]'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"members\",\n type: new ArrayType(\n \"Person[]\",\n new StructType(\"Person\"),\n \"Person\",\n Nothing,\n [Nothing],\n ),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(EIP712_DEF_FIELD_MEMBERS_PERSON);\n });\n\n it(\"should return the apdu for 'from' of type 'Person'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"from\",\n type: new StructType(\"Person\"),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(EIP712_DEF_FIELD_FROM_PERSON);\n });\n\n it(\"should return the apdu for 'wallets' of type 'address[]'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"wallets\",\n type: new ArrayType(\n \"address[]\",\n new PrimitiveType(\"address\", \"address\", Nothing),\n \"address\",\n Nothing,\n [Nothing],\n ),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(EIP712_DEF_FIELD_WALLETS_ADDRESS);\n });\n\n it(\"should return the apdu for 'staticExtradata' of type 'bytes'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"staticExtradata\",\n type: new PrimitiveType(\"bytes\", \"bytes\", Nothing),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(\n EIP712_DEF_FIELD_STATICEXTRADATA_BYTES,\n );\n });\n\n it(\"should return the apdu for 'replacementPattern' of type 'bytes'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"replacementPattern\",\n type: new PrimitiveType(\"bytes\", \"bytes\", Nothing),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(\n EIP712_DEF_FIELD_REPLACEMENTPATTERN_BYTES,\n );\n });\n\n it(\"should return the apdu for 'dataType' of type 'bytes4'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"dataType\",\n type: new PrimitiveType(\"bytes4\", \"bytes\", Just(4)),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(\n EIP712_DEF_FIELD_DATA_TYPE_BYTES4,\n );\n });\n\n it(\"should return the apdu for 'document' of type 'string[3][]'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"document\",\n type: new ArrayType(\n \"string[3][]\",\n new PrimitiveType(\"string\", \"string\", Nothing),\n \"string[3]\",\n Nothing,\n [Just(3), Nothing],\n ),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(EIP712_DEF_FIELD_DOCUMENT_STRING);\n });\n\n it(\"should return the apdu for 'depthy' of type 'uint8[][][][]'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"depthy\",\n type: new ArrayType(\n \"uint8[][][][]\",\n new PrimitiveType(\"uint8\", \"uint\", Just(1)),\n \"uint8[][][]\",\n Nothing,\n [Nothing, Nothing, Nothing, Nothing],\n ),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(EIP712_DEF_FIELD_DEPTHY_UINT8);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should parse the response\", () => {\n // GIVEN\n const response = {\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: new Uint8Array(),\n };\n\n // WHEN\n const parsedResponse = command.parseResponse(response);\n\n // THEN\n expect(parsedResponse).toStrictEqual(\n CommandResultFactory({ data: undefined }),\n );\n });\n\n it(\"should throw an error if the response is not successful\", () => {\n // GIVEN\n const response = {\n statusCode: Uint8Array.from([0x55, 0x15]),\n data: new Uint8Array(),\n };\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OAEE,wBAAAA,EACA,0BAAAC,MACK,kCACP,OAAS,QAAAC,EAAM,WAAAC,MAAe,YAE9B,OACE,aAAAC,EACA,iBAAAC,EACA,cAAAC,MACK,mCAGP,OACE,qCAAAC,EAEA,2BAAAC,MACK,sCAEP,MAAMC,EAA+B,WAAW,KAAK,CACnD,IAAM,GAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM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M,IAAM,IAAM,GAAM,IAAM,IAAM,GACxE,GAAM,IAAM,IAAM,IAAM,GAAM,IAAM,GAAM,IAAM,EAClD,CAAC,EAGKC,EAA4C,WAAW,KAAK,CAChE,IAAM,GAAM,EAAM,IAAM,GAAM,EAAM,GAAM,IAAM,IAAM,IAAM,IAAM,GAAM,GACxE,IAAM,IAAM,IAAM,IAAM,IAAM,GAAM,GAAM,IAAM,IAAM,IAAM,IAAM,GACpE,CAAC,EAGKC,EAAoC,WAAW,KAAK,CACxD,IAAM,GAAM,EAAM,IAAM,GAAM,GAAM,EAAM,EAAM,IAAM,GAAM,IAAM,GAAM,GACxE,IAAM,IAAM,GACd,CAAC,EAGKC,EAAmC,WAAW,KAAK,CACvD,IAAM,GAAM,EAAM,IAAM,GAAM,IAAM,EAAM,EAAM,EAAM,EAAM,EAAM,IAAM,IACxE,GAAM,IAAM,IAAM,IAAM,IAAM,GAChC,CAAC,EAGKC,EAAgC,WAAW,KAAK,CACpD,IAAM,GAAM,EAAM,IAAM,GAAM,IAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EACxE,IAAM,IAAM,IAAM,IAAM,IAAM,GAChC,CAAC,EAID,SAAS,oCAAqC,IAAM,CAClD,IAAIC,EAMJ,SAAS,UAAW,IAAM,CACxB,GAAG,4DAA6D,IAAM,
|
|
6
|
-
"names": ["CommandResultFactory", "isSuccessCommandResult", "Just", "Nothing", "ArrayType", "PrimitiveType", "StructType", "SendEIP712StructDefinitionCommand", "StructDefinitionCommand", "EIP712_DEF_NAME_EIP712DOMAIN", "EIP712_DEF_NAME_GROUP", "EIP712_DEF_FIELD_NAME_STRING", "EIP712_DEF_FIELD_VERSION_STRING", "EIP712_DEF_FIELD_CHAINID_UINT256", "EIP712_DEF_FIELD_VERIFYINGCONTRACT_ADDRESS", "EIP712_DEF_FIELD_MEMBERS_PERSON", "EIP712_DEF_FIELD_FROM_PERSON", "EIP712_DEF_FIELD_WALLETS_ADDRESS", "EIP712_DEF_FIELD_STATICEXTRADATA_BYTES", "EIP712_DEF_FIELD_REPLACEMENTPATTERN_BYTES", "EIP712_DEF_FIELD_DATA_TYPE_BYTES4", "EIP712_DEF_FIELD_DOCUMENT_STRING", "EIP712_DEF_FIELD_DEPTHY_UINT8", "command", "apdu", "response", "parsedResponse", "result"]
|
|
4
|
+
"sourcesContent": ["import {\n type Command,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, Nothing } from \"purify-ts\";\n\nimport {\n ArrayType,\n PrimitiveType,\n StructType,\n} from \"@internal/typed-data/model/Types\";\n\nimport { type EthErrorCodes } from \"./utils/ethAppErrors\";\nimport {\n SendEIP712StructDefinitionCommand,\n type SendEIP712StructDefinitionCommandArgs,\n StructDefinitionCommand,\n} from \"./SendEIP712StructDefinitionCommand\";\n\nconst EIP712_DEF_NAME_EIP712DOMAIN = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0x00, 0x0c, 0x45, 0x49, 0x50, 0x37, 0x31, 0x32, 0x44, 0x6f,\n 0x6d, 0x61, 0x69, 0x6e,\n]);\n\nconst EIP712_DEF_NAME_GROUP = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0x00, 0x05, 0x47, 0x72, 0x6f, 0x75, 0x70,\n]);\n\n// name string\nconst EIP712_DEF_FIELD_NAME_STRING = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x06, 0x05, 0x04, 0x6e, 0x61, 0x6d, 0x65,\n]);\n\n// version string\nconst EIP712_DEF_FIELD_VERSION_STRING = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x09, 0x05, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f,\n 0x6e,\n]);\n\n// chainId uint256\nconst EIP712_DEF_FIELD_CHAINID_UINT256 = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x0a, 0x42, 0x20, 0x07, 0x63, 0x68, 0x61, 0x69, 0x6e,\n 0x49, 0x64,\n]);\n\n// verifyingContract address\nconst EIP712_DEF_FIELD_VERIFYINGCONTRACT_ADDRESS = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x13, 0x03, 0x11, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79,\n 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74,\n]);\n\n// members Person[]\nconst EIP712_DEF_FIELD_MEMBERS_PERSON = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x12, 0x80, 0x06, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e,\n 0x01, 0x00, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73,\n]);\n\n// from Person\nconst EIP712_DEF_FIELD_FROM_PERSON = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x0d, 0x00, 0x06, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e,\n 0x04, 0x66, 0x72, 0x6f, 0x6d,\n]);\n\n// wallets address[]\nconst EIP712_DEF_FIELD_WALLETS_ADDRESS = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x0b, 0x83, 0x01, 0x00, 0x07, 0x77, 0x61, 0x6c, 0x6c,\n 0x65, 0x74, 0x73,\n]);\n\n// staticExtradata bytes\nconst EIP712_DEF_FIELD_STATICEXTRADATA_BYTES = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x11, 0x07, 0x0f, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63,\n 0x45, 0x78, 0x74, 0x72, 0x61, 0x64, 0x61, 0x74, 0x61,\n]);\n\n// replacementPattern bytes\nconst EIP712_DEF_FIELD_REPLACEMENTPATTERN_BYTES = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x14, 0x07, 0x12, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63,\n 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e,\n]);\n\n// dataType bytes4\nconst EIP712_DEF_FIELD_DATA_TYPE_BYTES4 = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x0b, 0x46, 0x04, 0x08, 0x64, 0x61, 0x74, 0x61, 0x54,\n 0x79, 0x70, 0x65,\n]);\n\n// document string[3][]\nconst EIP712_DEF_FIELD_DOCUMENT_STRING = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x0e, 0x85, 0x02, 0x01, 0x03, 0x00, 0x08, 0x64, 0x6f,\n 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74,\n]);\n\n// depthy uint8[][][][]\nconst EIP712_DEF_FIELD_DEPTHY_UINT8 = Uint8Array.from([\n 0xe0, 0x1a, 0x00, 0xff, 0x0e, 0xc2, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x06,\n 0x64, 0x65, 0x70, 0x74, 0x68, 0x79,\n]);\n\n// TODO: find examples for bool and int types.\n\ndescribe(\"SendEIP712StructDefinitionCommand\", () => {\n let command: Command<\n void,\n SendEIP712StructDefinitionCommandArgs,\n EthErrorCodes\n >;\n\n describe(\"name\", () => {\n it(\"should be 'sendEIP712StructDefinition'\", () => {\n const cmd = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Name,\n name: \"test\",\n });\n expect(cmd.name).toBe(\"sendEIP712StructDefinition\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the apdu for 'EIP712Domain' name definition\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Name,\n name: \"EIP712Domain\",\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(EIP712_DEF_NAME_EIP712DOMAIN);\n });\n\n it(\"should return the apdu for 'Group' name definition\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Name,\n name: \"Group\",\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(EIP712_DEF_NAME_GROUP);\n });\n\n it(\"should return the apdu for 'name' of type 'string'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"name\",\n type: new PrimitiveType(\"string\", \"string\", Nothing),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(EIP712_DEF_FIELD_NAME_STRING);\n });\n\n it(\"should return the apdu for 'version' of type 'string'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"version\",\n type: new PrimitiveType(\"string\", \"string\", Nothing),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(EIP712_DEF_FIELD_VERSION_STRING);\n });\n\n it(\"should return the apdu for 'chainId' of type 'uint256'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"chainId\",\n type: new PrimitiveType(\"uint256\", \"uint\", Just(32)),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(EIP712_DEF_FIELD_CHAINID_UINT256);\n });\n\n it(\"should return the apdu for 'verifyingContract' of type 'address'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"verifyingContract\",\n type: new PrimitiveType(\"address\", \"address\", Nothing),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(\n EIP712_DEF_FIELD_VERIFYINGCONTRACT_ADDRESS,\n );\n });\n\n it(\"should return the apdu for 'members' of type 'Person[]'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"members\",\n type: new ArrayType(\n \"Person[]\",\n new StructType(\"Person\"),\n \"Person\",\n Nothing,\n [Nothing],\n ),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(EIP712_DEF_FIELD_MEMBERS_PERSON);\n });\n\n it(\"should return the apdu for 'from' of type 'Person'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"from\",\n type: new StructType(\"Person\"),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(EIP712_DEF_FIELD_FROM_PERSON);\n });\n\n it(\"should return the apdu for 'wallets' of type 'address[]'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"wallets\",\n type: new ArrayType(\n \"address[]\",\n new PrimitiveType(\"address\", \"address\", Nothing),\n \"address\",\n Nothing,\n [Nothing],\n ),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(EIP712_DEF_FIELD_WALLETS_ADDRESS);\n });\n\n it(\"should return the apdu for 'staticExtradata' of type 'bytes'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"staticExtradata\",\n type: new PrimitiveType(\"bytes\", \"bytes\", Nothing),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(\n EIP712_DEF_FIELD_STATICEXTRADATA_BYTES,\n );\n });\n\n it(\"should return the apdu for 'replacementPattern' of type 'bytes'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"replacementPattern\",\n type: new PrimitiveType(\"bytes\", \"bytes\", Nothing),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(\n EIP712_DEF_FIELD_REPLACEMENTPATTERN_BYTES,\n );\n });\n\n it(\"should return the apdu for 'dataType' of type 'bytes4'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"dataType\",\n type: new PrimitiveType(\"bytes4\", \"bytes\", Just(4)),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(\n EIP712_DEF_FIELD_DATA_TYPE_BYTES4,\n );\n });\n\n it(\"should return the apdu for 'document' of type 'string[3][]'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"document\",\n type: new ArrayType(\n \"string[3][]\",\n new PrimitiveType(\"string\", \"string\", Nothing),\n \"string[3]\",\n Nothing,\n [Just(3), Nothing],\n ),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(EIP712_DEF_FIELD_DOCUMENT_STRING);\n });\n\n it(\"should return the apdu for 'depthy' of type 'uint8[][][][]'\", () => {\n // GIVEN\n command = new SendEIP712StructDefinitionCommand({\n command: StructDefinitionCommand.Field,\n name: \"depthy\",\n type: new ArrayType(\n \"uint8[][][][]\",\n new PrimitiveType(\"uint8\", \"uint\", Just(1)),\n \"uint8[][][]\",\n Nothing,\n [Nothing, Nothing, Nothing, Nothing],\n ),\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(EIP712_DEF_FIELD_DEPTHY_UINT8);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should parse the response\", () => {\n // GIVEN\n const response = {\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: new Uint8Array(),\n };\n\n // WHEN\n const parsedResponse = command.parseResponse(response);\n\n // THEN\n expect(parsedResponse).toStrictEqual(\n CommandResultFactory({ data: undefined }),\n );\n });\n\n it(\"should throw an error if the response is not successful\", () => {\n // GIVEN\n const response = {\n statusCode: Uint8Array.from([0x55, 0x15]),\n data: new Uint8Array(),\n };\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAEE,wBAAAA,EACA,0BAAAC,MACK,kCACP,OAAS,QAAAC,EAAM,WAAAC,MAAe,YAE9B,OACE,aAAAC,EACA,iBAAAC,EACA,cAAAC,MACK,mCAGP,OACE,qCAAAC,EAEA,2BAAAC,MACK,sCAEP,MAAMC,EAA+B,WAAW,KAAK,CACnD,IAAM,GAAM,EAAM,EAAM,GAAM,GAAM,GAAM,GAAM,GAAM,GAAM,GAAM,GAAM,IACxE,IAAM,GAAM,IAAM,GACpB,CAAC,EAEKC,EAAwB,WAAW,KAAK,CAC5C,IAAM,GAAM,EAAM,EAAM,EAAM,GAAM,IAAM,IAAM,IAAM,GACxD,CAAC,EAGKC,EAA+B,WAAW,KAAK,CACnD,IAAM,GAAM,EAAM,IAAM,EAAM,EAAM,EAAM,IAAM,GAAM,IAAM,GAC9D,CAAC,EAGKC,EAAkC,WAAW,KAAK,CACtD,IAAM,GAAM,EAAM,IAAM,EAAM,EAAM,EAAM,IAAM,IAAM,IAAM,IAAM,IAAM,IACxE,GACF,CAAC,EAGKC,EAAmC,WAAW,KAAK,CACvD,IAAM,GAAM,EAAM,IAAM,GAAM,GAAM,GAAM,EAAM,GAAM,IAAM,GAAM,IAAM,IACxE,GAAM,GACR,CAAC,EAGKC,EAA6C,WAAW,KAAK,CACjE,IAAM,GAAM,EAAM,IAAM,GAAM,EAAM,GAAM,IAAM,IAAM,IAAM,IAAM,IAAM,IACxE,IAAM,IAAM,IAAM,GAAM,IAAM,IAAM,IAAM,IAAM,GAAM,GAAM,GAC9D,CAAC,EAGKC,EAAkC,WAAW,KAAK,CACtD,IAAM,GAAM,EAAM,IAAM,GAAM,IAAM,EAAM,GAAM,IAAM,IAAM,IAAM,IAAM,IACxE,EAAM,EAAM,EAAM,IAAM,IAAM,IAAM,GAAM,IAAM,IAAM,GACxD,CAAC,E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CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,GAAG,4BAA6B,IAAM,CAEpC,MAAMI,EAAW,CACf,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAM,IAAI,UACZ,EAGMC,EAAiBJ,EAAQ,cAAcG,CAAQ,EAGrD,OAAOC,CAAc,EAAE,cACrB3B,EAAqB,CAAE,KAAM,MAAU,CAAC,CAC1C,CACF,CAAC,EAED,GAAG,0DAA2D,IAAM,CAElE,MAAM0B,EAAW,CACf,WAAY,WAAW,KAAK,CAAC,GAAM,EAAI,CAAC,EACxC,KAAM,IAAI,UACZ,EAGME,EAASL,EAAQ,cAAcG,CAAQ,EAG7C,OAAOzB,EAAuB2B,CAAM,CAAC,EAAE,KAAK,EAAK,CACnD,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["CommandResultFactory", "isSuccessCommandResult", "Just", "Nothing", "ArrayType", "PrimitiveType", "StructType", "SendEIP712StructDefinitionCommand", "StructDefinitionCommand", "EIP712_DEF_NAME_EIP712DOMAIN", "EIP712_DEF_NAME_GROUP", "EIP712_DEF_FIELD_NAME_STRING", "EIP712_DEF_FIELD_VERSION_STRING", "EIP712_DEF_FIELD_CHAINID_UINT256", "EIP712_DEF_FIELD_VERIFYINGCONTRACT_ADDRESS", "EIP712_DEF_FIELD_MEMBERS_PERSON", "EIP712_DEF_FIELD_FROM_PERSON", "EIP712_DEF_FIELD_WALLETS_ADDRESS", "EIP712_DEF_FIELD_STATICEXTRADATA_BYTES", "EIP712_DEF_FIELD_REPLACEMENTPATTERN_BYTES", "EIP712_DEF_FIELD_DATA_TYPE_BYTES4", "EIP712_DEF_FIELD_DOCUMENT_STRING", "EIP712_DEF_FIELD_DEPTHY_UINT8", "command", "cmd", "apdu", "response", "parsedResponse", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduBuilder as t,CommandResultFactory as a}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as o}from"@ledgerhq/signer-utils";import{Maybe as
|
|
1
|
+
import{ApduBuilder as t,CommandResultFactory as a}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as o}from"@ledgerhq/signer-utils";import{Maybe as d}from"purify-ts";import{ETH_APP_ERRORS as s,EthAppCommandErrorFactory as p}from"./utils/ethAppErrors";var m=(r=>(r[r.ROOT=0]="ROOT",r[r.ARRAY=15]="ARRAY",r[r.FIELD=255]="FIELD",r))(m||{});class E{constructor(e){this.args=e}name="sendEIP712StructImplem";errorHelper=new o(s,p);getApdu(){const e={cla:224,ins:28,p1:this.args.type!=255||this.args.value.isLastChunk?0:1,p2:this.args.type};switch(this.args.type){case 0:return new t(e).addAsciiStringToData(this.args.value).build();case 15:return new t(e).add8BitUIntToData(this.args.value).build();case 255:return new t(e).addBufferToData(this.args.value.data).build()}}parseResponse(e){return d.fromNullable(this.errorHelper.getError(e)).orDefault(a({data:void 0}))}}export{E as SendEIP712StructImplemCommand,m as StructImplemType};
|
|
2
2
|
//# sourceMappingURL=SendEIP712StructImplemCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SendEIP712StructImplemCommand.ts"],
|
|
4
|
-
"sourcesContent": ["// https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#eip712-send-struct-implementation\nimport {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport {\n ETH_APP_ERRORS,\n EthAppCommandErrorFactory,\n type EthErrorCodes,\n} from \"./utils/ethAppErrors\";\n\nexport enum StructImplemType {\n ROOT = 0x00,\n ARRAY = 0x0f,\n FIELD = 0xff,\n}\n\nexport type SendEIP712StructImplemCommandArgs =\n | {\n type: StructImplemType.ROOT;\n value: string;\n }\n | {\n type: StructImplemType.ARRAY;\n value: number;\n }\n | {\n type: StructImplemType.FIELD;\n value: {\n /**\n * The chunk of the data that is ready to send, that is to say, prefixed by its length in two bytes.\n * Eg. 01020304 => [0x00, 0x04, 0x01, 0x02, 0x03, 0x04] where [0x00, 0x04] are the length of the data.\n */\n data: Uint8Array;\n isLastChunk: boolean;\n };\n };\n\nexport class SendEIP712StructImplemCommand\n implements Command<void, SendEIP712StructImplemCommandArgs, EthErrorCodes>\n{\n private readonly errorHelper = new CommandErrorHelper<void, EthErrorCodes>(\n ETH_APP_ERRORS,\n EthAppCommandErrorFactory,\n );\n constructor(private readonly args: SendEIP712StructImplemCommandArgs) {}\n\n getApdu(): Apdu {\n const apduBuilderArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x1c,\n p1:\n this.args.type != StructImplemType.FIELD || this.args.value.isLastChunk\n ? 0x00\n : 0x01,\n p2: this.args.type,\n };\n switch (this.args.type) {\n case StructImplemType.ROOT:\n return new ApduBuilder(apduBuilderArgs)\n .addAsciiStringToData(this.args.value)\n .build();\n case StructImplemType.ARRAY:\n return new ApduBuilder(apduBuilderArgs)\n .add8BitUIntToData(this.args.value)\n .build();\n case StructImplemType.FIELD:\n return new ApduBuilder(apduBuilderArgs)\n .addBufferToData(this.args.value.data)\n .build();\n }\n }\n\n parseResponse(response: ApduResponse): CommandResult<void, EthErrorCodes> {\n return Maybe.fromNullable(this.errorHelper.getError(response)).orDefault(\n CommandResultFactory({ data: undefined }),\n );\n }\n}\n"],
|
|
5
|
-
"mappings": "AACA,OAEE,eAAAA,EAKA,wBAAAC,MACK,kCACP,OAAS,sBAAAC,MAA0B,yBACnC,OAAS,SAAAC,MAAa,YAEtB,OACE,kBAAAC,EACA,6BAAAC,MAEK,uBAEA,IAAKC,OACVA,IAAA,KAAO,GAAP,OACAA,IAAA,MAAQ,IAAR,QACAA,IAAA,MAAQ,KAAR,QAHUA,OAAA,IA2BL,MAAMC,CAEb,
|
|
4
|
+
"sourcesContent": ["// https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#eip712-send-struct-implementation\nimport {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport {\n ETH_APP_ERRORS,\n EthAppCommandErrorFactory,\n type EthErrorCodes,\n} from \"./utils/ethAppErrors\";\n\nexport enum StructImplemType {\n ROOT = 0x00,\n ARRAY = 0x0f,\n FIELD = 0xff,\n}\n\nexport type SendEIP712StructImplemCommandArgs =\n | {\n type: StructImplemType.ROOT;\n value: string;\n }\n | {\n type: StructImplemType.ARRAY;\n value: number;\n }\n | {\n type: StructImplemType.FIELD;\n value: {\n /**\n * The chunk of the data that is ready to send, that is to say, prefixed by its length in two bytes.\n * Eg. 01020304 => [0x00, 0x04, 0x01, 0x02, 0x03, 0x04] where [0x00, 0x04] are the length of the data.\n */\n data: Uint8Array;\n isLastChunk: boolean;\n };\n };\n\nexport class SendEIP712StructImplemCommand\n implements Command<void, SendEIP712StructImplemCommandArgs, EthErrorCodes>\n{\n readonly name = \"sendEIP712StructImplem\";\n private readonly errorHelper = new CommandErrorHelper<void, EthErrorCodes>(\n ETH_APP_ERRORS,\n EthAppCommandErrorFactory,\n );\n constructor(private readonly args: SendEIP712StructImplemCommandArgs) {}\n\n getApdu(): Apdu {\n const apduBuilderArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x1c,\n p1:\n this.args.type != StructImplemType.FIELD || this.args.value.isLastChunk\n ? 0x00\n : 0x01,\n p2: this.args.type,\n };\n switch (this.args.type) {\n case StructImplemType.ROOT:\n return new ApduBuilder(apduBuilderArgs)\n .addAsciiStringToData(this.args.value)\n .build();\n case StructImplemType.ARRAY:\n return new ApduBuilder(apduBuilderArgs)\n .add8BitUIntToData(this.args.value)\n .build();\n case StructImplemType.FIELD:\n return new ApduBuilder(apduBuilderArgs)\n .addBufferToData(this.args.value.data)\n .build();\n }\n }\n\n parseResponse(response: ApduResponse): CommandResult<void, EthErrorCodes> {\n return Maybe.fromNullable(this.errorHelper.getError(response)).orDefault(\n CommandResultFactory({ data: undefined }),\n );\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,OAEE,eAAAA,EAKA,wBAAAC,MACK,kCACP,OAAS,sBAAAC,MAA0B,yBACnC,OAAS,SAAAC,MAAa,YAEtB,OACE,kBAAAC,EACA,6BAAAC,MAEK,uBAEA,IAAKC,OACVA,IAAA,KAAO,GAAP,OACAA,IAAA,MAAQ,IAAR,QACAA,IAAA,MAAQ,KAAR,QAHUA,OAAA,IA2BL,MAAMC,CAEb,CAME,YAA6BC,EAAyC,CAAzC,UAAAA,CAA0C,CAL9D,KAAO,yBACC,YAAc,IAAIN,EACjCE,EACAC,CACF,EAGA,SAAgB,CACd,MAAMI,EAAmC,CACvC,IAAK,IACL,IAAK,GACL,GACE,KAAK,KAAK,MAAQ,KAA0B,KAAK,KAAK,MAAM,YACxD,EACA,EACN,GAAI,KAAK,KAAK,IAChB,EACA,OAAQ,KAAK,KAAK,KAAM,CACtB,IAAK,GACH,OAAO,IAAIT,EAAYS,CAAe,EACnC,qBAAqB,KAAK,KAAK,KAAK,EACpC,MAAM,EACX,IAAK,IACH,OAAO,IAAIT,EAAYS,CAAe,EACnC,kBAAkB,KAAK,KAAK,KAAK,EACjC,MAAM,EACX,IAAK,KACH,OAAO,IAAIT,EAAYS,CAAe,EACnC,gBAAgB,KAAK,KAAK,MAAM,IAAI,EACpC,MAAM,CACb,CACF,CAEA,cAAcC,EAA4D,CACxE,OAAOP,EAAM,aAAa,KAAK,YAAY,SAASO,CAAQ,CAAC,EAAE,UAC7DT,EAAqB,CAAE,KAAM,MAAU,CAAC,CAC1C,CACF,CACF",
|
|
6
6
|
"names": ["ApduBuilder", "CommandResultFactory", "CommandErrorHelper", "Maybe", "ETH_APP_ERRORS", "EthAppCommandErrorFactory", "StructImplemType", "SendEIP712StructImplemCommand", "args", "apduBuilderArgs", "response"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{CommandResultFactory as s,isSuccessCommandResult as c}from"@ledgerhq/device-management-kit";import{SendEIP712StructImplemCommand as
|
|
1
|
+
import{CommandResultFactory as s,isSuccessCommandResult as c}from"@ledgerhq/device-management-kit";import{SendEIP712StructImplemCommand as r,StructImplemType as n}from"./SendEIP712StructImplemCommand";const a=Uint8Array.from([224,28,0,0,6,108,101,100,103,101,114]),m=Uint8Array.from([224,28,0,15,1,19]),d=Uint8Array.from([224,28,0,255,6,0,4,1,2,3,4]),u=Uint8Array.from([224,28,1,255,5,5,6,7,8,9]);describe("SendEIP712StructImplemCommand",()=>{describe("name",()=>{it("should be 'sendEIP712StructImplem'",()=>{const e=new r({type:n.ROOT,value:"test"});expect(e.name).toBe("sendEIP712StructImplem")})}),describe("getApdu",()=>{it("should return the correct APDU for ROOT",()=>{const e={type:n.ROOT,value:"ledger"},t=new r(e).getApdu();expect(t.getRawApdu()).toStrictEqual(a)}),it("should return the correct APDU for ARRAY",()=>{const e={type:n.ARRAY,value:19},t=new r(e).getApdu();expect(t.getRawApdu()).toStrictEqual(m)}),it("should return the correct APDU for FIELD when receiving last chunk",()=>{const e={type:n.FIELD,value:{data:Uint8Array.from([0,4,1,2,3,4]),isLastChunk:!0}},t=new r(e).getApdu();expect(t.getRawApdu()).toStrictEqual(d)}),it("should return the correct APDU for FIELD when receiving other chunk",()=>{const e={type:n.FIELD,value:{data:Uint8Array.from([5,6,7,8,9]),isLastChunk:!1}},t=new r(e).getApdu();expect(t.getRawApdu()).toStrictEqual(u)})}),describe("parseResponse",()=>{it("should return an error if the response status code is not success",()=>{const e={data:new Uint8Array,statusCode:new Uint8Array([106,128])},t=new r({type:n.ROOT,value:"ledger"}).parseResponse(e);expect(c(t)).toBe(!1)}),it("should not return an error if the response status code is success",()=>{const e={data:new Uint8Array,statusCode:new Uint8Array([144,0])},o=new r({type:n.ROOT,value:"ledger"});expect(o.parseResponse(e)).toStrictEqual(s({data:void 0}))})})});
|
|
2
2
|
//# sourceMappingURL=SendEIP712StructImplemCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SendEIP712StructImplemCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {\n SendEIP712StructImplemCommand,\n type SendEIP712StructImplemCommandArgs,\n StructImplemType,\n} from \"./SendEIP712StructImplemCommand\";\n\nconst ROOT_APDU = Uint8Array.from([\n 0xe0, 0x1c, 0x00, 0x00, 0x06, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x72,\n]);\n\nconst ARRAY_APDU = Uint8Array.from([0xe0, 0x1c, 0x00, 0x0f, 0x01, 0x13]);\n\nconst FIELD_LAST_CHUNK_APDU = Uint8Array.from([\n 0xe0, 0x1c, 0x00, 0xff, 0x06, 0x00, 0x04, 0x01, 0x02, 0x03, 0x04,\n]);\n\nconst FIELD_OTHER_CHUNK_APDU = Uint8Array.from([\n 0xe0, 0x1c, 0x01, 0xff, 0x05, 0x05, 0x06, 0x07, 0x08, 0x09,\n]);\n\ndescribe(\"SendEIP712StructImplemCommand\", () => {\n describe(\"getApdu\", () => {\n it(\"should return the correct APDU for ROOT\", () => {\n // GIVEN\n const args: SendEIP712StructImplemCommandArgs = {\n type: StructImplemType.ROOT,\n value: \"ledger\",\n };\n // WHEN\n const command = new SendEIP712StructImplemCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(ROOT_APDU);\n });\n it(\"should return the correct APDU for ARRAY\", () => {\n // GIVEN\n const args: SendEIP712StructImplemCommandArgs = {\n type: StructImplemType.ARRAY,\n value: 19,\n };\n // WHEN\n const command = new SendEIP712StructImplemCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(ARRAY_APDU);\n });\n it(\"should return the correct APDU for FIELD when receiving last chunk\", () => {\n // GIVEN\n const args: SendEIP712StructImplemCommandArgs = {\n type: StructImplemType.FIELD,\n value: {\n data: Uint8Array.from([0x00, 0x04, 0x01, 0x02, 0x03, 0x04]),\n isLastChunk: true,\n },\n };\n // WHEN\n const command = new SendEIP712StructImplemCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(FIELD_LAST_CHUNK_APDU);\n });\n it(\"should return the correct APDU for FIELD when receiving other chunk\", () => {\n // GIVEN\n const args: SendEIP712StructImplemCommandArgs = {\n type: StructImplemType.FIELD,\n value: {\n data: Uint8Array.from([0x05, 0x06, 0x07, 0x08, 0x09]),\n isLastChunk: false,\n },\n };\n // WHEN\n const command = new SendEIP712StructImplemCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(FIELD_OTHER_CHUNK_APDU);\n });\n });\n describe(\"parseResponse\", () => {\n it(\"should return an error if the response status code is not success\", () => {\n // GIVEN\n const response = {\n data: new Uint8Array(),\n statusCode: new Uint8Array([0x6a, 0x80]),\n };\n // WHEN\n const command = new SendEIP712StructImplemCommand({\n type: StructImplemType.ROOT,\n value: \"ledger\",\n });\n // THEN\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n it(\"should not return an error if the response status code is success\", () => {\n // GIVEN\n const response = {\n data: new Uint8Array(),\n statusCode: new Uint8Array([0x90, 0x00]),\n };\n // WHEN\n const command = new SendEIP712StructImplemCommand({\n type: StructImplemType.ROOT,\n value: \"ledger\",\n });\n // THEN\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({ data: undefined }),\n );\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OACE,wBAAAA,EACA,0BAAAC,MACK,kCAEP,OACE,iCAAAC,EAEA,oBAAAC,MACK,kCAEP,MAAMC,EAAY,WAAW,KAAK,CAChC,IAAM,GAAM,EAAM,EAAM,EAAM,IAAM,IAAM,IAAM,IAAM,IAAM,GAC9D,CAAC,EAEKC,EAAa,WAAW,KAAK,CAAC,IAAM,GAAM,EAAM,GAAM,EAAM,EAAI,CAAC,EAEjEC,EAAwB,WAAW,KAAK,CAC5C,IAAM,GAAM,EAAM,IAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,CAC9D,CAAC,EAEKC,EAAyB,WAAW,KAAK,CAC7C,IAAM,GAAM,EAAM,IAAM,EAAM,EAAM,EAAM,EAAM,EAAM,CACxD,CAAC,EAED,SAAS,gCAAiC,IAAM,CAC9C,SAAS,UAAW,IAAM,CACxB,GAAG,0CAA2C,IAAM,CAElD,MAAMC,EAA0C,CAC9C,
|
|
6
|
-
"names": ["CommandResultFactory", "isSuccessCommandResult", "SendEIP712StructImplemCommand", "StructImplemType", "ROOT_APDU", "ARRAY_APDU", "FIELD_LAST_CHUNK_APDU", "FIELD_OTHER_CHUNK_APDU", "args", "apdu", "response", "result"
|
|
4
|
+
"sourcesContent": ["import {\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {\n SendEIP712StructImplemCommand,\n type SendEIP712StructImplemCommandArgs,\n StructImplemType,\n} from \"./SendEIP712StructImplemCommand\";\n\nconst ROOT_APDU = Uint8Array.from([\n 0xe0, 0x1c, 0x00, 0x00, 0x06, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x72,\n]);\n\nconst ARRAY_APDU = Uint8Array.from([0xe0, 0x1c, 0x00, 0x0f, 0x01, 0x13]);\n\nconst FIELD_LAST_CHUNK_APDU = Uint8Array.from([\n 0xe0, 0x1c, 0x00, 0xff, 0x06, 0x00, 0x04, 0x01, 0x02, 0x03, 0x04,\n]);\n\nconst FIELD_OTHER_CHUNK_APDU = Uint8Array.from([\n 0xe0, 0x1c, 0x01, 0xff, 0x05, 0x05, 0x06, 0x07, 0x08, 0x09,\n]);\n\ndescribe(\"SendEIP712StructImplemCommand\", () => {\n describe(\"name\", () => {\n it(\"should be 'sendEIP712StructImplem'\", () => {\n const command = new SendEIP712StructImplemCommand({\n type: StructImplemType.ROOT,\n value: \"test\",\n });\n expect(command.name).toBe(\"sendEIP712StructImplem\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the correct APDU for ROOT\", () => {\n // GIVEN\n const args: SendEIP712StructImplemCommandArgs = {\n type: StructImplemType.ROOT,\n value: \"ledger\",\n };\n // WHEN\n const command = new SendEIP712StructImplemCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(ROOT_APDU);\n });\n it(\"should return the correct APDU for ARRAY\", () => {\n // GIVEN\n const args: SendEIP712StructImplemCommandArgs = {\n type: StructImplemType.ARRAY,\n value: 19,\n };\n // WHEN\n const command = new SendEIP712StructImplemCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(ARRAY_APDU);\n });\n it(\"should return the correct APDU for FIELD when receiving last chunk\", () => {\n // GIVEN\n const args: SendEIP712StructImplemCommandArgs = {\n type: StructImplemType.FIELD,\n value: {\n data: Uint8Array.from([0x00, 0x04, 0x01, 0x02, 0x03, 0x04]),\n isLastChunk: true,\n },\n };\n // WHEN\n const command = new SendEIP712StructImplemCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(FIELD_LAST_CHUNK_APDU);\n });\n it(\"should return the correct APDU for FIELD when receiving other chunk\", () => {\n // GIVEN\n const args: SendEIP712StructImplemCommandArgs = {\n type: StructImplemType.FIELD,\n value: {\n data: Uint8Array.from([0x05, 0x06, 0x07, 0x08, 0x09]),\n isLastChunk: false,\n },\n };\n // WHEN\n const command = new SendEIP712StructImplemCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(FIELD_OTHER_CHUNK_APDU);\n });\n });\n describe(\"parseResponse\", () => {\n it(\"should return an error if the response status code is not success\", () => {\n // GIVEN\n const response = {\n data: new Uint8Array(),\n statusCode: new Uint8Array([0x6a, 0x80]),\n };\n // WHEN\n const command = new SendEIP712StructImplemCommand({\n type: StructImplemType.ROOT,\n value: \"ledger\",\n });\n // THEN\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n it(\"should not return an error if the response status code is success\", () => {\n // GIVEN\n const response = {\n data: new Uint8Array(),\n statusCode: new Uint8Array([0x90, 0x00]),\n };\n // WHEN\n const command = new SendEIP712StructImplemCommand({\n type: StructImplemType.ROOT,\n value: \"ledger\",\n });\n // THEN\n expect(command.parseResponse(response)).toStrictEqual(\n CommandResultFactory({ data: undefined }),\n );\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,wBAAAA,EACA,0BAAAC,MACK,kCAEP,OACE,iCAAAC,EAEA,oBAAAC,MACK,kCAEP,MAAMC,EAAY,WAAW,KAAK,CAChC,IAAM,GAAM,EAAM,EAAM,EAAM,IAAM,IAAM,IAAM,IAAM,IAAM,GAC9D,CAAC,EAEKC,EAAa,WAAW,KAAK,CAAC,IAAM,GAAM,EAAM,GAAM,EAAM,EAAI,CAAC,EAEjEC,EAAwB,WAAW,KAAK,CAC5C,IAAM,GAAM,EAAM,IAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,CAC9D,CAAC,EAEKC,EAAyB,WAAW,KAAK,CAC7C,IAAM,GAAM,EAAM,IAAM,EAAM,EAAM,EAAM,EAAM,EAAM,CACxD,CAAC,EAED,SAAS,gCAAiC,IAAM,CAC9C,SAAS,OAAQ,IAAM,CACrB,GAAG,qCAAsC,IAAM,CAC7C,MAAMC,EAAU,IAAIN,EAA8B,CAChD,KAAMC,EAAiB,KACvB,MAAO,MACT,CAAC,EACD,OAAOK,EAAQ,IAAI,EAAE,KAAK,wBAAwB,CACpD,CAA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Q,CAAQ,EAC7C,OAAOV,EAAuBW,CAAM,CAAC,EAAE,KAAK,EAAK,CACnD,CAAC,EACD,GAAG,oEAAqE,IAAM,CAE5E,MAAMD,EAAW,CACf,KAAM,IAAI,WACV,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,CACzC,EAEMH,EAAU,IAAIN,EAA8B,CAChD,KAAMC,EAAiB,KACvB,MAAO,QACT,CAAC,EAED,OAAOK,EAAQ,cAAcG,CAAQ,CAAC,EAAE,cACtCX,EAAqB,CAAE,KAAM,MAAU,CAAC,CAC1C,CACF,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["CommandResultFactory", "isSuccessCommandResult", "SendEIP712StructImplemCommand", "StructImplemType", "ROOT_APDU", "ARRAY_APDU", "FIELD_LAST_CHUNK_APDU", "FIELD_OTHER_CHUNK_APDU", "command", "args", "apdu", "response", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduBuilder as e,CommandResultFactory as t}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as o}from"@ledgerhq/signer-utils";import{Maybe as a}from"purify-ts";import{ETH_APP_ERRORS as
|
|
1
|
+
import{ApduBuilder as e,CommandResultFactory as t}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as o}from"@ledgerhq/signer-utils";import{Maybe as a}from"purify-ts";import{ETH_APP_ERRORS as n,EthAppCommandErrorFactory as d}from"./utils/ethAppErrors";class u{constructor(r){this.args=r}name="setExternalPlugin";errorHelper=new o(n,d);getApdu(){const r={cla:224,ins:18,p1:0,p2:0};return new e(r).addHexaStringToData(this.args.payload).addHexaStringToData(this.args.signature??"").build()}parseResponse(r){return a.fromNullable(this.errorHelper.getError(r)).orDefault(t({data:void 0}))}}export{u as SetExternalPluginCommand};
|
|
2
2
|
//# sourceMappingURL=SetExternalPluginCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SetExternalPluginCommand.ts"],
|
|
4
|
-
"sourcesContent": ["// https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#set-external-plugin\nimport {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport {\n ETH_APP_ERRORS,\n EthAppCommandErrorFactory,\n type EthErrorCodes,\n} from \"./utils/ethAppErrors\";\n\ntype SetExternalPluginCommandArgs = {\n payload: string;\n signature?: string;\n};\n\nexport class SetExternalPluginCommand\n implements Command<void, SetExternalPluginCommandArgs, EthErrorCodes>\n{\n constructor(private readonly args: SetExternalPluginCommandArgs) {}\n private readonly errorHelper = new CommandErrorHelper<void, EthErrorCodes>(\n ETH_APP_ERRORS,\n EthAppCommandErrorFactory,\n );\n\n getApdu(): Apdu {\n const setExternalPluginBuilderArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x12,\n p1: 0x00,\n p2: 0x00,\n };\n return (\n new ApduBuilder(setExternalPluginBuilderArgs)\n .addHexaStringToData(this.args.payload)\n /**\n * The signature is normally integrated in the payload, but keeping this step for safety reasons and will be removed in the future.\n */\n .addHexaStringToData(this.args.signature ?? \"\")\n .build()\n );\n }\n\n parseResponse(\n apduResponse: ApduResponse,\n ): CommandResult<void, EthErrorCodes> {\n return Maybe.fromNullable(\n this.errorHelper.getError(apduResponse),\n ).orDefault(CommandResultFactory({ data: undefined }));\n }\n}\n"],
|
|
5
|
-
"mappings": "AACA,OAEE,eAAAA,EAKA,wBAAAC,MACK,kCACP,OAAS,sBAAAC,MAA0B,yBACnC,OAAS,SAAAC,MAAa,YAEtB,OACE,kBAAAC,EACA,6BAAAC,MAEK,uBAOA,MAAMC,CAEb,
|
|
4
|
+
"sourcesContent": ["// https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#set-external-plugin\nimport {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport {\n ETH_APP_ERRORS,\n EthAppCommandErrorFactory,\n type EthErrorCodes,\n} from \"./utils/ethAppErrors\";\n\ntype SetExternalPluginCommandArgs = {\n payload: string;\n signature?: string;\n};\n\nexport class SetExternalPluginCommand\n implements Command<void, SetExternalPluginCommandArgs, EthErrorCodes>\n{\n readonly name = \"setExternalPlugin\";\n\n constructor(private readonly args: SetExternalPluginCommandArgs) {}\n private readonly errorHelper = new CommandErrorHelper<void, EthErrorCodes>(\n ETH_APP_ERRORS,\n EthAppCommandErrorFactory,\n );\n\n getApdu(): Apdu {\n const setExternalPluginBuilderArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x12,\n p1: 0x00,\n p2: 0x00,\n };\n return (\n new ApduBuilder(setExternalPluginBuilderArgs)\n .addHexaStringToData(this.args.payload)\n /**\n * The signature is normally integrated in the payload, but keeping this step for safety reasons and will be removed in the future.\n */\n .addHexaStringToData(this.args.signature ?? \"\")\n .build()\n );\n }\n\n parseResponse(\n apduResponse: ApduResponse,\n ): CommandResult<void, EthErrorCodes> {\n return Maybe.fromNullable(\n this.errorHelper.getError(apduResponse),\n ).orDefault(CommandResultFactory({ data: undefined }));\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,OAEE,eAAAA,EAKA,wBAAAC,MACK,kCACP,OAAS,sBAAAC,MAA0B,yBACnC,OAAS,SAAAC,MAAa,YAEtB,OACE,kBAAAC,EACA,6BAAAC,MAEK,uBAOA,MAAMC,CAEb,CAGE,YAA6BC,EAAoC,CAApC,UAAAA,CAAqC,CAFzD,KAAO,oBAGC,YAAc,IAAIL,EACjCE,EACAC,CACF,EAEA,SAAgB,CACd,MAAMG,EAAgD,CACpD,IAAK,IACL,IAAK,GACL,GAAI,EACJ,GAAI,CACN,EACA,OACE,IAAIR,EAAYQ,CAA4B,EACzC,oBAAoB,KAAK,KAAK,OAAO,EAIrC,oBAAoB,KAAK,KAAK,WAAa,EAAE,EAC7C,MAAM,CAEb,CAEA,cACEC,EACoC,CACpC,OAAON,EAAM,aACX,KAAK,YAAY,SAASM,CAAY,CACxC,EAAE,UAAUR,EAAqB,CAAE,KAAM,MAAU,CAAC,CAAC,CACvD,CACF",
|
|
6
6
|
"names": ["ApduBuilder", "CommandResultFactory", "CommandErrorHelper", "Maybe", "ETH_APP_ERRORS", "EthAppCommandErrorFactory", "SetExternalPluginCommand", "args", "setExternalPluginBuilderArgs", "apduResponse"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{ApduResponse as n,CommandResultFactory as
|
|
1
|
+
import{ApduResponse as n,CommandResultFactory as p,GlobalCommandError as c,isSuccessCommandResult as a}from"@ledgerhq/device-management-kit";import{SetExternalPluginCommand as o}from"../../app-binder/command/SetExternalPluginCommand";import{EthAppCommandError as i}from"./utils/ethAppErrors";const s=[8,80,97,114,97,115,119,97,112,222,241,113,254,72,207,1,21,177,216,11,136,220,142,171,89,23,111,238,87,169,5,156,187],d=[4,130,187,242,243,79,54,123,46,91,194,24,71,182,86,111,33,240,151,107,34,211,56,138,154,94,68,106,198,45,37,207,114,91,98,162,85,91,45,212,100,164,218,10,178,244,213,6,130,5,67,175,29,36,36,112,177,177,169,105,162,117,120,243,83],m=[224,18,0,0,s.length+d.length,...s,...d];describe("Set External plugin",()=>{describe("name",()=>{it("should be 'setExternalPlugin'",()=>{const x=new o({payload:""});expect(x.name).toBe("setExternalPlugin")})}),describe("getApdu",()=>{it("should retrieve correct apdu",()=>{const r=new o({payload:s.map(e=>e.toString(16).padStart(2,"0")).join(""),signature:d.map(e=>e.toString(16).padStart(2,"0")).join("")}).getApdu();expect(r.getRawApdu()).toStrictEqual(Uint8Array.from(m))})}),describe("parseResponse",()=>{it.each`
|
|
2
2
|
apduResponseCode | errorCode
|
|
3
3
|
${Uint8Array.from([106,128])} | ${"6a80"}
|
|
4
4
|
${Uint8Array.from([105,132])} | ${"6984"}
|
|
5
5
|
${Uint8Array.from([109,0])} | ${"6d00"}
|
|
6
|
-
`("should return an error for the response status code $errorCode",({apduResponseCode:
|
|
6
|
+
`("should return an error for the response status code $errorCode",({apduResponseCode:x,errorCode:r})=>{const e=new n({data:Uint8Array.from([]),statusCode:x}),t=new o({payload:"",signature:""}).parseResponse(e);expect(a(t)).toBe(!1),a(t)||(expect(t.error).toBeInstanceOf(i),t.error instanceof i&&expect(t.error.errorCode).toStrictEqual(r))}),it("should return a global error",()=>{const x=new o({payload:"",signature:""}),r=new n({statusCode:Uint8Array.from([85,21]),data:Uint8Array.from([])}),e=x.parseResponse(r);expect(a(e)).toBe(!1),a(e)||(expect(e.error).toBeInstanceOf(c),e.error instanceof c&&expect(e.error.errorCode).toStrictEqual("5515"))}),it("should return void if status is success",()=>{const x=new o({payload:"",signature:""}),r=new n({statusCode:Uint8Array.from([144,0]),data:Uint8Array.from([])});expect(x.parseResponse(r)).toStrictEqual(p({data:void 0}))})})});
|
|
7
7
|
//# sourceMappingURL=SetExternalPluginCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SetExternalPluginCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n GlobalCommandError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { SetExternalPluginCommand } from \"@internal/app-binder/command/SetExternalPluginCommand\";\n\nimport { EthAppCommandError } from \"./utils/ethAppErrors\";\n\n/**\n * Test payload contains:\n * Length of plugin name : 08\n * Plugin Name : Paraswap\n * contract address: 0xdef171fe48cf0115b1d80b88dc8eab59176fee57\n * method selector: 0xa9059cbb\n */\nconst SET_EXTERNAL_PLUGIN_PAYLOAD = [\n 0x08, 0x50, 0x61, 0x72, 0x61, 0x73, 0x77, 0x61, 0x70, 0xde, 0xf1, 0x71, 0xfe,\n 0x48, 0xcf, 0x01, 0x15, 0xb1, 0xd8, 0x0b, 0x88, 0xdc, 0x8e, 0xab, 0x59, 0x17,\n 0x6f, 0xee, 0x57, 0xa9, 0x05, 0x9c, 0xbb,\n];\n// Public signature key: https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#set-external-plugin\nconst SET_EXTERNAL_PLUGIN_SIGNATURE = [\n 0x04, 0x82, 0xbb, 0xf2, 0xf3, 0x4f, 0x36, 0x7b, 0x2e, 0x5b, 0xc2, 0x18, 0x47,\n 0xb6, 0x56, 0x6f, 0x21, 0xf0, 0x97, 0x6b, 0x22, 0xd3, 0x38, 0x8a, 0x9a, 0x5e,\n 0x44, 0x6a, 0xc6, 0x2d, 0x25, 0xcf, 0x72, 0x5b, 0x62, 0xa2, 0x55, 0x5b, 0x2d,\n 0xd4, 0x64, 0xa4, 0xda, 0x0a, 0xb2, 0xf4, 0xd5, 0x06, 0x82, 0x05, 0x43, 0xaf,\n 0x1d, 0x24, 0x24, 0x70, 0xb1, 0xb1, 0xa9, 0x69, 0xa2, 0x75, 0x78, 0xf3, 0x53,\n];\nconst SET_EXTERNAL_PLUGIN_APDU = [\n 0xe0,\n 0x12,\n 0x00,\n 0x00,\n SET_EXTERNAL_PLUGIN_PAYLOAD.length + SET_EXTERNAL_PLUGIN_SIGNATURE.length,\n ...SET_EXTERNAL_PLUGIN_PAYLOAD,\n ...SET_EXTERNAL_PLUGIN_SIGNATURE,\n];\n\ndescribe(\"Set External plugin\", () => {\n describe(\"getApdu\", () => {\n it(\"should retrieve correct apdu\", () => {\n // given\n const command = new SetExternalPluginCommand({\n payload: SET_EXTERNAL_PLUGIN_PAYLOAD.map((x) =>\n x.toString(16).padStart(2, \"0\"),\n ).join(\"\"),\n signature: SET_EXTERNAL_PLUGIN_SIGNATURE.map((x) =>\n x.toString(16).padStart(2, \"0\"),\n ).join(\"\"),\n });\n // when\n const apdu = command.getApdu();\n // then\n expect(apdu.getRawApdu()).toStrictEqual(\n Uint8Array.from(SET_EXTERNAL_PLUGIN_APDU),\n );\n });\n });\n describe(\"parseResponse\", () => {\n it.each`\n apduResponseCode | errorCode\n ${Uint8Array.from([0x6a, 0x80])} | ${\"6a80\"}\n ${Uint8Array.from([0x69, 0x84])} | ${\"6984\"}\n ${Uint8Array.from([0x6d, 0x00])} | ${\"6d00\"}\n `(\n \"should return an error for the response status code $errorCode\",\n ({\n apduResponseCode,\n errorCode,\n }: Record<\"apduResponseCode\" | \"errorCode\", Uint8Array>) => {\n // GIVEN\n const response = new ApduResponse({\n data: Uint8Array.from([]),\n statusCode: apduResponseCode,\n });\n const command = new SetExternalPluginCommand({\n payload: \"\",\n signature: \"\",\n });\n // WHEN\n const result = command.parseResponse(response);\n // THEN\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toBeInstanceOf(EthAppCommandError);\n if (result.error instanceof EthAppCommandError)\n expect(result.error.errorCode).toStrictEqual(errorCode);\n }\n },\n );\n it(\"should return a global error\", () => {\n // given\n const command = new SetExternalPluginCommand({\n payload: \"\",\n signature: \"\",\n });\n // when\n const apduResponse = new ApduResponse({\n statusCode: Uint8Array.from([0x55, 0x15]),\n data: Uint8Array.from([]),\n });\n // then\n const result = command.parseResponse(apduResponse);\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toBeInstanceOf(GlobalCommandError);\n if (result.error instanceof GlobalCommandError)\n expect(result.error.errorCode).toStrictEqual(\"5515\");\n }\n });\n it(\"should return void if status is success\", () => {\n // given\n const command = new SetExternalPluginCommand({\n payload: \"\",\n signature: \"\",\n });\n // when\n const apduResponse = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: Uint8Array.from([]),\n });\n // then\n expect(command.parseResponse(apduResponse)).toStrictEqual(\n CommandResultFactory({ data: undefined }),\n );\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OACE,gBAAAA,EACA,wBAAAC,EACA,sBAAAC,EACA,0BAAAC,MACK,kCAEP,OAAS,4BAAAC,MAAgC,wDAEzC,OAAS,sBAAAC,MAA0B,uBASnC,MAAMC,EAA8B,CAClC,EAAM,GAAM,GAAM,IAAM,GAAM,IAAM,IAAM,GAAM,IAAM,IAAM,IAAM,IAAM,IACxE,GAAM,IAAM,EAAM,GAAM,IAAM,IAAM,GAAM,IAAM,IAAM,IAAM,IAAM,GAAM,GACxE,IAAM,IAAM,GAAM,IAAM,EAAM,IAAM,GACtC,EAEMC,EAAgC,CACpC,EAAM,IAAM,IAAM,IAAM,IAAM,GAAM,GAAM,IAAM,GAAM,GAAM,IAAM,GAAM,GACxE,IAAM,GAAM,IAAM,GAAM,IAAM,IAAM,IAAM,GAAM,IAAM,GAAM,IAAM,IAAM,GACxE,GAAM,IAAM,IAAM,GAAM,GAAM,IAAM,IAAM,GAAM,GAAM,IAAM,GAAM,GAAM,GACxE,IAAM,IAAM,IAAM,IAAM,GAAM,IAAM,IAAM,IAAM,EAAM,IAAM,EAAM,GAAM,IACxE,GAAM,GAAM,GAAM,IAAM,IAAM,IAAM,IAAM,IAAM,IAAM,IAAM,IAAM,IAAM,EAC1E,EACMC,EAA2B,CAC/B,IACA,GACA,EACA,EACAF,EAA4B,OAASC,EAA8B,OACnE,GAAGD,EACH,GAAGC,CACL,EAEA,SAAS,sBAAuB,IAAM,CACpC,SAAS,UAAW,IAAM,CACxB,GAAG,+BAAgC,IAAM,CAWvC,
|
|
6
|
-
"names": ["ApduResponse", "CommandResultFactory", "GlobalCommandError", "isSuccessCommandResult", "SetExternalPluginCommand", "EthAppCommandError", "SET_EXTERNAL_PLUGIN_PAYLOAD", "SET_EXTERNAL_PLUGIN_SIGNATURE", "SET_EXTERNAL_PLUGIN_APDU", "apdu", "x", "apduResponseCode", "errorCode", "response", "result", "
|
|
4
|
+
"sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n GlobalCommandError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { SetExternalPluginCommand } from \"@internal/app-binder/command/SetExternalPluginCommand\";\n\nimport { EthAppCommandError } from \"./utils/ethAppErrors\";\n\n/**\n * Test payload contains:\n * Length of plugin name : 08\n * Plugin Name : Paraswap\n * contract address: 0xdef171fe48cf0115b1d80b88dc8eab59176fee57\n * method selector: 0xa9059cbb\n */\nconst SET_EXTERNAL_PLUGIN_PAYLOAD = [\n 0x08, 0x50, 0x61, 0x72, 0x61, 0x73, 0x77, 0x61, 0x70, 0xde, 0xf1, 0x71, 0xfe,\n 0x48, 0xcf, 0x01, 0x15, 0xb1, 0xd8, 0x0b, 0x88, 0xdc, 0x8e, 0xab, 0x59, 0x17,\n 0x6f, 0xee, 0x57, 0xa9, 0x05, 0x9c, 0xbb,\n];\n// Public signature key: https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#set-external-plugin\nconst SET_EXTERNAL_PLUGIN_SIGNATURE = [\n 0x04, 0x82, 0xbb, 0xf2, 0xf3, 0x4f, 0x36, 0x7b, 0x2e, 0x5b, 0xc2, 0x18, 0x47,\n 0xb6, 0x56, 0x6f, 0x21, 0xf0, 0x97, 0x6b, 0x22, 0xd3, 0x38, 0x8a, 0x9a, 0x5e,\n 0x44, 0x6a, 0xc6, 0x2d, 0x25, 0xcf, 0x72, 0x5b, 0x62, 0xa2, 0x55, 0x5b, 0x2d,\n 0xd4, 0x64, 0xa4, 0xda, 0x0a, 0xb2, 0xf4, 0xd5, 0x06, 0x82, 0x05, 0x43, 0xaf,\n 0x1d, 0x24, 0x24, 0x70, 0xb1, 0xb1, 0xa9, 0x69, 0xa2, 0x75, 0x78, 0xf3, 0x53,\n];\nconst SET_EXTERNAL_PLUGIN_APDU = [\n 0xe0,\n 0x12,\n 0x00,\n 0x00,\n SET_EXTERNAL_PLUGIN_PAYLOAD.length + SET_EXTERNAL_PLUGIN_SIGNATURE.length,\n ...SET_EXTERNAL_PLUGIN_PAYLOAD,\n ...SET_EXTERNAL_PLUGIN_SIGNATURE,\n];\n\ndescribe(\"Set External plugin\", () => {\n describe(\"name\", () => {\n it(\"should be 'setExternalPlugin'\", () => {\n const command = new SetExternalPluginCommand({ payload: \"\" });\n expect(command.name).toBe(\"setExternalPlugin\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should retrieve correct apdu\", () => {\n // given\n const command = new SetExternalPluginCommand({\n payload: SET_EXTERNAL_PLUGIN_PAYLOAD.map((x) =>\n x.toString(16).padStart(2, \"0\"),\n ).join(\"\"),\n signature: SET_EXTERNAL_PLUGIN_SIGNATURE.map((x) =>\n x.toString(16).padStart(2, \"0\"),\n ).join(\"\"),\n });\n // when\n const apdu = command.getApdu();\n // then\n expect(apdu.getRawApdu()).toStrictEqual(\n Uint8Array.from(SET_EXTERNAL_PLUGIN_APDU),\n );\n });\n });\n describe(\"parseResponse\", () => {\n it.each`\n apduResponseCode | errorCode\n ${Uint8Array.from([0x6a, 0x80])} | ${\"6a80\"}\n ${Uint8Array.from([0x69, 0x84])} | ${\"6984\"}\n ${Uint8Array.from([0x6d, 0x00])} | ${\"6d00\"}\n `(\n \"should return an error for the response status code $errorCode\",\n ({\n apduResponseCode,\n errorCode,\n }: Record<\"apduResponseCode\" | \"errorCode\", Uint8Array>) => {\n // GIVEN\n const response = new ApduResponse({\n data: Uint8Array.from([]),\n statusCode: apduResponseCode,\n });\n const command = new SetExternalPluginCommand({\n payload: \"\",\n signature: \"\",\n });\n // WHEN\n const result = command.parseResponse(response);\n // THEN\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toBeInstanceOf(EthAppCommandError);\n if (result.error instanceof EthAppCommandError)\n expect(result.error.errorCode).toStrictEqual(errorCode);\n }\n },\n );\n it(\"should return a global error\", () => {\n // given\n const command = new SetExternalPluginCommand({\n payload: \"\",\n signature: \"\",\n });\n // when\n const apduResponse = new ApduResponse({\n statusCode: Uint8Array.from([0x55, 0x15]),\n data: Uint8Array.from([]),\n });\n // then\n const result = command.parseResponse(apduResponse);\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toBeInstanceOf(GlobalCommandError);\n if (result.error instanceof GlobalCommandError)\n expect(result.error.errorCode).toStrictEqual(\"5515\");\n }\n });\n it(\"should return void if status is success\", () => {\n // given\n const command = new SetExternalPluginCommand({\n payload: \"\",\n signature: \"\",\n });\n // when\n const apduResponse = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: Uint8Array.from([]),\n });\n // then\n expect(command.parseResponse(apduResponse)).toStrictEqual(\n CommandResultFactory({ data: undefined }),\n );\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,gBAAAA,EACA,wBAAAC,EACA,sBAAAC,EACA,0BAAAC,MACK,kCAEP,OAAS,4BAAAC,MAAgC,wDAEzC,OAAS,sBAAAC,MAA0B,uBASnC,MAAMC,EAA8B,CAClC,EAAM,GAAM,GAAM,IAAM,GAAM,IAAM,IAAM,GAAM,IAAM,IAAM,IAAM,IAAM,IACxE,GAAM,IAAM,EAAM,GAAM,IAAM,IAAM,GAAM,IAAM,IAAM,IAAM,IAAM,GAAM,GACxE,IAAM,IAAM,GAAM,IAAM,EAAM,IAAM,GACtC,EAEMC,EAAgC,CACpC,EAAM,IAAM,IAAM,IAAM,IAAM,GAAM,GAAM,IAAM,GAAM,GAAM,IAAM,GAAM,GACxE,IAAM,GAAM,IAAM,GAAM,IAAM,IAAM,IAAM,GAAM,IAAM,GAAM,IAAM,IAAM,GACxE,GAAM,IAAM,IAAM,GAAM,GAAM,IAAM,IAAM,GAAM,GAAM,IAAM,GAAM,GAAM,GACxE,IAAM,IAAM,IAAM,IAAM,GAAM,IAAM,IAAM,IAAM,EAAM,I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AC3C,QAAS,GACT,UAAW,EACb,CAAC,EAEsB,cAAcU,CAAQ,EAE7C,OAAOX,EAAuBY,CAAM,CAAC,EAAE,KAAK,EAAK,EAC5CZ,EAAuBY,CAAM,IAChC,OAAOA,EAAO,KAAK,EAAE,eAAeV,CAAkB,EAClDU,EAAO,iBAAiBV,GAC1B,OAAOU,EAAO,MAAM,SAAS,EAAE,cAAcF,CAAS,EAE5D,CACF,EACA,GAAG,+BAAgC,IAAM,CAEvC,MAAMJ,EAAU,IAAIL,EAAyB,CAC3C,QAAS,GACT,UAAW,EACb,CAAC,EAEKY,EAAe,IAAIhB,EAAa,CACpC,WAAY,WAAW,KAAK,CAAC,GAAM,EAAI,CAAC,EACxC,KAAM,WAAW,KAAK,CAAC,CAAC,CAC1B,CAAC,EAEKe,EAASN,EAAQ,cAAcO,CAAY,EACjD,OAAOb,EAAuBY,CAAM,CAAC,EAAE,KAAK,EAAK,EAC5CZ,EAAuBY,CAAM,IAChC,OAAOA,EAAO,KAAK,EAAE,eAAeb,CAAkB,EAClDa,EAAO,iBAAiBb,GAC1B,OAAOa,EAAO,MAAM,SAAS,EAAE,cAAc,MAAM,EAEzD,CAAC,EACD,GAAG,0CAA2C,IAAM,CAElD,MAAMN,EAAU,IAAIL,EAAyB,CAC3C,QAAS,GACT,UAAW,EACb,CAAC,EAEKY,EAAe,IAAIhB,EAAa,CACpC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAM,WAAW,KAAK,CAAC,CAAC,CAC1B,CAAC,EAED,OAAOS,EAAQ,cAAcO,CAAY,CAAC,EAAE,cAC1Cf,EAAqB,CAAE,KAAM,MAAU,CAAC,CAC1C,CACF,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["ApduResponse", "CommandResultFactory", "GlobalCommandError", "isSuccessCommandResult", "SetExternalPluginCommand", "EthAppCommandError", "SET_EXTERNAL_PLUGIN_PAYLOAD", "SET_EXTERNAL_PLUGIN_SIGNATURE", "SET_EXTERNAL_PLUGIN_APDU", "command", "apdu", "x", "apduResponseCode", "errorCode", "response", "result", "apduResponse"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduBuilder as e,CommandResultFactory as o}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as t}from"@ledgerhq/signer-utils";import{Maybe as d}from"purify-ts";import{ETH_APP_ERRORS as
|
|
1
|
+
import{ApduBuilder as e,CommandResultFactory as o}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as t}from"@ledgerhq/signer-utils";import{Maybe as d}from"purify-ts";import{ETH_APP_ERRORS as a,EthAppCommandErrorFactory as p}from"./utils/ethAppErrors";class i{constructor(r){this.args=r}name="setPlugin";errorHelper=new t(a,p);getApdu(){const r={cla:224,ins:22,p1:0,p2:0};return new e(r).addHexaStringToData(this.args.payload).build()}parseResponse(r){return d.fromNullable(this.errorHelper.getError(r)).orDefault(o({data:void 0}))}}export{i as SetPluginCommand};
|
|
2
2
|
//# sourceMappingURL=SetPluginCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SetPluginCommand.ts"],
|
|
4
|
-
"sourcesContent": ["// https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#set-plugin\nimport {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport {\n ETH_APP_ERRORS,\n EthAppCommandErrorFactory,\n type EthErrorCodes,\n} from \"./utils/ethAppErrors\";\n\nexport type SetPluginCommandArgs = {\n /**\n * The stringified hexa representation of the plugin signature.\n */\n payload: string;\n};\n\nexport class SetPluginCommand\n implements Command<void, SetPluginCommandArgs, EthErrorCodes>\n{\n private readonly errorHelper = new CommandErrorHelper<void, EthErrorCodes>(\n ETH_APP_ERRORS,\n EthAppCommandErrorFactory,\n );\n\n constructor(private readonly args: SetPluginCommandArgs) {}\n\n getApdu(): Apdu {\n const apduBuilderArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x16,\n p1: 0x00,\n p2: 0x00,\n };\n return new ApduBuilder(apduBuilderArgs)\n .addHexaStringToData(this.args.payload)\n .build();\n }\n\n parseResponse(response: ApduResponse): CommandResult<void, EthErrorCodes> {\n return Maybe.fromNullable(this.errorHelper.getError(response)).orDefault(\n CommandResultFactory({ data: undefined }),\n );\n }\n}\n"],
|
|
5
|
-
"mappings": "AACA,OAEE,eAAAA,EAKA,wBAAAC,MACK,kCACP,OAAS,sBAAAC,MAA0B,yBACnC,OAAS,SAAAC,MAAa,YAEtB,OACE,kBAAAC,EACA,6BAAAC,MAEK,uBASA,MAAMC,CAEb,
|
|
4
|
+
"sourcesContent": ["// https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#set-plugin\nimport {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport {\n ETH_APP_ERRORS,\n EthAppCommandErrorFactory,\n type EthErrorCodes,\n} from \"./utils/ethAppErrors\";\n\nexport type SetPluginCommandArgs = {\n /**\n * The stringified hexa representation of the plugin signature.\n */\n payload: string;\n};\n\nexport class SetPluginCommand\n implements Command<void, SetPluginCommandArgs, EthErrorCodes>\n{\n readonly name = \"setPlugin\";\n private readonly errorHelper = new CommandErrorHelper<void, EthErrorCodes>(\n ETH_APP_ERRORS,\n EthAppCommandErrorFactory,\n );\n\n constructor(private readonly args: SetPluginCommandArgs) {}\n\n getApdu(): Apdu {\n const apduBuilderArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x16,\n p1: 0x00,\n p2: 0x00,\n };\n return new ApduBuilder(apduBuilderArgs)\n .addHexaStringToData(this.args.payload)\n .build();\n }\n\n parseResponse(response: ApduResponse): CommandResult<void, EthErrorCodes> {\n return Maybe.fromNullable(this.errorHelper.getError(response)).orDefault(\n CommandResultFactory({ data: undefined }),\n );\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,OAEE,eAAAA,EAKA,wBAAAC,MACK,kCACP,OAAS,sBAAAC,MAA0B,yBACnC,OAAS,SAAAC,MAAa,YAEtB,OACE,kBAAAC,EACA,6BAAAC,MAEK,uBASA,MAAMC,CAEb,CAOE,YAA6BC,EAA4B,CAA5B,UAAAA,CAA6B,CANjD,KAAO,YACC,YAAc,IAAIL,EACjCE,EACAC,CACF,EAIA,SAAgB,CACd,MAAMG,EAAmC,CACvC,IAAK,IACL,IAAK,GACL,GAAI,EACJ,GAAI,CACN,EACA,OAAO,IAAIR,EAAYQ,CAAe,EACnC,oBAAoB,KAAK,KAAK,OAAO,EACrC,MAAM,CACX,CAEA,cAAcC,EAA4D,CACxE,OAAON,EAAM,aAAa,KAAK,YAAY,SAASM,CAAQ,CAAC,EAAE,UAC7DR,EAAqB,CAAE,KAAM,MAAU,CAAC,CAC1C,CACF,CACF",
|
|
6
6
|
"names": ["ApduBuilder", "CommandResultFactory", "CommandErrorHelper", "Maybe", "ETH_APP_ERRORS", "EthAppCommandErrorFactory", "SetPluginCommand", "args", "apduBuilderArgs", "response"]
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{ApduResponse as s,isSuccessCommandResult as
|
|
1
|
+
import{ApduResponse as s,isSuccessCommandResult as d}from"@ledgerhq/device-management-kit";import{EthAppCommandError as t}from"./utils/ethAppErrors";import{SetPluginCommand as r}from"./SetPluginCommand";const a="010106455243373231c5b07a55501014f36ec5d39d950a321439f6dd7642842e0e0000000000000001020147304502206d9f515916283e08fa6cdab205668c0739c558dcd6691a69ce74cd89fbc2cc6e022100c28c17b058e6d453570a58d69ff62042037dc61149af2f5161d5c36fdc5dc301",n=Uint8Array.from([224,22,0,0,115,1,1,6,69,82,67,55,50,49,197,176,122,85,80,16,20,243,110,197,211,157,149,10,50,20,57,246,221,118,66,132,46,14,0,0,0,0,0,0,0,1,2,1,71,48,69,2,32,109,159,81,89,22,40,62,8,250,108,218,178,5,102,140,7,57,197,88,220,214,105,26,105,206,116,205,137,251,194,204,110,2,33,0,194,140,23,176,88,230,212,83,87,10,88,214,159,246,32,66,3,125,198,17,73,175,47,81,97,213,195,111,220,93,195,1]);describe("SetPluginCommand",()=>{describe("name",()=>{it("should be 'setPlugin'",()=>{const x=new r({payload:""});expect(x.name).toBe("setPlugin")})}),describe("getApdu",()=>{it("returns the correct APDU",()=>{const x={payload:a},e=new r(x).getApdu();expect(e.getRawApdu()).toStrictEqual(n)})}),describe("parseResponse",()=>{it.each`
|
|
2
2
|
apduResponseCode | errorCode
|
|
3
3
|
${Uint8Array.from([105,132])} | ${"6984"}
|
|
4
4
|
${Uint8Array.from([109,0])} | ${"6d00"}
|
|
5
|
-
`("should return an error for the response status code $errorCode",({apduResponseCode:x,errorCode:
|
|
5
|
+
`("should return an error for the response status code $errorCode",({apduResponseCode:x,errorCode:c})=>{const e=new s({data:Uint8Array.from([]),statusCode:x}),o=new r({payload:""}).parseResponse(e);expect(d(o)).toBe(!1),d(o)||(expect(o.error).toBeInstanceOf(t),o.error instanceof t&&expect(o.error.errorCode).toStrictEqual(c))}),it("should return success if the response status code is correct",()=>{const x={data:Buffer.from([]),statusCode:Buffer.from([144,0])},e=new r({payload:""}).parseResponse(x);expect(d(e)).toBe(!0)})})});
|
|
6
6
|
//# sourceMappingURL=SetPluginCommand.test.js.map
|