@ledgerhq/context-module 1.1.0 → 1.2.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 +8 -7
- package/lib/cjs/src/ContextModuleBuilder.test.js +1 -1
- package/lib/cjs/src/ContextModuleBuilder.test.js.map +2 -2
- 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 +2 -2
- package/lib/cjs/src/di.js +1 -1
- package/lib/cjs/src/di.js.map +3 -3
- package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
- package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +2 -2
- package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
- package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +2 -2
- package/lib/cjs/src/index.js +1 -1
- package/lib/cjs/src/index.js.map +2 -2
- package/lib/cjs/src/nft/data/HttpNftDataSource.test.js +1 -1
- package/lib/cjs/src/nft/data/HttpNftDataSource.test.js.map +2 -2
- package/lib/cjs/src/nft/domain/NftContextLoader.test.js +1 -1
- package/lib/cjs/src/nft/domain/NftContextLoader.test.js.map +2 -2
- package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.js +2 -0
- package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.js.map +7 -0
- package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.test.js +2 -0
- package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.test.js.map +7 -0
- package/lib/cjs/src/pki/data/PkiCertificateDataSource.js +2 -0
- package/lib/cjs/src/pki/data/PkiCertificateDataSource.js.map +7 -0
- package/lib/cjs/src/pki/data/pkiDataSourceTypes.js +2 -0
- package/lib/cjs/src/pki/data/pkiDataSourceTypes.js.map +7 -0
- package/lib/cjs/src/pki/di/pkiModuleFactory.js +2 -0
- package/lib/cjs/src/pki/di/pkiModuleFactory.js.map +7 -0
- package/lib/cjs/src/pki/di/pkiTypes.js +2 -0
- package/lib/cjs/src/pki/di/pkiTypes.js.map +7 -0
- package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.js +2 -0
- package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.js.map +7 -0
- package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js +2 -0
- package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +7 -0
- package/lib/cjs/src/pki/domain/PkiCertificateLoader.js +2 -0
- package/lib/cjs/src/pki/domain/PkiCertificateLoader.js.map +7 -0
- package/lib/cjs/src/pki/model/KeyId.js +2 -0
- package/lib/cjs/src/pki/model/KeyId.js.map +7 -0
- package/lib/cjs/src/pki/model/KeyUsage.js +2 -0
- package/lib/cjs/src/pki/model/KeyUsage.js.map +7 -0
- package/lib/cjs/src/pki/model/PkiCertificate.js +2 -0
- package/lib/cjs/src/pki/model/PkiCertificate.js.map +7 -0
- package/lib/cjs/src/pki/model/PkiCertificateInfo.js +2 -0
- package/lib/cjs/src/pki/model/PkiCertificateInfo.js.map +7 -0
- package/lib/cjs/src/shared/model/ClearSignContext.js +1 -1
- package/lib/cjs/src/shared/model/ClearSignContext.js.map +2 -2
- package/lib/cjs/src/shared/model/GenericPath.js +1 -1
- package/lib/cjs/src/shared/model/GenericPath.js.map +1 -1
- package/lib/cjs/src/shared/model/SignatureTags.js +2 -0
- package/lib/cjs/src/shared/model/SignatureTags.js.map +7 -0
- package/lib/cjs/src/shared/model/TransactionContext.js +1 -1
- package/lib/cjs/src/shared/model/TransactionContext.js.map +1 -1
- package/lib/cjs/src/shared/utils/HexStringUtils.js +1 -1
- package/lib/cjs/src/shared/utils/HexStringUtils.js.map +3 -3
- package/lib/cjs/src/shared/utils/HexStringUtils.test.js +2 -0
- package/lib/cjs/src/shared/utils/HexStringUtils.test.js.map +7 -0
- package/lib/cjs/src/shared/utils/KeyUsageMapper.js +2 -0
- package/lib/cjs/src/shared/utils/KeyUsageMapper.js.map +7 -0
- package/lib/cjs/src/shared/utils/KeyUsageMapper.test.js +2 -0
- package/lib/cjs/src/shared/utils/KeyUsageMapper.test.js.map +7 -0
- package/lib/cjs/src/token/data/HttpTokenDataSource.test.js +1 -1
- package/lib/cjs/src/token/data/HttpTokenDataSource.test.js.map +2 -2
- package/lib/cjs/src/token/domain/TokenContextLoader.test.js +1 -1
- package/lib/cjs/src/token/domain/TokenContextLoader.test.js.map +2 -2
- package/lib/cjs/src/transaction/data/CalldataDto.js +1 -1
- package/lib/cjs/src/transaction/data/CalldataDto.js.map +1 -1
- package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js +1 -1
- package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js.map +3 -3
- package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js +1 -1
- package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js.map +3 -3
- package/lib/cjs/src/transaction/data/TransactionDataSource.js +1 -1
- package/lib/cjs/src/transaction/data/TransactionDataSource.js.map +1 -1
- package/lib/cjs/src/transaction/domain/TransactionContextLoader.js +1 -1
- package/lib/cjs/src/transaction/domain/TransactionContextLoader.js.map +2 -2
- package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js +1 -1
- package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js.map +2 -2
- 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/domain/TrustedNameContextLoader.js +1 -1
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js.map +2 -2
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +2 -2
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +2 -2
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +2 -2
- package/lib/cjs/src/uniswap/constants/plugin.js +2 -0
- package/lib/cjs/src/uniswap/constants/plugin.js.map +7 -0
- package/lib/cjs/src/uniswap/constants/uniswap.js +2 -0
- package/lib/cjs/src/uniswap/constants/uniswap.js.map +7 -0
- package/lib/cjs/src/uniswap/constants/weth.js +2 -0
- package/lib/cjs/src/uniswap/constants/weth.js.map +7 -0
- package/lib/cjs/src/uniswap/data/AbiDecoderDataSource.js +2 -0
- package/lib/cjs/src/uniswap/data/AbiDecoderDataSource.js.map +7 -0
- package/lib/cjs/src/uniswap/data/CommandDecoderDataSource.js +2 -0
- package/lib/cjs/src/uniswap/data/CommandDecoderDataSource.js.map +7 -0
- package/lib/cjs/src/uniswap/data/DefaultCommandDecoderDataSource.js +2 -0
- package/lib/cjs/src/uniswap/data/DefaultCommandDecoderDataSource.js.map +7 -0
- package/lib/cjs/src/uniswap/data/DefaultCommandDecoderDataSource.test.js +2 -0
- package/lib/cjs/src/uniswap/data/DefaultCommandDecoderDataSource.test.js.map +7 -0
- package/lib/cjs/src/uniswap/data/EthersAbiDecoderDataSource.js +2 -0
- package/lib/cjs/src/uniswap/data/EthersAbiDecoderDataSource.js.map +7 -0
- package/lib/cjs/src/uniswap/data/EthersAbiDecoderDataSource.test.js +2 -0
- package/lib/cjs/src/uniswap/data/EthersAbiDecoderDataSource.test.js.map +7 -0
- package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js +2 -0
- package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js.map +7 -0
- package/lib/cjs/src/uniswap/di/uniswapTypes.js +2 -0
- package/lib/cjs/src/uniswap/di/uniswapTypes.js.map +7 -0
- package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js +2 -0
- package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js.map +7 -0
- package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js +2 -0
- package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js.map +7 -0
- package/lib/esm/package.json +8 -7
- package/lib/esm/src/ContextModuleBuilder.test.js +1 -1
- package/lib/esm/src/ContextModuleBuilder.test.js.map +2 -2
- 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 +2 -2
- package/lib/esm/src/di.js +1 -1
- package/lib/esm/src/di.js.map +3 -3
- package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
- package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +2 -2
- package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
- package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +2 -2
- package/lib/esm/src/index.js +1 -1
- package/lib/esm/src/index.js.map +2 -2
- package/lib/esm/src/nft/data/HttpNftDataSource.test.js +1 -1
- package/lib/esm/src/nft/data/HttpNftDataSource.test.js.map +2 -2
- package/lib/esm/src/nft/domain/NftContextLoader.test.js +1 -1
- package/lib/esm/src/nft/domain/NftContextLoader.test.js.map +2 -2
- package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.js +2 -0
- package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.js.map +7 -0
- package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.test.js +2 -0
- package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.test.js.map +7 -0
- package/lib/esm/src/pki/data/PkiCertificateDataSource.js +1 -0
- package/lib/esm/src/pki/data/PkiCertificateDataSource.js.map +7 -0
- package/lib/esm/src/pki/data/pkiDataSourceTypes.js +1 -0
- package/lib/esm/src/pki/data/pkiDataSourceTypes.js.map +7 -0
- package/lib/esm/src/pki/di/pkiModuleFactory.js +2 -0
- package/lib/esm/src/pki/di/pkiModuleFactory.js.map +7 -0
- package/lib/esm/src/pki/di/pkiTypes.js +2 -0
- package/lib/esm/src/pki/di/pkiTypes.js.map +7 -0
- package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.js +2 -0
- package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.js.map +7 -0
- package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js +2 -0
- package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +7 -0
- package/lib/esm/src/pki/domain/PkiCertificateLoader.js +1 -0
- package/lib/esm/src/pki/domain/PkiCertificateLoader.js.map +7 -0
- package/lib/esm/src/pki/model/KeyId.js +2 -0
- package/lib/esm/src/pki/model/KeyId.js.map +7 -0
- package/lib/esm/src/pki/model/KeyUsage.js +2 -0
- package/lib/esm/src/pki/model/KeyUsage.js.map +7 -0
- package/lib/esm/src/pki/model/PkiCertificate.js +1 -0
- package/lib/esm/src/pki/model/PkiCertificate.js.map +7 -0
- package/lib/esm/src/pki/model/PkiCertificateInfo.js +1 -0
- package/lib/esm/src/pki/model/PkiCertificateInfo.js.map +7 -0
- package/lib/esm/src/shared/model/ClearSignContext.js +1 -1
- package/lib/esm/src/shared/model/ClearSignContext.js.map +2 -2
- package/lib/esm/src/shared/model/GenericPath.js.map +1 -1
- package/lib/esm/src/shared/model/SignatureTags.js +2 -0
- package/lib/esm/src/shared/model/SignatureTags.js.map +7 -0
- package/lib/esm/src/shared/utils/HexStringUtils.js +1 -1
- package/lib/esm/src/shared/utils/HexStringUtils.js.map +3 -3
- package/lib/esm/src/shared/utils/HexStringUtils.test.js +2 -0
- package/lib/esm/src/shared/utils/HexStringUtils.test.js.map +7 -0
- package/lib/esm/src/shared/utils/KeyUsageMapper.js +2 -0
- package/lib/esm/src/shared/utils/KeyUsageMapper.js.map +7 -0
- package/lib/esm/src/shared/utils/KeyUsageMapper.test.js +2 -0
- package/lib/esm/src/shared/utils/KeyUsageMapper.test.js.map +7 -0
- package/lib/esm/src/token/data/HttpTokenDataSource.test.js +1 -1
- package/lib/esm/src/token/data/HttpTokenDataSource.test.js.map +2 -2
- package/lib/esm/src/token/domain/TokenContextLoader.test.js +1 -1
- package/lib/esm/src/token/domain/TokenContextLoader.test.js.map +2 -2
- package/lib/esm/src/transaction/data/HttpTransactionDataSource.js +1 -1
- package/lib/esm/src/transaction/data/HttpTransactionDataSource.js.map +3 -3
- package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js +1 -1
- package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js.map +3 -3
- package/lib/esm/src/transaction/domain/TransactionContextLoader.js +1 -1
- package/lib/esm/src/transaction/domain/TransactionContextLoader.js.map +2 -2
- package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js +1 -1
- package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js.map +2 -2
- 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/domain/TrustedNameContextLoader.js +1 -1
- package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js.map +2 -2
- package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
- package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +2 -2
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +2 -2
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +2 -2
- package/lib/esm/src/uniswap/constants/plugin.js +2 -0
- package/lib/esm/src/uniswap/constants/plugin.js.map +7 -0
- package/lib/esm/src/uniswap/constants/uniswap.js +2 -0
- package/lib/esm/src/uniswap/constants/uniswap.js.map +7 -0
- package/lib/esm/src/uniswap/constants/weth.js +2 -0
- package/lib/esm/src/uniswap/constants/weth.js.map +7 -0
- package/lib/esm/src/uniswap/data/AbiDecoderDataSource.js +1 -0
- package/lib/esm/src/uniswap/data/AbiDecoderDataSource.js.map +7 -0
- package/lib/esm/src/uniswap/data/CommandDecoderDataSource.js +1 -0
- package/lib/esm/src/uniswap/data/CommandDecoderDataSource.js.map +7 -0
- package/lib/esm/src/uniswap/data/DefaultCommandDecoderDataSource.js +2 -0
- package/lib/esm/src/uniswap/data/DefaultCommandDecoderDataSource.js.map +7 -0
- package/lib/esm/src/uniswap/data/DefaultCommandDecoderDataSource.test.js +2 -0
- package/lib/esm/src/uniswap/data/DefaultCommandDecoderDataSource.test.js.map +7 -0
- package/lib/esm/src/uniswap/data/EthersAbiDecoderDataSource.js +2 -0
- package/lib/esm/src/uniswap/data/EthersAbiDecoderDataSource.js.map +7 -0
- package/lib/esm/src/uniswap/data/EthersAbiDecoderDataSource.test.js +2 -0
- package/lib/esm/src/uniswap/data/EthersAbiDecoderDataSource.test.js.map +7 -0
- package/lib/esm/src/uniswap/di/uniswapModuleFactory.js +2 -0
- package/lib/esm/src/uniswap/di/uniswapModuleFactory.js.map +7 -0
- package/lib/esm/src/uniswap/di/uniswapTypes.js +2 -0
- package/lib/esm/src/uniswap/di/uniswapTypes.js.map +7 -0
- package/lib/esm/src/uniswap/domain/UniswapContextLoader.js +2 -0
- package/lib/esm/src/uniswap/domain/UniswapContextLoader.js.map +7 -0
- package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js +2 -0
- package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js.map +7 -0
- package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
- package/lib/types/src/di.d.ts.map +1 -1
- package/lib/types/src/index.d.ts +5 -0
- package/lib/types/src/index.d.ts.map +1 -1
- package/lib/types/src/pki/data/HttpPkiCertificateDataSource.d.ts +12 -0
- package/lib/types/src/pki/data/HttpPkiCertificateDataSource.d.ts.map +1 -0
- package/lib/types/src/pki/data/HttpPkiCertificateDataSource.test.d.ts +2 -0
- package/lib/types/src/pki/data/HttpPkiCertificateDataSource.test.d.ts.map +1 -0
- package/lib/types/src/pki/data/PkiCertificateDataSource.d.ts +7 -0
- package/lib/types/src/pki/data/PkiCertificateDataSource.d.ts.map +1 -0
- package/lib/types/src/pki/data/pkiDataSourceTypes.d.ts +23 -0
- package/lib/types/src/pki/data/pkiDataSourceTypes.d.ts.map +1 -0
- package/lib/types/src/pki/di/pkiModuleFactory.d.ts +3 -0
- package/lib/types/src/pki/di/pkiModuleFactory.d.ts.map +1 -0
- package/lib/types/src/pki/di/pkiTypes.d.ts +5 -0
- package/lib/types/src/pki/di/pkiTypes.d.ts.map +1 -0
- package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.d.ts +10 -0
- package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.d.ts.map +1 -0
- package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.test.d.ts +2 -0
- package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.test.d.ts.map +1 -0
- package/lib/types/src/pki/domain/PkiCertificateLoader.d.ts +6 -0
- package/lib/types/src/pki/domain/PkiCertificateLoader.d.ts.map +1 -0
- package/lib/types/src/pki/model/KeyId.d.ts +14 -0
- package/lib/types/src/pki/model/KeyId.d.ts.map +1 -0
- package/lib/types/src/pki/model/KeyUsage.d.ts +15 -0
- package/lib/types/src/pki/model/KeyUsage.d.ts.map +1 -0
- package/lib/types/src/pki/model/PkiCertificate.d.ts +5 -0
- package/lib/types/src/pki/model/PkiCertificate.d.ts.map +1 -0
- package/lib/types/src/pki/model/PkiCertificateInfo.d.ts +7 -0
- package/lib/types/src/pki/model/PkiCertificateInfo.d.ts.map +1 -0
- package/lib/types/src/shared/model/ClearSignContext.d.ts +24 -13
- package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
- package/lib/types/src/shared/model/GenericPath.d.ts +2 -2
- package/lib/types/src/shared/model/GenericPath.d.ts.map +1 -1
- package/lib/types/src/shared/model/SignatureTags.d.ts +3 -0
- package/lib/types/src/shared/model/SignatureTags.d.ts.map +1 -0
- package/lib/types/src/shared/model/TransactionContext.d.ts +3 -1
- package/lib/types/src/shared/model/TransactionContext.d.ts.map +1 -1
- package/lib/types/src/shared/utils/HexStringUtils.d.ts +1 -0
- package/lib/types/src/shared/utils/HexStringUtils.d.ts.map +1 -1
- package/lib/types/src/shared/utils/HexStringUtils.test.d.ts +2 -0
- package/lib/types/src/shared/utils/HexStringUtils.test.d.ts.map +1 -0
- package/lib/types/src/shared/utils/KeyUsageMapper.d.ts +6 -0
- package/lib/types/src/shared/utils/KeyUsageMapper.d.ts.map +1 -0
- package/lib/types/src/shared/utils/KeyUsageMapper.test.d.ts +2 -0
- package/lib/types/src/shared/utils/KeyUsageMapper.test.d.ts.map +1 -0
- package/lib/types/src/transaction/data/CalldataDto.d.ts +15 -4
- package/lib/types/src/transaction/data/CalldataDto.d.ts.map +1 -1
- package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts +8 -4
- package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts.map +1 -1
- package/lib/types/src/transaction/data/TransactionDataSource.d.ts +2 -1
- package/lib/types/src/transaction/data/TransactionDataSource.d.ts.map +1 -1
- package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts.map +1 -1
- package/lib/types/src/uniswap/constants/plugin.d.ts +3 -0
- package/lib/types/src/uniswap/constants/plugin.d.ts.map +1 -0
- package/lib/types/src/uniswap/constants/uniswap.d.ts +21 -0
- package/lib/types/src/uniswap/constants/uniswap.d.ts.map +1 -0
- package/lib/types/src/uniswap/constants/weth.d.ts +20 -0
- package/lib/types/src/uniswap/constants/weth.d.ts.map +1 -0
- package/lib/types/src/uniswap/data/AbiDecoderDataSource.d.ts +5 -0
- package/lib/types/src/uniswap/data/AbiDecoderDataSource.d.ts.map +1 -0
- package/lib/types/src/uniswap/data/CommandDecoderDataSource.d.ts +6 -0
- package/lib/types/src/uniswap/data/CommandDecoderDataSource.d.ts.map +1 -0
- package/lib/types/src/uniswap/data/DefaultCommandDecoderDataSource.d.ts +14 -0
- package/lib/types/src/uniswap/data/DefaultCommandDecoderDataSource.d.ts.map +1 -0
- package/lib/types/src/uniswap/data/DefaultCommandDecoderDataSource.test.d.ts +2 -0
- package/lib/types/src/uniswap/data/DefaultCommandDecoderDataSource.test.d.ts.map +1 -0
- package/lib/types/src/uniswap/data/EthersAbiDecoderDataSource.d.ts +5 -0
- package/lib/types/src/uniswap/data/EthersAbiDecoderDataSource.d.ts.map +1 -0
- package/lib/types/src/uniswap/data/EthersAbiDecoderDataSource.test.d.ts +2 -0
- package/lib/types/src/uniswap/data/EthersAbiDecoderDataSource.test.d.ts.map +1 -0
- package/lib/types/src/uniswap/di/uniswapModuleFactory.d.ts +3 -0
- package/lib/types/src/uniswap/di/uniswapModuleFactory.d.ts.map +1 -0
- package/lib/types/src/uniswap/di/uniswapTypes.d.ts +6 -0
- package/lib/types/src/uniswap/di/uniswapTypes.d.ts.map +1 -0
- package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts +105 -0
- package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts.map +1 -0
- package/lib/types/src/uniswap/domain/UniswapContextLoader.test.d.ts +2 -0
- package/lib/types/src/uniswap/domain/UniswapContextLoader.test.d.ts.map +1 -0
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +10 -9
package/lib/cjs/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/context-module",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"private": false,
|
|
4
5
|
"license": "Apache-2.0",
|
|
5
6
|
"exports": {
|
|
6
7
|
".": {
|
|
@@ -28,18 +29,18 @@
|
|
|
28
29
|
"postpack": "find . -name '*.tgz' -exec cp {} ../../../dist/ \\; ",
|
|
29
30
|
"prettier": "prettier . --check",
|
|
30
31
|
"prettier:fix": "prettier . --write",
|
|
31
|
-
"test": "
|
|
32
|
-
"test:watch": "
|
|
33
|
-
"test:coverage": "
|
|
32
|
+
"test": "vitest run",
|
|
33
|
+
"test:watch": "vitest",
|
|
34
|
+
"test:coverage": "vitest run --coverage",
|
|
34
35
|
"typecheck": "tsc --noEmit"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@ledgerhq/device-management-kit": "workspace:*",
|
|
38
39
|
"@ledgerhq/esbuild-tools": "workspace:*",
|
|
39
40
|
"@ledgerhq/eslint-config-dsdk": "workspace:*",
|
|
40
|
-
"@ledgerhq/jest-config-dsdk": "workspace:*",
|
|
41
41
|
"@ledgerhq/prettier-config-dsdk": "workspace:*",
|
|
42
42
|
"@ledgerhq/tsconfig-dsdk": "workspace:*",
|
|
43
|
+
"@ledgerhq/vitest-config-dmk": "workspace:*",
|
|
43
44
|
"@types/crypto-js": "^4.2.2",
|
|
44
45
|
"ts-node": "^10.9.2"
|
|
45
46
|
},
|
|
@@ -47,11 +48,11 @@
|
|
|
47
48
|
"axios": "^1.7.9",
|
|
48
49
|
"crypto-js": "^4.2.0",
|
|
49
50
|
"ethers": "6.13.4",
|
|
50
|
-
"inversify": "^6.
|
|
51
|
+
"inversify": "^6.2.2",
|
|
51
52
|
"purify-ts": "^2.1.0",
|
|
52
53
|
"reflect-metadata": "^0.2.2"
|
|
53
54
|
},
|
|
54
55
|
"peerDependencies": {
|
|
55
|
-
"@ledgerhq/device-management-kit": "
|
|
56
|
+
"@ledgerhq/device-management-kit": "workspace:*"
|
|
56
57
|
}
|
|
57
58
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var o=require("./ContextModuleBuilder"),d=require("./DefaultContextModule");describe("ContextModuleBuilder",()=>{const u={url:"https://crypto-assets-service.api.ledger.com/v1",mode:"prod",branch:"main"};it("should return a default context module",()=>{const e=new o.ContextModuleBuilder().build();expect(e).toBeInstanceOf(d.DefaultContextModule)}),it("should return a custom context module",()=>{const t=new o.ContextModuleBuilder,e={load:
|
|
1
|
+
"use strict";var o=require("./ContextModuleBuilder"),d=require("./DefaultContextModule");describe("ContextModuleBuilder",()=>{const u={url:"https://crypto-assets-service.api.ledger.com/v1",mode:"prod",branch:"main"};it("should return a default context module",()=>{const e=new o.ContextModuleBuilder().build();expect(e).toBeInstanceOf(d.DefaultContextModule)}),it("should return a custom context module",()=>{const t=new o.ContextModuleBuilder,e={load:vi.fn()},n=t.removeDefaultLoaders().addLoader(e).build();expect(n).toBeInstanceOf(d.DefaultContextModule)}),it("should return a custom context module with a custom typed data loader",()=>{const t=new o.ContextModuleBuilder,e={load:vi.fn()},n=t.removeDefaultLoaders().addTypedDataLoader(e).build();expect(n).toBeInstanceOf(d.DefaultContextModule)}),it("should return a custom context module with a custom config",()=>{const e=new o.ContextModuleBuilder().addCalConfig(u).build();expect(e).toBeInstanceOf(d.DefaultContextModule)})});
|
|
2
2
|
//# sourceMappingURL=ContextModuleBuilder.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/ContextModuleBuilder.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { type ContextModuleCalConfig } from \"./config/model/ContextModuleConfig\";\nimport { ContextModuleBuilder } from \"./ContextModuleBuilder\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\ndescribe(\"ContextModuleBuilder\", () => {\n const defaultCalConfig: ContextModuleCalConfig = {\n url: \"https://crypto-assets-service.api.ledger.com/v1\",\n mode: \"prod\",\n branch: \"main\",\n };\n it(\"should return a default context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\n\n const res = contextModuleBuilder.build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\n const customLoader = { load:
|
|
5
|
-
"mappings": "aACA,IAAAA,EAAqC,kCACrCC,EAAqC,kCAErC,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA2C,CAC/C,IAAK,kDACL,KAAM,OACN,OAAQ,MACV,EACA,GAAG,yCAA0C,IAAM,CAGjD,MAAMC,EAFuB,IAAI,uBAAqB,EAErB,MAAM,EAEvC,OAAOA,CAAG,EAAE,eAAe,sBAAoB,CACjD,CAAC,EAED,GAAG,wCAAyC,IAAM,CAChD,MAAMC,EAAuB,IAAI,uBAC3BC,EAAe,CAAE,KAAM,
|
|
4
|
+
"sourcesContent": ["import { type ContextModuleCalConfig } from \"./config/model/ContextModuleConfig\";\nimport { ContextModuleBuilder } from \"./ContextModuleBuilder\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\ndescribe(\"ContextModuleBuilder\", () => {\n const defaultCalConfig: ContextModuleCalConfig = {\n url: \"https://crypto-assets-service.api.ledger.com/v1\",\n mode: \"prod\",\n branch: \"main\",\n };\n it(\"should return a default context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\n\n const res = contextModuleBuilder.build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\n const customLoader = { load: vi.fn() };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module with a custom typed data loader\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\n const customLoader = { load: vi.fn() };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addTypedDataLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module with a custom config\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\n\n const res = contextModuleBuilder.addCalConfig(defaultCalConfig).build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n});\n"],
|
|
5
|
+
"mappings": "aACA,IAAAA,EAAqC,kCACrCC,EAAqC,kCAErC,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA2C,CAC/C,IAAK,kDACL,KAAM,OACN,OAAQ,MACV,EACA,GAAG,yCAA0C,IAAM,CAGjD,MAAMC,EAFuB,IAAI,uBAAqB,EAErB,MAAM,EAEvC,OAAOA,CAAG,EAAE,eAAe,sBAAoB,CACjD,CAAC,EAED,GAAG,wCAAyC,IAAM,CAChD,MAAMC,EAAuB,IAAI,uBAC3BC,EAAe,CAAE,KAAM,GAAG,GAAG,CAAE,EAE/BF,EAAMC,EACT,qBAAqB,EACrB,UAAUC,CAAY,EACtB,MAAM,EAET,OAAOF,CAAG,EAAE,eAAe,sBAAoB,CACjD,CAAC,EAED,GAAG,wEAAyE,IAAM,CAChF,MAAMC,EAAuB,IAAI,uBAC3BC,EAAe,CAAE,KAAM,GAAG,GAAG,CAAE,EAE/BF,EAAMC,EACT,qBAAqB,EACrB,mBAAmBC,CAAY,EAC/B,MAAM,EAET,OAAOF,CAAG,EAAE,eAAe,sBAAoB,CACjD,CAAC,EAED,GAAG,6DAA8D,IAAM,CAGrE,MAAMA,EAFuB,IAAI,uBAAqB,EAErB,aAAaD,CAAgB,EAAE,MAAM,EAEtE,OAAOC,CAAG,EAAE,eAAe,sBAAoB,CACjD,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_ContextModuleBuilder", "import_DefaultContextModule", "defaultCalConfig", "res", "contextModuleBuilder", "customLoader"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var n=Object.defineProperty;var
|
|
1
|
+
"use strict";var n=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var u=(o,t)=>{for(var a in t)n(o,a,{get:t[a],enumerable:!0})},c=(o,t,a,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of L(t))!T.call(o,e)&&e!==a&&n(o,e,{get:()=>t[e],enumerable:!(r=f(t,e))||r.enumerable});return o};var g=o=>c(n({},"__esModule",{value:!0}),o);var _={};u(_,{DefaultContextModule:()=>D});module.exports=g(_);var i=require("./transaction/di/transactionTypes"),p=require("./trusted-name/di/trustedNameTypes"),d=require("./external-plugin/di/externalPluginTypes"),s=require("./nft/di/nftTypes"),m=require("./shared/model/ClearSignContext"),C=require("./token/di/tokenTypes"),l=require("./typed-data/di/typedDataTypes"),x=require("./uniswap/di/uniswapTypes"),y=require("./di");class D{_container;_loaders;_typedDataLoader;constructor(t){this._container=(0,y.makeContainer)({config:t}),this._loaders=t.defaultLoaders?this._getDefaultLoaders():[],this._loaders.push(...t.customLoaders),this._typedDataLoader=t.customTypedDataLoader??this._getDefaultTypedDataLoader()}_getDefaultLoaders(){return[this._container.get(d.externalPluginTypes.ExternalPluginContextLoader),this._container.get(p.trustedNameTypes.TrustedNameContextLoader),this._container.get(s.nftTypes.NftContextLoader),this._container.get(C.tokenTypes.TokenContextLoader),this._container.get(i.transactionTypes.TransactionContextLoader),this._container.get(x.uniswapTypes.UniswapContextLoader)]}_getDefaultTypedDataLoader(){return this._container.get(l.typedDataTypes.TypedDataContextLoader)}async getContexts(t){const a=this._loaders.map(e=>e.load(t));return(await Promise.all(a)).flat()}async getContext(t){const a=this._loaders.filter(e=>e.loadField).map(e=>e.loadField(t));return(await Promise.all(a)).find(e=>e!==null)||{type:m.ClearSignContextType.ERROR,error:new Error(`Field type not supported: ${t.type}`)}}async getTypedDataFilters(t){return this._typedDataLoader.load(t)}}0&&(module.exports={DefaultContextModule});
|
|
2
2
|
//# sourceMappingURL=DefaultContextModule.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/DefaultContextModule.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Container } from \"inversify\";\n\nimport type { TypedDataClearSignContext } from \"@/shared/model/TypedDataClearSignContext\";\nimport type { TypedDataContext } from \"@/shared/model/TypedDataContext\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\nimport { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { externalPluginTypes } from \"./external-plugin/di/externalPluginTypes\";\nimport { type ExternalPluginContextLoader } from \"./external-plugin/domain/ExternalPluginContextLoader\";\nimport { nftTypes } from \"./nft/di/nftTypes\";\nimport { type NftContextLoader } from \"./nft/domain/NftContextLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"./shared/model/TransactionContext\";\nimport { tokenTypes } from \"./token/di/tokenTypes\";\nimport { type TokenContextLoader } from \"./token/domain/TokenContextLoader\";\nimport { type TransactionContextLoader } from \"./transaction/domain/TransactionContextLoader\";\nimport { type TrustedNameContextLoader } from \"./trusted-name/domain/TrustedNameContextLoader\";\nimport { typedDataTypes } from \"./typed-data/di/typedDataTypes\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { makeContainer } from \"./di\";\n\nexport class DefaultContextModule implements ContextModule {\n private _container: Container;\n private _loaders: ContextLoader[];\n private _typedDataLoader: TypedDataContextLoader;\n\n constructor(args: ContextModuleConfig) {\n this._container = makeContainer({ config: args });\n this._loaders = args.defaultLoaders ? this._getDefaultLoaders() : [];\n this._loaders.push(...args.customLoaders);\n this._typedDataLoader =\n args.customTypedDataLoader ?? this._getDefaultTypedDataLoader();\n }\n\n private _getDefaultLoaders(): ContextLoader[] {\n return [\n this._container.get<ExternalPluginContextLoader>(\n externalPluginTypes.ExternalPluginContextLoader,\n ),\n this._container.get<TrustedNameContextLoader>(\n trustedNameTypes.TrustedNameContextLoader,\n ),\n this._container.get<NftContextLoader>(nftTypes.NftContextLoader),\n this._container.get<TokenContextLoader>(tokenTypes.TokenContextLoader),\n this._container.get<TransactionContextLoader>(\n transactionTypes.TransactionContextLoader,\n ),\n ];\n }\n\n private _getDefaultTypedDataLoader(): TypedDataContextLoader {\n return this._container.get<TypedDataContextLoader>(\n typedDataTypes.TypedDataContextLoader,\n );\n }\n\n public async getContexts(\n transaction: TransactionContext,\n ): Promise<ClearSignContext[]> {\n const promises = this._loaders.map((fetcher) => fetcher.load(transaction));\n const responses = await Promise.all(promises);\n return responses.flat();\n }\n\n public async getContext(\n field: TransactionFieldContext,\n ): Promise<ClearSignContext> {\n const promises = this._loaders\n .filter((fetcher) => fetcher.loadField)\n .map((fetcher) => fetcher.loadField!(field));\n const responses = await Promise.all(promises);\n return (\n responses.find((resp) => resp !== null) || {\n type: ClearSignContextType.ERROR,\n error: new Error(`Field type not supported: ${field.type}`),\n }\n );\n }\n\n public async getTypedDataFilters(\n typedData: TypedDataContext,\n ): Promise<TypedDataClearSignContext> {\n return this._typedDataLoader.load(typedData);\n }\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GAIA,IAAAI,EAAiC,6CACjCC,EAAiC,8CAGjCC,EAAoC,oDAEpCC,EAAyB,6BAGzBC,EAGO,2CAKPC,EAA2B,iCAI3BC,EAA+B,
|
|
6
|
-
"names": ["DefaultContextModule_exports", "__export", "DefaultContextModule", "__toCommonJS", "import_transactionTypes", "import_trustedNameTypes", "import_externalPluginTypes", "import_nftTypes", "import_ClearSignContext", "import_tokenTypes", "import_typedDataTypes", "import_di", "args", "transaction", "promises", "fetcher", "field", "resp", "typedData"]
|
|
4
|
+
"sourcesContent": ["import { type Container } from \"inversify\";\n\nimport type { TypedDataClearSignContext } from \"@/shared/model/TypedDataClearSignContext\";\nimport type { TypedDataContext } from \"@/shared/model/TypedDataContext\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\nimport { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { externalPluginTypes } from \"./external-plugin/di/externalPluginTypes\";\nimport { type ExternalPluginContextLoader } from \"./external-plugin/domain/ExternalPluginContextLoader\";\nimport { nftTypes } from \"./nft/di/nftTypes\";\nimport { type NftContextLoader } from \"./nft/domain/NftContextLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"./shared/model/TransactionContext\";\nimport { tokenTypes } from \"./token/di/tokenTypes\";\nimport { type TokenContextLoader } from \"./token/domain/TokenContextLoader\";\nimport { type TransactionContextLoader } from \"./transaction/domain/TransactionContextLoader\";\nimport { type TrustedNameContextLoader } from \"./trusted-name/domain/TrustedNameContextLoader\";\nimport { typedDataTypes } from \"./typed-data/di/typedDataTypes\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { uniswapTypes } from \"./uniswap/di/uniswapTypes\";\nimport { type UniswapContextLoader } from \"./uniswap/domain/UniswapContextLoader\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { makeContainer } from \"./di\";\n\nexport class DefaultContextModule implements ContextModule {\n private _container: Container;\n private _loaders: ContextLoader[];\n private _typedDataLoader: TypedDataContextLoader;\n\n constructor(args: ContextModuleConfig) {\n this._container = makeContainer({ config: args });\n this._loaders = args.defaultLoaders ? this._getDefaultLoaders() : [];\n this._loaders.push(...args.customLoaders);\n this._typedDataLoader =\n args.customTypedDataLoader ?? this._getDefaultTypedDataLoader();\n }\n\n private _getDefaultLoaders(): ContextLoader[] {\n return [\n this._container.get<ExternalPluginContextLoader>(\n externalPluginTypes.ExternalPluginContextLoader,\n ),\n this._container.get<TrustedNameContextLoader>(\n trustedNameTypes.TrustedNameContextLoader,\n ),\n this._container.get<NftContextLoader>(nftTypes.NftContextLoader),\n this._container.get<TokenContextLoader>(tokenTypes.TokenContextLoader),\n this._container.get<TransactionContextLoader>(\n transactionTypes.TransactionContextLoader,\n ),\n this._container.get<UniswapContextLoader>(\n uniswapTypes.UniswapContextLoader,\n ),\n ];\n }\n\n private _getDefaultTypedDataLoader(): TypedDataContextLoader {\n return this._container.get<TypedDataContextLoader>(\n typedDataTypes.TypedDataContextLoader,\n );\n }\n\n public async getContexts(\n transaction: TransactionContext,\n ): Promise<ClearSignContext[]> {\n const promises = this._loaders.map((fetcher) => fetcher.load(transaction));\n const responses = await Promise.all(promises);\n return responses.flat();\n }\n\n public async getContext(\n field: TransactionFieldContext,\n ): Promise<ClearSignContext> {\n const promises = this._loaders\n .filter((fetcher) => fetcher.loadField)\n .map((fetcher) => fetcher.loadField!(field));\n const responses = await Promise.all(promises);\n return (\n responses.find((resp) => resp !== null) || {\n type: ClearSignContextType.ERROR,\n error: new Error(`Field type not supported: ${field.type}`),\n }\n );\n }\n\n public async getTypedDataFilters(\n typedData: TypedDataContext,\n ): Promise<TypedDataClearSignContext> {\n return this._typedDataLoader.load(typedData);\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GAIA,IAAAI,EAAiC,6CACjCC,EAAiC,8CAGjCC,EAAoC,oDAEpCC,EAAyB,6BAGzBC,EAGO,2CAKPC,EAA2B,iCAI3BC,EAA+B,0CAE/BC,EAA6B,qCAG7BC,EAA8B,gBAEvB,MAAMV,CAA8C,CACjD,WACA,SACA,iBAER,YAAYW,EAA2B,CACrC,KAAK,cAAa,iBAAc,CAAE,OAAQA,CAAK,CAAC,EAChD,KAAK,SAAWA,EAAK,eAAiB,KAAK,mBAAmB,EAAI,CAAC,EACnE,KAAK,SAAS,KAAK,GAAGA,EAAK,aAAa,EACxC,KAAK,iBACHA,EAAK,uBAAyB,KAAK,2BAA2B,CAClE,CAEQ,oBAAsC,CAC5C,MAAO,CACL,KAAK,WAAW,IACd,sBAAoB,2BACtB,EACA,KAAK,WAAW,IACd,mBAAiB,wBACnB,EACA,KAAK,WAAW,IAAsB,WAAS,gBAAgB,EAC/D,KAAK,WAAW,IAAwB,aAAW,kBAAkB,EACrE,KAAK,WAAW,IACd,mBAAiB,wBACnB,EACA,KAAK,WAAW,IACd,eAAa,oBACf,CACF,CACF,CAEQ,4BAAqD,CAC3D,OAAO,KAAK,WAAW,IACrB,iBAAe,sBACjB,CACF,CAEA,MAAa,YACXC,EAC6B,CAC7B,MAAMC,EAAW,KAAK,SAAS,IAAKC,GAAYA,EAAQ,KAAKF,CAAW,CAAC,EAEzE,OADkB,MAAM,QAAQ,IAAIC,CAAQ,GAC3B,KAAK,CACxB,CAEA,MAAa,WACXE,EAC2B,CAC3B,MAAMF,EAAW,KAAK,SACnB,OAAQC,GAAYA,EAAQ,SAAS,EACrC,IAAKA,GAAYA,EAAQ,UAAWC,CAAK,CAAC,EAE7C,OADkB,MAAM,QAAQ,IAAIF,CAAQ,GAEhC,KAAMG,GAASA,IAAS,IAAI,GAAK,CACzC,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,6BAA6BD,EAAM,IAAI,EAAE,CAC5D,CAEJ,CAEA,MAAa,oBACXE,EACoC,CACpC,OAAO,KAAK,iBAAiB,KAAKA,CAAS,CAC7C,CACF",
|
|
6
|
+
"names": ["DefaultContextModule_exports", "__export", "DefaultContextModule", "__toCommonJS", "import_transactionTypes", "import_trustedNameTypes", "import_externalPluginTypes", "import_nftTypes", "import_ClearSignContext", "import_tokenTypes", "import_typedDataTypes", "import_uniswapTypes", "import_di", "args", "transaction", "promises", "fetcher", "field", "resp", "typedData"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var o=require("./DefaultContextModule");const l=()=>({load:
|
|
1
|
+
"use strict";var o=require("./DefaultContextModule");const l=()=>({load:vi.fn(),loadField:vi.fn()});describe("DefaultContextModule",()=>{const d={load:vi.fn()},a={customLoaders:[],defaultLoaders:!1,customTypedDataLoader:d,cal:{url:"https://crypto-assets-service.api.ledger.com/v1",mode:"prod",branch:"main"}};beforeEach(()=>{vi.restoreAllMocks()}),it("should initialize the context module with all the default loaders",async()=>{const t=await new o.DefaultContextModule(a).getContexts({});expect(t).toEqual([])}),it("should return an empty array when no loaders",async()=>{const t=await new o.DefaultContextModule(a).getContexts({});expect(t).toEqual([])}),it("should call all fetch method from metadata fetcher",async()=>{const e=l();await new o.DefaultContextModule({...a,customLoaders:[e,e]}).getContexts({}),expect(e.load).toHaveBeenCalledTimes(2)}),it("should return an array of context response",async()=>{const e=l(),t=[[{type:"provideERC20Info",payload:"payload1"}],[{type:"provideERC20Info",payload:"payload2"},{type:"plugin",payload:"payload3"}]];vi.spyOn(e,"load").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const n=await new o.DefaultContextModule({...a,customLoaders:[e,e]}).getContexts({});expect(e.load).toHaveBeenCalledTimes(2),expect(n).toEqual(t.flat())}),it("should call the typed data loader",async()=>{await new o.DefaultContextModule({...a,customTypedDataLoader:d}).getTypedDataFilters({}),expect(d.load).toHaveBeenCalledTimes(1)}),it("should return a single context",async()=>{const e=l(),t=[null,{type:"token",payload:"payload"}];vi.spyOn(e,"loadField").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const n=await new o.DefaultContextModule({...a,customLoaders:[e,{load:vi.fn()},e]}).getContext({type:"token"});expect(e.loadField).toHaveBeenCalledTimes(2),expect(n).toEqual({type:"token",payload:"payload"})}),it("context field not supported",async()=>{const e=l(),t=[null,null];vi.spyOn(e,"loadField").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const n=await new o.DefaultContextModule({...a,customLoaders:[e,{load:vi.fn()},e]}).getContext({type:"token"});expect(e.loadField).toHaveBeenCalledTimes(2),expect(n).toEqual({type:"error",error:new Error("Field type not supported: token")})}),it("getField not implemented",async()=>{const t=await new o.DefaultContextModule({...a,customLoaders:[{load:vi.fn()}]}).getContext({type:"token"});expect(t).toEqual({type:"error",error:new Error("Field type not supported: token")})})});
|
|
2
2
|
//# sourceMappingURL=DefaultContextModule.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/DefaultContextModule.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"./shared/model/TransactionContext\";\nimport { type TypedDataContext } from \"./shared/model/TypedDataContext\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst contextLoaderStubBuilder = () => {\n return { load:
|
|
5
|
-
"mappings": "aAOA,IAAAA,EAAqC,kCAErC,MAAMC,EAA2B,KACxB,CAAE,KAAM,
|
|
4
|
+
"sourcesContent": ["import { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"./shared/model/TransactionContext\";\nimport { type TypedDataContext } from \"./shared/model/TypedDataContext\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst contextLoaderStubBuilder = () => {\n return { load: vi.fn(), loadField: vi.fn() };\n};\n\ndescribe(\"DefaultContextModule\", () => {\n const typedDataLoader: TypedDataContextLoader = { load: vi.fn() };\n const defaultContextModuleConfig: ContextModuleConfig = {\n customLoaders: [],\n defaultLoaders: false,\n customTypedDataLoader: typedDataLoader,\n cal: {\n url: \"https://crypto-assets-service.api.ledger.com/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n };\n\n beforeEach(() => {\n vi.restoreAllMocks();\n });\n\n it(\"should initialize the context module with all the default loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({} as TransactionContext);\n\n expect(res).toEqual([]);\n });\n\n it(\"should return an empty array when no loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({} as TransactionContext);\n\n expect(res).toEqual([]);\n });\n\n it(\"should call all fetch method from metadata fetcher\", async () => {\n const loader = contextLoaderStubBuilder();\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n await contextModule.getContexts({} as TransactionContext);\n\n expect(loader.load).toHaveBeenCalledTimes(2);\n });\n\n it(\"should return an array of context response\", async () => {\n const loader = contextLoaderStubBuilder();\n const responses = [\n [{ type: \"provideERC20Info\", payload: \"payload1\" }],\n [\n { type: \"provideERC20Info\", payload: \"payload2\" },\n { type: \"plugin\", payload: \"payload3\" },\n ],\n ];\n vi.spyOn(loader, \"load\")\n .mockResolvedValueOnce(responses[0])\n .mockResolvedValueOnce(responses[1]);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n const res = await contextModule.getContexts({} as TransactionContext);\n\n expect(loader.load).toHaveBeenCalledTimes(2);\n expect(res).toEqual(responses.flat());\n });\n\n it(\"should call the typed data loader\", async () => {\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customTypedDataLoader: typedDataLoader,\n });\n\n await contextModule.getTypedDataFilters({} as TypedDataContext);\n\n expect(typedDataLoader.load).toHaveBeenCalledTimes(1);\n });\n\n it(\"should return a single context\", async () => {\n const loader = contextLoaderStubBuilder();\n const responses = [null, { type: \"token\", payload: \"payload\" }];\n vi.spyOn(loader, \"loadField\")\n .mockResolvedValueOnce(responses[0])\n .mockResolvedValueOnce(responses[1]);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, { load: vi.fn() }, loader],\n });\n\n const res = await contextModule.getContext({\n type: \"token\",\n } as TransactionFieldContext);\n\n expect(loader.loadField).toHaveBeenCalledTimes(2);\n expect(res).toEqual({ type: \"token\", payload: \"payload\" });\n });\n\n it(\"context field not supported\", async () => {\n const loader = contextLoaderStubBuilder();\n const responses = [null, null];\n vi.spyOn(loader, \"loadField\")\n .mockResolvedValueOnce(responses[0])\n .mockResolvedValueOnce(responses[1]);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, { load: vi.fn() }, loader],\n });\n\n const res = await contextModule.getContext({\n type: \"token\",\n } as TransactionFieldContext);\n\n expect(loader.loadField).toHaveBeenCalledTimes(2);\n expect(res).toEqual({\n type: \"error\",\n error: new Error(\"Field type not supported: token\"),\n });\n });\n\n it(\"getField not implemented\", async () => {\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [{ load: vi.fn() }],\n });\n\n const res = await contextModule.getContext({\n type: \"token\",\n } as TransactionFieldContext);\n\n expect(res).toEqual({\n type: \"error\",\n error: new Error(\"Field type not supported: token\"),\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "aAOA,IAAAA,EAAqC,kCAErC,MAAMC,EAA2B,KACxB,CAAE,KAAM,GAAG,GAAG,EAAG,UAAW,GAAG,GAAG,CAAE,GAG7C,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA0C,CAAE,KAAM,GAAG,GAAG,CAAE,EAC1DC,EAAkD,CACtD,cAAe,CAAC,EAChB,eAAgB,GAChB,sBAAuBD,EACvB,IAAK,CACH,IAAK,kDACL,KAAM,OACN,OAAQ,MACV,CACF,EAEA,WAAW,IAAM,CACf,GAAG,gBAAgB,CACrB,CAAC,EAED,GAAG,oEAAqE,SAAY,CAGlF,MAAME,EAAM,MAFU,IAAI,uBAAqBD,CAA0B,EAEzC,YAAY,CAAC,CAAuB,EAEpE,OAAOC,CAAG,EAAE,QAAQ,CAAC,CAAC,CACxB,CAAC,EAED,GAAG,+CAAgD,SAAY,CAG7D,MAAMA,EAAM,MAFU,IAAI,uBAAqBD,CAA0B,EAEzC,YAAY,CAAC,CAAuB,EAEpE,OAAOC,CAAG,EAAE,QAAQ,CAAC,CAAC,CACxB,CAAC,EAED,GAAG,qDAAsD,SAAY,CACnE,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,CAAE,EAAGA,CAAM,CACnD,CAAC,EAE+B,WAAW,CACzC,KAAM,OACR,CAA4B,EAE5B,OAAOA,EAAO,SAAS,EAAE,sBAAsB,CAAC,EAChD,OAAOD,CAAG,EAAE,QAAQ,CAAE,KAAM,QAAS,QAAS,SAAU,CAAC,CAC3D,CAAC,EAED,GAAG,8BAA+B,SAAY,CAC5C,MAAMC,EAASJ,EAAyB,EAClCK,EAAY,CAAC,KAAM,IAAI,EAC7B,GAAG,MAAMD,EAAQ,WAAW,EACzB,sBAAsBC,EAAU,CAAC,CAAC,EAClC,sBAAsBA,EAAU,CAAC,CAAC,EAMrC,MAAMF,EAAM,MALU,IAAI,uBAAqB,CAC7C,GAAGD,EACH,cAAe,CAACE,EAAQ,CAAE,KAAM,GAAG,GAAG,CAAE,EAAGA,CAAM,CACnD,CAAC,EAE+B,WAAW,CACzC,KAAM,OACR,CAA4B,EAE5B,OAAOA,EAAO,SAAS,EAAE,sBAAsB,CAAC,EAChD,OAAOD,CAAG,EAAE,QAAQ,CAClB,KAAM,QACN,MAAO,IAAI,MAAM,iCAAiC,CACpD,CAAC,CACH,CAAC,EAED,GAAG,2BAA4B,SAAY,CAMzC,MAAMA,EAAM,MALU,IAAI,uBAAqB,CAC7C,GAAGD,EACH,cAAe,CAAC,CAAE,KAAM,GAAG,GAAG,CAAE,CAAC,CACnC,CAAC,EAE+B,WAAW,CACzC,KAAM,OACR,CAA4B,EAE5B,OAAOC,CAAG,EAAE,QAAQ,CAClB,KAAM,QACN,MAAO,IAAI,MAAM,iCAAiC,CACpD,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_DefaultContextModule", "contextLoaderStubBuilder", "typedDataLoader", "defaultContextModuleConfig", "res", "loader", "responses"]
|
|
7
7
|
}
|
package/lib/cjs/src/di.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var n=Object.defineProperty;var
|
|
1
|
+
"use strict";var n=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var s=(r,o)=>{for(var e in o)n(r,e,{get:o[e],enumerable:!0})},k=(r,o,e,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of C(o))!g.call(r,t)&&t!==e&&n(r,t,{get:()=>o[t],enumerable:!(a=F(o,t))||a.enumerable});return r};var x=r=>k(n({},"__esModule",{value:!0}),r);var A={};s(A,{makeContainer:()=>w});module.exports=x(A);var i=require("inversify"),m=require("./config/di/configModuleFactory"),f=require("./external-plugin/di/externalPluginModuleFactory"),p=require("./nft/di/nftModuleFactory"),c=require("./pki/di/pkiModuleFactory"),u=require("./token/di/tokenModuleFactory"),d=require("./transaction/di/transactionModuleFactory"),l=require("./trusted-name/di/trustedNameModuleFactory"),M=require("./typed-data/di/typedDataModuleFactory"),y=require("./uniswap/di/uniswapModuleFactory");const w=({config:r})=>{const o=new i.Container;return o.load((0,m.configModuleFactory)(r),(0,f.externalPluginModuleFactory)(),(0,p.nftModuleFactory)(),(0,u.tokenModuleFactory)(),(0,d.transactionModuleFactory)(),(0,l.trustedNameModuleFactory)(),(0,M.typedDataModuleFactory)(),(0,c.nanoPkiModuleFactory)(),(0,y.uniswapModuleFactory)()),o};0&&(module.exports={makeContainer});
|
|
2
2
|
//# sourceMappingURL=di.js.map
|
package/lib/cjs/src/di.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/di.ts"],
|
|
4
|
-
"sourcesContent": ["import { Container } from \"inversify\";\n\nimport { configModuleFactory } from \"@/config/di/configModuleFactory\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { externalPluginModuleFactory } from \"@/external-plugin/di/externalPluginModuleFactory\";\nimport { nftModuleFactory } from \"@/nft/di/nftModuleFactory\";\nimport { tokenModuleFactory } from \"@/token/di/tokenModuleFactory\";\nimport { transactionModuleFactory } from \"@/transaction/di/transactionModuleFactory\";\nimport { trustedNameModuleFactory } from \"@/trusted-name/di/trustedNameModuleFactory\";\nimport { typedDataModuleFactory } from \"@/typed-data/di/typedDataModuleFactory\";\n\ntype MakeContainerArgs = {\n config: ContextModuleConfig;\n};\n\nexport const makeContainer = ({ config }: MakeContainerArgs) => {\n const container = new Container();\n\n container.load(\n configModuleFactory(config),\n externalPluginModuleFactory(),\n nftModuleFactory(),\n tokenModuleFactory(),\n transactionModuleFactory(),\n trustedNameModuleFactory(),\n typedDataModuleFactory(),\n );\n\n return container;\n};\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA0B,qBAE1BC,EAAoC,2CAEpCC,EAA4C,4DAC5CC,EAAiC,qCACjCC,EAAmC,yCACnCC,EAAyC,qDACzCC,EAAyC,sDACzCC,EAAuC,
|
|
6
|
-
"names": ["di_exports", "__export", "makeContainer", "__toCommonJS", "import_inversify", "import_configModuleFactory", "import_externalPluginModuleFactory", "import_nftModuleFactory", "import_tokenModuleFactory", "import_transactionModuleFactory", "import_trustedNameModuleFactory", "import_typedDataModuleFactory", "config", "container"]
|
|
4
|
+
"sourcesContent": ["import { Container } from \"inversify\";\n\nimport { configModuleFactory } from \"@/config/di/configModuleFactory\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { externalPluginModuleFactory } from \"@/external-plugin/di/externalPluginModuleFactory\";\nimport { nftModuleFactory } from \"@/nft/di/nftModuleFactory\";\nimport { nanoPkiModuleFactory } from \"@/pki/di/pkiModuleFactory\";\nimport { tokenModuleFactory } from \"@/token/di/tokenModuleFactory\";\nimport { transactionModuleFactory } from \"@/transaction/di/transactionModuleFactory\";\nimport { trustedNameModuleFactory } from \"@/trusted-name/di/trustedNameModuleFactory\";\nimport { typedDataModuleFactory } from \"@/typed-data/di/typedDataModuleFactory\";\nimport { uniswapModuleFactory } from \"@/uniswap/di/uniswapModuleFactory\";\n\ntype MakeContainerArgs = {\n config: ContextModuleConfig;\n};\n\nexport const makeContainer = ({ config }: MakeContainerArgs) => {\n const container = new Container();\n\n container.load(\n configModuleFactory(config),\n externalPluginModuleFactory(),\n nftModuleFactory(),\n tokenModuleFactory(),\n transactionModuleFactory(),\n trustedNameModuleFactory(),\n typedDataModuleFactory(),\n nanoPkiModuleFactory(),\n uniswapModuleFactory(),\n );\n\n return container;\n};\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA0B,qBAE1BC,EAAoC,2CAEpCC,EAA4C,4DAC5CC,EAAiC,qCACjCC,EAAqC,qCACrCC,EAAmC,yCACnCC,EAAyC,qDACzCC,EAAyC,sDACzCC,EAAuC,kDACvCC,EAAqC,6CAM9B,MAAMX,EAAgB,CAAC,CAAE,OAAAY,CAAO,IAAyB,CAC9D,MAAMC,EAAY,IAAI,YAEtB,OAAAA,EAAU,QACR,uBAAoBD,CAAM,KAC1B,+BAA4B,KAC5B,oBAAiB,KACjB,sBAAmB,KACnB,4BAAyB,KACzB,4BAAyB,KACzB,0BAAuB,KACvB,wBAAqB,KACrB,wBAAqB,CACvB,EAEOC,CACT",
|
|
6
|
+
"names": ["di_exports", "__export", "makeContainer", "__toCommonJS", "import_inversify", "import_configModuleFactory", "import_externalPluginModuleFactory", "import_nftModuleFactory", "import_pkiModuleFactory", "import_tokenModuleFactory", "import_transactionModuleFactory", "import_trustedNameModuleFactory", "import_typedDataModuleFactory", "import_uniswapModuleFactory", "config", "container"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var x=Object.create;var l=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var I=(s,n,c,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of m(n))!h.call(s,e)&&e!==c&&l(s,e,{get:()=>n[e],enumerable:!(o=b(n,e))||o.enumerable});return s};var d=(s,n,c)=>(c=s!=null?x(g(s)):{},I(n||!s||!s.__esModule?l(c,"default",{value:s,enumerable:!0}):c,s));var a=d(require("axios")),u=d(require("@/external-plugin/__tests__/abi.json")),p=require("../../external-plugin/data/HttpExternalPluginDataSource"),f=d(require("../../../package.json"));
|
|
1
|
+
"use strict";var x=Object.create;var l=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var I=(s,n,c,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of m(n))!h.call(s,e)&&e!==c&&l(s,e,{get:()=>n[e],enumerable:!(o=b(n,e))||o.enumerable});return s};var d=(s,n,c)=>(c=s!=null?x(g(s)):{},I(n||!s||!s.__esModule?l(c,"default",{value:s,enumerable:!0}):c,s));var a=d(require("axios")),u=d(require("@/external-plugin/__tests__/abi.json")),p=require("../../external-plugin/data/HttpExternalPluginDataSource"),f=d(require("../../../package.json"));vi.mock("axios");const r=s=>({data:s});describe("HttpExternalPuginDataSource",()=>{let s;const n={blockchainName:"ethereum",chainId:1,contracts:[{address:"0x1ef",contractName:"otherName",selectors:{"0x01ee":{erc20OfInterest:["fromToken"],method:"swap",plugin:"plugin"}}},{address:"0x0abc",contractName:"name",selectors:{"0x01ff":{erc20OfInterest:["fromToken"],method:"swap",plugin:"plugin"}}}],name:"test"},c={"0x1ef":u.default,"0x0abc":u.default},o={"0x1ef":{"0x01ee":{plugin:"plugin",serialized_data:"0x001",signature:"0x002"}},"0x0abc":{"0x01ff":{plugin:"plugin",serialized_data:"0x001",signature:"0x002"}}};beforeAll(()=>{const e={cal:{url:"https://crypto-assets-service.api.ledger.com/v1"}};s=new p.HttpExternalPluginDataSource(e),vi.clearAllMocks()}),it("should call axios with the ledger client version header",async()=>{const e=`context-module/${f.default.version}`,t=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(a.default,"request").mockImplementation(t),await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"}),expect(t).toHaveBeenCalledWith(expect.objectContaining({headers:{"X-Ledger-Client-Version":e}}))}),it("should return undefined when no abis is undefined",async()=>{const e=r([{b2c:n,b2c_signatures:o}]);vi.spyOn(a.default,"request").mockResolvedValue(e);const t=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(t.extract()).toEqual(void 0)}),it("should return undefined when no selectors",async()=>{const e=r([{abis:c,b2c_signatures:o}]);vi.spyOn(a.default,"request").mockResolvedValue(e);const t=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(t.extract()).toEqual(void 0)}),it("should return undefined when no abis data",async()=>{const e=r([{abis:{},b2c:n,b2c_signatures:o}]);vi.spyOn(a.default,"request").mockResolvedValue(e);const t=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(t.extract()).toEqual(void 0)}),it("should return undefined when no abis data",async()=>{const e=r([{abis:{},b2c:n,b2c_signatures:o}]);vi.spyOn(a.default,"request").mockResolvedValue(e);const t=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(t.extract()).toEqual(void 0)}),it("should return undefined when no abis data for the contract address",async()=>{const t=r([{abis:{"0x1":u.default},b2c:n,b2c_signatures:o}]);vi.spyOn(a.default,"request").mockResolvedValue(t);const i=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(i.extract()).toEqual(void 0)}),it("should return undefined when no b2c signature",async()=>{const e=r([{b2c:n,abis:c}]);vi.spyOn(a.default,"request").mockResolvedValue(e);const t=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(t.extract()).toEqual(void 0)}),it("should return undefined when no ecc20OfInterest",async()=>{const t=r([{b2c:{blockchainName:"ethereum",chainId:1,contracts:[{address:"0x0abc",contractName:"name",selectors:{"0x01ff":{method:"swap",plugin:"plugin"}}}],name:"test"},abis:c,b2c_signatures:o}]);vi.spyOn(a.default,"request").mockResolvedValue(t);const i=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(i.extract()).toEqual(void 0)}),it("should return undefined when no method",async()=>{const t=r([{b2c:{blockchainName:"ethereum",chainId:1,contracts:[{address:"0x0abc",contractName:"name",selectors:{"0x01ff":{erc20OfInterest:["fromToken"],plugin:"plugin"}}}],name:"test"},abis:c,b2c_signatures:o}]);vi.spyOn(a.default,"request").mockResolvedValue(t);const i=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(i.extract()).toEqual(void 0)}),it("should return undefined when no plugin",async()=>{const t=r([{b2c:{blockchainName:"ethereum",chainId:1,contracts:[{address:"0x0abc",contractName:"name",selectors:{"0x01ff":{erc20OfInterest:["fromToken"],method:"swap"}}}],name:"test"},abis:c,b2c_signatures:o}]);vi.spyOn(a.default,"request").mockResolvedValue(t);const i=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(i.extract()).toEqual(void 0)}),it("should return undefined when no method",async()=>{const t=r([{b2c:{blockchainName:"ethereum",chainId:1,contracts:[{address:"0x0abc",contractName:"name",selectors:{"0x01ff":{erc20OfInterest:["fromToken"],plugin:"plugin"}}}],name:"test"},abis:c,b2c_signatures:o}]);vi.spyOn(a.default,"request").mockResolvedValue(t);const i=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(i.extract()).toEqual(void 0)}),it("should return undefined when no signature",async()=>{const t=r([{b2c:n,abis:c,b2c_signatures:{"0x0abc":{"0x01ff":{plugin:"plugin",serialized_data:"0x001"}}}}]);vi.spyOn(a.default,"request").mockResolvedValue(t);const i=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(i.extract()).toEqual(void 0)}),it("should return undefined when no serialized data",async()=>{const t=r([{b2c:n,abis:c,b2c_signatures:{"0x0abc":{"0x01ff":{plugin:"plugin",signature:"0x002"}}}}]);vi.spyOn(a.default,"request").mockResolvedValue(t);const i=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(i.extract()).toEqual(void 0)}),it("should return a correct response",async()=>{const e=r([{b2c:n,abis:c,b2c_signatures:o}]);vi.spyOn(a.default,"request").mockResolvedValue(e);const t=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(t.extract()).toEqual({abi:u.default,selectorDetails:{erc20OfInterest:["fromToken"],method:"swap",plugin:"plugin",serializedData:"0x001",signature:"0x002"}})}),it("should normalize the address and selector",async()=>{const e=r([{b2c:n,abis:c,b2c_signatures:o}]);vi.spyOn(a.default,"request").mockResolvedValue(e);const t=await s.getDappInfos({chainId:1,address:"0x0AbC",selector:"0x01Ff"});expect(t.extract()).toEqual({abi:u.default,selectorDetails:{erc20OfInterest:["fromToken"],method:"swap",plugin:"plugin",serializedData:"0x001",signature:"0x002"}})}),it("should return an error when axios throws an error",async()=>{vi.spyOn(a.default,"request").mockRejectedValue(new Error("error"));const e=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e.extract()).toEqual(new Error("[ContextModule] HttpExternalPluginDataSource: Error fetching dapp infos"))})});
|
|
2
2
|
//# sourceMappingURL=HttpExternalPluginDataSource.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/external-plugin/data/HttpExternalPluginDataSource.test.ts"],
|
|
4
|
-
"sourcesContent": ["import axios from \"axios\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport ABI from \"@/external-plugin/__tests__/abi.json\";\nimport {\n type Abis,\n type B2c,\n type B2cSignatures,\n type DAppDto,\n} from \"@/external-plugin/data/DAppDto\";\nimport { type ExternalPluginDataSource } from \"@/external-plugin/data/ExternalPluginDataSource\";\nimport { HttpExternalPluginDataSource } from \"@/external-plugin/data/HttpExternalPluginDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\njest.mock(\"axios\");\n\nconst axiosResponseBuilder = (dto: Partial<DAppDto>[]) => {\n return { data: dto };\n};\n\ndescribe(\"HttpExternalPuginDataSource\", () => {\n let datasource: ExternalPluginDataSource;\n const exampleB2c: B2c = {\n blockchainName: \"ethereum\",\n chainId: 1,\n contracts: [\n {\n address: \"0x1ef\",\n contractName: \"otherName\",\n selectors: {\n \"0x01ee\": {\n erc20OfInterest: [\"fromToken\"],\n method: \"swap\",\n plugin: \"plugin\",\n },\n },\n },\n {\n address: \"0x0abc\",\n contractName: \"name\",\n selectors: {\n \"0x01ff\": {\n erc20OfInterest: [\"fromToken\"],\n method: \"swap\",\n plugin: \"plugin\",\n },\n },\n },\n ],\n name: \"test\",\n };\n const exampleAbis: Abis = { \"0x1ef\": ABI, \"0x0abc\": ABI };\n const exampleB2cSignatures: B2cSignatures = {\n \"0x1ef\": {\n \"0x01ee\": {\n plugin: \"plugin\",\n serialized_data: \"0x001\",\n signature: \"0x002\",\n },\n },\n \"0x0abc\": {\n \"0x01ff\": {\n plugin: \"plugin\",\n serialized_data: \"0x001\",\n signature: \"0x002\",\n },\n },\n };\n\n beforeAll(() => {\n const config = {\n cal: {\n url: \"https://crypto-assets-service.api.ledger.com/v1\",\n },\n } as ContextModuleConfig;\n datasource = new HttpExternalPluginDataSource(config);\n jest.clearAllMocks();\n });\n\n it(\"should call axios with the ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = jest.fn(() => Promise.resolve({ data: [] }));\n jest.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: { \"X-Ledger-Client-Version\": version },\n }),\n );\n });\n\n it(\"should return undefined when no abis is undefined\", async () => {\n // GIVEN\n const response = axiosResponseBuilder([\n { b2c: exampleB2c, b2c_signatures: exampleB2cSignatures },\n ]);\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return undefined when no selectors\", async () => {\n // GIVEN\n const response = axiosResponseBuilder([\n { abis: exampleAbis, b2c_signatures: exampleB2cSignatures },\n ]);\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return undefined when no abis data\", async () => {\n // GIVEN\n const response = axiosResponseBuilder([\n { abis: {}, b2c: exampleB2c, b2c_signatures: exampleB2cSignatures },\n ]);\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return undefined when no abis data\", async () => {\n // GIVEN\n const response = axiosResponseBuilder([\n { abis: {}, b2c: exampleB2c, b2c_signatures: exampleB2cSignatures },\n ]);\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return undefined when no abis data for the contract address\", async () => {\n // GIVEN\n const abis: Abis = { \"0x1\": ABI };\n const response = axiosResponseBuilder([\n { abis, b2c: exampleB2c, b2c_signatures: exampleB2cSignatures },\n ]);\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return undefined when no b2c signature\", async () => {\n // GIVEN\n const response = axiosResponseBuilder([\n { b2c: exampleB2c, abis: exampleAbis },\n ]);\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return undefined when no ecc20OfInterest\", async () => {\n // GIVEN\n const b2c = {\n blockchainName: \"ethereum\",\n chainId: 1,\n contracts: [\n {\n address: \"0x0abc\",\n contractName: \"name\",\n selectors: {\n \"0x01ff\": { method: \"swap\", plugin: \"plugin\" },\n },\n },\n ],\n name: \"test\",\n } as unknown as B2c;\n const response = axiosResponseBuilder([\n { b2c, abis: exampleAbis, b2c_signatures: exampleB2cSignatures },\n ]);\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return undefined when no method\", async () => {\n // GIVEN\n const b2c = {\n blockchainName: \"ethereum\",\n chainId: 1,\n contracts: [\n {\n address: \"0x0abc\",\n contractName: \"name\",\n selectors: {\n \"0x01ff\": { erc20OfInterest: [\"fromToken\"], plugin: \"plugin\" },\n },\n },\n ],\n name: \"test\",\n } as unknown as B2c;\n const response = axiosResponseBuilder([\n { b2c, abis: exampleAbis, b2c_signatures: exampleB2cSignatures },\n ]);\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return undefined when no plugin\", async () => {\n // GIVEN\n const b2c = {\n blockchainName: \"ethereum\",\n chainId: 1,\n contracts: [\n {\n address: \"0x0abc\",\n contractName: \"name\",\n selectors: {\n \"0x01ff\": { erc20OfInterest: [\"fromToken\"], method: \"swap\" },\n },\n },\n ],\n name: \"test\",\n } as unknown as B2c;\n const response = axiosResponseBuilder([\n { b2c, abis: exampleAbis, b2c_signatures: exampleB2cSignatures },\n ]);\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return undefined when no method\", async () => {\n // GIVEN\n const b2c = {\n blockchainName: \"ethereum\",\n chainId: 1,\n contracts: [\n {\n address: \"0x0abc\",\n contractName: \"name\",\n selectors: {\n \"0x01ff\": { erc20OfInterest: [\"fromToken\"], plugin: \"plugin\" },\n },\n },\n ],\n name: \"test\",\n } as unknown as B2c;\n const response = axiosResponseBuilder([\n { b2c, abis: exampleAbis, b2c_signatures: exampleB2cSignatures },\n ]);\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return undefined when no signature\", async () => {\n // GIVEN\n const B2CSignature = {\n \"0x0abc\": { \"0x01ff\": { plugin: \"plugin\", serialized_data: \"0x001\" } },\n } as unknown as B2cSignatures;\n\n // FIXME\n const response = axiosResponseBuilder([\n { b2c: exampleB2c, abis: exampleAbis, b2c_signatures: B2CSignature },\n ]);\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return undefined when no serialized data\", async () => {\n // GIVEN\n const B2CSignature = {\n \"0x0abc\": { \"0x01ff\": { plugin: \"plugin\", signature: \"0x002\" } },\n } as unknown as B2cSignatures;\n\n // FIXME\n const response = axiosResponseBuilder([\n { b2c: exampleB2c, abis: exampleAbis, b2c_signatures: B2CSignature },\n ]);\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return a correct response\", async () => {\n // GIVEN\n const response = axiosResponseBuilder([\n {\n b2c: exampleB2c,\n abis: exampleAbis,\n b2c_signatures: exampleB2cSignatures,\n },\n ]);\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"swap\",\n plugin: \"plugin\",\n serializedData: \"0x001\",\n signature: \"0x002\",\n },\n });\n });\n\n it(\"should normalize the address and selector\", async () => {\n // GIVEN\n const response = axiosResponseBuilder([\n {\n b2c: exampleB2c,\n abis: exampleAbis,\n b2c_signatures: exampleB2cSignatures,\n },\n ]);\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0AbC\",\n selector: \"0x01Ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"swap\",\n plugin: \"plugin\",\n serializedData: \"0x001\",\n signature: \"0x002\",\n },\n });\n });\n\n it(\"should return an error when axios throws an error\", async () => {\n // GIVEN\n jest.spyOn(axios, \"request\").mockRejectedValue(new Error(\"error\"));\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(\n new Error(\n \"[ContextModule] HttpExternalPluginDataSource: Error fetching dapp infos\",\n ),\n );\n });\n});\n"],
|
|
5
|
-
"mappings": "wdAAA,IAAAA,EAAkB,oBAGlBC,EAAgB,mDAQhBC,EAA6C,+DAC7CC,EAAoB,iCAEpB,
|
|
4
|
+
"sourcesContent": ["import axios from \"axios\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport ABI from \"@/external-plugin/__tests__/abi.json\";\nimport {\n type Abis,\n type B2c,\n type B2cSignatures,\n type DAppDto,\n} from \"@/external-plugin/data/DAppDto\";\nimport { type ExternalPluginDataSource } from \"@/external-plugin/data/ExternalPluginDataSource\";\nimport { HttpExternalPluginDataSource } from \"@/external-plugin/data/HttpExternalPluginDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\nvi.mock(\"axios\");\n\nconst axiosResponseBuilder = (dto: Partial<DAppDto>[]) => {\n return { data: dto };\n};\n\ndescribe(\"HttpExternalPuginDataSource\", () => {\n let datasource: ExternalPluginDataSource;\n const exampleB2c: B2c = {\n blockchainName: \"ethereum\",\n chainId: 1,\n contracts: [\n {\n address: \"0x1ef\",\n contractName: \"otherName\",\n selectors: {\n \"0x01ee\": {\n erc20OfInterest: [\"fromToken\"],\n method: \"swap\",\n plugin: \"plugin\",\n },\n },\n },\n {\n address: \"0x0abc\",\n contractName: \"name\",\n selectors: {\n \"0x01ff\": {\n erc20OfInterest: [\"fromToken\"],\n method: \"swap\",\n plugin: \"plugin\",\n },\n },\n },\n ],\n name: \"test\",\n };\n const exampleAbis: Abis = { \"0x1ef\": ABI, \"0x0abc\": ABI };\n const exampleB2cSignatures: B2cSignatures = {\n \"0x1ef\": {\n \"0x01ee\": {\n plugin: \"plugin\",\n serialized_data: \"0x001\",\n signature: \"0x002\",\n },\n },\n \"0x0abc\": {\n \"0x01ff\": {\n plugin: \"plugin\",\n serialized_data: \"0x001\",\n signature: \"0x002\",\n },\n },\n };\n\n beforeAll(() => {\n const config = {\n cal: {\n url: \"https://crypto-assets-service.api.ledger.com/v1\",\n },\n } as ContextModuleConfig;\n datasource = new HttpExternalPluginDataSource(config);\n vi.clearAllMocks();\n });\n\n it(\"should call axios with the ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() => Promise.resolve({ data: [] }));\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: { \"X-Ledger-Client-Version\": version },\n }),\n );\n });\n\n it(\"should return undefined when no abis is undefined\", async () => {\n // GIVEN\n const response = axiosResponseBuilder([\n { b2c: exampleB2c, b2c_signatures: exampleB2cSignatures },\n ]);\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return undefined when no selectors\", async () => {\n // GIVEN\n const response = axiosResponseBuilder([\n { abis: exampleAbis, b2c_signatures: exampleB2cSignatures },\n ]);\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return undefined when no abis data\", async () => {\n // GIVEN\n const response = axiosResponseBuilder([\n { abis: {}, b2c: exampleB2c, b2c_signatures: exampleB2cSignatures },\n ]);\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return undefined when no abis data\", async () => {\n // GIVEN\n const response = axiosResponseBuilder([\n { abis: {}, b2c: exampleB2c, b2c_signatures: exampleB2cSignatures },\n ]);\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return undefined when no abis data for the contract address\", async () => {\n // GIVEN\n const abis: Abis = { \"0x1\": ABI };\n const response = axiosResponseBuilder([\n { abis, b2c: exampleB2c, b2c_signatures: exampleB2cSignatures },\n ]);\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return undefined when no b2c signature\", async () => {\n // GIVEN\n const response = axiosResponseBuilder([\n { b2c: exampleB2c, abis: exampleAbis },\n ]);\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return undefined when no ecc20OfInterest\", async () => {\n // GIVEN\n const b2c = {\n blockchainName: \"ethereum\",\n chainId: 1,\n contracts: [\n {\n address: \"0x0abc\",\n contractName: \"name\",\n selectors: {\n \"0x01ff\": { method: \"swap\", plugin: \"plugin\" },\n },\n },\n ],\n name: \"test\",\n } as unknown as B2c;\n const response = axiosResponseBuilder([\n { b2c, abis: exampleAbis, b2c_signatures: exampleB2cSignatures },\n ]);\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return undefined when no method\", async () => {\n // GIVEN\n const b2c = {\n blockchainName: \"ethereum\",\n chainId: 1,\n contracts: [\n {\n address: \"0x0abc\",\n contractName: \"name\",\n selectors: {\n \"0x01ff\": { erc20OfInterest: [\"fromToken\"], plugin: \"plugin\" },\n },\n },\n ],\n name: \"test\",\n } as unknown as B2c;\n const response = axiosResponseBuilder([\n { b2c, abis: exampleAbis, b2c_signatures: exampleB2cSignatures },\n ]);\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return undefined when no plugin\", async () => {\n // GIVEN\n const b2c = {\n blockchainName: \"ethereum\",\n chainId: 1,\n contracts: [\n {\n address: \"0x0abc\",\n contractName: \"name\",\n selectors: {\n \"0x01ff\": { erc20OfInterest: [\"fromToken\"], method: \"swap\" },\n },\n },\n ],\n name: \"test\",\n } as unknown as B2c;\n const response = axiosResponseBuilder([\n { b2c, abis: exampleAbis, b2c_signatures: exampleB2cSignatures },\n ]);\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return undefined when no method\", async () => {\n // GIVEN\n const b2c = {\n blockchainName: \"ethereum\",\n chainId: 1,\n contracts: [\n {\n address: \"0x0abc\",\n contractName: \"name\",\n selectors: {\n \"0x01ff\": { erc20OfInterest: [\"fromToken\"], plugin: \"plugin\" },\n },\n },\n ],\n name: \"test\",\n } as unknown as B2c;\n const response = axiosResponseBuilder([\n { b2c, abis: exampleAbis, b2c_signatures: exampleB2cSignatures },\n ]);\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return undefined when no signature\", async () => {\n // GIVEN\n const B2CSignature = {\n \"0x0abc\": { \"0x01ff\": { plugin: \"plugin\", serialized_data: \"0x001\" } },\n } as unknown as B2cSignatures;\n\n // FIXME\n const response = axiosResponseBuilder([\n { b2c: exampleB2c, abis: exampleAbis, b2c_signatures: B2CSignature },\n ]);\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return undefined when no serialized data\", async () => {\n // GIVEN\n const B2CSignature = {\n \"0x0abc\": { \"0x01ff\": { plugin: \"plugin\", signature: \"0x002\" } },\n } as unknown as B2cSignatures;\n\n // FIXME\n const response = axiosResponseBuilder([\n { b2c: exampleB2c, abis: exampleAbis, b2c_signatures: B2CSignature },\n ]);\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(undefined);\n });\n\n it(\"should return a correct response\", async () => {\n // GIVEN\n const response = axiosResponseBuilder([\n {\n b2c: exampleB2c,\n abis: exampleAbis,\n b2c_signatures: exampleB2cSignatures,\n },\n ]);\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"swap\",\n plugin: \"plugin\",\n serializedData: \"0x001\",\n signature: \"0x002\",\n },\n });\n });\n\n it(\"should normalize the address and selector\", async () => {\n // GIVEN\n const response = axiosResponseBuilder([\n {\n b2c: exampleB2c,\n abis: exampleAbis,\n b2c_signatures: exampleB2cSignatures,\n },\n ]);\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0AbC\",\n selector: \"0x01Ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"swap\",\n plugin: \"plugin\",\n serializedData: \"0x001\",\n signature: \"0x002\",\n },\n });\n });\n\n it(\"should return an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"error\"));\n\n // WHEN\n const result = await datasource.getDappInfos({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result.extract()).toEqual(\n new Error(\n \"[ContextModule] HttpExternalPluginDataSource: Error fetching dapp infos\",\n ),\n );\n });\n});\n"],
|
|
5
|
+
"mappings": "wdAAA,IAAAA,EAAkB,oBAGlBC,EAAgB,mDAQhBC,EAA6C,+DAC7CC,EAAoB,iCAEpB,GAAG,KAAK,OAAO,EAEf,MAAMC,EAAwBC,IACrB,CAAE,KAAMA,CAAI,GAGrB,SAAS,8BAA+B,IAAM,CAC5C,IAAIC,EACJ,MAAMC,EAAkB,CACtB,eAAgB,WAChB,QAAS,EACT,UAAW,CACT,CACE,QAAS,QACT,aAAc,YACd,UAAW,CACT,SAAU,CACR,gBAAiB,CAAC,WAAW,EAC7B,OAAQ,OACR,OAAQ,QACV,CACF,CACF,EACA,CACE,QAAS,SACT,aAAc,OACd,UAAW,CACT,SAAU,CACR,gBAAiB,CAAC,WAAW,EAC7B,OAAQ,OACR,OAAQ,QACV,CACF,CACF,CACF,EACA,KAAM,MACR,EACMC,EAAoB,CAAE,QAAS,EAAAC,QAAK,SAAU,EAAAA,OAAI,EAClDC,EAAsC,CAC1C,QAAS,CACP,SAAU,CACR,OAAQ,SACR,gBAAiB,QACjB,UAAW,OACb,CACF,EACA,SAAU,CACR,SAAU,CACR,OAAQ,SACR,gBAAiB,QACjB,UAAW,OACb,CACF,CACF,EAEA,UAAU,IAAM,CACd,MAAMC,EA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ElE,GAAG,MAAM,EAAAM,QAAO,SAAS,EAAE,kBAAkB,IAAI,MAAM,OAAO,CAAC,EAG/D,MAAME,EAAS,MAAMX,EAAW,aAAa,CAC3C,QAAS,EACT,QAAS,SACT,SAAU,QACZ,CAAC,EAGD,OAAOW,EAAO,QAAQ,CAAC,EAAE,QACvB,IAAI,MACF,yEACF,CACF,CACF,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_axios", "import_abi", "import_HttpExternalPluginDataSource", "import_package", "axiosResponseBuilder", "dto", "datasource", "exampleB2c", "exampleAbis", "ABI", "exampleB2cSignatures", "config", "version", "PACKAGE", "requestSpy", "axios", "response", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var y=Object.create;var i=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var b=(s,o,r,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of f(o))!D.call(s,e)&&e!==r&&i(s,e,{get:()=>o[e],enumerable:!(a=E(o,e))||a.enumerable});return s};var I=(s,o,r)=>(r=s!=null?y(x(s)):{},b(o||!s||!s.__esModule?i(r,"default",{value:s,enumerable:!0}):r,s));var u=require("ethers"),l=require("purify-ts"),n=I(require("@/external-plugin/__tests__/abi.json")),m=require("../../external-plugin/domain/ExternalPluginContextLoader"),t=require("../../shared/model/ClearSignContext");const d=({abi:s,selectorDetails:o})=>({abi:s,selectorDetails:{erc20OfInterest:[],method:"",plugin:"",serializedData:"123456",signature:"7890",...o}}),p=(s,o,r)=>({to:"0x0",data:new u.Interface(JSON.stringify(s)).encodeFunctionData(o,r)});describe("ExternalPluginContextLoader",()=>{const s={getTokenInfosPayload:
|
|
1
|
+
"use strict";var y=Object.create;var i=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var b=(s,o,r,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of f(o))!D.call(s,e)&&e!==r&&i(s,e,{get:()=>o[e],enumerable:!(a=E(o,e))||a.enumerable});return s};var I=(s,o,r)=>(r=s!=null?y(x(s)):{},b(o||!s||!s.__esModule?i(r,"default",{value:s,enumerable:!0}):r,s));var u=require("ethers"),l=require("purify-ts"),n=I(require("@/external-plugin/__tests__/abi.json")),m=require("../../external-plugin/domain/ExternalPluginContextLoader"),t=require("../../shared/model/ClearSignContext");const d=({abi:s,selectorDetails:o})=>({abi:s,selectorDetails:{erc20OfInterest:[],method:"",plugin:"",serializedData:"123456",signature:"7890",...o}}),p=(s,o,r)=>({to:"0x0",data:new u.Interface(JSON.stringify(s)).encodeFunctionData(o,r)});describe("ExternalPluginContextLoader",()=>{const s={getTokenInfosPayload:vi.fn()},o={getDappInfos:vi.fn()},r=new m.ExternalPluginContextLoader(o,s);beforeEach(()=>{vi.clearAllMocks(),vi.spyOn(s,"getTokenInfosPayload").mockImplementation(({address:a})=>Promise.resolve((0,l.Right)(`payload-${a}`)))}),describe("load function",async()=>{it("should return an empty array if no destination address is provided",async()=>{const a={},e=()=>r.load(a);await expect(e()).resolves.toEqual([])}),it("should return an empty array if data is undefined",async()=>{const a={to:"0x0"},e=await r.load(a);expect(e).toEqual([])}),it("should return an empty array if no data provided",async()=>{const a={to:"0x0",data:"0x"},e=await r.load(a);expect(e).toEqual([])}),it("should return an empty array if no dapp info is povided",async()=>{const a=p(n.default,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(o,"getDappInfos").mockResolvedValue((0,l.Right)(void 0));const e=await r.load(a);expect(e).toEqual([])}),it("should return e plugin if no erc20OfInterest is provided",async()=>{const a=d({abi:n.default,selectorDetails:{erc20OfInterest:[],method:"singleParam"}}),e=p(n.default,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(o,"getDappInfos").mockResolvedValue((0,l.Right)(a));const c=await r.load(e);expect(c).toEqual([{type:t.ClearSignContextType.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return a list of context responses when one erc20OfInterest is provided for a single parameter",async()=>{const a=d({abi:n.default,selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam"}}),e=p(n.default,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(o,"getDappInfos").mockResolvedValue((0,l.Right)(a));const c=await r.load(e);expect(c).toEqual(expect.arrayContaining([{type:t.ClearSignContextType.EXTERNAL_PLUGIN,payload:"1234567890"},{type:t.ClearSignContextType.TOKEN,payload:"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"}]))}),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()=>{const a=d({abi:n.default,selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam"}}),e=p(n.default,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(o,"getDappInfos").mockResolvedValue((0,l.Right)(a)),vi.spyOn(s,"getTokenInfosPayload").mockResolvedValue((0,l.Left)(Error("error")));const c=await r.load(e);expect(c).toEqual([{type:t.ClearSignContextType.ERROR,error:new Error("error")},{type:t.ClearSignContextType.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return a list of context responses when two erc20OfInterest are provided for two parameters",async()=>{const a=d({abi:n.default,selectorDetails:{erc20OfInterest:["fromToken","toToken"],method:"multipleParams"}}),e=p(n.default,"multipleParams",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7"]);vi.spyOn(o,"getDappInfos").mockResolvedValue((0,l.Right)(a));const c=await r.load(e);expect(c).toEqual(expect.arrayContaining([{type:t.ClearSignContextType.EXTERNAL_PLUGIN,payload:"1234567890"},{type:t.ClearSignContextType.TOKEN,payload:"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{type:t.ClearSignContextType.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"}]))}),it("should return a list of context responses when one erc20OfInterest is an array",async()=>{const a=d({abi:n.default,selectorDetails:{erc20OfInterest:["fromToken.0","fromToken.1","fromToken.2","fromToken.-1"],method:"arrayParam"}}),e=p(n.default,"arrayParam",[["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7","0xB8c77482e45F1F44dE1745F52C74426C631bDD52"]]);vi.spyOn(o,"getDappInfos").mockResolvedValue((0,l.Right)(a));const c=await r.load(e);expect(c).toEqual([{type:t.ClearSignContextType.TOKEN,payload:"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{type:t.ClearSignContextType.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"},{type:t.ClearSignContextType.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:t.ClearSignContextType.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:t.ClearSignContextType.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return an error when a token datasource returns an error",async()=>{const a=d({abi:n.default,selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam"}}),e=p(n.default,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(o,"getDappInfos").mockResolvedValue((0,l.Right)(a)),vi.spyOn(s,"getTokenInfosPayload").mockResolvedValue((0,l.Left)(new Error("error")));const c=await r.load(e);expect(c).toEqual([{type:t.ClearSignContextType.ERROR,error:new Error("error")},{type:t.ClearSignContextType.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return an error when the abi is not conform",async()=>{const a=d({abi:[{fakeabi:"notworking"}],selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam"}}),e=p(n.default,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(o,"getDappInfos").mockResolvedValue((0,l.Right)(a));const c=await r.load(e);expect(c).toEqual([{type:t.ClearSignContextType.ERROR,error:new Error("[ContextModule] ExternalPluginContextLoader: Unable to parse abi")},{type:t.ClearSignContextType.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should throw an error when the erc20OfInterest doest not exist in the transaction",async()=>{const a=d({abi:n.default,selectorDetails:{erc20OfInterest:["notFound"],method:"singleParam"}}),e=p(n.default,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(o,"getDappInfos").mockResolvedValue((0,l.Right)(a));const c=await r.load(e);expect(c).toEqual([{type:t.ClearSignContextType.ERROR,error:new Error("[ContextModule] ExternalPluginContextLoader: Unable to get address")}])}),it("should throw an error when an out-of-bounds element is present in erc20OfInterest",async()=>{const a=d({abi:n.default,selectorDetails:{erc20OfInterest:["fromToken.3"],method:"arrayParam"}}),e=p(n.default,"arrayParam",[["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7","0xB8c77482e45F1F44dE1745F52C74426C631bDD52"]]);vi.spyOn(o,"getDappInfos").mockResolvedValue((0,l.Right)(a));const c=await r.load(e);expect(c).toEqual([{type:t.ClearSignContextType.ERROR,error:new RangeError("out of result range")}])}),it("should return a list of context responses when one erc20OfInterest is a complex struct",async()=>{const a=d({abi:n.default,selectorDetails:{erc20OfInterest:["complexStruct.address1","complexStruct.param1.param2.0.param3.addresses.0","complexStruct.param1.param2.0.param3.addresses.1","complexStruct.param1.param2.0.param3.addresses.-1","complexStruct.param1.param2.1.param3.addresses.0","complexStruct.param1.param2.-1.param3.addresses.0"],method:"complexStructParam"}}),e=p(n.default,"complexStructParam",[{address1:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",param1:{param2:[{param3:{addresses:["0xdAC17F958D2ee523a2206206994597C13D831ec7","0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE"]}},{param3:{addresses:["0xB8c77482e45F1F44dE1745F52C74426C631bDD52"]}}]}}]);vi.spyOn(o,"getDappInfos").mockResolvedValue((0,l.Right)(a));const c=await r.load(e);expect(c).toEqual([{type:t.ClearSignContextType.TOKEN,payload:"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{type:t.ClearSignContextType.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"},{type:t.ClearSignContextType.TOKEN,payload:"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE"},{type:t.ClearSignContextType.TOKEN,payload:"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE"},{type:t.ClearSignContextType.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:t.ClearSignContextType.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:t.ClearSignContextType.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return an error when datasource return a Left",async()=>{const a=p(n.default,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(o,"getDappInfos").mockResolvedValue((0,l.Left)(new Error("error")));const e=await r.load(a);expect(e).toEqual([{type:t.ClearSignContextType.ERROR,error:new Error("error")}])}),it("should return an error when transaction data is not a valid hex string",async()=>{const a={to:"0x0",data:"notAHexString"},e=await r.load(a);expect(e).toEqual([{type:t.ClearSignContextType.ERROR,error:new Error("Invalid selector")}])})})});
|
|
2
2
|
//# sourceMappingURL=ExternalPluginContextLoader.test.js.map
|
|
@@ -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 } as TransactionContext;\n};\n\ndescribe(\"ExternalPluginContextLoader\", () => {\n const mockTokenDataSource: TokenDataSource = {\n getTokenInfosPayload: jest.fn(),\n };\n const mockExternalPluginDataSource: ExternalPluginDataSource = {\n getDappInfos: jest.fn(),\n };\n const loader = new ExternalPluginContextLoader(\n mockExternalPluginDataSource,\n mockTokenDataSource,\n );\n\n beforeEach(() => {\n jest.clearAllMocks();\n jest\n .spyOn(mockTokenDataSource, \"getTokenInfosPayload\")\n .mockImplementation(({ address }) =>\n 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\", () => {\n // GIVEN\n const transaction = {} as TransactionContext;\n\n // WHEN\n const promise = () => loader.load(transaction);\n\n // THEN\n expect(promise()).resolves.toEqual([]);\n });\n\n it(\"should return an empty array if data is undefined\", async () => {\n // GIVEN\n const transaction = { to: \"0x0\" } 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 data provided\", async () => {\n // GIVEN\n const transaction = { to: \"0x0\", data: \"0x\" } 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 jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Right(undefined));\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 jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Right(dappInfos));\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 jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Right(dappInfos));\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 jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Right(dappInfos));\n jest\n .spyOn(mockTokenDataSource, \"getTokenInfosPayload\")\n .mockResolvedValue(Left(Error(\"error\")));\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 jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Right(dappInfos));\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 jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Right(dappInfos));\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 jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Right(dappInfos));\n jest\n .spyOn(mockTokenDataSource, \"getTokenInfosPayload\")\n .mockResolvedValue(Left(new Error(\"error\")));\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 jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Right(dappInfos));\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 jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Right(dappInfos));\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 jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Right(dappInfos));\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 jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Right(dappInfos));\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 jest\n .spyOn(mockExternalPluginDataSource, \"getDappInfos\")\n .mockResolvedValue(Left(new Error(\"error\")));\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": "wdAAA,IAAAA,EAA0B,kBAC1BC,EAA4B,qBAE5BC,EAAgB,mDAEhBC,EAA4C,gEAG5CC,EAAqC,2CAIrC,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,EAAqB,CACzBF,EACAG,EACAC,KAIO,CACL,GAAI,MACJ,KAJe,IAAI,YAAU,KAAK,UAAUJ,CAAG,CAAC,EAC5B,mBAAmBG,EAAcC,CAAM,CAI7D,GAGF,SAAS,8BAA+B,IAAM,CAC5C,MAAMC,EAAuC,CAC3C,qBAAsB,
|
|
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 } 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\", async () => {\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 data is undefined\", async () => {\n // GIVEN\n const transaction = { to: \"0x0\" } 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 data provided\", async () => {\n // GIVEN\n const transaction = { to: \"0x0\", data: \"0x\" } 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": "wdAAA,IAAAA,EAA0B,kBAC1BC,EAA4B,qBAE5BC,EAAgB,mDAEhBC,EAA4C,gEAG5CC,EAAqC,2CAIrC,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,EAAqB,CACzBF,EACAG,EACAC,KAIO,CACL,GAAI,MACJ,KAJe,IAAI,YAAU,KAAK,UAAUJ,CAAG,CAAC,EAC5B,mBAAmBG,EAAcC,CAAM,CAI7D,GAGF,SAAS,8BAA+B,IAAM,CAC5C,MAAMC,EAAuC,CAC3C,qBAAsB,GAAG,GAAG,CAC9B,EACMC,EAAyD,CAC7D,aAAc,GAAG,GAAG,CACtB,EACMC,EAAS,IAAI,8BACjBD,EACAD,CACF,EAEA,WAAW,IAAM,CACf,GAAG,cAAc,EACjB,GAAG,MAAMA,EAAqB,sBAAsB,EAAE,mBACpD,CAAC,CAAE,QAAAG,CAAQ,IAAM,QAAQ,WAAQ,SAAM,WAAWA,CAAO,EAAE,CAAC,CAC9D,CACF,CAAC,EAED,SAAS,gBAAiB,SAAY,CACpC,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,EAAAU,QAAK,cAAe,CACzD,4CACF,CAAC,EACD,GAAG,MAAMN,EAA8B,cAAc,EAAE,qBACrD,QAAK,IAAI,MAAM,OAAO,CAAC,CACzB,EAGA,MAAMK,EAAS,MAAMJ,EAAO,KAAKE,CAAW,EAG5C,OAAOE,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,OAAO,CAC1B,CACF,CAAC,CACH,CAAC,EAED,GAAG,yEAA0E,SAAY,CAEvF,MAAMF,EAAc,CAClB,GAAI,MACJ,KAAM,eACR,EAGME,EAAS,MAAMJ,EAAO,KAAKE,CAAW,EAG5C,OAAOE,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_ethers", "import_purify_ts", "import_abi", "import_ExternalPluginContextLoader", "import_ClearSignContext", "dappInfosBuilder", "abi", "selectorDetails", "transactionBuilder", "functionName", "params", "mockTokenDataSource", "mockExternalPluginDataSource", "loader", "address", "transaction", "promise", "result", "ABI", "dappInfos"]
|
|
7
7
|
}
|