@ledgerhq/context-module 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/package.json +2 -2
- package/lib/cjs/src/ContextModule.js +1 -1
- package/lib/cjs/src/ContextModule.js.map +1 -1
- package/lib/cjs/src/ContextModuleBuilder.js +1 -1
- package/lib/cjs/src/ContextModuleBuilder.js.map +3 -3
- package/lib/cjs/src/ContextModuleBuilder.test.js +1 -1
- package/lib/cjs/src/ContextModuleBuilder.test.js.map +3 -3
- package/lib/cjs/src/DefaultContextModule.js +1 -1
- package/lib/cjs/src/DefaultContextModule.js.map +3 -3
- package/lib/cjs/src/DefaultContextModule.test.js +1 -1
- package/lib/cjs/src/DefaultContextModule.test.js.map +3 -3
- package/lib/cjs/src/calldata/data/CalldataDescriptorDataSource.js +2 -0
- package/lib/cjs/src/calldata/data/CalldataDescriptorDataSource.js.map +7 -0
- package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.js +2 -0
- package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.js.map +7 -0
- package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.test.js +2 -0
- package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.test.js.map +7 -0
- package/lib/cjs/src/calldata/data/dto/CalldataDto.js +2 -0
- package/lib/cjs/src/calldata/data/dto/CalldataDto.js.map +7 -0
- package/lib/cjs/src/calldata/di/calldataModuleFactory.js +2 -0
- package/lib/cjs/src/calldata/di/calldataModuleFactory.js.map +7 -0
- package/lib/cjs/src/calldata/di/calldataTypes.js +2 -0
- package/lib/cjs/src/calldata/di/calldataTypes.js.map +7 -0
- package/lib/cjs/src/calldata/domain/CalldataContextLoader.js +2 -0
- package/lib/cjs/src/calldata/domain/CalldataContextLoader.js.map +7 -0
- package/lib/cjs/src/calldata/domain/CalldataContextLoader.test.js +2 -0
- package/lib/cjs/src/calldata/domain/CalldataContextLoader.test.js.map +7 -0
- package/lib/cjs/src/config/model/ContextModuleConfig.js +1 -1
- package/lib/cjs/src/config/model/ContextModuleConfig.js.map +1 -1
- package/lib/cjs/src/di.js +1 -1
- package/lib/cjs/src/di.js.map +3 -3
- package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js +1 -1
- package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +3 -3
- package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +1 -1
- package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +3 -3
- package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js +1 -1
- package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js.map +3 -3
- package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
- package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +3 -3
- package/lib/cjs/src/index.js +1 -1
- package/lib/cjs/src/index.js.map +2 -2
- package/lib/cjs/src/nft/di/nftModuleFactory.js +1 -1
- package/lib/cjs/src/nft/di/nftModuleFactory.js.map +3 -3
- package/lib/cjs/src/nft/di/nftTypes.js +1 -1
- package/lib/cjs/src/nft/di/nftTypes.js.map +2 -2
- package/lib/cjs/src/nft/domain/NftContextFieldLoader.js +2 -0
- package/lib/cjs/src/nft/domain/NftContextFieldLoader.js.map +7 -0
- package/lib/cjs/src/nft/domain/NftContextFieldLoader.test.js +2 -0
- package/lib/cjs/src/nft/domain/NftContextFieldLoader.test.js.map +7 -0
- package/lib/cjs/src/nft/domain/NftContextLoader.js +1 -1
- package/lib/cjs/src/nft/domain/NftContextLoader.js.map +3 -3
- package/lib/cjs/src/nft/domain/NftContextLoader.test.js +1 -1
- package/lib/cjs/src/nft/domain/NftContextLoader.test.js.map +3 -3
- package/lib/cjs/src/pki/model/PkiCertificateInfo.js +1 -1
- package/lib/cjs/src/pki/model/PkiCertificateInfo.js.map +1 -1
- package/lib/cjs/src/proxy/data/HttpProxyDataSource.js +2 -0
- package/lib/cjs/src/proxy/data/HttpProxyDataSource.js.map +7 -0
- package/lib/cjs/src/proxy/data/HttpProxyDataSource.test.js +2 -0
- package/lib/cjs/src/proxy/data/HttpProxyDataSource.test.js.map +7 -0
- package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.js +2 -0
- package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.js.map +7 -0
- package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.test.js +2 -0
- package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.test.js.map +7 -0
- package/lib/cjs/src/proxy/data/ProxyDataSource.js +2 -0
- package/lib/cjs/src/proxy/data/ProxyDataSource.js.map +7 -0
- package/lib/cjs/src/{transaction → proxy}/data/dto/ProxyDelegateCallDto.js.map +1 -1
- package/lib/cjs/src/{transaction → proxy}/data/dto/ProxyImplementationAddressDto.js.map +1 -1
- package/lib/cjs/src/proxy/data/dto/SafeProxyImplementationAddressDto.js +2 -0
- package/lib/cjs/src/proxy/data/dto/SafeProxyImplementationAddressDto.js.map +7 -0
- package/lib/cjs/src/proxy/di/proxyModuleFactory.js +2 -0
- package/lib/cjs/src/proxy/di/proxyModuleFactory.js.map +7 -0
- package/lib/cjs/src/proxy/di/proxyModuleFactory.test.js +2 -0
- package/lib/cjs/src/proxy/di/proxyModuleFactory.test.js.map +7 -0
- package/lib/cjs/src/proxy/di/proxyTypes.js +2 -0
- package/lib/cjs/src/proxy/di/proxyTypes.js.map +7 -0
- package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.js +2 -0
- package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.js.map +7 -0
- package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.test.js +2 -0
- package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.test.js.map +7 -0
- package/lib/cjs/src/proxy/model/ProxyDelegateCall.js +2 -0
- package/lib/cjs/src/proxy/model/ProxyDelegateCall.js.map +7 -0
- package/lib/cjs/src/shared/domain/ContextFieldLoader.js +2 -0
- package/lib/cjs/src/shared/domain/ContextFieldLoader.js.map +7 -0
- package/lib/cjs/src/shared/domain/ContextLoader.js +1 -1
- package/lib/cjs/src/shared/domain/ContextLoader.js.map +1 -1
- package/lib/cjs/src/shared/model/ClearSignContext.js +1 -1
- package/lib/cjs/src/shared/model/ClearSignContext.js.map +3 -3
- package/lib/cjs/src/shared/model/TransactionSubset.js +1 -1
- package/lib/cjs/src/shared/model/TransactionSubset.js.map +1 -1
- package/lib/cjs/src/shared/model/TypedDataClearSignContext.js +1 -1
- package/lib/cjs/src/shared/model/TypedDataClearSignContext.js.map +3 -3
- package/lib/cjs/src/shared/model/TypedDataContext.js +1 -1
- package/lib/cjs/src/shared/model/TypedDataContext.js.map +1 -1
- package/lib/cjs/src/shared/utils/KeyUsageMapper.js +1 -1
- package/lib/cjs/src/shared/utils/KeyUsageMapper.js.map +2 -2
- package/lib/cjs/src/token/di/tokenModuleFactory.js +1 -1
- package/lib/cjs/src/token/di/tokenModuleFactory.js.map +3 -3
- package/lib/cjs/src/token/di/tokenTypes.js +1 -1
- package/lib/cjs/src/token/di/tokenTypes.js.map +2 -2
- package/lib/cjs/src/token/domain/TokenContextFieldLoader.js +2 -0
- package/lib/cjs/src/token/domain/TokenContextFieldLoader.js.map +7 -0
- package/lib/cjs/src/token/domain/TokenContextFieldLoader.test.js +2 -0
- package/lib/cjs/src/token/domain/TokenContextFieldLoader.test.js.map +7 -0
- package/lib/cjs/src/token/domain/TokenContextLoader.js +1 -1
- package/lib/cjs/src/token/domain/TokenContextLoader.js.map +3 -3
- package/lib/cjs/src/token/domain/TokenContextLoader.test.js +1 -1
- package/lib/cjs/src/token/domain/TokenContextLoader.test.js.map +3 -3
- package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
- package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
- package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
- package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +2 -2
- package/lib/cjs/src/trusted-name/data/TrustedNameDataSource.js +1 -1
- package/lib/cjs/src/trusted-name/data/TrustedNameDataSource.js.map +1 -1
- package/lib/cjs/src/trusted-name/data/TrustedNameDto.js +1 -1
- package/lib/cjs/src/trusted-name/data/TrustedNameDto.js.map +1 -1
- package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
- package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
- package/lib/cjs/src/trusted-name/di/trustedNameTypes.js +1 -1
- package/lib/cjs/src/trusted-name/di/trustedNameTypes.js.map +2 -2
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.js +2 -0
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.js.map +7 -0
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js +2 -0
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js.map +7 -0
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +3 -3
- package/lib/cjs/src/typed-data/data/FiltersDto.js +1 -1
- package/lib/cjs/src/typed-data/data/FiltersDto.js.map +1 -1
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js.map +3 -3
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
- package/lib/cjs/src/typed-data/data/TypedDataDataSource.js +1 -1
- package/lib/cjs/src/typed-data/data/TypedDataDataSource.js.map +1 -1
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js +1 -1
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +3 -3
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +3 -3
- package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js +1 -1
- package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js.map +3 -3
- package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
- package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js.map +3 -3
- package/lib/esm/package.json +2 -2
- package/lib/esm/src/ContextModuleBuilder.js +1 -1
- package/lib/esm/src/ContextModuleBuilder.js.map +3 -3
- package/lib/esm/src/ContextModuleBuilder.test.js +1 -1
- package/lib/esm/src/ContextModuleBuilder.test.js.map +3 -3
- package/lib/esm/src/DefaultContextModule.js +1 -1
- package/lib/esm/src/DefaultContextModule.js.map +3 -3
- package/lib/esm/src/DefaultContextModule.test.js +1 -1
- package/lib/esm/src/DefaultContextModule.test.js.map +3 -3
- package/lib/esm/src/calldata/data/CalldataDescriptorDataSource.js +1 -0
- package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.js +2 -0
- package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.js.map +7 -0
- package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.test.js +2 -0
- package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.test.js.map +7 -0
- package/lib/esm/src/calldata/di/calldataModuleFactory.js +2 -0
- package/lib/esm/src/calldata/di/calldataModuleFactory.js.map +7 -0
- package/lib/esm/src/calldata/di/calldataTypes.js +2 -0
- package/lib/esm/src/calldata/di/calldataTypes.js.map +7 -0
- package/lib/esm/src/calldata/domain/CalldataContextLoader.js +2 -0
- package/lib/esm/src/calldata/domain/CalldataContextLoader.js.map +7 -0
- package/lib/esm/src/calldata/domain/CalldataContextLoader.test.js +2 -0
- package/lib/esm/src/calldata/domain/CalldataContextLoader.test.js.map +7 -0
- package/lib/esm/src/di.js +1 -1
- package/lib/esm/src/di.js.map +3 -3
- package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js +1 -1
- package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +3 -3
- package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +1 -1
- package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +3 -3
- package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js +1 -1
- package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js.map +3 -3
- package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
- package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +3 -3
- package/lib/esm/src/index.js +1 -1
- package/lib/esm/src/index.js.map +2 -2
- package/lib/esm/src/nft/di/nftModuleFactory.js +1 -1
- package/lib/esm/src/nft/di/nftModuleFactory.js.map +3 -3
- package/lib/esm/src/nft/di/nftTypes.js +1 -1
- package/lib/esm/src/nft/di/nftTypes.js.map +2 -2
- package/lib/esm/src/nft/domain/NftContextFieldLoader.js +2 -0
- package/lib/esm/src/nft/domain/NftContextFieldLoader.js.map +7 -0
- package/lib/esm/src/nft/domain/NftContextFieldLoader.test.js +2 -0
- package/lib/esm/src/nft/domain/NftContextFieldLoader.test.js.map +7 -0
- package/lib/esm/src/nft/domain/NftContextLoader.js +1 -1
- package/lib/esm/src/nft/domain/NftContextLoader.js.map +3 -3
- package/lib/esm/src/nft/domain/NftContextLoader.test.js +1 -1
- package/lib/esm/src/nft/domain/NftContextLoader.test.js.map +3 -3
- package/lib/esm/src/proxy/data/HttpProxyDataSource.js +2 -0
- package/lib/esm/src/proxy/data/HttpProxyDataSource.js.map +7 -0
- package/lib/esm/src/proxy/data/HttpProxyDataSource.test.js +2 -0
- package/lib/esm/src/proxy/data/HttpProxyDataSource.test.js.map +7 -0
- package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.js +2 -0
- package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.js.map +7 -0
- package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.test.js +2 -0
- package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.test.js.map +7 -0
- package/lib/esm/src/proxy/data/ProxyDataSource.js +1 -0
- package/lib/esm/src/proxy/data/dto/SafeProxyImplementationAddressDto.js +1 -0
- package/lib/esm/src/proxy/di/proxyModuleFactory.js +2 -0
- package/lib/esm/src/proxy/di/proxyModuleFactory.js.map +7 -0
- package/lib/esm/src/proxy/di/proxyModuleFactory.test.js +2 -0
- package/lib/esm/src/proxy/di/proxyModuleFactory.test.js.map +7 -0
- package/lib/esm/src/proxy/di/proxyTypes.js +2 -0
- package/lib/esm/src/proxy/di/proxyTypes.js.map +7 -0
- package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.js +2 -0
- package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.js.map +7 -0
- package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.test.js +2 -0
- package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.test.js.map +7 -0
- package/lib/esm/src/shared/domain/ContextFieldLoader.js +1 -0
- package/lib/esm/src/shared/domain/ContextFieldLoader.js.map +7 -0
- package/lib/esm/src/shared/model/ClearSignContext.js +1 -1
- package/lib/esm/src/shared/model/ClearSignContext.js.map +3 -3
- package/lib/esm/src/shared/model/TypedDataClearSignContext.js +1 -1
- package/lib/esm/src/shared/model/TypedDataClearSignContext.js.map +3 -3
- package/lib/esm/src/shared/utils/KeyUsageMapper.js +1 -1
- package/lib/esm/src/shared/utils/KeyUsageMapper.js.map +2 -2
- package/lib/esm/src/token/di/tokenModuleFactory.js +1 -1
- package/lib/esm/src/token/di/tokenModuleFactory.js.map +3 -3
- package/lib/esm/src/token/di/tokenTypes.js +1 -1
- package/lib/esm/src/token/di/tokenTypes.js.map +2 -2
- package/lib/esm/src/token/domain/TokenContextFieldLoader.js +2 -0
- package/lib/esm/src/token/domain/TokenContextFieldLoader.js.map +7 -0
- package/lib/esm/src/token/domain/TokenContextFieldLoader.test.js +2 -0
- package/lib/esm/src/token/domain/TokenContextFieldLoader.test.js.map +7 -0
- package/lib/esm/src/token/domain/TokenContextLoader.js +1 -1
- package/lib/esm/src/token/domain/TokenContextLoader.js.map +3 -3
- package/lib/esm/src/token/domain/TokenContextLoader.test.js +1 -1
- package/lib/esm/src/token/domain/TokenContextLoader.test.js.map +3 -3
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +2 -2
- package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
- package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
- package/lib/esm/src/trusted-name/di/trustedNameTypes.js +1 -1
- package/lib/esm/src/trusted-name/di/trustedNameTypes.js.map +2 -2
- package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.js +2 -0
- package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.js.map +7 -0
- package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js +2 -0
- package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js.map +7 -0
- package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
- package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
- package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
- package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +3 -3
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js.map +3 -3
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js +1 -1
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +3 -3
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +3 -3
- package/lib/esm/src/uniswap/domain/UniswapContextLoader.js +1 -1
- package/lib/esm/src/uniswap/domain/UniswapContextLoader.js.map +3 -3
- package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
- package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js.map +3 -3
- package/lib/types/src/ContextModule.d.ts +3 -4
- package/lib/types/src/ContextModule.d.ts.map +1 -1
- package/lib/types/src/ContextModuleBuilder.d.ts +8 -1
- package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -1
- package/lib/types/src/DefaultContextModule.d.ts +4 -3
- package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
- package/lib/types/src/{transaction/data/TransactionDataSource.d.ts → calldata/data/CalldataDescriptorDataSource.d.ts} +4 -4
- package/lib/types/src/calldata/data/CalldataDescriptorDataSource.d.ts.map +1 -0
- package/lib/types/src/{transaction/data/HttpTransactionDataSource.d.ts → calldata/data/HttpCalldataDescriptorDataSource.d.ts} +6 -5
- package/lib/types/src/calldata/data/HttpCalldataDescriptorDataSource.d.ts.map +1 -0
- package/lib/types/src/calldata/data/HttpCalldataDescriptorDataSource.test.d.ts +2 -0
- package/lib/types/src/calldata/data/HttpCalldataDescriptorDataSource.test.d.ts.map +1 -0
- package/lib/types/src/{transaction → calldata}/data/dto/CalldataDto.d.ts +10 -1
- package/lib/types/src/calldata/data/dto/CalldataDto.d.ts.map +1 -0
- package/lib/types/src/calldata/di/calldataModuleFactory.d.ts +3 -0
- package/lib/types/src/calldata/di/calldataModuleFactory.d.ts.map +1 -0
- package/lib/types/src/calldata/di/calldataTypes.d.ts +6 -0
- package/lib/types/src/calldata/di/calldataTypes.d.ts.map +1 -0
- package/lib/types/src/calldata/domain/CalldataContextLoader.d.ts +23 -0
- package/lib/types/src/calldata/domain/CalldataContextLoader.d.ts.map +1 -0
- package/lib/types/src/calldata/domain/CalldataContextLoader.test.d.ts +2 -0
- package/lib/types/src/calldata/domain/CalldataContextLoader.test.d.ts.map +1 -0
- package/lib/types/src/config/model/ContextModuleConfig.d.ts +7 -0
- package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -1
- package/lib/types/src/di.d.ts.map +1 -1
- package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts +9 -5
- package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts.map +1 -1
- package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.d.ts +11 -4
- package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.d.ts.map +1 -1
- package/lib/types/src/index.d.ts +40 -1
- package/lib/types/src/index.d.ts.map +1 -1
- package/lib/types/src/nft/di/nftModuleFactory.d.ts.map +1 -1
- package/lib/types/src/nft/di/nftTypes.d.ts +1 -0
- package/lib/types/src/nft/di/nftTypes.d.ts.map +1 -1
- package/lib/types/src/nft/domain/NftContextFieldLoader.d.ts +15 -0
- package/lib/types/src/nft/domain/NftContextFieldLoader.d.ts.map +1 -0
- package/lib/types/src/nft/domain/NftContextFieldLoader.test.d.ts +2 -0
- package/lib/types/src/nft/domain/NftContextFieldLoader.test.d.ts.map +1 -0
- package/lib/types/src/nft/domain/NftContextLoader.d.ts +10 -5
- package/lib/types/src/nft/domain/NftContextLoader.d.ts.map +1 -1
- package/lib/types/src/pki/model/PkiCertificateInfo.d.ts +1 -2
- package/lib/types/src/pki/model/PkiCertificateInfo.d.ts.map +1 -1
- package/lib/types/src/proxy/data/HttpProxyDataSource.d.ts +13 -0
- package/lib/types/src/proxy/data/HttpProxyDataSource.d.ts.map +1 -0
- package/lib/types/src/proxy/data/HttpProxyDataSource.test.d.ts.map +1 -0
- package/lib/types/src/proxy/data/HttpSafeProxyDataSource.d.ts +13 -0
- package/lib/types/src/proxy/data/HttpSafeProxyDataSource.d.ts.map +1 -0
- package/lib/types/src/proxy/data/HttpSafeProxyDataSource.test.d.ts +2 -0
- package/lib/types/src/proxy/data/HttpSafeProxyDataSource.test.d.ts.map +1 -0
- package/lib/types/src/proxy/data/ProxyDataSource.d.ts +17 -0
- package/lib/types/src/proxy/data/ProxyDataSource.d.ts.map +1 -0
- package/lib/types/src/proxy/data/dto/ProxyDelegateCallDto.d.ts.map +1 -0
- package/lib/types/src/proxy/data/dto/ProxyImplementationAddressDto.d.ts.map +1 -0
- package/lib/types/src/proxy/data/dto/SafeProxyImplementationAddressDto.d.ts +10 -0
- package/lib/types/src/proxy/data/dto/SafeProxyImplementationAddressDto.d.ts.map +1 -0
- package/lib/types/src/proxy/di/proxyModuleFactory.d.ts +4 -0
- package/lib/types/src/proxy/di/proxyModuleFactory.d.ts.map +1 -0
- package/lib/types/src/proxy/di/proxyModuleFactory.test.d.ts +2 -0
- package/lib/types/src/proxy/di/proxyModuleFactory.test.d.ts.map +1 -0
- package/lib/types/src/proxy/di/proxyTypes.d.ts +5 -0
- package/lib/types/src/proxy/di/proxyTypes.d.ts.map +1 -0
- package/lib/types/src/proxy/domain/ProxyContextFieldLoader.d.ts +21 -0
- package/lib/types/src/proxy/domain/ProxyContextFieldLoader.d.ts.map +1 -0
- package/lib/types/src/proxy/domain/ProxyContextFieldLoader.test.d.ts +2 -0
- package/lib/types/src/proxy/domain/ProxyContextFieldLoader.test.d.ts.map +1 -0
- package/lib/types/src/proxy/model/ProxyDelegateCall.d.ts +7 -0
- package/lib/types/src/proxy/model/ProxyDelegateCall.d.ts.map +1 -0
- package/lib/types/src/shared/domain/ContextFieldLoader.d.ts +15 -0
- package/lib/types/src/shared/domain/ContextFieldLoader.d.ts.map +1 -0
- package/lib/types/src/shared/domain/ContextLoader.d.ts +13 -5
- package/lib/types/src/shared/domain/ContextLoader.d.ts.map +1 -1
- package/lib/types/src/shared/model/ClearSignContext.d.ts +27 -9
- package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
- package/lib/types/src/shared/model/TransactionSubset.d.ts +1 -0
- package/lib/types/src/shared/model/TransactionSubset.d.ts.map +1 -1
- package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts +33 -1
- package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts.map +1 -1
- package/lib/types/src/shared/model/TypedDataContext.d.ts +3 -0
- package/lib/types/src/shared/model/TypedDataContext.d.ts.map +1 -1
- package/lib/types/src/shared/utils/KeyUsageMapper.d.ts +1 -2
- package/lib/types/src/shared/utils/KeyUsageMapper.d.ts.map +1 -1
- package/lib/types/src/token/di/tokenModuleFactory.d.ts.map +1 -1
- package/lib/types/src/token/di/tokenTypes.d.ts +1 -0
- package/lib/types/src/token/di/tokenTypes.d.ts.map +1 -1
- package/lib/types/src/token/domain/TokenContextFieldLoader.d.ts +14 -0
- package/lib/types/src/token/domain/TokenContextFieldLoader.d.ts.map +1 -0
- package/lib/types/src/token/domain/TokenContextFieldLoader.test.d.ts +2 -0
- package/lib/types/src/token/domain/TokenContextFieldLoader.test.d.ts.map +1 -0
- package/lib/types/src/token/domain/TokenContextLoader.d.ts +10 -5
- package/lib/types/src/token/domain/TokenContextLoader.d.ts.map +1 -1
- package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts +7 -3
- package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts.map +1 -1
- package/lib/types/src/trusted-name/data/TrustedNameDataSource.d.ts +7 -2
- package/lib/types/src/trusted-name/data/TrustedNameDataSource.d.ts.map +1 -1
- package/lib/types/src/trusted-name/data/TrustedNameDto.d.ts +4 -5
- package/lib/types/src/trusted-name/data/TrustedNameDto.d.ts.map +1 -1
- package/lib/types/src/trusted-name/di/trustedNameModuleFactory.d.ts.map +1 -1
- package/lib/types/src/trusted-name/di/trustedNameTypes.d.ts +1 -0
- package/lib/types/src/trusted-name/di/trustedNameTypes.d.ts.map +1 -1
- package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.d.ts +22 -0
- package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.d.ts.map +1 -0
- package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.test.d.ts +2 -0
- package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.test.d.ts.map +1 -0
- package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts +14 -6
- package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts.map +1 -1
- package/lib/types/src/typed-data/data/FiltersDto.d.ts +32 -2
- package/lib/types/src/typed-data/data/FiltersDto.d.ts.map +1 -1
- package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts +3 -0
- package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts.map +1 -1
- package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts +1 -0
- package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts.map +1 -1
- package/lib/types/src/typed-data/data/TypedDataDataSource.d.ts +2 -1
- package/lib/types/src/typed-data/data/TypedDataDataSource.d.ts.map +1 -1
- package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts +12 -1
- package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts.map +1 -1
- package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts +11 -4
- package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/lib/cjs/src/shared/model/TransactionContext.js +0 -2
- package/lib/cjs/src/shared/model/TransactionContext.js.map +0 -7
- package/lib/cjs/src/transaction/data/HttpProxyDataSource.js +0 -2
- package/lib/cjs/src/transaction/data/HttpProxyDataSource.js.map +0 -7
- package/lib/cjs/src/transaction/data/HttpProxyDataSource.test.js +0 -2
- package/lib/cjs/src/transaction/data/HttpProxyDataSource.test.js.map +0 -7
- package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js +0 -2
- package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js.map +0 -7
- package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js +0 -2
- package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js.map +0 -7
- package/lib/cjs/src/transaction/data/TransactionDataSource.js +0 -2
- package/lib/cjs/src/transaction/data/TransactionDataSource.js.map +0 -7
- package/lib/cjs/src/transaction/data/dto/CalldataDto.js +0 -2
- package/lib/cjs/src/transaction/data/dto/CalldataDto.js.map +0 -7
- package/lib/cjs/src/transaction/di/transactionModuleFactory.js +0 -2
- package/lib/cjs/src/transaction/di/transactionModuleFactory.js.map +0 -7
- package/lib/cjs/src/transaction/di/transactionTypes.js +0 -2
- package/lib/cjs/src/transaction/di/transactionTypes.js.map +0 -7
- package/lib/cjs/src/transaction/domain/TransactionContextLoader.js +0 -2
- package/lib/cjs/src/transaction/domain/TransactionContextLoader.js.map +0 -7
- package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js +0 -2
- package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js.map +0 -7
- package/lib/cjs/src/transaction/model/ProxyDelegateCall.js +0 -2
- package/lib/cjs/src/transaction/model/ProxyDelegateCall.js.map +0 -7
- package/lib/cjs/src/transaction/model/ProxyImplementationAddress.js +0 -2
- package/lib/cjs/src/transaction/model/ProxyImplementationAddress.js.map +0 -7
- package/lib/esm/src/shared/model/TransactionContext.js +0 -1
- package/lib/esm/src/transaction/data/HttpProxyDataSource.js +0 -2
- package/lib/esm/src/transaction/data/HttpProxyDataSource.js.map +0 -7
- package/lib/esm/src/transaction/data/HttpProxyDataSource.test.js +0 -2
- package/lib/esm/src/transaction/data/HttpProxyDataSource.test.js.map +0 -7
- package/lib/esm/src/transaction/data/HttpTransactionDataSource.js +0 -2
- package/lib/esm/src/transaction/data/HttpTransactionDataSource.js.map +0 -7
- package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js +0 -2
- package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js.map +0 -7
- package/lib/esm/src/transaction/data/TransactionDataSource.js +0 -1
- package/lib/esm/src/transaction/di/transactionModuleFactory.js +0 -2
- package/lib/esm/src/transaction/di/transactionModuleFactory.js.map +0 -7
- package/lib/esm/src/transaction/di/transactionTypes.js +0 -2
- package/lib/esm/src/transaction/di/transactionTypes.js.map +0 -7
- package/lib/esm/src/transaction/domain/TransactionContextLoader.js +0 -2
- package/lib/esm/src/transaction/domain/TransactionContextLoader.js.map +0 -7
- package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js +0 -2
- package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js.map +0 -7
- package/lib/esm/src/transaction/model/ProxyImplementationAddress.js +0 -1
- package/lib/types/src/shared/model/TransactionContext.d.ts +0 -21
- package/lib/types/src/shared/model/TransactionContext.d.ts.map +0 -1
- package/lib/types/src/transaction/data/HttpProxyDataSource.d.ts +0 -33
- package/lib/types/src/transaction/data/HttpProxyDataSource.d.ts.map +0 -1
- package/lib/types/src/transaction/data/HttpProxyDataSource.test.d.ts.map +0 -1
- package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts.map +0 -1
- package/lib/types/src/transaction/data/HttpTransactionDataSource.test.d.ts +0 -2
- package/lib/types/src/transaction/data/HttpTransactionDataSource.test.d.ts.map +0 -1
- package/lib/types/src/transaction/data/TransactionDataSource.d.ts.map +0 -1
- package/lib/types/src/transaction/data/dto/CalldataDto.d.ts.map +0 -1
- package/lib/types/src/transaction/data/dto/ProxyDelegateCallDto.d.ts.map +0 -1
- package/lib/types/src/transaction/data/dto/ProxyImplementationAddressDto.d.ts.map +0 -1
- package/lib/types/src/transaction/di/transactionModuleFactory.d.ts +0 -3
- package/lib/types/src/transaction/di/transactionModuleFactory.d.ts.map +0 -1
- package/lib/types/src/transaction/di/transactionTypes.d.ts +0 -6
- package/lib/types/src/transaction/di/transactionTypes.d.ts.map +0 -1
- package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts +0 -12
- package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts.map +0 -1
- package/lib/types/src/transaction/domain/TransactionContextLoader.test.d.ts +0 -2
- package/lib/types/src/transaction/domain/TransactionContextLoader.test.d.ts.map +0 -1
- package/lib/types/src/transaction/model/ProxyDelegateCall.d.ts +0 -5
- package/lib/types/src/transaction/model/ProxyDelegateCall.d.ts.map +0 -1
- package/lib/types/src/transaction/model/ProxyImplementationAddress.d.ts +0 -4
- package/lib/types/src/transaction/model/ProxyImplementationAddress.d.ts.map +0 -1
- /package/lib/cjs/src/{transaction → proxy}/data/dto/ProxyDelegateCallDto.js +0 -0
- /package/lib/cjs/src/{transaction → proxy}/data/dto/ProxyImplementationAddressDto.js +0 -0
- /package/lib/esm/src/{shared/model/TransactionContext.js.map → calldata/data/CalldataDescriptorDataSource.js.map} +0 -0
- /package/lib/esm/src/{transaction → calldata}/data/dto/CalldataDto.js +0 -0
- /package/lib/esm/src/{transaction → calldata}/data/dto/CalldataDto.js.map +0 -0
- /package/lib/esm/src/{transaction/data/TransactionDataSource.js.map → proxy/data/ProxyDataSource.js.map} +0 -0
- /package/lib/esm/src/{transaction → proxy}/data/dto/ProxyDelegateCallDto.js +0 -0
- /package/lib/esm/src/{transaction → proxy}/data/dto/ProxyDelegateCallDto.js.map +0 -0
- /package/lib/esm/src/{transaction → proxy}/data/dto/ProxyImplementationAddressDto.js +0 -0
- /package/lib/esm/src/{transaction → proxy}/data/dto/ProxyImplementationAddressDto.js.map +0 -0
- /package/lib/esm/src/{transaction/model/ProxyDelegateCall.js.map → proxy/data/dto/SafeProxyImplementationAddressDto.js.map} +0 -0
- /package/lib/esm/src/{transaction → proxy}/model/ProxyDelegateCall.js +0 -0
- /package/lib/esm/src/{transaction/model/ProxyImplementationAddress.js.map → proxy/model/ProxyDelegateCall.js.map} +0 -0
- /package/lib/types/src/{transaction → proxy}/data/HttpProxyDataSource.test.d.ts +0 -0
- /package/lib/types/src/{transaction → proxy}/data/dto/ProxyDelegateCallDto.d.ts +0 -0
- /package/lib/types/src/{transaction → proxy}/data/dto/ProxyImplementationAddressDto.d.ts +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/external-plugin/domain/ExternalPluginContextLoader.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { Interface } from \"ethers\";\nimport { Left, Right } from \"purify-ts\";\n\nimport ABI from \"@/external-plugin/__tests__/abi.json\";\nimport { type ExternalPluginDataSource } from \"@/external-plugin/data/ExternalPluginDataSource\";\nimport { ExternalPluginContextLoader } from \"@/external-plugin/domain/ExternalPluginContextLoader\";\nimport { type DappInfos } from \"@/external-plugin/model/DappInfos\";\nimport { type SelectorDetails } from \"@/external-plugin/model/SelectorDetails\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TransactionContext } from \"@/shared/model/TransactionContext\";\nimport { type TokenDataSource } from \"@/token/data/TokenDataSource\";\n\nconst dappInfosBuilder = ({\n abi,\n selectorDetails,\n}: {\n abi?: object[];\n selectorDetails?: Partial<SelectorDetails>;\n}) => {\n return {\n abi: abi,\n selectorDetails: {\n erc20OfInterest: [],\n method: \"\",\n plugin: \"\",\n serializedData: \"123456\",\n signature: \"7890\",\n ...selectorDetails,\n },\n } as DappInfos;\n};\n\nconst transactionBuilder = (\n abi: object,\n functionName: string,\n params: unknown[],\n): TransactionContext => {\n const contract = new Interface(JSON.stringify(abi));\n const data = contract.encodeFunctionData(functionName, params);\n return {\n to: \"0x0\",\n data,\n selector: data.slice(0, 10),\n } as TransactionContext;\n};\n\ndescribe(\"ExternalPluginContextLoader\", () => {\n const mockTokenDataSource: TokenDataSource = {\n getTokenInfosPayload: vi.fn(),\n };\n const mockExternalPluginDataSource: ExternalPluginDataSource = {\n getDappInfos: vi.fn(),\n };\n const loader = new ExternalPluginContextLoader(\n mockExternalPluginDataSource,\n mockTokenDataSource,\n );\n\n beforeEach(() => {\n vi.clearAllMocks();\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockImplementation(\n ({ address }) => Promise.resolve(Right(`payload-${address}`)),\n );\n });\n\n describe(\"load function\", () => {\n it(\"should return an empty array if no destination address is provided\", async () => {\n // GIVEN\n const transaction = {} as TransactionContext;\n\n // WHEN\n const promise = () => loader.load(transaction);\n\n // THEN\n await expect(promise()).resolves.toEqual([]);\n });\n\n it(\"should return an empty array if no data provided\", async () => {\n // GIVEN\n const transaction = {\n to: \"0x0\",\n data: \"0x\",\n selector: \"0x0\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if no dapp info is povided\", async () => {\n // GIVEN\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(undefined),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return e plugin if no erc20OfInterest is provided\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is provided for a single parameter\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual(\n expect.arrayContaining([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n ]),\n );\n });\n\n it(\"should return a context response with only set external plugin when one erc20OfInterest is provided for a single parameter but no payload is feched\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return a list of context responses when two erc20OfInterest are provided for two parameters\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\", \"toToken\"],\n method: \"multipleParams\",\n },\n });\n const transaction = transactionBuilder(ABI, \"multipleParams\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual(\n expect.arrayContaining([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n ]),\n );\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is an array\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\n \"fromToken.0\",\n \"fromToken.1\",\n \"fromToken.2\",\n \"fromToken.-1\",\n ],\n method: \"arrayParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"arrayParam\", [\n [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n ],\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n // fromToken.2\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n // fromToken.-1\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return an error when a token datasource returns an error\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return an error when the abi is not conform\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: [{ fakeabi: \"notworking\" }],\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to parse abi\",\n ),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should throw an error when the erc20OfInterest doest not exist in the transaction\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"notFound\"],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to get address\",\n ),\n },\n ]);\n });\n\n it(\"should throw an error when an out-of-bounds element is present in erc20OfInterest\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken.3\"],\n method: \"arrayParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"arrayParam\", [\n [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n ],\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new RangeError(\"out of result range\"),\n },\n ]);\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is a complex struct\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\n \"complexStruct.address1\",\n \"complexStruct.param1.param2.0.param3.addresses.0\",\n \"complexStruct.param1.param2.0.param3.addresses.1\",\n \"complexStruct.param1.param2.0.param3.addresses.-1\",\n \"complexStruct.param1.param2.1.param3.addresses.0\",\n \"complexStruct.param1.param2.-1.param3.addresses.0\",\n ],\n method: \"complexStructParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"complexStructParam\", [\n {\n address1: \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n param1: {\n param2: [\n {\n param3: {\n addresses: [\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n ],\n },\n },\n {\n param3: {\n addresses: [\"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\"],\n },\n },\n ],\n },\n },\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return an error when datasource return a Left\", async () => {\n // GIVEN\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n ]);\n });\n\n it(\"should return an error when transaction data is not a valid hex string\", async () => {\n // GIVEN\n const transaction = {\n to: \"0x0\",\n data: \"notAHexString\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ]);\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,aAAAA,MAAiB,SAC1B,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAE5B,OAAOC,MAAS,uCAEhB,
|
|
6
|
-
"names": ["Interface", "Left", "Right", "ABI", "ExternalPluginContextLoader", "ClearSignContextType", "dappInfosBuilder", "abi", "selectorDetails", "
|
|
4
|
+
"sourcesContent": ["import { Interface } from \"ethers\";\nimport { Left, Right } from \"purify-ts\";\n\nimport ABI from \"@/external-plugin/__tests__/abi.json\";\nimport { type ExternalPluginDataSource } from \"@/external-plugin/data/ExternalPluginDataSource\";\nimport {\n type ExternalPluginContextInput,\n ExternalPluginContextLoader,\n} from \"@/external-plugin/domain/ExternalPluginContextLoader\";\nimport { type DappInfos } from \"@/external-plugin/model/DappInfos\";\nimport { type SelectorDetails } from \"@/external-plugin/model/SelectorDetails\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TokenDataSource } from \"@/token/data/TokenDataSource\";\n\nconst dappInfosBuilder = ({\n abi,\n selectorDetails,\n}: {\n abi?: object[];\n selectorDetails?: Partial<SelectorDetails>;\n}) => {\n return {\n abi: abi,\n selectorDetails: {\n erc20OfInterest: [],\n method: \"\",\n plugin: \"\",\n serializedData: \"123456\",\n signature: \"7890\",\n ...selectorDetails,\n },\n } as DappInfos;\n};\n\nconst inputBuilder = (\n abi: object,\n functionName: string,\n params: unknown[],\n): ExternalPluginContextInput => {\n const contract = new Interface(JSON.stringify(abi));\n const data = contract.encodeFunctionData(functionName, params);\n return {\n to: \"0x0\",\n data: data as `0x${string}`,\n selector: data.slice(0, 10) as `0x${string}`,\n chainId: 1,\n };\n};\n\ndescribe(\"ExternalPluginContextLoader\", () => {\n const mockTokenDataSource: TokenDataSource = {\n getTokenInfosPayload: vi.fn(),\n };\n const mockExternalPluginDataSource: ExternalPluginDataSource = {\n getDappInfos: vi.fn(),\n };\n const loader = new ExternalPluginContextLoader(\n mockExternalPluginDataSource,\n mockTokenDataSource,\n );\n\n beforeEach(() => {\n vi.clearAllMocks();\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockImplementation(\n ({ address }) => Promise.resolve(Right(`payload-${address}`)),\n );\n });\n\n describe(\"canHandle function\", () => {\n const validInput: ExternalPluginContextInput = {\n to: \"0x1234567890123456789012345678901234567890\",\n data: \"0x095ea7b30000000000000000000000001234567890123456789012345678901234567890\",\n selector: \"0x095ea7b3\",\n chainId: 1,\n };\n\n it(\"should return true for valid input\", () => {\n expect(\n loader.canHandle(validInput, [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\n ]),\n ).toBe(true);\n });\n\n it(\"should return false for invalid expected type\", () => {\n expect(loader.canHandle(validInput, [ClearSignContextType.NFT])).toBe(\n false,\n );\n expect(loader.canHandle(validInput, [ClearSignContextType.TOKEN])).toBe(\n false,\n );\n expect(\n loader.canHandle(validInput, [ClearSignContextType.EXTERNAL_PLUGIN]),\n ).toBe(false);\n });\n\n it.each([\n [null, \"null input\"],\n [undefined, \"undefined input\"],\n [{}, \"empty object\"],\n [\"string\", \"string input\"],\n [123, \"number input\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\n ]),\n ).toBe(false);\n });\n\n it.each([\n [{ ...validInput, to: undefined }, \"missing to\"],\n [{ ...validInput, data: undefined }, \"missing data\"],\n [{ ...validInput, selector: undefined }, \"missing selector\"],\n [{ ...validInput, chainId: undefined }, \"missing chainId\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\n ]),\n ).toBe(false);\n });\n\n it.each([\n [{ ...validInput, to: \"invalid-hex\" }, \"invalid to hex\"],\n [{ ...validInput, to: \"0x\" }, \"empty to hex\"],\n [{ ...validInput, data: \"invalid-hex\" }, \"invalid data hex\"],\n [{ ...validInput, data: \"0x\" }, \"empty data (0x)\"],\n [{ ...validInput, selector: \"invalid-hex\" }, \"invalid selector hex\"],\n [{ ...validInput, selector: \"0x\" }, \"empty selector hex\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\n ]),\n ).toBe(false);\n });\n\n it.each([\n [{ ...validInput, chainId: \"1\" }, \"string chainId\"],\n [{ ...validInput, chainId: null }, \"null chainId\"],\n [{ ...validInput, chainId: undefined }, \"undefined chainId\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\n ]),\n ).toBe(false);\n });\n });\n\n describe(\"load function\", () => {\n it(\"should return an empty array if no dapp info is provided\", async () => {\n // GIVEN\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(undefined),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return e plugin if no erc20OfInterest is provided\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [],\n method: \"singleParam\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is provided for a single parameter\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual(\n expect.arrayContaining([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n ]),\n );\n });\n\n it(\"should return a context response with only set external plugin when one erc20OfInterest is provided for a single parameter but no payload is feched\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return a list of context responses when two erc20OfInterest are provided for two parameters\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\", \"toToken\"],\n method: \"multipleParams\",\n },\n });\n const input = inputBuilder(ABI, \"multipleParams\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual(\n expect.arrayContaining([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n ]),\n );\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is an array\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\n \"fromToken.0\",\n \"fromToken.1\",\n \"fromToken.2\",\n \"fromToken.-1\",\n ],\n method: \"arrayParam\",\n },\n });\n const input = inputBuilder(ABI, \"arrayParam\", [\n [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n ],\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n // fromToken.2\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n // fromToken.-1\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return an error when a token datasource returns an error\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return an error when the abi is not conform\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: [{ fakeabi: \"notworking\" }],\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to parse abi\",\n ),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should throw an error when the erc20OfInterest doest not exist in the transaction\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"notFound\"],\n method: \"singleParam\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to get address\",\n ),\n },\n ]);\n });\n\n it(\"should throw an error when an out-of-bounds element is present in erc20OfInterest\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken.3\"],\n method: \"arrayParam\",\n },\n });\n const input = inputBuilder(ABI, \"arrayParam\", [\n [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n ],\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new RangeError(\"out of result range\"),\n },\n ]);\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is a complex struct\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\n \"complexStruct.address1\",\n \"complexStruct.param1.param2.0.param3.addresses.0\",\n \"complexStruct.param1.param2.0.param3.addresses.1\",\n \"complexStruct.param1.param2.0.param3.addresses.-1\",\n \"complexStruct.param1.param2.1.param3.addresses.0\",\n \"complexStruct.param1.param2.-1.param3.addresses.0\",\n ],\n method: \"complexStructParam\",\n },\n });\n const input = inputBuilder(ABI, \"complexStructParam\", [\n {\n address1: \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n param1: {\n param2: [\n {\n param3: {\n addresses: [\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n ],\n },\n },\n {\n param3: {\n addresses: [\"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\"],\n },\n },\n ],\n },\n },\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return an error when datasource return a Left\", async () => {\n // GIVEN\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n ]);\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,aAAAA,MAAiB,SAC1B,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAE5B,OAAOC,MAAS,uCAEhB,OAEE,+BAAAC,MACK,uDAGP,OAAS,wBAAAC,MAA4B,kCAGrC,MAAMC,EAAmB,CAAC,CACxB,IAAAC,EACA,gBAAAC,CACF,KAIS,CACL,IAAKD,EACL,gBAAiB,CACf,gBAAiB,CAAC,EAClB,OAAQ,GACR,OAAQ,GACR,eAAgB,SAChB,UAAW,OACX,GAAGC,CACL,CACF,GAGIC,EAAe,CACnBF,EACAG,EACAC,IAC+B,CAE/B,MAAMC,EADW,IAAIZ,EAAU,KAAK,UAAUO,CAAG,CAAC,EAC5B,mBAAmBG,EAAcC,CAAM,EAC7D,MAAO,CACL,GAAI,MACJ,KAAMC,EACN,SAAUA,EAAK,MAAM,EAAG,EAAE,EAC1B,QAAS,CACX,CACF,EAEA,SAAS,8BAA+B,IAAM,CAC5C,MAAMC,EAAuC,CAC3C,qBAAsB,GAAG,GAAG,CAC9B,EACMC,EAAyD,CAC7D,aAAc,GAAG,GAAG,CACtB,EACMC,EAAS,IAAIX,EACjBU,EACAD,CACF,EAEA,WAAW,IAAM,CACf,GAAG,cAAc,EACjB,GAAG,MAAMA,EAAqB,sBAAsB,EAAE,mBACpD,CAAC,CAAE,QAAAG,CAAQ,IAAM,QAAQ,QAAQd,EAAM,WAAWc,CAAO,EAAE,CAAC,CAC9D,CACF,CAAC,EAED,SAAS,qBAAsB,IAAM,CACnC,MAAMC,EAAyC,CAC7C,GAAI,6CACJ,KAAM,6EACN,SAAU,aACV,QAAS,CACX,EAEA,GAAG,qCAAsC,IAAM,CAC7C,OACEF,EAAO,UAAUE,EAAY,CAC3BZ,EAAqB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AAS,oDACX,EACA,CACE,KAAMA,EAAqB,gBAC3B,QAAS,YACX,CACF,CAAC,CACH,CAAC,EAED,GAAG,uDAAwD,SAAY,CAErE,MAAMa,EAAQT,EAAaN,EAAK,cAAe,CAC7C,4CACF,CAAC,EACD,GAAG,MAAMW,EAA8B,cAAc,EAAE,kBACrDb,EAAK,IAAI,MAAM,OAAO,CAAC,CACzB,EAGA,MAAMmB,EAAS,MAAML,EAAO,KAAKG,CAAK,EAGtC,OAAOE,CAAM,EAAE,QAAQ,CACrB,CACE,KAAMf,EAAqB,MAC3B,MAAO,IAAI,MAAM,OAAO,CAC1B,CACF,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["Interface", "Left", "Right", "ABI", "ExternalPluginContextLoader", "ClearSignContextType", "dappInfosBuilder", "abi", "selectorDetails", "inputBuilder", "functionName", "params", "data", "mockTokenDataSource", "mockExternalPluginDataSource", "loader", "address", "validInput", "input", "_description", "result", "dappInfos"]
|
|
7
7
|
}
|
package/lib/esm/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export*from"./config/model/ContextModuleConfig";export*from"./ContextModule";export*from"./ContextModuleBuilder";export*from"./DefaultContextModule";export*from"./dynamic-network/domain/DynamicNetworkContextLoader";export*from"./dynamic-network/model/DynamicNetworkConfiguration";export*from"./external-plugin/domain/ExternalPluginContextLoader";export*from"./nft/domain/NftContextLoader";export*from"./pki/domain/PkiCertificateLoader";export*from"./pki/model/KeyId";export*from"./pki/model/KeyUsage";export*from"./pki/model/PkiCertificate";export*from"./pki/model/PkiCertificateInfo";export*from"./shared/domain/
|
|
1
|
+
export*from"./calldata/data/CalldataDescriptorDataSource";export*from"./calldata/data/HttpCalldataDescriptorDataSource";export*from"./calldata/domain/CalldataContextLoader";export*from"./config/model/ContextModuleConfig";export*from"./ContextModule";export*from"./ContextModuleBuilder";export*from"./DefaultContextModule";export*from"./dynamic-network/data/DynamicNetworkDataSource";export*from"./dynamic-network/data/HttpDynamicNetworkDataSource";export*from"./dynamic-network/domain/DynamicNetworkContextLoader";export*from"./dynamic-network/model/DynamicNetworkConfiguration";export*from"./external-plugin/data/ExternalPluginDataSource";export*from"./external-plugin/data/HttpExternalPluginDataSource";export*from"./external-plugin/domain/ExternalPluginContextLoader";export*from"./nft/data/HttpNftDataSource";export*from"./nft/data/NftDataSource";export*from"./nft/domain/NftContextFieldLoader";export*from"./nft/domain/NftContextLoader";export*from"./pki/data/HttpPkiCertificateDataSource";export*from"./pki/data/PkiCertificateDataSource";export*from"./pki/domain/DefaultPkiCertificateLoader";export*from"./pki/domain/PkiCertificateLoader";export*from"./pki/model/KeyId";export*from"./pki/model/KeyUsage";export*from"./pki/model/PkiCertificate";export*from"./pki/model/PkiCertificateInfo";export*from"./proxy/data/HttpProxyDataSource";export*from"./proxy/data/HttpSafeProxyDataSource";export*from"./proxy/data/ProxyDataSource";export*from"./proxy/domain/ProxyContextFieldLoader";export*from"./shared/domain/ContextFieldLoader";export*from"./shared/domain/ContextLoader";export*from"./shared/model/ClearSignContext";export*from"./shared/model/GenericPath";export*from"./shared/model/TransactionSubset";export*from"./shared/model/TypedDataClearSignContext";export*from"./shared/model/TypedDataContext";export*from"./solana/data/HttpSolanaOwnerInfoDataSource";export*from"./solana/data/SolanaDataSource";export*from"./solana/domain/DefaultSolanaContextLoader";export*from"./solana/domain/SolanaContextLoader";export*from"./token/data/HttpTokenDataSource";export*from"./token/data/TokenDataSource";export*from"./token/domain/TokenContextFieldLoader";export*from"./token/domain/TokenContextLoader";export*from"./trusted-name/data/HttpTrustedNameDataSource";export*from"./trusted-name/data/TrustedNameDataSource";export*from"./trusted-name/domain/TrustedNameContextFieldLoader";export*from"./trusted-name/domain/TrustedNameContextLoader";export*from"./typed-data/data/HttpTypedDataDataSource";export*from"./typed-data/data/TypedDataDataSource";export*from"./typed-data/domain/DefaultTypedDataContextLoader";export*from"./typed-data/domain/TypedDataContextLoader";export*from"./uniswap/data/AbiDecoderDataSource";export*from"./uniswap/data/CommandDecoderDataSource";export*from"./uniswap/data/DefaultCommandDecoderDataSource";export*from"./uniswap/data/EthersAbiDecoderDataSource";export*from"./uniswap/domain/UniswapContextLoader";export*from"./web3-check/data/HttpWeb3CheckDataSource";export*from"./web3-check/data/Web3CheckDataSource";export*from"./web3-check/domain/DefaultWeb3CheckLoader";export*from"./web3-check/domain/Web3CheckContextLoader";export*from"./web3-check/domain/web3CheckTypes";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/src/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from \"./config/model/ContextModuleConfig\";\nexport * from \"./ContextModule\";\nexport * from \"./ContextModuleBuilder\";\nexport * from \"./DefaultContextModule\";\nexport * from \"./dynamic-network/domain/DynamicNetworkContextLoader\";\nexport * from \"./dynamic-network/model/DynamicNetworkConfiguration\";\nexport * from \"./external-plugin/domain/ExternalPluginContextLoader\";\nexport * from \"./nft/domain/NftContextLoader\";\nexport * from \"./pki/domain/PkiCertificateLoader\";\nexport * from \"./pki/model/KeyId\";\nexport * from \"./pki/model/KeyUsage\";\nexport * from \"./pki/model/PkiCertificate\";\nexport * from \"./pki/model/PkiCertificateInfo\";\nexport * from \"./shared/domain/
|
|
5
|
-
"mappings": "AAAA,WAAc,qCACd,WAAc,kBACd,WAAc,yBACd,WAAc,yBACd,WAAc,uDACd,WAAc,sDACd,WAAc,uDACd,WAAc,gCACd,WAAc,oCACd,WAAc,oBACd,WAAc,uBACd,WAAc,6BACd,WAAc,iCACd,WAAc,gCACd,WAAc,kCACd,WAAc,6BACd,WAAc,
|
|
4
|
+
"sourcesContent": ["export * from \"./calldata/data/CalldataDescriptorDataSource\";\nexport * from \"./calldata/data/HttpCalldataDescriptorDataSource\";\nexport * from \"./calldata/domain/CalldataContextLoader\";\nexport * from \"./config/model/ContextModuleConfig\";\nexport * from \"./ContextModule\";\nexport * from \"./ContextModuleBuilder\";\nexport * from \"./DefaultContextModule\";\nexport * from \"./dynamic-network/data/DynamicNetworkDataSource\";\nexport * from \"./dynamic-network/data/HttpDynamicNetworkDataSource\";\nexport * from \"./dynamic-network/domain/DynamicNetworkContextLoader\";\nexport * from \"./dynamic-network/model/DynamicNetworkConfiguration\";\nexport * from \"./external-plugin/data/ExternalPluginDataSource\";\nexport * from \"./external-plugin/data/HttpExternalPluginDataSource\";\nexport * from \"./external-plugin/domain/ExternalPluginContextLoader\";\nexport * from \"./nft/data/HttpNftDataSource\";\nexport * from \"./nft/data/NftDataSource\";\nexport * from \"./nft/domain/NftContextFieldLoader\";\nexport * from \"./nft/domain/NftContextLoader\";\nexport * from \"./pki/data/HttpPkiCertificateDataSource\";\nexport * from \"./pki/data/PkiCertificateDataSource\";\nexport * from \"./pki/domain/DefaultPkiCertificateLoader\";\nexport * from \"./pki/domain/PkiCertificateLoader\";\nexport * from \"./pki/model/KeyId\";\nexport * from \"./pki/model/KeyUsage\";\nexport * from \"./pki/model/PkiCertificate\";\nexport * from \"./pki/model/PkiCertificateInfo\";\nexport * from \"./proxy/data/HttpProxyDataSource\";\nexport * from \"./proxy/data/HttpSafeProxyDataSource\";\nexport * from \"./proxy/data/ProxyDataSource\";\nexport * from \"./proxy/domain/ProxyContextFieldLoader\";\nexport * from \"./shared/domain/ContextFieldLoader\";\nexport * from \"./shared/domain/ContextLoader\";\nexport * from \"./shared/model/ClearSignContext\";\nexport * from \"./shared/model/GenericPath\";\nexport * from \"./shared/model/TransactionSubset\";\nexport * from \"./shared/model/TypedDataClearSignContext\";\nexport * from \"./shared/model/TypedDataContext\";\nexport * from \"./solana/data/HttpSolanaOwnerInfoDataSource\";\nexport * from \"./solana/data/SolanaDataSource\";\nexport * from \"./solana/domain/DefaultSolanaContextLoader\";\nexport * from \"./solana/domain/SolanaContextLoader\";\nexport * from \"./token/data/HttpTokenDataSource\";\nexport * from \"./token/data/TokenDataSource\";\nexport * from \"./token/domain/TokenContextFieldLoader\";\nexport * from \"./token/domain/TokenContextLoader\";\nexport * from \"./trusted-name/data/HttpTrustedNameDataSource\";\nexport * from \"./trusted-name/data/TrustedNameDataSource\";\nexport * from \"./trusted-name/domain/TrustedNameContextFieldLoader\";\nexport * from \"./trusted-name/domain/TrustedNameContextLoader\";\nexport * from \"./typed-data/data/HttpTypedDataDataSource\";\nexport * from \"./typed-data/data/TypedDataDataSource\";\nexport * from \"./typed-data/domain/DefaultTypedDataContextLoader\";\nexport * from \"./typed-data/domain/TypedDataContextLoader\";\nexport * from \"./uniswap/data/AbiDecoderDataSource\";\nexport * from \"./uniswap/data/CommandDecoderDataSource\";\nexport * from \"./uniswap/data/DefaultCommandDecoderDataSource\";\nexport * from \"./uniswap/data/EthersAbiDecoderDataSource\";\nexport * from \"./uniswap/domain/UniswapContextLoader\";\nexport * from \"./web3-check/data/HttpWeb3CheckDataSource\";\nexport * from \"./web3-check/data/Web3CheckDataSource\";\nexport * from \"./web3-check/domain/DefaultWeb3CheckLoader\";\nexport * from \"./web3-check/domain/Web3CheckContextLoader\";\nexport * from \"./web3-check/domain/web3CheckTypes\";\n"],
|
|
5
|
+
"mappings": "AAAA,WAAc,+CACd,WAAc,mDACd,WAAc,0CACd,WAAc,qCACd,WAAc,kBACd,WAAc,yBACd,WAAc,yBACd,WAAc,kDACd,WAAc,sDACd,WAAc,uDACd,WAAc,sDACd,WAAc,kDACd,WAAc,sDACd,WAAc,uDACd,WAAc,+BACd,WAAc,2BACd,WAAc,qCACd,WAAc,gCACd,WAAc,0CACd,WAAc,sCACd,WAAc,2CACd,WAAc,oCACd,WAAc,oBACd,WAAc,uBACd,WAAc,6BACd,WAAc,iCACd,WAAc,mCACd,WAAc,uCACd,WAAc,+BACd,WAAc,yCACd,WAAc,qCACd,WAAc,gCACd,WAAc,kCACd,WAAc,6BACd,WAAc,mCACd,WAAc,2CACd,WAAc,kCACd,WAAc,8CACd,WAAc,iCACd,WAAc,6CACd,WAAc,sCACd,WAAc,mCACd,WAAc,+BACd,WAAc,yCACd,WAAc,oCACd,WAAc,gDACd,WAAc,4CACd,WAAc,sDACd,WAAc,iDACd,WAAc,4CACd,WAAc,wCACd,WAAc,oDACd,WAAc,6CACd,WAAc,sCACd,WAAc,0CACd,WAAc,iDACd,WAAc,4CACd,WAAc,wCACd,WAAc,4CACd,WAAc,wCACd,WAAc,6CACd,WAAc,6CACd,WAAc",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ContainerModule as r}from"inversify";import{HttpNftDataSource as e}from"../../nft/data/HttpNftDataSource";import{nftTypes as o}from"../../nft/di/nftTypes";import{
|
|
1
|
+
import{ContainerModule as r}from"inversify";import{HttpNftDataSource as e}from"../../nft/data/HttpNftDataSource";import{nftTypes as o}from"../../nft/di/nftTypes";import{NftContextFieldLoader as f}from"../../nft/domain/NftContextFieldLoader";import{NftContextLoader as a}from"../../nft/domain/NftContextLoader";const N=()=>new r(({bind:t})=>{t(o.NftDataSource).to(e),t(o.NftContextLoader).to(a),t(o.NftContextFieldLoader).to(f)});export{N as nftModuleFactory};
|
|
2
2
|
//# sourceMappingURL=nftModuleFactory.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/nft/di/nftModuleFactory.ts"],
|
|
4
|
-
"sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpNftDataSource } from \"@/nft/data/HttpNftDataSource\";\nimport { nftTypes } from \"@/nft/di/nftTypes\";\nimport { NftContextLoader } from \"@/nft/domain/NftContextLoader\";\n\nexport const nftModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(nftTypes.NftDataSource).to(HttpNftDataSource);\n bind(nftTypes.NftContextLoader).to(NftContextLoader);\n });\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,qBAAAC,MAAyB,+BAClC,OAAS,YAAAC,MAAgB,oBACzB,OAAS,oBAAAC,MAAwB,gCAE1B,MAAMC,EAAmB,IAC9B,
|
|
6
|
-
"names": ["ContainerModule", "HttpNftDataSource", "nftTypes", "NftContextLoader", "nftModuleFactory", "bind"]
|
|
4
|
+
"sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpNftDataSource } from \"@/nft/data/HttpNftDataSource\";\nimport { nftTypes } from \"@/nft/di/nftTypes\";\nimport { NftContextFieldLoader } from \"@/nft/domain/NftContextFieldLoader\";\nimport { NftContextLoader } from \"@/nft/domain/NftContextLoader\";\n\nexport const nftModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(nftTypes.NftDataSource).to(HttpNftDataSource);\n bind(nftTypes.NftContextLoader).to(NftContextLoader);\n bind(nftTypes.NftContextFieldLoader).to(NftContextFieldLoader);\n });\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,qBAAAC,MAAyB,+BAClC,OAAS,YAAAC,MAAgB,oBACzB,OAAS,yBAAAC,MAA6B,qCACtC,OAAS,oBAAAC,MAAwB,gCAE1B,MAAMC,EAAmB,IAC9B,IAAIL,EAAgB,CAAC,CAAE,KAAAM,CAAK,IAAM,CAChCA,EAAKJ,EAAS,aAAa,EAAE,GAAGD,CAAiB,EACjDK,EAAKJ,EAAS,gBAAgB,EAAE,GAAGE,CAAgB,EACnDE,EAAKJ,EAAS,qBAAqB,EAAE,GAAGC,CAAqB,CAC/D,CAAC",
|
|
6
|
+
"names": ["ContainerModule", "HttpNftDataSource", "nftTypes", "NftContextFieldLoader", "NftContextLoader", "nftModuleFactory", "bind"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const t={NftDataSource:Symbol.for("nftDataSource"),NftContextLoader:Symbol.for("nftContextLoader")};export{t as nftTypes};
|
|
1
|
+
const t={NftDataSource:Symbol.for("nftDataSource"),NftContextLoader:Symbol.for("nftContextLoader"),NftContextFieldLoader:Symbol.for("nftContextFieldLoader")};export{t as nftTypes};
|
|
2
2
|
//# sourceMappingURL=nftTypes.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/nft/di/nftTypes.ts"],
|
|
4
|
-
"sourcesContent": ["export const nftTypes = {\n NftDataSource: Symbol.for(\"nftDataSource\"),\n NftContextLoader: Symbol.for(\"nftContextLoader\"),\n};\n"],
|
|
5
|
-
"mappings": "AAAO,MAAMA,EAAW,CACtB,cAAe,OAAO,IAAI,eAAe,EACzC,iBAAkB,OAAO,IAAI,kBAAkB,
|
|
4
|
+
"sourcesContent": ["export const nftTypes = {\n NftDataSource: Symbol.for(\"nftDataSource\"),\n NftContextLoader: Symbol.for(\"nftContextLoader\"),\n NftContextFieldLoader: Symbol.for(\"nftContextFieldLoader\"),\n};\n"],
|
|
5
|
+
"mappings": "AAAO,MAAMA,EAAW,CACtB,cAAe,OAAO,IAAI,eAAe,EACzC,iBAAkB,OAAO,IAAI,kBAAkB,EAC/C,sBAAuB,OAAO,IAAI,uBAAuB,CAC3D",
|
|
6
6
|
"names": ["nftTypes"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var c=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=(r,t,a,e)=>{for(var n=e>1?void 0:e?f(t,a):t,i=r.length-1,d;i>=0;i--)(d=r[i])&&(n=(e?d(t,a,n):d(n))||n);return e&&n&&c(t,a,n),n},p=(r,t)=>(a,e)=>t(a,e,r);import{inject as m,injectable as y}from"inversify";import{nftTypes as u}from"../../nft/di/nftTypes";import{ClearSignContextType as s}from"../../shared/model/ClearSignContext";let o=class{constructor(t){this._dataSource=t}canHandle(t,a){return a===s.NFT&&typeof t=="object"&&t!==null&&"chainId"in t&&"address"in t}async loadField(t){return(await this._dataSource.getNftInfosPayload({address:t.address,chainId:t.chainId})).caseOf({Left:e=>({type:s.ERROR,error:e}),Right:e=>({type:s.NFT,payload:e})})}};o=l([y(),p(0,m(u.NftDataSource))],o);export{o as NftContextFieldLoader};
|
|
2
|
+
//# sourceMappingURL=NftContextFieldLoader.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/nft/domain/NftContextFieldLoader.ts"],
|
|
4
|
+
"sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport * as NftDataSource from \"@/nft/data/NftDataSource\";\nimport { nftTypes } from \"@/nft/di/nftTypes\";\nimport { type ContextFieldLoader } from \"@/shared/domain/ContextFieldLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\n\ntype NftFieldInput = {\n chainId: number;\n address: string;\n};\n\n@injectable()\nexport class NftContextFieldLoader\n implements ContextFieldLoader<NftFieldInput>\n{\n constructor(\n @inject(nftTypes.NftDataSource)\n private _dataSource: NftDataSource.NftDataSource,\n ) {}\n\n canHandle(\n input: unknown,\n expectedType: ClearSignContextType,\n ): input is NftFieldInput {\n return (\n expectedType === ClearSignContextType.NFT &&\n typeof input === \"object\" &&\n input !== null &&\n \"chainId\" in input &&\n \"address\" in input\n );\n }\n\n async loadField(input: NftFieldInput): Promise<ClearSignContext> {\n const payload = await this._dataSource.getNftInfosPayload({\n address: input.address,\n chainId: input.chainId,\n });\n return payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.NFT,\n payload: value,\n }),\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "iOAAA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YAGnC,OAAS,YAAAC,MAAgB,oBAEzB,OAEE,wBAAAC,MACK,kCAQA,IAAMC,EAAN,KAEP,CACE,YAEUC,EACR,CADQ,iBAAAA,CACP,CAEH,UACEC,EACAC,EACwB,CACxB,OACEA,IAAiBC,EAAqB,KACtC,OAAOF,GAAU,UACjBA,IAAU,MACV,YAAaA,GACb,YAAaA,CAEjB,CAEA,MAAM,UAAUA,EAAiD,CAK/D,OAJgB,MAAM,KAAK,YAAY,mBAAmB,CACxD,QAASA,EAAM,QACf,QAASA,EAAM,OACjB,CAAC,GACc,OAAO,CACpB,KAAOG,IAA6B,CAClC,KAAMD,EAAqB,MAC3B,MAAAC,CACF,GACA,MAAQC,IAA6B,CACnC,KAAMF,EAAqB,IAC3B,QAASE,CACX,EACF,CAAC,CACH,CACF,EArCaN,EAANO,EAAA,CADNC,EAAW,EAKPC,EAAA,EAAAC,EAAOC,EAAS,aAAa,IAJrBX",
|
|
6
|
+
"names": ["inject", "injectable", "nftTypes", "ClearSignContextType", "NftContextFieldLoader", "_dataSource", "input", "expectedType", "ClearSignContextType", "error", "value", "__decorateClass", "injectable", "__decorateParam", "inject", "nftTypes"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Left as r,Right as s}from"purify-ts";import{NftContextFieldLoader as c}from"../../nft/domain/NftContextFieldLoader";import{ClearSignContextType as l}from"../../shared/model/ClearSignContext";describe("NftContextFieldLoader",()=>{const t={getNftInfosPayload:vi.fn(),getSetPluginPayload:vi.fn()},d=new c(t),a={chainId:1,address:"0x1234567890abcdef"},n="0x123456789abcdef0";beforeEach(()=>{vi.resetAllMocks()}),describe("canHandle",()=>{it("should return true for valid NFT field",()=>{const e={chainId:1,address:"0x1234567890abcdef"};expect(d.canHandle(e,l.NFT)).toBe(!0)}),describe("should return false for invalid fields",()=>{const e=[{name:"null",value:null},{name:"undefined",value:void 0},{name:"string",value:"invalid"},{name:"number",value:123},{name:"boolean",value:!0},{name:"array",value:[]},{name:"empty object",value:{}},{name:"object missing chainId",value:{address:"0x123"}},{name:"object missing address",value:{chainId:1}}];test.each(e)("$name",({value:o})=>{expect(d.canHandle(o,l.NFT)).toBe(!1)})}),it("should return false for invalid expected type",()=>{expect(d.canHandle(a,l.TOKEN)).toBe(!1)})}),describe("loadField",()=>{it("should return error context when NFT data source fails",async()=>{const e=new Error("NFT data source error");vi.spyOn(t,"getNftInfosPayload").mockResolvedValue(r(e));const o=await d.loadField(a);expect(t.getNftInfosPayload).toHaveBeenCalledWith({address:a.address,chainId:a.chainId}),expect(o).toEqual({type:l.ERROR,error:e})}),it("should return NFT context when successful",async()=>{vi.spyOn(t,"getNftInfosPayload").mockResolvedValue(s(n));const e=await d.loadField(a);expect(t.getNftInfosPayload).toHaveBeenCalledWith({address:a.address,chainId:a.chainId}),expect(e).toEqual({type:l.NFT,payload:n})}),it("should handle different chain IDs and addresses correctly",async()=>{const e={...a,chainId:137,address:"0xdeadbeef"};vi.spyOn(t,"getNftInfosPayload").mockResolvedValue(s(n));const o=await d.loadField(e);expect(t.getNftInfosPayload).toHaveBeenCalledWith({address:"0xdeadbeef",chainId:137}),expect(o).toEqual({type:l.NFT,payload:n})}),it("should preserve error message from NFT data source",async()=>{const e=new Error("Network timeout error");vi.spyOn(t,"getNftInfosPayload").mockResolvedValue(r(e));const o=await d.loadField(a);expect(o).toEqual({type:l.ERROR,error:e})}),it("should handle empty NFT payload",async()=>{const e="";vi.spyOn(t,"getNftInfosPayload").mockResolvedValue(s(e));const o=await d.loadField(a);expect(o).toEqual({type:l.NFT,payload:e})})})});
|
|
2
|
+
//# sourceMappingURL=NftContextFieldLoader.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/nft/domain/NftContextFieldLoader.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { type NftDataSource } from \"@/nft/data/NftDataSource\";\nimport { NftContextFieldLoader } from \"@/nft/domain/NftContextFieldLoader\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\n\ndescribe(\"NftContextFieldLoader\", () => {\n const mockNftDataSource: NftDataSource = {\n getNftInfosPayload: vi.fn(),\n getSetPluginPayload: vi.fn(),\n };\n const nftContextFieldLoader = new NftContextFieldLoader(mockNftDataSource);\n\n const mockTransactionField = {\n chainId: 1,\n address: \"0x1234567890abcdef\",\n };\n\n const mockNftPayload = \"0x123456789abcdef0\";\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"canHandle\", () => {\n it(\"should return true for valid NFT field\", () => {\n // GIVEN\n const validField = {\n chainId: 1,\n address: \"0x1234567890abcdef\",\n };\n\n // THEN\n expect(\n nftContextFieldLoader.canHandle(validField, ClearSignContextType.NFT),\n ).toBe(true);\n });\n\n describe(\"should return false for invalid fields\", () => {\n const invalidFields = [\n { name: \"null\", value: null },\n { name: \"undefined\", value: undefined },\n { name: \"string\", value: \"invalid\" },\n { name: \"number\", value: 123 },\n { name: \"boolean\", value: true },\n { name: \"array\", value: [] },\n { name: \"empty object\", value: {} },\n {\n name: \"object missing chainId\",\n value: { address: \"0x123\" },\n },\n {\n name: \"object missing address\",\n value: { chainId: 1 },\n },\n ];\n\n test.each(invalidFields)(\"$name\", ({ value }) => {\n expect(\n nftContextFieldLoader.canHandle(value, ClearSignContextType.NFT),\n ).toBe(false);\n });\n });\n\n it(\"should return false for invalid expected type\", () => {\n expect(\n nftContextFieldLoader.canHandle(\n mockTransactionField,\n ClearSignContextType.TOKEN,\n ),\n ).toBe(false);\n });\n });\n\n describe(\"loadField\", () => {\n it(\"should return error context when NFT data source fails\", async () => {\n // GIVEN\n const error = new Error(\"NFT data source error\");\n vi.spyOn(mockNftDataSource, \"getNftInfosPayload\").mockResolvedValue(\n Left(error),\n );\n\n // WHEN\n const result =\n await nftContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(mockNftDataSource.getNftInfosPayload).toHaveBeenCalledWith({\n address: mockTransactionField.address,\n chainId: mockTransactionField.chainId,\n });\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: error,\n });\n });\n\n it(\"should return NFT context when successful\", async () => {\n // GIVEN\n vi.spyOn(mockNftDataSource, \"getNftInfosPayload\").mockResolvedValue(\n Right(mockNftPayload),\n );\n\n // WHEN\n const result =\n await nftContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(mockNftDataSource.getNftInfosPayload).toHaveBeenCalledWith({\n address: mockTransactionField.address,\n chainId: mockTransactionField.chainId,\n });\n expect(result).toEqual({\n type: ClearSignContextType.NFT,\n payload: mockNftPayload,\n });\n });\n\n it(\"should handle different chain IDs and addresses correctly\", async () => {\n // GIVEN\n const customField = {\n ...mockTransactionField,\n chainId: 137,\n address: \"0xdeadbeef\",\n };\n vi.spyOn(mockNftDataSource, \"getNftInfosPayload\").mockResolvedValue(\n Right(mockNftPayload),\n );\n\n // WHEN\n const result = await nftContextFieldLoader.loadField(customField);\n\n // THEN\n expect(mockNftDataSource.getNftInfosPayload).toHaveBeenCalledWith({\n address: \"0xdeadbeef\",\n chainId: 137,\n });\n expect(result).toEqual({\n type: ClearSignContextType.NFT,\n payload: mockNftPayload,\n });\n });\n\n it(\"should preserve error message from NFT data source\", async () => {\n // GIVEN\n const specificError = new Error(\"Network timeout error\");\n vi.spyOn(mockNftDataSource, \"getNftInfosPayload\").mockResolvedValue(\n Left(specificError),\n );\n\n // WHEN\n const result =\n await nftContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: specificError,\n });\n });\n\n it(\"should handle empty NFT payload\", async () => {\n // GIVEN\n const emptyPayload = \"\";\n vi.spyOn(mockNftDataSource, \"getNftInfosPayload\").mockResolvedValue(\n Right(emptyPayload),\n );\n\n // WHEN\n const result =\n await nftContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.NFT,\n payload: emptyPayload,\n });\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAG5B,OAAS,yBAAAC,MAA6B,qCACtC,OAAS,wBAAAC,MAA4B,kCAErC,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qB,MAC3B,MAAOW,CACT,CAAC,CACH,CAAC,EAED,GAAG,kCAAmC,SAAY,CAEhD,MAAMC,EAAe,GACrB,GAAG,MAAMX,EAAmB,oBAAoB,EAAE,kBAChDH,EAAMc,CAAY,CACpB,EAGA,MAAMH,EACJ,MAAMP,EAAsB,UAAUC,CAAoB,EAG5D,OAAOM,CAAM,EAAE,QAAQ,CACrB,KAAMT,EAAqB,IAC3B,QAASY,CACX,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["Left", "Right", "NftContextFieldLoader", "ClearSignContextType", "mockNftDataSource", "nftContextFieldLoader", "mockTransactionField", "mockNftPayload", "validField", "invalidFields", "value", "error", "result", "customField", "specificError", "emptyPayload"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var S=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var d=(l,e,o,t)=>{for(var r=t>1?void 0:t?m(e,o):e,a=l.length-1,i;a>=0;a--)(i=l[a])&&(r=(t?i(e,o,r):i(r))||r);return t&&r&&S(e,o,r),r},u=(l,e)=>(o,t)=>e(o,t,l);import{isHexaString as x}from"@ledgerhq/device-management-kit";import{inject as h,injectable as I}from"inversify";import{nftTypes as b}from"../../nft/di/nftTypes";import{ClearSignContextType as n}from"../../shared/model/ClearSignContext";var g=(a=>(a.Approve="0x095ea7b3",a.SetApprovalForAll="0xa22cb465",a.TransferFrom="0x23b872dd",a.SafeTransferFrom="0x42842e0e",a.SafeTransferFromWithData="0xb88d4fde",a))(g||{}),y=(t=>(t.SetApprovalForAll="0xa22cb465",t.SafeTransferFrom="0xf242432a",t.SafeBatchTransferFrom="0x2eb2c2d6",t))(y||{});const N=[...Object.values(g),...Object.values(y)],v=[n.PLUGIN,n.NFT];let c=class{_dataSource;constructor(e){this._dataSource=e}canHandle(e,o){return typeof e=="object"&&e!==null&&"to"in e&&"selector"in e&&"chainId"in e&&typeof e.chainId=="number"&&x(e.to)&&e.to!=="0x"&&x(e.selector)&&this.isSelectorSupported(e.selector)&&v.every(t=>o.includes(t))}async load(e){const o=[],{to:t,selector:r,chainId:a}=e,f=(await this._dataSource.getSetPluginPayload({chainId:a,address:t,selector:r})).caseOf({Left:s=>({type:n.ERROR,error:s}),Right:s=>({type:n.PLUGIN,payload:s})});if(f.type===n.ERROR)return[f];o.push(f);const p=(await this._dataSource.getNftInfosPayload({chainId:a,address:t})).caseOf({Left:s=>({type:n.ERROR,error:s}),Right:s=>({type:n.NFT,payload:s})});return p.type===n.ERROR?[p]:(o.push(p),o)}isSelectorSupported(e){return Object.values(N).includes(e)}};c=d([I(),u(0,h(b.NftDataSource))],c);export{c as NftContextLoader};
|
|
2
2
|
//# sourceMappingURL=NftContextLoader.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/nft/domain/NftContextLoader.ts"],
|
|
4
|
-
"sourcesContent": ["import { HexaString, isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport type { NftDataSource } from \"@/nft/data/NftDataSource\";\nimport { nftTypes } from \"@/nft/di/nftTypes\";\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\
|
|
5
|
-
"mappings": "iOAAA,OAAqB,gBAAAA,MAAoB,kCACzC,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YAGnC,OAAS,YAAAC,MAAgB,oBAEzB,OAEE,wBAAAC,MACK,
|
|
6
|
-
"names": ["isHexaString", "inject", "injectable", "nftTypes", "ClearSignContextType", "ERC721_SUPPORTED_SELECTOR", "ERC1155_SUPPORTED_SELECTOR", "SUPPORTED_SELECTORS", "NftContextLoader", "dataSource", "
|
|
4
|
+
"sourcesContent": ["import { HexaString, isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport type { NftDataSource } from \"@/nft/data/NftDataSource\";\nimport { nftTypes } from \"@/nft/di/nftTypes\";\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\n\nexport type NftContextInput = {\n to: HexaString;\n selector: HexaString;\n chainId: number;\n};\n\nenum ERC721_SUPPORTED_SELECTOR {\n Approve = \"0x095ea7b3\",\n SetApprovalForAll = \"0xa22cb465\",\n TransferFrom = \"0x23b872dd\",\n SafeTransferFrom = \"0x42842e0e\",\n SafeTransferFromWithData = \"0xb88d4fde\",\n}\n\nenum ERC1155_SUPPORTED_SELECTOR {\n SetApprovalForAll = \"0xa22cb465\",\n SafeTransferFrom = \"0xf242432a\",\n SafeBatchTransferFrom = \"0x2eb2c2d6\",\n}\n\nconst SUPPORTED_SELECTORS: HexaString[] = [\n ...Object.values(ERC721_SUPPORTED_SELECTOR),\n ...Object.values(ERC1155_SUPPORTED_SELECTOR),\n];\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.PLUGIN,\n ClearSignContextType.NFT,\n];\n\n@injectable()\nexport class NftContextLoader implements ContextLoader<NftContextInput> {\n private _dataSource: NftDataSource;\n\n constructor(@inject(nftTypes.NftDataSource) dataSource: NftDataSource) {\n this._dataSource = dataSource;\n }\n\n canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is NftContextInput {\n return (\n typeof input === \"object\" &&\n input !== null &&\n \"to\" in input &&\n \"selector\" in input &&\n \"chainId\" in input &&\n typeof input.chainId === \"number\" &&\n isHexaString(input.to) &&\n input.to !== \"0x\" &&\n isHexaString(input.selector) &&\n this.isSelectorSupported(input.selector) &&\n SUPPORTED_TYPES.every((type) => expectedTypes.includes(type))\n );\n }\n\n async load(input: NftContextInput): Promise<ClearSignContext[]> {\n const responses: ClearSignContext[] = [];\n const { to, selector, chainId } = input;\n\n // EXAMPLE:\n // https://nft.api.live.ledger.com/v1/ethereum/1/contracts/0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D/plugin-selector/0x095ea7b3\n const getPluginPayloadResponse = await this._dataSource.getSetPluginPayload(\n {\n chainId,\n address: to,\n selector,\n },\n );\n\n const pluginPayload = getPluginPayloadResponse.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.PLUGIN,\n payload: value,\n }),\n });\n\n if (pluginPayload.type === ClearSignContextType.ERROR) {\n return [pluginPayload];\n }\n\n responses.push(pluginPayload);\n\n const getNftInfosPayloadResponse =\n await this._dataSource.getNftInfosPayload({\n chainId,\n address: to,\n });\n\n const nftInfosPayload = getNftInfosPayloadResponse.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.NFT,\n payload: value,\n }),\n });\n\n if (nftInfosPayload.type === ClearSignContextType.ERROR) {\n return [nftInfosPayload];\n }\n\n responses.push(nftInfosPayload);\n\n return responses;\n }\n\n private isSelectorSupported(selector: HexaString) {\n return Object.values(SUPPORTED_SELECTORS).includes(selector);\n }\n}\n"],
|
|
5
|
+
"mappings": "iOAAA,OAAqB,gBAAAA,MAAoB,kCACzC,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YAGnC,OAAS,YAAAC,MAAgB,oBAEzB,OAEE,wBAAAC,MACK,kCAQP,IAAKC,OACHA,EAAA,QAAU,aACVA,EAAA,kBAAoB,aACpBA,EAAA,aAAe,aACfA,EAAA,iBAAmB,aACnBA,EAAA,yBAA2B,aALxBA,OAAA,IAQAC,OACHA,EAAA,kBAAoB,aACpBA,EAAA,iBAAmB,aACnBA,EAAA,sBAAwB,aAHrBA,OAAA,IAML,MAAMC,EAAoC,CACxC,GAAG,OAAO,OAAOF,CAAyB,EAC1C,GAAG,OAAO,OAAOC,CAA0B,CAC7C,EAEME,EAA0C,CAC9CC,EAAqB,O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aR,EAANc,EAAA,CADNC,EAAW,EAIGC,EAAA,EAAAC,EAAOC,EAAS,aAAa,IAH/BlB",
|
|
6
|
+
"names": ["isHexaString", "inject", "injectable", "nftTypes", "ClearSignContextType", "ERC721_SUPPORTED_SELECTOR", "ERC1155_SUPPORTED_SELECTOR", "SUPPORTED_SELECTORS", "SUPPORTED_TYPES", "ClearSignContextType", "NftContextLoader", "dataSource", "input", "expectedTypes", "isHexaString", "type", "responses", "to", "selector", "chainId", "pluginPayload", "error", "value", "nftInfosPayload", "__decorateClass", "injectable", "__decorateParam", "inject", "nftTypes"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Left as
|
|
1
|
+
import{Left as d,Right as l}from"purify-ts";import{NftContextLoader as i}from"../../nft/domain/NftContextLoader";import{ClearSignContextType as t}from"../../shared/model/ClearSignContext";describe("NftContextLoader",()=>{const r=vi.fn(),a=vi.fn();let c,o;beforeEach(()=>{vi.restoreAllMocks(),c={getNftInfosPayload:r,getSetPluginPayload:a},o=new i(c)}),describe("canHandle function",()=>{const e={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",selector:"0x095ea7b3",chainId:1};it("should return true for valid input",()=>{expect(o.canHandle(e,[t.NFT,t.PLUGIN])).toBe(!0)}),it("should return false for invalid expected type",()=>{expect(o.canHandle(e,[t.TOKEN])).toBe(!1),expect(o.canHandle(e,[t.PLUGIN])).toBe(!1),expect(o.canHandle(e,[t.NFT])).toBe(!1)}),it.each([[null,"null input"],[void 0,"undefined input"],[{},"empty object"],["string","string input"],[123,"number input"],[{...e,to:void 0},"missing to"],[{...e,selector:void 0},"missing selector"],[{...e,chainId:void 0},"missing chainId"],[{...e,to:"invalid-hex"},"invalid to hex"],[{...e,to:"0x"},"empty to hex"],[{...e,selector:"invalid-hex"},"invalid selector hex"],[{...e,selector:"0x"},"empty selector hex"],[{...e,selector:"0x00000000"},"different selector"],[{...e,chainId:"1"},"string chainId"],[{...e,chainId:null},"null chainId"]])("should return false for %s",(n,s)=>{expect(o.canHandle(n,[t.NFT,t.PLUGIN])).toBe(!1)})}),describe("load function",()=>{it("should return an error when datasource get plugin payload return a Left",async()=>{const e={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",selector:"0x095ea7b3",chainId:1};a.mockResolvedValueOnce(d(new Error("error")));const n=await o.load(e);expect(n).toEqual([{type:t.ERROR,error:new Error("error")}])}),it("should return an error when datasource get nft infos payload return a Left",async()=>{const e={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",selector:"0x095ea7b3",chainId:1};a.mockResolvedValueOnce(l("payload1")),r.mockResolvedValueOnce(d(new Error("error")));const n=await o.load(e);expect(n).toEqual([{type:t.ERROR,error:new Error("error")}])}),it("should return a response",async()=>{const e={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",selector:"0x095ea7b3",chainId:1};a.mockResolvedValueOnce(l("payload1")),r.mockResolvedValueOnce(l("payload2"));const n=await o.load(e);expect(n).toEqual([{type:t.PLUGIN,payload:"payload1"},{type:t.NFT,payload:"payload2"}])})})});
|
|
2
2
|
//# sourceMappingURL=NftContextLoader.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/nft/domain/NftContextLoader.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { type NftDataSource } from \"@/nft/data/NftDataSource\";\nimport { NftContextLoader
|
|
5
|
-
"mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAG5B,
|
|
6
|
-
"names": ["Left", "Right", "NftContextLoader", "ClearSignContextType", "spyGetNftInfosPayload", "spyGetPluginPayload", "mockDataSource", "loader", "
|
|
4
|
+
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { type NftDataSource } from \"@/nft/data/NftDataSource\";\nimport {\n type NftContextInput,\n NftContextLoader,\n} from \"@/nft/domain/NftContextLoader\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\n\ndescribe(\"NftContextLoader\", () => {\n const spyGetNftInfosPayload = vi.fn();\n const spyGetPluginPayload = vi.fn();\n let mockDataSource: NftDataSource;\n let loader: NftContextLoader;\n\n beforeEach(() => {\n vi.restoreAllMocks();\n mockDataSource = {\n getNftInfosPayload: spyGetNftInfosPayload,\n getSetPluginPayload: spyGetPluginPayload,\n };\n loader = new NftContextLoader(mockDataSource);\n });\n\n describe(\"canHandle function\", () => {\n const validInput: NftContextInput = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n selector: \"0x095ea7b3\",\n chainId: 1,\n };\n\n it(\"should return true for valid input\", () => {\n expect(\n loader.canHandle(validInput, [\n ClearSignContextType.NFT,\n ClearSignContextType.PLUGIN,\n ]),\n ).toBe(true);\n });\n\n it(\"should return false for invalid expected type\", () => {\n expect(loader.canHandle(validInput, [ClearSignContextType.TOKEN])).toBe(\n false,\n );\n expect(loader.canHandle(validInput, [ClearSignContextType.PLUGIN])).toBe(\n false,\n );\n expect(loader.canHandle(validInput, [ClearSignContextType.NFT])).toBe(\n false,\n );\n });\n\n it.each([\n [null, \"null input\"],\n [undefined, \"undefined input\"],\n [{}, \"empty object\"],\n [\"string\", \"string input\"],\n [123, \"number input\"],\n [{ ...validInput, to: undefined }, \"missing to\"],\n [{ ...validInput, selector: undefined }, \"missing selector\"],\n [{ ...validInput, chainId: undefined }, \"missing chainId\"],\n [{ ...validInput, to: \"invalid-hex\" }, \"invalid to hex\"],\n [{ ...validInput, to: \"0x\" }, \"empty to hex\"],\n [{ ...validInput, selector: \"invalid-hex\" }, \"invalid selector hex\"],\n [{ ...validInput, selector: \"0x\" }, \"empty selector hex\"],\n [{ ...validInput, selector: \"0x00000000\" }, \"different selector\"],\n [{ ...validInput, chainId: \"1\" }, \"string chainId\"],\n [{ ...validInput, chainId: null }, \"null chainId\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.NFT,\n ClearSignContextType.PLUGIN,\n ]),\n ).toBe(false);\n });\n });\n\n describe(\"load function\", () => {\n it(\"should return an error when datasource get plugin payload return a Left\", async () => {\n const input: NftContextInput = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n selector: \"0x095ea7b3\",\n chainId: 1,\n };\n spyGetPluginPayload.mockResolvedValueOnce(Left(new Error(\"error\")));\n\n const result = await loader.load(input);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n ]);\n });\n\n it(\"should return an error when datasource get nft infos payload return a Left\", async () => {\n const input: NftContextInput = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n selector: \"0x095ea7b3\",\n chainId: 1,\n };\n spyGetPluginPayload.mockResolvedValueOnce(Right(\"payload1\"));\n spyGetNftInfosPayload.mockResolvedValueOnce(Left(new Error(\"error\")));\n\n const result = await loader.load(input);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n ]);\n });\n\n it(\"should return a response\", async () => {\n const input: NftContextInput = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n selector: \"0x095ea7b3\",\n chainId: 1,\n };\n spyGetPluginPayload.mockResolvedValueOnce(Right(\"payload1\"));\n spyGetNftInfosPayload.mockResolvedValueOnce(Right(\"payload2\"));\n\n const result = await loader.load(input);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.PLUGIN,\n payload: \"payload1\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload2\",\n },\n ]);\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAG5B,OAEE,oBAAAC,MACK,gCACP,OAAS,wBAAAC,MAA4B,kCAErC,SAAS,mBAAoB,IAAM,CACjC,MAAMC,EAAwB,GAAG,GAAG,EAC9BC,EAAsB,GAAG,GAAG,EAClC,IAAIC,EACAC,EAEJ,WAAW,IAAM,CACf,G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MR,EAAqB,OAC3B,QAAS,UACX,EACA,CACE,KAAMA,EAAqB,IAC3B,QAAS,UACX,CACF,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["Left", "Right", "NftContextLoader", "ClearSignContextType", "spyGetNftInfosPayload", "spyGetPluginPayload", "mockDataSource", "loader", "validInput", "input", "_description", "result"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var p=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var d=(a,e,r,n)=>{for(var t=n>1?void 0:n?y(e,r):e,o=a.length-1,i;o>=0;o--)(i=a[o])&&(t=(n?i(e,r,t):i(t))||t);return n&&t&&p(e,r,t),t},l=(a,e)=>(r,n)=>e(r,n,a);import f from"axios";import{inject as c,injectable as g}from"inversify";import{Left as s,Right as x}from"purify-ts";import{configTypes as D}from"../../config/di/configTypes";import{KeyId as u}from"../../pki/model/KeyId";import{KeyUsage as E}from"../../pki/model/KeyUsage";import{LEDGER_CLIENT_VERSION_HEADER as P,LEDGER_ORIGIN_TOKEN_HEADER as C}from"../../shared/constant/HttpHeaders";import h from"../../../package.json";let m=class{constructor(e){this.config=e}async getProxyImplementationAddress({proxyAddress:e,chainId:r,challenge:n,calldata:t}){let o;try{o=(await f.request({method:"POST",url:`${this.config.metadataServiceDomain.url}/v2/ethereum/${r}/contract/proxy/delegate`,headers:{[P]:`context-module/${h.version}`,[C]:this.config.originToken},data:{proxy:e,data:t,challenge:n}})).data}catch{return s(new Error("[ContextModule] HttpProxyDataSource: Failed to fetch delegate proxy"))}return o?this.isProxyDelegateCallDto(o)?o.addresses[0]?x({implementationAddress:o.addresses[0],signedDescriptor:o.signedDescriptor,keyId:u.DomainMetadataKey,keyUsage:E.TrustedName}):s(new Error(`[ContextModule] HttpProxyDataSource: No implementation address found for proxy ${e} on chain ${r}`)):s(new Error(`[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${e} on chain ${r}`)):s(new Error(`[ContextModule] HttpProxyDataSource: No data received for proxy ${e} on chain ${r}`))}isProxyDelegateCallDto(e){return typeof e=="object"&&e!==null&&"addresses"in e&&"signedDescriptor"in e&&Array.isArray(e.addresses)&&e.addresses.every(r=>typeof r=="string")&&typeof e.signedDescriptor=="string"}};m=d([g(),l(0,c(D.Config))],m);export{m as HttpProxyDataSource};
|
|
2
|
+
//# sourceMappingURL=HttpProxyDataSource.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/proxy/data/HttpProxyDataSource.ts"],
|
|
4
|
+
"sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { ProxyDelegateCallDto } from \"./dto/ProxyDelegateCallDto\";\nimport {\n GetProxyImplementationAddressParam,\n ProxyDataSource,\n ProxyImplementationAddress,\n} from \"./ProxyDataSource\";\n\n@injectable()\nexport class HttpProxyDataSource implements ProxyDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n async getProxyImplementationAddress({\n proxyAddress,\n chainId,\n challenge,\n calldata,\n }: GetProxyImplementationAddressParam): Promise<\n Either<Error, ProxyImplementationAddress>\n > {\n let dto: ProxyDelegateCallDto | undefined;\n try {\n const response = await axios.request<ProxyDelegateCallDto>({\n method: \"POST\",\n url: `${this.config.metadataServiceDomain.url}/v2/ethereum/${chainId}/contract/proxy/delegate`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n data: {\n proxy: proxyAddress,\n data: calldata,\n challenge,\n },\n });\n dto = response.data;\n } catch (_error) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: Failed to fetch delegate proxy`,\n ),\n );\n }\n\n if (!dto) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: No data received for proxy ${proxyAddress} on chain ${chainId}`,\n ),\n );\n }\n\n if (!this.isProxyDelegateCallDto(dto)) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${proxyAddress} on chain ${chainId}`,\n ),\n );\n }\n\n if (!dto.addresses[0]) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: No implementation address found for proxy ${proxyAddress} on chain ${chainId}`,\n ),\n );\n }\n\n return Right({\n implementationAddress: dto.addresses[0],\n signedDescriptor: dto.signedDescriptor,\n keyId: KeyId.DomainMetadataKey,\n keyUsage: KeyUsage.TrustedName,\n });\n }\n\n /**\n * Type guard to validate ProxyDelegateCallDto\n */\n private isProxyDelegateCallDto(\n value: unknown,\n ): value is ProxyDelegateCallDto {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"addresses\" in value &&\n \"signedDescriptor\" in value &&\n Array.isArray(value.addresses) &&\n value.addresses.every((address) => typeof address === \"string\") &&\n typeof value.signedDescriptor === \"string\"\n );\n }\n}\n"],
|
|
5
|
+
"mappings": "iOAAA,OAAOA,MAAW,QAClB,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAE5B,OAAS,SAAAC,MAAa,oBACtB,OAAS,YAAAC,MAAgB,uBACzB,OACE,gCAAAC,EACA,8BAAAC,MACK,gCACP,OAAOC,MAAa,qBAUb,IAAMC,EAAN,KAAqD,CAC1D,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAM,8BAA8B,CAClC,aAAAC,EACA,QAAAC,EACA,UAAAC,EACA,SAAAC,CACF,EAEE,CACA,IAAIC,EACJ,GAAI,CAcFA,GAbiB,MAAMC,EAAM,QAA8B,CACzD,OAAQ,OACR,IAAK,GAAG,KAAK,OAAO,sBAAsB,GAAG,gBAAgBJ,CAAO,2BACpE,QAAS,CACP,CAACK,CAA4B,EAAG,kBAAkBC,EAAQ,OAAO,GACjE,CAACC,CAA0B,EAAG,KAAK,OAAO,WAC5C,EACA,KAAM,CACJ,MAAOR,EACP,KAAMG,EACN,UAAAD,CACF,CACF,CAAC,GACc,IACjB,MAAiB,CACf,OAAOO,EACL,IAAI,MACF,qEACF,CACF,CACF,CAEA,OAAKL,EAQA,KAAK,uBAAuBA,CAAG,EAQ/BA,EAAI,UAAU,CAAC,EAQbM,EAAM,CACX,sBAAuBN,EAAI,UAAU,CAAC,EACtC,iBAAkBA,EAAI,iBACtB,MAAOO,EAAM,kBACb,SAAUC,EAAS,WACrB,CAAC,EAZQH,EACL,IAAI,MACF,kFAAkFT,CAAY,aAAaC,CAAO,EACpH,CACF,EAZOQ,EACL,IAAI,MACF,8FAA8FT,CAAY,aAAaC,CAAO,EAChI,CACF,EAZOQ,EACL,IAAI,MACF,mEAAmET,CAAY,aAAaC,CAAO,EACrG,CACF,CAyBJ,CAKQ,uBACNY,EAC+B,CAC/B,OACE,OAAOA,GAAU,UACjBA,IAAU,MACV,cAAeA,GACf,qBAAsBA,GACtB,MAAM,QAAQA,EAAM,SAAS,GAC7BA,EAAM,UAAU,MAAOC,GAAY,OAAOA,GAAY,QAAQ,GAC9D,OAAOD,EAAM,kBAAqB,QAEtC,CACF,EArFaf,EAANiB,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,IAFjBrB",
|
|
6
|
+
"names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "KeyId", "KeyUsage", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "PACKAGE", "HttpProxyDataSource", "config", "proxyAddress", "chainId", "challenge", "calldata", "dto", "axios", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "LEDGER_ORIGIN_TOKEN_HEADER", "Left", "Right", "KeyId", "KeyUsage", "value", "address", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import a from"axios";import{KeyId as i}from"../../pki/model/KeyId";import{KeyUsage as c}from"../../pki/model/KeyUsage";import{LEDGER_CLIENT_VERSION_HEADER as l,LEDGER_ORIGIN_TOKEN_HEADER as p}from"../../shared/constant/HttpHeaders";import u from"../../../package.json";import{HttpProxyDataSource as x}from"./HttpProxyDataSource";vi.mock("axios");const d={metadataServiceDomain:{url:"https://metadata.api.live.ledger.com"},originToken:"test-origin-token"};describe("HttpProxyDataSource",()=>{let o;beforeAll(()=>{o=new x(d),vi.clearAllMocks()}),beforeEach(()=>{vi.clearAllMocks()});const t={proxyAddress:"0x1234567890123456789012345678901234567890",chainId:1,challenge:"test-challenge",calldata:"0xabcdef"},s={addresses:["0x9876543210987654321098765432109876543210"],signedDescriptor:"signed-descriptor-data"};describe("getProxyImplementationAddress",()=>{it("should call axios with correct URL, headers, and data",async()=>{const e=`context-module/${u.version}`,r=vi.fn(()=>Promise.resolve({data:s}));vi.spyOn(a,"request").mockImplementation(r),await o.getProxyImplementationAddress(t),expect(r).toHaveBeenCalledWith({method:"POST",url:`${d.metadataServiceDomain.url}/v2/ethereum/${t.chainId}/contract/proxy/delegate`,headers:{[l]:e,[p]:d.originToken},data:{proxy:t.proxyAddress,data:t.calldata,challenge:t.challenge}})}),it("should return Right with proxy implementation data when request succeeds with valid DTO",async()=>{vi.spyOn(a,"request").mockResolvedValue({data:s});const e=await o.getProxyImplementationAddress(t);expect(e.isRight()).toBe(!0),expect(e.extract()).toEqual({implementationAddress:s.addresses[0],signedDescriptor:s.signedDescriptor,keyId:i.DomainMetadataKey,keyUsage:c.TrustedName})}),it("should return Right with first address when multiple addresses are provided",async()=>{const e={addresses:["0x9876543210987654321098765432109876543210","0x1111111111111111111111111111111111111111"],signedDescriptor:"signed-descriptor-data"};vi.spyOn(a,"request").mockResolvedValue({data:e});const r=await o.getProxyImplementationAddress(t);expect(r.isRight()).toBe(!0),expect(r.extract()).toEqual({implementationAddress:e.addresses[0],signedDescriptor:e.signedDescriptor,keyId:i.DomainMetadataKey,keyUsage:c.TrustedName})}),it("should return Left with error when axios throws an error",async()=>{vi.spyOn(a,"request").mockRejectedValue(new Error("Network error"));const e=await o.getProxyImplementationAddress(t);expect(e.isLeft()).toBe(!0),expect(e.extract()).toEqual(new Error("[ContextModule] HttpProxyDataSource: Failed to fetch delegate proxy"))}),it("should return Left with error when response data is undefined",async()=>{vi.spyOn(a,"request").mockResolvedValue({data:void 0});const e=await o.getProxyImplementationAddress(t);expect(e.isLeft()).toBe(!0),expect(e.extract()).toEqual(new Error(`[ContextModule] HttpProxyDataSource: No data received for proxy ${t.proxyAddress} on chain ${t.chainId}`))}),it("should return Left with error when response data is null",async()=>{vi.spyOn(a,"request").mockResolvedValue({data:null});const e=await o.getProxyImplementationAddress(t);expect(e.isLeft()).toBe(!0),expect(e.extract()).toEqual(new Error(`[ContextModule] HttpProxyDataSource: No data received for proxy ${t.proxyAddress} on chain ${t.chainId}`))}),it("should return Left with error when addresses field is missing",async()=>{const{addresses:e,...r}=s;vi.spyOn(a,"request").mockResolvedValue({data:r});const n=await o.getProxyImplementationAddress(t);expect(n.isLeft()).toBe(!0),expect(n.extract()).toEqual(new Error(`[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${t.proxyAddress} on chain ${t.chainId}`))}),it("should return Left with error when signedDescriptor is missing",async()=>{const{signedDescriptor:e,...r}=s;vi.spyOn(a,"request").mockResolvedValue({data:r});const n=await o.getProxyImplementationAddress(t);expect(n.isLeft()).toBe(!0),expect(n.extract()).toEqual(new Error(`[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${t.proxyAddress} on chain ${t.chainId}`))}),it("should return Left with error when addresses is not an array",async()=>{const e={...s,addresses:"not-an-array"};vi.spyOn(a,"request").mockResolvedValue({data:e});const r=await o.getProxyImplementationAddress(t);expect(r.isLeft()).toBe(!0),expect(r.extract()).toEqual(new Error(`[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${t.proxyAddress} on chain ${t.chainId}`))}),it("should return Left with error when addresses array contains non-string values",async()=>{const e={...s,addresses:[123,"valid-address"]};vi.spyOn(a,"request").mockResolvedValue({data:e});const r=await o.getProxyImplementationAddress(t);expect(r.isLeft()).toBe(!0),expect(r.extract()).toEqual(new Error(`[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${t.proxyAddress} on chain ${t.chainId}`))}),it("should return Left with error when signedDescriptor is not a string",async()=>{const e={...s,signedDescriptor:123};vi.spyOn(a,"request").mockResolvedValue({data:e});const r=await o.getProxyImplementationAddress(t);expect(r.isLeft()).toBe(!0),expect(r.extract()).toEqual(new Error(`[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${t.proxyAddress} on chain ${t.chainId}`))}),it("should return Left with error when addresses array is empty",async()=>{const e={addresses:[],signedDescriptor:"signed-descriptor-data"};vi.spyOn(a,"request").mockResolvedValue({data:e});const r=await o.getProxyImplementationAddress(t);expect(r.isLeft()).toBe(!0),expect(r.extract()).toEqual(new Error(`[ContextModule] HttpProxyDataSource: No implementation address found for proxy ${t.proxyAddress} on chain ${t.chainId}`))}),it("should return Left with error when response is not an object",async()=>{vi.spyOn(a,"request").mockResolvedValue({data:"not an object"});const e=await o.getProxyImplementationAddress(t);expect(e.isLeft()).toBe(!0),expect(e.extract()).toEqual(new Error(`[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${t.proxyAddress} on chain ${t.chainId}`))}),it("should handle different chainId values correctly",async()=>{const e={...t,chainId:137};vi.spyOn(a,"request").mockResolvedValue({data:s});const r=await o.getProxyImplementationAddress(e);expect(r.isRight()).toBe(!0),expect(a.request).toHaveBeenCalledWith(expect.objectContaining({url:`${d.metadataServiceDomain.url}/v2/ethereum/137/contract/proxy/delegate`}))}),it("should handle different proxy addresses correctly",async()=>{const e="0xabcdefabcdefabcdefabcdefabcdefabcdefabcd",r={...t,proxyAddress:e};vi.spyOn(a,"request").mockResolvedValue({data:s});const n=await o.getProxyImplementationAddress(r);expect(n.isRight()).toBe(!0),expect(a.request).toHaveBeenCalledWith(expect.objectContaining({data:expect.objectContaining({proxy:e})}))}),it("should handle different calldata values correctly",async()=>{const e="0x123456789abcdef",r={...t,calldata:e};vi.spyOn(a,"request").mockResolvedValue({data:s});const n=await o.getProxyImplementationAddress(r);expect(n.isRight()).toBe(!0),expect(a.request).toHaveBeenCalledWith(expect.objectContaining({data:expect.objectContaining({data:e})}))}),it("should pass challenge parameter correctly",async()=>{const e="custom-challenge-string",r={...t,challenge:e};vi.spyOn(a,"request").mockResolvedValue({data:s});const n=await o.getProxyImplementationAddress(r);expect(n.isRight()).toBe(!0),expect(a.request).toHaveBeenCalledWith(expect.objectContaining({data:expect.objectContaining({challenge:e})}))})})});
|
|
2
|
+
//# sourceMappingURL=HttpProxyDataSource.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/proxy/data/HttpProxyDataSource.test.ts"],
|
|
4
|
+
"sourcesContent": ["import axios from \"axios\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { type ProxyDelegateCallDto } from \"./dto/ProxyDelegateCallDto\";\nimport { HttpProxyDataSource } from \"./HttpProxyDataSource\";\nimport { type ProxyDataSource } from \"./ProxyDataSource\";\n\nvi.mock(\"axios\");\n\nconst config = {\n metadataServiceDomain: {\n url: \"https://metadata.api.live.ledger.com\",\n },\n originToken: \"test-origin-token\",\n} as ContextModuleConfig;\n\ndescribe(\"HttpProxyDataSource\", () => {\n let datasource: ProxyDataSource;\n\n beforeAll(() => {\n datasource = new HttpProxyDataSource(config);\n vi.clearAllMocks();\n });\n\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n const validParams = {\n proxyAddress: \"0x1234567890123456789012345678901234567890\",\n chainId: 1,\n challenge: \"test-challenge\",\n calldata: \"0xabcdef\",\n };\n\n const validDto: ProxyDelegateCallDto = {\n addresses: [\"0x9876543210987654321098765432109876543210\"],\n signedDescriptor: \"signed-descriptor-data\",\n };\n\n describe(\"getProxyImplementationAddress\", () => {\n it(\"should call axios with correct URL, headers, and data\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() => Promise.resolve({ data: validDto }));\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith({\n method: \"POST\",\n url: `${config.metadataServiceDomain.url}/v2/ethereum/${validParams.chainId}/contract/proxy/delegate`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: version,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n data: {\n proxy: validParams.proxyAddress,\n data: validParams.calldata,\n challenge: validParams.challenge,\n },\n });\n });\n\n it(\"should return Right with proxy implementation data when request succeeds with valid DTO\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: validDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isRight()).toBe(true);\n expect(result.extract()).toEqual({\n implementationAddress: validDto.addresses[0],\n signedDescriptor: validDto.signedDescriptor,\n keyId: KeyId.DomainMetadataKey,\n keyUsage: KeyUsage.TrustedName,\n });\n });\n\n it(\"should return Right with first address when multiple addresses are provided\", async () => {\n // GIVEN\n const dtoWithMultipleAddresses: ProxyDelegateCallDto = {\n addresses: [\n \"0x9876543210987654321098765432109876543210\",\n \"0x1111111111111111111111111111111111111111\",\n ],\n signedDescriptor: \"signed-descriptor-data\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: dtoWithMultipleAddresses,\n });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isRight()).toBe(true);\n expect(result.extract()).toEqual({\n implementationAddress: dtoWithMultipleAddresses.addresses[0],\n signedDescriptor: dtoWithMultipleAddresses.signedDescriptor,\n keyId: KeyId.DomainMetadataKey,\n keyUsage: KeyUsage.TrustedName,\n });\n });\n\n it(\"should return Left with error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"Network error\"));\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n \"[ContextModule] HttpProxyDataSource: Failed to fetch delegate proxy\",\n ),\n );\n });\n\n it(\"should return Left with error when response data is undefined\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: undefined });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpProxyDataSource: No data received for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when response data is null\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: null });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpProxyDataSource: No data received for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when addresses field is missing\", async () => {\n // GIVEN\n const { addresses: _, ...invalidDto } = validDto;\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: invalidDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when signedDescriptor is missing\", async () => {\n // GIVEN\n const { signedDescriptor: _, ...invalidDto } = validDto;\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: invalidDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when addresses is not an array\", async () => {\n // GIVEN\n const invalidDto = { ...validDto, addresses: \"not-an-array\" };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: invalidDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when addresses array contains non-string values\", async () => {\n // GIVEN\n const invalidDto = { ...validDto, addresses: [123, \"valid-address\"] };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: invalidDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when signedDescriptor is not a string\", async () => {\n // GIVEN\n const invalidDto = { ...validDto, signedDescriptor: 123 };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: invalidDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when addresses array is empty\", async () => {\n // GIVEN\n const invalidDto: ProxyDelegateCallDto = {\n addresses: [],\n signedDescriptor: \"signed-descriptor-data\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: invalidDto });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpProxyDataSource: No implementation address found for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should return Left with error when response is not an object\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: \"not an object\" });\n\n // WHEN\n const result =\n await datasource.getProxyImplementationAddress(validParams);\n\n // THEN\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).toEqual(\n new Error(\n `[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${validParams.proxyAddress} on chain ${validParams.chainId}`,\n ),\n );\n });\n\n it(\"should handle different chainId values correctly\", async () => {\n // GIVEN\n const paramsWithDifferentChainId = { ...validParams, chainId: 137 };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: validDto });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n paramsWithDifferentChainId,\n );\n\n // THEN\n expect(result.isRight()).toBe(true);\n expect(axios.request).toHaveBeenCalledWith(\n expect.objectContaining({\n url: `${config.metadataServiceDomain.url}/v2/ethereum/137/contract/proxy/delegate`,\n }),\n );\n });\n\n it(\"should handle different proxy addresses correctly\", async () => {\n // GIVEN\n const differentProxyAddress =\n \"0xabcdefabcdefabcdefabcdefabcdefabcdefabcd\";\n const paramsWithDifferentAddress = {\n ...validParams,\n proxyAddress: differentProxyAddress,\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: validDto });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n paramsWithDifferentAddress,\n );\n\n // THEN\n expect(result.isRight()).toBe(true);\n expect(axios.request).toHaveBeenCalledWith(\n expect.objectContaining({\n data: expect.objectContaining({\n proxy: differentProxyAddress,\n }),\n }),\n );\n });\n\n it(\"should handle different calldata values correctly\", async () => {\n // GIVEN\n const customCalldata = \"0x123456789abcdef\";\n const paramsWithCustomCalldata = {\n ...validParams,\n calldata: customCalldata,\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: validDto });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n paramsWithCustomCalldata,\n );\n\n // THEN\n expect(result.isRight()).toBe(true);\n expect(axios.request).toHaveBeenCalledWith(\n expect.objectContaining({\n data: expect.objectContaining({\n data: customCalldata,\n }),\n }),\n );\n });\n\n it(\"should pass challenge parameter correctly\", async () => {\n // GIVEN\n const customChallenge = \"custom-challenge-string\";\n const paramsWithCustomChallenge = {\n ...validParams,\n challenge: customChallenge,\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: validDto });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n paramsWithCustomChallenge,\n );\n\n // THEN\n expect(result.isRight()).toBe(true);\n expect(axios.request).toHaveBeenCalledWith(\n expect.objectContaining({\n data: expect.objectContaining({\n challenge: customChallenge,\n }),\n }),\n );\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAOA,MAAW,QAGlB,OAAS,SAAAC,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AAGZ,EACH,SAAUW,CACZ,EACA,GAAG,MAAMpB,EAAO,SAAS,EAAE,kBAAkB,CAAE,KAAMU,CAAS,CAAC,EAG/D,MAAMG,EAAS,MAAML,EAAW,8BAC9Ba,CACF,EAGA,OAAOR,EAAO,QAAQ,CAAC,EAAE,KAAK,EAAI,EAClC,OAAOb,EAAM,OAAO,EAAE,qBACpB,OAAO,iBAAiB,CACtB,KAAM,OAAO,iBAAiB,CAC5B,KAAMoB,CACR,CAAC,CACH,CAAC,CACH,CACF,CAAC,EAED,GAAG,4CAA6C,SAAY,CAE1D,MAAME,EAAkB,0BAClBC,EAA4B,CAChC,GAAGd,EACH,UAAWa,CACb,EACA,GAAG,MAAMtB,EAAO,SAAS,EAAE,kBAAkB,CAAE,KAAMU,CAAS,CAAC,EAG/D,MAAMG,EAAS,MAAML,EAAW,8BAC9Be,CACF,EAGA,OAAOV,EAAO,QAAQ,CAAC,EAAE,KAAK,EAAI,EAClC,OAAOb,EAAM,OAAO,EAAE,qBACpB,OAAO,iBAAiB,CACtB,KAAM,OAAO,iBAAiB,CAC5B,UAAWsB,CACb,CAAC,CACH,CAAC,CACH,CACF,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["axios", "KeyId", "KeyUsage", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "PACKAGE", "HttpProxyDataSource", "config", "datasource", "validParams", "validDto", "version", "requestSpy", "result", "dtoWithMultipleAddresses", "_", "invalidDto", "paramsWithDifferentChainId", "differentProxyAddress", "paramsWithDifferentAddress", "customCalldata", "paramsWithCustomCalldata", "customChallenge", "paramsWithCustomChallenge"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var y=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var p=(n,e,t,o)=>{for(var r=o>1?void 0:o?f(e,t):e,i=n.length-1,d;i>=0;i--)(d=n[i])&&(r=(o?d(e,t,r):d(r))||r);return o&&r&&y(e,t,r),r},a=(n,e)=>(t,o)=>e(t,o,n);import c from"axios";import{inject as x,injectable as g}from"inversify";import{Left as m,Right as A}from"purify-ts";import{configTypes as E}from"../../config/di/configTypes";import{LEDGER_CLIENT_VERSION_HEADER as l,LEDGER_ORIGIN_TOKEN_HEADER as I}from"../../shared/constant/HttpHeaders";import D from"../../../package.json";let s=class{constructor(e){this.config=e}async getProxyImplementationAddress({proxyAddress:e,chainId:t,challenge:o}){let r;try{r=(await c.request({method:"GET",url:`${this.config.metadataServiceDomain.url}/v3/ethereum/${t}/contract/proxy/${e}`,headers:{[l]:`context-module/${D.version}`,[I]:this.config.originToken},params:{challenge:o,resolver:"SAFE_GATEWAY"}})).data}catch{return m(new Error("[ContextModule] HttpSafeProxyDataSource: Failed to fetch safe proxy implementation"))}return r?this.isSafeProxyImplementationAddressDto(r)?A({implementationAddress:r.implementationAddress,signedDescriptor:r.signedDescriptor,keyId:r.keyId,keyUsage:r.keyUsage}):m(new Error(`[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${e} on chain ${t}`)):m(new Error(`[ContextModule] HttpSafeProxyDataSource: No data received for proxy ${e} on chain ${t}`))}isSafeProxyImplementationAddressDto(e){return typeof e=="object"&&e!==null&&"proxyAddress"in e&&"implementationAddress"in e&&"standard"in e&&"signedDescriptor"in e&&"providedBy"in e&&"keyId"in e&&"keyUsage"in e&&typeof e.proxyAddress=="string"&&typeof e.implementationAddress=="string"&&typeof e.standard=="string"&&typeof e.signedDescriptor=="string"&&typeof e.providedBy=="string"&&typeof e.keyId=="string"&&typeof e.keyUsage=="string"}};s=p([g(),a(0,x(E.Config))],s);export{s as HttpSafeProxyDataSource};
|
|
2
|
+
//# sourceMappingURL=HttpSafeProxyDataSource.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/proxy/data/HttpSafeProxyDataSource.ts"],
|
|
4
|
+
"sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { SafeProxyImplementationAddressDto } from \"./dto/SafeProxyImplementationAddressDto\";\nimport {\n GetProxyImplementationAddressParam,\n type ProxyDataSource,\n ProxyImplementationAddress,\n} from \"./ProxyDataSource\";\n\n@injectable()\nexport class HttpSafeProxyDataSource implements ProxyDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n async getProxyImplementationAddress({\n proxyAddress,\n chainId,\n challenge,\n }: GetProxyImplementationAddressParam): Promise<\n Either<Error, ProxyImplementationAddress>\n > {\n let dto: SafeProxyImplementationAddressDto | undefined;\n try {\n const response = await axios.request<SafeProxyImplementationAddressDto>({\n method: \"GET\",\n url: `${this.config.metadataServiceDomain.url}/v3/ethereum/${chainId}/contract/proxy/${proxyAddress}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n params: {\n challenge,\n resolver: \"SAFE_GATEWAY\",\n },\n });\n dto = response.data;\n } catch (_error) {\n return Left(\n new Error(\n `[ContextModule] HttpSafeProxyDataSource: Failed to fetch safe proxy implementation`,\n ),\n );\n }\n\n if (!dto) {\n return Left(\n new Error(\n `[ContextModule] HttpSafeProxyDataSource: No data received for proxy ${proxyAddress} on chain ${chainId}`,\n ),\n );\n }\n\n if (!this.isSafeProxyImplementationAddressDto(dto)) {\n return Left(\n new Error(\n `[ContextModule] HttpSafeProxyDataSource: Invalid safe proxy response format for proxy ${proxyAddress} on chain ${chainId}`,\n ),\n );\n }\n\n return Right({\n implementationAddress: dto.implementationAddress,\n signedDescriptor: dto.signedDescriptor,\n keyId: dto.keyId,\n keyUsage: dto.keyUsage,\n });\n }\n\n /**\n * Type guard to validate SafeProxyImplementationAddressDto\n */\n private isSafeProxyImplementationAddressDto(\n value: unknown,\n ): value is SafeProxyImplementationAddressDto {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"proxyAddress\" in value &&\n \"implementationAddress\" in value &&\n \"standard\" in value &&\n \"signedDescriptor\" in value &&\n \"providedBy\" in value &&\n \"keyId\" in value &&\n \"keyUsage\" in value &&\n typeof value.proxyAddress === \"string\" &&\n typeof value.implementationAddress === \"string\" &&\n typeof value.standard === \"string\" &&\n typeof value.signedDescriptor === \"string\" &&\n typeof value.providedBy === \"string\" &&\n typeof value.keyId === \"string\" &&\n typeof value.keyUsage === \"string\"\n );\n }\n}\n"],
|
|
5
|
+
"mappings": "iOAAA,OAAOA,MAAW,QAClB,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAE5B,OACE,gCAAAC,EACA,8BAAAC,MACK,gCACP,OAAOC,MAAa,qBAUb,IAAMC,EAAN,KAAyD,CAC9D,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAM,8BAA8B,CAClC,aAAAC,EACA,QAAAC,EACA,UAAAC,CACF,EAEE,CACA,IAAIC,EACJ,GAAI,CAaFA,GAZiB,MAAMC,EAAM,QAA2C,CACtE,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,sBAAsB,GAAG,gBAAgBH,CAAO,mBAAmBD,CAAY,GACnG,QAAS,CACP,CAACK,CAA4B,EAAG,kBAAkBC,EAAQ,OAAO,GACjE,CAACC,CAA0B,EAAG,KAAK,OAAO,WAC5C,EACA,OAAQ,CACN,UAAAL,EACA,SAAU,cACZ,CACF,CAAC,GACc,IACjB,MAAiB,CACf,OAAOM,EACL,IAAI,MACF,oFACF,CACF,CACF,CAEA,OAAKL,EAQA,KAAK,oCAAoCA,CAAG,EAQ1CM,EAAM,CACX,sBAAuBN,EAAI,sBAC3B,iBAAkBA,EAAI,iBACtB,MAAOA,EAAI,MACX,SAAUA,EAAI,QAChB,CAAC,EAZQK,EACL,IAAI,MACF,yFAAyFR,CAAY,aAAaC,CAAO,EAC3H,CACF,EAZOO,EACL,IAAI,MACF,uEAAuER,CAAY,aAAaC,CAAO,EACzG,CACF,CAiBJ,CAKQ,oCACNS,EAC4C,CAC5C,OACE,OAAOA,GAAU,UACjBA,IAAU,MACV,iBAAkBA,GAClB,0BAA2BA,GAC3B,aAAcA,GACd,qBAAsBA,GACtB,eAAgBA,GAChB,UAAWA,GACX,aAAcA,GACd,OAAOA,EAAM,cAAiB,UAC9B,OAAOA,EAAM,uBAA0B,UACvC,OAAOA,EAAM,UAAa,UAC1B,OAAOA,EAAM,kBAAqB,UAClC,OAAOA,EAAM,YAAe,UAC5B,OAAOA,EAAM,OAAU,UACvB,OAAOA,EAAM,UAAa,QAE9B,CACF,EApFaZ,EAANa,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,IAFjBjB",
|
|
6
|
+
"names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "PACKAGE", "HttpSafeProxyDataSource", "config", "proxyAddress", "chainId", "challenge", "dto", "axios", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "LEDGER_ORIGIN_TOKEN_HEADER", "Left", "Right", "value", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes"]
|
|
7
|
+
}
|