@ledgerhq/context-module 0.0.0-develop-20241017000946 → 0.0.0-signer-eth-20250122093657
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -6
- package/lib/cjs/index.js +1 -1126
- package/lib/cjs/index.js.map +4 -4
- package/lib/cjs/package.json +58 -0
- package/lib/cjs/src/ContextModule.js +2 -0
- package/lib/cjs/src/ContextModule.js.map +7 -0
- package/lib/cjs/src/ContextModuleBuilder.js +2 -0
- package/lib/cjs/src/ContextModuleBuilder.js.map +7 -0
- package/lib/cjs/src/ContextModuleBuilder.test.js +2 -0
- package/lib/cjs/src/ContextModuleBuilder.test.js.map +7 -0
- package/lib/cjs/src/DefaultContextModule.js +2 -0
- package/lib/cjs/src/DefaultContextModule.js.map +7 -0
- package/lib/cjs/src/DefaultContextModule.test.js +2 -0
- package/lib/cjs/src/DefaultContextModule.test.js.map +7 -0
- package/lib/cjs/src/config/di/configModuleFactory.js +2 -0
- package/lib/cjs/src/config/di/configModuleFactory.js.map +7 -0
- package/lib/cjs/src/config/di/configTypes.js +2 -0
- package/lib/cjs/src/config/di/configTypes.js.map +7 -0
- package/lib/cjs/src/config/model/ContextModuleConfig.js +2 -0
- package/lib/cjs/src/config/model/ContextModuleConfig.js.map +7 -0
- package/lib/cjs/src/di.js +2 -0
- package/lib/cjs/src/di.js.map +7 -0
- package/lib/cjs/src/external-plugin/data/DAppDto.js +2 -0
- package/lib/cjs/src/external-plugin/data/DAppDto.js.map +7 -0
- package/lib/cjs/src/external-plugin/data/ExternalPluginDataSource.js +2 -0
- package/lib/cjs/src/external-plugin/data/ExternalPluginDataSource.js.map +7 -0
- package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js +2 -0
- package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js.map +7 -0
- package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js +2 -0
- package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +7 -0
- package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js +2 -0
- package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js.map +7 -0
- package/lib/cjs/src/external-plugin/di/externalPluginTypes.js +2 -0
- package/lib/cjs/src/external-plugin/di/externalPluginTypes.js.map +7 -0
- package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js +2 -0
- package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js.map +7 -0
- package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js +2 -0
- package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +7 -0
- package/lib/cjs/src/external-plugin/model/DappInfos.js +2 -0
- package/lib/cjs/src/external-plugin/model/DappInfos.js.map +7 -0
- package/lib/cjs/src/external-plugin/model/SelectorDetails.js +2 -0
- package/lib/cjs/src/external-plugin/model/SelectorDetails.js.map +7 -0
- package/lib/cjs/src/index.js +2 -0
- package/lib/cjs/src/index.js.map +7 -0
- package/lib/cjs/src/nft/data/HttpNftDataSource.js +2 -0
- package/lib/cjs/src/nft/data/HttpNftDataSource.js.map +7 -0
- package/lib/cjs/src/nft/data/HttpNftDataSource.test.js +2 -0
- package/lib/cjs/src/nft/data/HttpNftDataSource.test.js.map +7 -0
- package/lib/cjs/src/nft/data/NftDataSource.js +2 -0
- package/lib/cjs/src/nft/data/NftDataSource.js.map +7 -0
- package/lib/cjs/src/nft/di/nftModuleFactory.js +2 -0
- package/lib/cjs/src/nft/di/nftModuleFactory.js.map +7 -0
- package/lib/cjs/src/nft/di/nftTypes.js +2 -0
- package/lib/cjs/src/nft/di/nftTypes.js.map +7 -0
- package/lib/cjs/src/nft/domain/NftContextLoader.js +2 -0
- package/lib/cjs/src/nft/domain/NftContextLoader.js.map +7 -0
- package/lib/cjs/src/nft/domain/NftContextLoader.test.js +2 -0
- package/lib/cjs/src/nft/domain/NftContextLoader.test.js.map +7 -0
- package/lib/cjs/src/shared/domain/ContextLoader.js +2 -0
- package/lib/cjs/src/shared/domain/ContextLoader.js.map +7 -0
- package/lib/cjs/src/shared/model/ClearSignContext.js +2 -0
- package/lib/cjs/src/shared/model/ClearSignContext.js.map +7 -0
- package/lib/cjs/src/shared/model/GenericPath.js +2 -0
- package/lib/cjs/src/shared/model/GenericPath.js.map +7 -0
- package/lib/cjs/src/shared/model/TransactionContext.js +2 -0
- package/lib/cjs/src/shared/model/TransactionContext.js.map +7 -0
- package/lib/cjs/src/shared/model/TransactionSubset.js +2 -0
- package/lib/cjs/src/shared/model/TransactionSubset.js.map +7 -0
- package/lib/cjs/src/shared/model/TypedDataClearSignContext.js +2 -0
- package/lib/cjs/src/shared/model/TypedDataClearSignContext.js.map +7 -0
- package/lib/cjs/src/shared/model/TypedDataContext.js +2 -0
- package/lib/cjs/src/shared/model/TypedDataContext.js.map +7 -0
- package/lib/cjs/src/shared/utils/HexStringUtils.js +2 -0
- package/lib/cjs/src/shared/utils/HexStringUtils.js.map +7 -0
- package/lib/cjs/src/token/data/HttpTokenDataSource.js +2 -0
- package/lib/cjs/src/token/data/HttpTokenDataSource.js.map +7 -0
- package/lib/cjs/src/token/data/HttpTokenDataSource.test.js +2 -0
- package/lib/cjs/src/token/data/HttpTokenDataSource.test.js.map +7 -0
- package/lib/cjs/src/token/data/TokenDataSource.js +2 -0
- package/lib/cjs/src/token/data/TokenDataSource.js.map +7 -0
- package/lib/cjs/src/token/data/TokenDto.js +2 -0
- package/lib/cjs/src/token/data/TokenDto.js.map +7 -0
- package/lib/cjs/src/token/di/tokenModuleFactory.js +2 -0
- package/lib/cjs/src/token/di/tokenModuleFactory.js.map +7 -0
- package/lib/cjs/src/token/di/tokenTypes.js +2 -0
- package/lib/cjs/src/token/di/tokenTypes.js.map +7 -0
- package/lib/cjs/src/token/domain/TokenContextLoader.js +2 -0
- package/lib/cjs/src/token/domain/TokenContextLoader.js.map +7 -0
- package/lib/cjs/src/token/domain/TokenContextLoader.test.js +2 -0
- package/lib/cjs/src/token/domain/TokenContextLoader.test.js.map +7 -0
- package/lib/cjs/src/transaction/data/CalldataDto.js +2 -0
- package/lib/cjs/src/transaction/data/CalldataDto.js.map +7 -0
- package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js +2 -0
- package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js.map +7 -0
- package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js +2 -0
- package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js.map +7 -0
- package/lib/cjs/src/transaction/data/TransactionDataSource.js +2 -0
- package/lib/cjs/src/transaction/data/TransactionDataSource.js.map +7 -0
- package/lib/cjs/src/transaction/di/transactionModuleFactory.js +2 -0
- package/lib/cjs/src/transaction/di/transactionModuleFactory.js.map +7 -0
- package/lib/cjs/src/transaction/di/transactionTypes.js +2 -0
- package/lib/cjs/src/transaction/di/transactionTypes.js.map +7 -0
- package/lib/cjs/src/transaction/domain/TransactionContextLoader.js +2 -0
- package/lib/cjs/src/transaction/domain/TransactionContextLoader.js.map +7 -0
- package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js +2 -0
- package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js.map +7 -0
- package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js +2 -0
- package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js.map +7 -0
- package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js +2 -0
- package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +7 -0
- package/lib/cjs/src/trusted-name/data/TrustedNameDataSource.js +2 -0
- package/lib/cjs/src/trusted-name/data/TrustedNameDataSource.js.map +7 -0
- package/lib/cjs/src/trusted-name/data/TrustedNameDto.js +2 -0
- package/lib/cjs/src/trusted-name/data/TrustedNameDto.js.map +7 -0
- package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js +2 -0
- package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js.map +7 -0
- package/lib/cjs/src/trusted-name/di/trustedNameTypes.js +2 -0
- package/lib/cjs/src/trusted-name/di/trustedNameTypes.js.map +7 -0
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js +2 -0
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js.map +7 -0
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js +2 -0
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +7 -0
- package/lib/cjs/src/typed-data/data/FiltersDto.js +2 -0
- package/lib/cjs/src/typed-data/data/FiltersDto.js.map +7 -0
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js +2 -0
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js.map +7 -0
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +2 -0
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +7 -0
- package/lib/cjs/src/typed-data/data/TypedDataDataSource.js +2 -0
- package/lib/cjs/src/typed-data/data/TypedDataDataSource.js.map +7 -0
- package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js +2 -0
- package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js.map +7 -0
- package/lib/cjs/src/typed-data/di/typedDataTypes.js +2 -0
- package/lib/cjs/src/typed-data/di/typedDataTypes.js.map +7 -0
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js +2 -0
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +7 -0
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +2 -0
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +7 -0
- package/lib/cjs/src/typed-data/domain/TypedDataContextLoader.js +2 -0
- package/lib/cjs/src/typed-data/domain/TypedDataContextLoader.js.map +7 -0
- package/lib/esm/index.js +1 -37617
- package/lib/esm/index.js.map +4 -4
- package/lib/esm/package.json +58 -0
- package/lib/esm/src/ContextModule.js +1 -0
- package/lib/esm/src/ContextModule.js.map +7 -0
- package/lib/esm/src/ContextModuleBuilder.js +2 -0
- package/lib/esm/src/ContextModuleBuilder.js.map +7 -0
- package/lib/esm/src/ContextModuleBuilder.test.js +2 -0
- package/lib/esm/src/ContextModuleBuilder.test.js.map +7 -0
- package/lib/esm/src/DefaultContextModule.js +2 -0
- package/lib/esm/src/DefaultContextModule.js.map +7 -0
- package/lib/esm/src/DefaultContextModule.test.js +2 -0
- package/lib/esm/src/DefaultContextModule.test.js.map +7 -0
- package/lib/esm/src/config/di/configModuleFactory.js +2 -0
- package/lib/esm/src/config/di/configModuleFactory.js.map +7 -0
- package/lib/esm/src/config/di/configTypes.js +2 -0
- package/lib/esm/src/config/di/configTypes.js.map +7 -0
- package/lib/esm/src/config/model/ContextModuleConfig.js +1 -0
- package/lib/esm/src/config/model/ContextModuleConfig.js.map +7 -0
- package/lib/esm/src/di.js +2 -0
- package/lib/esm/src/di.js.map +7 -0
- package/lib/esm/src/external-plugin/data/DAppDto.js +1 -0
- package/lib/esm/src/external-plugin/data/DAppDto.js.map +7 -0
- package/lib/esm/src/external-plugin/data/ExternalPluginDataSource.js +1 -0
- package/lib/esm/src/external-plugin/data/ExternalPluginDataSource.js.map +7 -0
- package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js +2 -0
- package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js.map +7 -0
- package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js +2 -0
- package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +7 -0
- package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js +2 -0
- package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js.map +7 -0
- package/lib/esm/src/external-plugin/di/externalPluginTypes.js +2 -0
- package/lib/esm/src/external-plugin/di/externalPluginTypes.js.map +7 -0
- package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js +2 -0
- package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js.map +7 -0
- package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js +2 -0
- package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +7 -0
- package/lib/esm/src/external-plugin/model/DappInfos.js +1 -0
- package/lib/esm/src/external-plugin/model/DappInfos.js.map +7 -0
- package/lib/esm/src/external-plugin/model/SelectorDetails.js +1 -0
- package/lib/esm/src/external-plugin/model/SelectorDetails.js.map +7 -0
- package/lib/esm/src/index.js +2 -0
- package/lib/esm/src/index.js.map +7 -0
- package/lib/esm/src/nft/data/HttpNftDataSource.js +2 -0
- package/lib/esm/src/nft/data/HttpNftDataSource.js.map +7 -0
- package/lib/esm/src/nft/data/HttpNftDataSource.test.js +2 -0
- package/lib/esm/src/nft/data/HttpNftDataSource.test.js.map +7 -0
- package/lib/esm/src/nft/data/NftDataSource.js +1 -0
- package/lib/esm/src/nft/data/NftDataSource.js.map +7 -0
- package/lib/esm/src/nft/di/nftModuleFactory.js +2 -0
- package/lib/esm/src/nft/di/nftModuleFactory.js.map +7 -0
- package/lib/esm/src/nft/di/nftTypes.js +2 -0
- package/lib/esm/src/nft/di/nftTypes.js.map +7 -0
- package/lib/esm/src/nft/domain/NftContextLoader.js +2 -0
- package/lib/esm/src/nft/domain/NftContextLoader.js.map +7 -0
- package/lib/esm/src/nft/domain/NftContextLoader.test.js +2 -0
- package/lib/esm/src/nft/domain/NftContextLoader.test.js.map +7 -0
- package/lib/esm/src/shared/domain/ContextLoader.js +1 -0
- package/lib/esm/src/shared/domain/ContextLoader.js.map +7 -0
- package/lib/esm/src/shared/model/ClearSignContext.js +2 -0
- package/lib/esm/src/shared/model/ClearSignContext.js.map +7 -0
- package/lib/esm/src/shared/model/GenericPath.js +2 -0
- package/lib/esm/src/shared/model/GenericPath.js.map +7 -0
- package/lib/esm/src/shared/model/TransactionContext.js +1 -0
- package/lib/esm/src/shared/model/TransactionContext.js.map +7 -0
- package/lib/esm/src/shared/model/TransactionSubset.js +1 -0
- package/lib/esm/src/shared/model/TransactionSubset.js.map +7 -0
- package/lib/esm/src/shared/model/TypedDataClearSignContext.js +2 -0
- package/lib/esm/src/shared/model/TypedDataClearSignContext.js.map +7 -0
- package/lib/esm/src/shared/model/TypedDataContext.js +1 -0
- package/lib/esm/src/shared/model/TypedDataContext.js.map +7 -0
- package/lib/esm/src/shared/utils/HexStringUtils.js +2 -0
- package/lib/esm/src/shared/utils/HexStringUtils.js.map +7 -0
- package/lib/esm/src/token/data/HttpTokenDataSource.js +2 -0
- package/lib/esm/src/token/data/HttpTokenDataSource.js.map +7 -0
- package/lib/esm/src/token/data/HttpTokenDataSource.test.js +2 -0
- package/lib/esm/src/token/data/HttpTokenDataSource.test.js.map +7 -0
- package/lib/esm/src/token/data/TokenDataSource.js +1 -0
- package/lib/esm/src/token/data/TokenDataSource.js.map +7 -0
- package/lib/esm/src/token/data/TokenDto.js +1 -0
- package/lib/esm/src/token/data/TokenDto.js.map +7 -0
- package/lib/esm/src/token/di/tokenModuleFactory.js +2 -0
- package/lib/esm/src/token/di/tokenModuleFactory.js.map +7 -0
- package/lib/esm/src/token/di/tokenTypes.js +2 -0
- package/lib/esm/src/token/di/tokenTypes.js.map +7 -0
- package/lib/esm/src/token/domain/TokenContextLoader.js +2 -0
- package/lib/esm/src/token/domain/TokenContextLoader.js.map +7 -0
- package/lib/esm/src/token/domain/TokenContextLoader.test.js +2 -0
- package/lib/esm/src/token/domain/TokenContextLoader.test.js.map +7 -0
- package/lib/esm/src/transaction/data/CalldataDto.js +1 -0
- package/lib/esm/src/transaction/data/CalldataDto.js.map +7 -0
- package/lib/esm/src/transaction/data/HttpTransactionDataSource.js +2 -0
- package/lib/esm/src/transaction/data/HttpTransactionDataSource.js.map +7 -0
- package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js +2 -0
- package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js.map +7 -0
- package/lib/esm/src/transaction/data/TransactionDataSource.js +1 -0
- package/lib/esm/src/transaction/data/TransactionDataSource.js.map +7 -0
- package/lib/esm/src/transaction/di/transactionModuleFactory.js +2 -0
- package/lib/esm/src/transaction/di/transactionModuleFactory.js.map +7 -0
- package/lib/esm/src/transaction/di/transactionTypes.js +2 -0
- package/lib/esm/src/transaction/di/transactionTypes.js.map +7 -0
- package/lib/esm/src/transaction/domain/TransactionContextLoader.js +2 -0
- package/lib/esm/src/transaction/domain/TransactionContextLoader.js.map +7 -0
- package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js +2 -0
- package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js.map +7 -0
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js +2 -0
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js.map +7 -0
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js +2 -0
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +7 -0
- package/lib/esm/src/trusted-name/data/TrustedNameDataSource.js +1 -0
- package/lib/esm/src/trusted-name/data/TrustedNameDataSource.js.map +7 -0
- package/lib/esm/src/trusted-name/data/TrustedNameDto.js +1 -0
- package/lib/esm/src/trusted-name/data/TrustedNameDto.js.map +7 -0
- package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js +2 -0
- package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js.map +7 -0
- package/lib/esm/src/trusted-name/di/trustedNameTypes.js +2 -0
- package/lib/esm/src/trusted-name/di/trustedNameTypes.js.map +7 -0
- package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js +2 -0
- package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js.map +7 -0
- package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js +2 -0
- package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +7 -0
- package/lib/esm/src/typed-data/data/FiltersDto.js +1 -0
- package/lib/esm/src/typed-data/data/FiltersDto.js.map +7 -0
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js +2 -0
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js.map +7 -0
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +2 -0
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +7 -0
- package/lib/esm/src/typed-data/data/TypedDataDataSource.js +1 -0
- package/lib/esm/src/typed-data/data/TypedDataDataSource.js.map +7 -0
- package/lib/esm/src/typed-data/di/typedDataModuleFactory.js +2 -0
- package/lib/esm/src/typed-data/di/typedDataModuleFactory.js.map +7 -0
- package/lib/esm/src/typed-data/di/typedDataTypes.js +2 -0
- package/lib/esm/src/typed-data/di/typedDataTypes.js.map +7 -0
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js +2 -0
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +7 -0
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +2 -0
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +7 -0
- package/lib/esm/src/typed-data/domain/TypedDataContextLoader.js +1 -0
- package/lib/esm/src/typed-data/domain/TypedDataContextLoader.js.map +7 -0
- package/lib/types/src/ContextModule.d.ts +3 -2
- package/lib/types/src/ContextModule.d.ts.map +1 -1
- package/lib/types/src/ContextModuleBuilder.d.ts +9 -11
- package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -1
- package/lib/types/src/DefaultContextModule.d.ts +9 -11
- package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
- package/lib/types/src/config/di/configModuleFactory.d.ts +1 -1
- package/lib/types/src/config/di/configModuleFactory.d.ts.map +1 -1
- package/lib/types/src/config/model/ContextModuleConfig.d.ts +5 -0
- package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -1
- package/lib/types/src/di.d.ts +1 -1
- package/lib/types/src/di.d.ts.map +1 -1
- package/lib/types/src/external-plugin/data/ExternalPluginDataSource.d.ts +3 -3
- package/lib/types/src/external-plugin/data/ExternalPluginDataSource.d.ts.map +1 -1
- package/lib/types/src/external-plugin/model/DappInfos.d.ts +1 -1
- package/lib/types/src/external-plugin/model/DappInfos.d.ts.map +1 -1
- package/lib/types/src/index.d.ts +2 -1
- package/lib/types/src/index.d.ts.map +1 -1
- package/lib/types/src/nft/data/NftDataSource.d.ts +1 -1
- package/lib/types/src/nft/data/NftDataSource.d.ts.map +1 -1
- package/lib/types/src/nft/domain/NftContextLoader.d.ts +2 -1
- package/lib/types/src/nft/domain/NftContextLoader.d.ts.map +1 -1
- package/lib/types/src/shared/domain/ContextLoader.d.ts +3 -2
- package/lib/types/src/shared/domain/ContextLoader.d.ts.map +1 -1
- package/lib/types/src/shared/model/ClearSignContext.d.ts +33 -6
- package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
- package/lib/types/src/shared/model/GenericPath.d.ts +105 -0
- package/lib/types/src/shared/model/GenericPath.d.ts.map +1 -0
- package/lib/types/src/shared/model/TransactionContext.d.ts +15 -2
- package/lib/types/src/shared/model/TransactionContext.d.ts.map +1 -1
- package/lib/types/src/token/data/TokenDataSource.d.ts +1 -1
- package/lib/types/src/token/data/TokenDataSource.d.ts.map +1 -1
- package/lib/types/src/token/domain/TokenContextLoader.d.ts +2 -1
- package/lib/types/src/token/domain/TokenContextLoader.d.ts.map +1 -1
- package/lib/types/src/transaction/data/CalldataDto.d.ts +128 -0
- package/lib/types/src/transaction/data/CalldataDto.d.ts.map +1 -0
- package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts +22 -0
- package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts.map +1 -0
- package/lib/types/src/transaction/data/HttpTransactionDataSource.test.d.ts +2 -0
- package/lib/types/src/transaction/data/HttpTransactionDataSource.test.d.ts.map +1 -0
- package/lib/types/src/transaction/data/TransactionDataSource.d.ts +12 -0
- package/lib/types/src/transaction/data/TransactionDataSource.d.ts.map +1 -0
- package/lib/types/src/transaction/di/transactionModuleFactory.d.ts +3 -0
- package/lib/types/src/transaction/di/transactionModuleFactory.d.ts.map +1 -0
- package/lib/types/src/transaction/di/transactionTypes.d.ts +5 -0
- package/lib/types/src/transaction/di/transactionTypes.d.ts.map +1 -0
- package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts +10 -0
- package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts.map +1 -0
- package/lib/types/src/transaction/domain/TransactionContextLoader.test.d.ts +2 -0
- package/lib/types/src/transaction/domain/TransactionContextLoader.test.d.ts.map +1 -0
- package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts +11 -0
- package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts.map +1 -0
- package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.test.d.ts +2 -0
- package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.test.d.ts.map +1 -0
- package/lib/types/src/trusted-name/data/TrustedNameDataSource.d.ts +16 -0
- package/lib/types/src/trusted-name/data/TrustedNameDataSource.d.ts.map +1 -0
- package/lib/types/src/trusted-name/data/TrustedNameDto.d.ts +15 -0
- package/lib/types/src/trusted-name/data/TrustedNameDto.d.ts.map +1 -0
- package/lib/types/src/trusted-name/di/trustedNameModuleFactory.d.ts +3 -0
- package/lib/types/src/trusted-name/di/trustedNameModuleFactory.d.ts.map +1 -0
- package/lib/types/src/trusted-name/di/trustedNameTypes.d.ts +5 -0
- package/lib/types/src/trusted-name/di/trustedNameTypes.d.ts.map +1 -0
- package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts +12 -0
- package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts.map +1 -0
- package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.test.d.ts +2 -0
- package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.test.d.ts.map +1 -0
- package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts +1 -1
- package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts.map +1 -1
- package/lib/types/src/typed-data/data/TypedDataDataSource.d.ts +3 -3
- package/lib/types/src/typed-data/data/TypedDataDataSource.d.ts.map +1 -1
- package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +18 -15
- package/lib/types/src/forward-domain/data/ForwardDomainDataSource.d.ts +0 -9
- package/lib/types/src/forward-domain/data/ForwardDomainDataSource.d.ts.map +0 -1
- package/lib/types/src/forward-domain/data/HttpForwardDomainDataSource.d.ts +0 -6
- package/lib/types/src/forward-domain/data/HttpForwardDomainDataSource.d.ts.map +0 -1
- package/lib/types/src/forward-domain/data/HttpForwardDomainDataSource.test.d.ts +0 -2
- package/lib/types/src/forward-domain/data/HttpForwardDomainDataSource.test.d.ts.map +0 -1
- package/lib/types/src/forward-domain/di/forwardDomainModuleFactory.d.ts +0 -3
- package/lib/types/src/forward-domain/di/forwardDomainModuleFactory.d.ts.map +0 -1
- package/lib/types/src/forward-domain/di/forwardDomainTypes.d.ts +0 -5
- package/lib/types/src/forward-domain/di/forwardDomainTypes.d.ts.map +0 -1
- package/lib/types/src/forward-domain/domain/ForwardDomainContextLoader.d.ts +0 -11
- package/lib/types/src/forward-domain/domain/ForwardDomainContextLoader.d.ts.map +0 -1
- package/lib/types/src/forward-domain/domain/ForwardDomainContextLoader.test.d.ts +0 -2
- package/lib/types/src/forward-domain/domain/ForwardDomainContextLoader.test.d.ts.map +0 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ledgerhq/context-module",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./lib/types/index.d.ts",
|
|
9
|
+
"import": "./lib/esm/index.js",
|
|
10
|
+
"require": "./lib/cjs/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./*": {
|
|
13
|
+
"types": "./lib/types/*",
|
|
14
|
+
"import": "./lib/esm/*",
|
|
15
|
+
"require": "./lib/cjs/*"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"./lib"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"prebuild": "rimraf lib",
|
|
23
|
+
"build": "pnpm lmdk-build --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
24
|
+
"dev": "concurrently \"pnpm watch:builds\" \"pnpm watch:types\"",
|
|
25
|
+
"watch:builds": "pnpm lmdk-watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
26
|
+
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\"",
|
|
27
|
+
"lint": "eslint",
|
|
28
|
+
"lint:fix": "pnpm lint --fix",
|
|
29
|
+
"postpack": "find . -name '*.tgz' -exec cp {} ../../../dist/ \\; ",
|
|
30
|
+
"prettier": "prettier . --check",
|
|
31
|
+
"prettier:fix": "prettier . --write",
|
|
32
|
+
"test": "jest",
|
|
33
|
+
"test:watch": "pnpm test -- --watch",
|
|
34
|
+
"test:coverage": "pnpm test -- --coverage",
|
|
35
|
+
"typecheck": "tsc --noEmit"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@ledgerhq/device-management-kit": "workspace:*",
|
|
39
|
+
"@ledgerhq/esbuild-tools": "workspace:*",
|
|
40
|
+
"@ledgerhq/eslint-config-dsdk": "workspace:*",
|
|
41
|
+
"@ledgerhq/jest-config-dsdk": "workspace:*",
|
|
42
|
+
"@ledgerhq/prettier-config-dsdk": "workspace:*",
|
|
43
|
+
"@ledgerhq/tsconfig-dsdk": "workspace:*",
|
|
44
|
+
"@types/crypto-js": "^4.2.2",
|
|
45
|
+
"ts-node": "^10.9.2"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"axios": "^1.7.9",
|
|
49
|
+
"crypto-js": "^4.2.0",
|
|
50
|
+
"ethers": "6.13.4",
|
|
51
|
+
"inversify": "^6.2.1",
|
|
52
|
+
"purify-ts": "^2.1.0",
|
|
53
|
+
"reflect-metadata": "^0.2.2"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"@ledgerhq/device-management-kit": "workspace:*"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=ContextModule.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{DefaultContextModule as e}from"./DefaultContextModule";const r="https://crypto-assets-service.api.ledger.com/v1",o={cal:{url:r,mode:"prod",branch:"main"},defaultLoaders:!0,customLoaders:[],customTypedDataLoader:void 0};class n{config=o;constructor(){}removeDefaultLoaders(){return this.config.defaultLoaders=!1,this}addLoader(t){return this.config.customLoaders.push(t),this}addTypedDataLoader(t){return this.config.customTypedDataLoader=t,this}addCalConfig(t){return this.config.cal={...o.cal,...t},this}build(){return new e(this.config)}}export{n as ContextModuleBuilder,o as DEFAULT_CONFIG};
|
|
2
|
+
//# sourceMappingURL=ContextModuleBuilder.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/ContextModuleBuilder.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n type ContextModuleCalConfig,\n type ContextModuleConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport { type TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst DEFAULT_CAL_URL = \"https://crypto-assets-service.api.ledger.com/v1\";\n\nexport const DEFAULT_CONFIG: ContextModuleConfig = {\n cal: {\n url: DEFAULT_CAL_URL,\n mode: \"prod\",\n branch: \"main\",\n },\n defaultLoaders: true,\n customLoaders: [],\n customTypedDataLoader: undefined,\n};\n\nexport class ContextModuleBuilder {\n private config: ContextModuleConfig = DEFAULT_CONFIG;\n\n constructor() {}\n\n /**\n * Remove default loaders from the list of loaders\n *\n * @returns this\n */\n removeDefaultLoaders() {\n this.config.defaultLoaders = false;\n return this;\n }\n\n /**\n * Add a custom loader to the list of loaders\n *\n * @param loader loader to add to the list of loaders\n * @returns this\n */\n addLoader(loader: ContextLoader) {\n this.config.customLoaders.push(loader);\n return this;\n }\n\n /**\n * Replace the default loader for typed data clear signing contexts\n *\n * @param loader loader to use for typed data clear signing contexts\n * @returns this\n */\n addTypedDataLoader(loader: TypedDataContextLoader) {\n this.config.customTypedDataLoader = loader;\n return this;\n }\n\n /**\n * Add a custom CAL configuration\n *\n * @param calConfig\n * @returns this\n */\n addCalConfig(calConfig: ContextModuleCalConfig) {\n this.config.cal = { ...DEFAULT_CONFIG.cal, ...calConfig };\n return this;\n }\n\n /**\n * Build the context module\n *\n * @returns the context module\n */\n build(): ContextModule {\n return new DefaultContextModule(this.config);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAOA,OAAS,wBAAAA,MAA4B,yBAErC,MAAMC,EAAkB,kDAEXC,EAAsC,CACjD,IAAK,CACH,IAAKD,EACL,KAAM,OACN,OAAQ,MACV,EACA,eAAgB,GAChB,cAAe,CAAC,EAChB,sBAAuB,MACzB,EAEO,MAAME,CAAqB,CACxB,OAA8BD,EAEtC,aAAc,CAAC,CAOf,sBAAuB,CACrB,YAAK,OAAO,eAAiB,GACtB,IACT,CAQA,UAAUE,EAAuB,CAC/B,YAAK,OAAO,cAAc,KAAKA,CAAM,EAC9B,IACT,CAQA,mBAAmBA,EAAgC,CACjD,YAAK,OAAO,sBAAwBA,EAC7B,IACT,CAQA,aAAaC,EAAmC,CAC9C,YAAK,OAAO,IAAM,CAAE,GAAGH,EAAe,IAAK,GAAGG,CAAU,EACjD,IACT,CAOA,OAAuB,CACrB,OAAO,IAAIL,EAAqB,KAAK,MAAM,CAC7C,CACF",
|
|
6
|
+
"names": ["DefaultContextModule", "DEFAULT_CAL_URL", "DEFAULT_CONFIG", "ContextModuleBuilder", "loader", "calConfig"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{ContextModuleBuilder as o}from"./ContextModuleBuilder";import{DefaultContextModule as d}from"./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().build();expect(e).toBeInstanceOf(d)}),it("should return a custom context module",()=>{const t=new o,e={load:jest.fn()},n=t.removeDefaultLoaders().addLoader(e).build();expect(n).toBeInstanceOf(d)}),it("should return a custom context module with a custom typed data loader",()=>{const t=new o,e={load:jest.fn()},n=t.removeDefaultLoaders().addTypedDataLoader(e).build();expect(n).toBeInstanceOf(d)}),it("should return a custom context module with a custom config",()=>{const e=new o().addCalConfig(u).build();expect(e).toBeInstanceOf(d)})});
|
|
2
|
+
//# sourceMappingURL=ContextModuleBuilder.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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: jest.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: jest.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,OAAS,wBAAAA,MAA4B,yBACrC,OAAS,wBAAAC,MAA4B,yBAErC,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA2C,CAC/C,IAAK,kDACL,KAAM,OACN,OAAQ,MACV,EACA,GAAG,yCAA0C,IAAM,CAGjD,MAAMC,EAFuB,IAAIH,EAAqB,EAErB,MAAM,EAEvC,OAAOG,CAAG,EAAE,eAAeF,CAAoB,CACjD,CAAC,EAED,GAAG,wCAAyC,IAAM,CAChD,MAAMG,EAAuB,IAAIJ,EAC3BK,EAAe,CAAE,KAAM,KAAK,GAAG,CAAE,EAEjCF,EAAMC,EACT,qBAAqB,EACrB,UAAUC,CAAY,EACtB,MAAM,EAET,OAAOF,CAAG,EAAE,eAAeF,CAAoB,CACjD,CAAC,EAED,GAAG,wEAAyE,IAAM,CAChF,MAAMG,EAAuB,IAAIJ,EAC3BK,EAAe,CAAE,KAAM,KAAK,GAAG,CAAE,EAEjCF,EAAMC,EACT,qBAAqB,EACrB,mBAAmBC,CAAY,EAC/B,MAAM,EAET,OAAOF,CAAG,EAAE,eAAeF,CAAoB,CACjD,CAAC,EAED,GAAG,6DAA8D,IAAM,CAGrE,MAAME,EAFuB,IAAIH,EAAqB,EAErB,aAAaE,CAAgB,EAAE,MAAM,EAEtE,OAAOC,CAAG,EAAE,eAAeF,CAAoB,CACjD,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["ContextModuleBuilder", "DefaultContextModule", "defaultCalConfig", "res", "contextModuleBuilder", "customLoader"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{transactionTypes as r}from"./transaction/di/transactionTypes";import{trustedNameTypes as n}from"./trusted-name/di/trustedNameTypes";import{externalPluginTypes as i}from"./external-plugin/di/externalPluginTypes";import{nftTypes as p}from"./nft/di/nftTypes";import{ClearSignContextType as d}from"./shared/model/ClearSignContext";import{tokenTypes as s}from"./token/di/tokenTypes";import{typedDataTypes as m}from"./typed-data/di/typedDataTypes";import{makeContainer as C}from"./di";class g{_container;_loaders;_typedDataLoader;constructor(t){this._container=C({config:t}),this._loaders=t.defaultLoaders?this._getDefaultLoaders():[],this._loaders.push(...t.customLoaders),this._typedDataLoader=t.customTypedDataLoader??this._getDefaultTypedDataLoader()}_getDefaultLoaders(){return[this._container.get(i.ExternalPluginContextLoader),this._container.get(n.TrustedNameContextLoader),this._container.get(p.NftContextLoader),this._container.get(s.TokenContextLoader),this._container.get(r.TransactionContextLoader)]}_getDefaultTypedDataLoader(){return this._container.get(m.TypedDataContextLoader)}async getContexts(t){const o=this._loaders.map(e=>e.load(t));return(await Promise.all(o)).flat()}async getContext(t){const o=this._loaders.filter(e=>e.loadField).map(e=>e.loadField(t));return(await Promise.all(o)).find(e=>e!==null)||{type:d.ERROR,error:new Error(`Field type not supported: ${t.type}`)}}async getTypedDataFilters(t){return this._typedDataLoader.load(t)}}export{g as DefaultContextModule};
|
|
2
|
+
//# sourceMappingURL=DefaultContextModule.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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": "AAIA,OAAS,oBAAAA,MAAwB,oCACjC,OAAS,oBAAAC,MAAwB,qCAGjC,OAAS,uBAAAC,MAA2B,2CAEpC,OAAS,YAAAC,MAAgB,oBAGzB,OAEE,wBAAAC,MACK,kCAKP,OAAS,cAAAC,MAAkB,wBAI3B,OAAS,kBAAAC,MAAsB,iCAG/B,OAAS,iBAAAC,MAAqB,OAEvB,MAAMC,CAA8C,CACjD,WACA,SACA,iBAER,YAAYC,EAA2B,CACrC,KAAK,WAAaF,EAAc,CAAE,OAAQE,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,IACdP,EAAoB,2BACtB,EACA,KAAK,WAAW,IACdD,EAAiB,wBACnB,EACA,KAAK,WAAW,IAAsBE,EAAS,gBAAgB,EAC/D,KAAK,WAAW,IAAwBE,EAAW,kBAAkB,EACrE,KAAK,WAAW,IACdL,EAAiB,wBACnB,CACF,CACF,CAEQ,4BAAqD,CAC3D,OAAO,KAAK,WAAW,IACrBM,EAAe,sBACjB,CACF,CAEA,MAAa,YACXI,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,KAAMV,EAAqB,MAC3B,MAAO,IAAI,MAAM,6BAA6BS,EAAM,IAAI,EAAE,CAC5D,CAEJ,CAEA,MAAa,oBACXE,EACoC,CACpC,OAAO,KAAK,iBAAiB,KAAKA,CAAS,CAC7C,CACF",
|
|
6
|
+
"names": ["transactionTypes", "trustedNameTypes", "externalPluginTypes", "nftTypes", "ClearSignContextType", "tokenTypes", "typedDataTypes", "makeContainer", "DefaultContextModule", "args", "transaction", "promises", "fetcher", "field", "resp", "typedData"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{DefaultContextModule as a}from"./DefaultContextModule";const l=()=>({load:jest.fn(),loadField:jest.fn()});describe("DefaultContextModule",()=>{const s={load:jest.fn()},o={customLoaders:[],defaultLoaders:!1,customTypedDataLoader:s,cal:{url:"https://crypto-assets-service.api.ledger.com/v1",mode:"prod",branch:"main"}};beforeEach(()=>{jest.restoreAllMocks()}),it("should initialize the context module with all the default loaders",async()=>{const t=await new a(o).getContexts({});expect(t).toEqual([])}),it("should return an empty array when no loaders",async()=>{const t=await new a(o).getContexts({});expect(t).toEqual([])}),it("should call all fetch method from metadata fetcher",async()=>{const e=l();await new a({...o,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"}]];jest.spyOn(e,"load").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const n=await new a({...o,customLoaders:[e,e]}).getContexts({});expect(e.load).toHaveBeenCalledTimes(2),expect(n).toEqual(t.flat())}),it("should call the typed data loader",async()=>{await new a({...o,customTypedDataLoader:s}).getTypedDataFilters({}),expect(s.load).toHaveBeenCalledTimes(1)}),it("should return a single context",async()=>{const e=l(),t=[null,{type:"token",payload:"payload"}];jest.spyOn(e,"loadField").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const n=await new a({...o,customLoaders:[e,{load:jest.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];jest.spyOn(e,"loadField").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const n=await new a({...o,customLoaders:[e,{load:jest.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 a({...o,customLoaders:[{load:jest.fn()}]}).getContext({type:"token"});expect(t).toEqual({type:"error",error:new Error("Field type not supported: token")})})});
|
|
2
|
+
//# sourceMappingURL=DefaultContextModule.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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: jest.fn(), loadField: jest.fn() };\n};\n\ndescribe(\"DefaultContextModule\", () => {\n const typedDataLoader: TypedDataContextLoader = { load: jest.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 jest.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 jest\n .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 jest\n .spyOn(loader, \"loadField\")\n .mockResolvedValueOnce(responses[0])\n .mockResolvedValueOnce(responses[1]);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, { load: jest.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 jest\n .spyOn(loader, \"loadField\")\n .mockResolvedValueOnce(responses[0])\n .mockResolvedValueOnce(responses[1]);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, { load: jest.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: jest.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,OAAS,wBAAAA,MAA4B,yBAErC,MAAMC,EAA2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O,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,IAAIJ,EAAqB,CAC7C,GAAGG,EACH,cAAe,CAAC,CAAE,KAAM,KAAK,GAAG,CAAE,CAAC,CACrC,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
|
+
"names": ["DefaultContextModule", "contextLoaderStubBuilder", "typedDataLoader", "defaultContextModuleConfig", "res", "loader", "responses"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/config/di/configModuleFactory.ts"],
|
|
4
|
+
"sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\n\nimport { configTypes } from \"./configTypes\";\n\nexport const configModuleFactory = (config: ContextModuleConfig) =>\n new ContainerModule((bind, _unbind, _isBound, _rebind) => {\n bind<ContextModuleConfig>(configTypes.Config).toConstantValue(config);\n });\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAIhC,OAAS,eAAAC,MAAmB,gBAErB,MAAMC,EAAuBC,GAClC,IAAIH,EAAgB,CAACI,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAA0BH,EAAY,MAAM,EAAE,gBAAgBE,CAAM,CACtE,CAAC",
|
|
6
|
+
"names": ["ContainerModule", "configTypes", "configModuleFactory", "config", "bind", "_unbind", "_isBound", "_rebind"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/config/di/configTypes.ts"],
|
|
4
|
+
"sourcesContent": ["export const configTypes = {\n Config: Symbol.for(\"config\"),\n};\n"],
|
|
5
|
+
"mappings": "AAAO,MAAMA,EAAc,CACzB,OAAQ,OAAO,IAAI,QAAQ,CAC7B",
|
|
6
|
+
"names": ["configTypes"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=ContextModuleConfig.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Container as r}from"inversify";import{configModuleFactory as e}from"./config/di/configModuleFactory";import{externalPluginModuleFactory as n}from"./external-plugin/di/externalPluginModuleFactory";import{nftModuleFactory as a}from"./nft/di/nftModuleFactory";import{tokenModuleFactory as i}from"./token/di/tokenModuleFactory";import{transactionModuleFactory as m}from"./transaction/di/transactionModuleFactory";import{trustedNameModuleFactory as f}from"./trusted-name/di/trustedNameModuleFactory";import{typedDataModuleFactory as c}from"./typed-data/di/typedDataModuleFactory";const F=({config:t})=>{const o=new r;return o.load(e(t),n(),a(),i(),m(),f(),c()),o};export{F as makeContainer};
|
|
2
|
+
//# sourceMappingURL=di.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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": "AAAA,OAAS,aAAAA,MAAiB,YAE1B,OAAS,uBAAAC,MAA2B,kCAEpC,OAAS,+BAAAC,MAAmC,mDAC5C,OAAS,oBAAAC,MAAwB,4BACjC,OAAS,sBAAAC,MAA0B,gCACnC,OAAS,4BAAAC,MAAgC,4CACzC,OAAS,4BAAAC,MAAgC,6CACzC,OAAS,0BAAAC,MAA8B,yCAMhC,MAAMC,EAAgB,CAAC,CAAE,OAAAC,CAAO,IAAyB,CAC9D,MAAMC,EAAY,IAAIV,EAEtB,OAAAU,EAAU,KACRT,EAAoBQ,CAAM,EAC1BP,EAA4B,EAC5BC,EAAiB,EACjBC,EAAmB,EACnBC,EAAyB,EACzBC,EAAyB,EACzBC,EAAuB,CACzB,EAEOG,CACT",
|
|
6
|
+
"names": ["Container", "configModuleFactory", "externalPluginModuleFactory", "nftModuleFactory", "tokenModuleFactory", "transactionModuleFactory", "trustedNameModuleFactory", "typedDataModuleFactory", "makeContainer", "config", "container"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=DAppDto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=ExternalPluginDataSource.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var D=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var u=(a,r,o,e)=>{for(var t=e>1?void 0:e?C(r,o):r,i=a.length-1,n;i>=0;i--)(n=a[i])&&(t=(e?n(r,o,t):n(t))||t);return e&&t&&D(r,o,t),t},d=(a,r)=>(o,e)=>r(o,e,a);import h from"axios";import{inject as b,injectable as x}from"inversify";import{Left as E,Right as s}from"purify-ts";import{configTypes as I}from"../../config/di/configTypes";import y from"../../../package.json";let f=class{constructor(r){this.config=r}async getDappInfos({chainId:r,address:o,selector:e}){try{const t=await h.request({method:"GET",url:`${this.config.cal.url}/dapps`,params:{output:"b2c,b2c_signatures,abis",chain_id:r,contracts:o},headers:{"X-Ledger-Client-Version":`context-module/${y.version}`}});if(!t.data[0])return s(void 0);o=o.toLowerCase(),e=`0x${e.slice(2).toLowerCase()}`;const{erc20OfInterest:i,method:n,plugin:p}=t.data[0].b2c?.contracts?.find(g=>g.address===o)?.selectors?.[e]||{},{signature:c,serialized_data:m}=t.data[0].b2c_signatures?.[o]?.[e]||{};if(!i||!n||!p||!c||!m)return s(void 0);const l=t.data[0].abis?.[o];return l?s({selectorDetails:{method:n,plugin:p,erc20OfInterest:i,signature:c,serializedData:m},abi:l}):s(void 0)}catch{return E(new Error("[ContextModule] HttpExternalPluginDataSource: Error fetching dapp infos"))}}};f=u([x(),d(0,b(I.Config))],f);export{f as HttpExternalPluginDataSource};
|
|
2
|
+
//# sourceMappingURL=HttpExternalPluginDataSource.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/external-plugin/data/HttpExternalPluginDataSource.ts"],
|
|
4
|
+
"sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport type { ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { DAppDto } from \"@/external-plugin/data/DAppDto\";\nimport {\n ExternalPluginDataSource,\n GetDappInfos,\n} from \"@/external-plugin/data/ExternalPluginDataSource\";\nimport { DappInfos } from \"@/external-plugin/model/DappInfos\";\nimport { SelectorDetails } from \"@/external-plugin/model/SelectorDetails\";\nimport PACKAGE from \"@root/package.json\";\n\n@injectable()\nexport class HttpExternalPluginDataSource implements ExternalPluginDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n async getDappInfos({\n chainId,\n address,\n selector,\n }: GetDappInfos): Promise<Either<Error, DappInfos | undefined>> {\n try {\n const dappInfos = await axios.request<DAppDto[]>({\n method: \"GET\",\n url: `${this.config.cal.url}/dapps`,\n params: {\n output: \"b2c,b2c_signatures,abis\",\n chain_id: chainId,\n contracts: address,\n },\n headers: {\n \"X-Ledger-Client-Version\": `context-module/${PACKAGE.version}`,\n },\n });\n\n if (!dappInfos.data[0]) {\n return Right(undefined);\n }\n\n // Normalize the address and selector\n address = address.toLowerCase();\n selector = `0x${selector.slice(2).toLowerCase()}`;\n\n const { erc20OfInterest, method, plugin } =\n dappInfos.data[0].b2c?.contracts?.find((c) => c.address === address)\n ?.selectors?.[selector] || {};\n const { signature, serialized_data: serializedData } =\n dappInfos.data[0].b2c_signatures?.[address]?.[selector] || {};\n\n if (\n !erc20OfInterest ||\n !method ||\n !plugin ||\n !signature ||\n !serializedData\n ) {\n return Right(undefined);\n }\n\n const abi = dappInfos.data[0].abis?.[address];\n\n if (!abi) {\n return Right(undefined);\n }\n\n const selectorDetails: SelectorDetails = {\n method,\n plugin,\n erc20OfInterest,\n signature,\n serializedData,\n };\n\n return Right({ selectorDetails, abi });\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpExternalPluginDataSource: Error fetching dapp infos\",\n ),\n );\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "iOAAA,OAAOA,MAAW,QAClB,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAS5B,OAAOC,MAAa,qBAGb,IAAMC,EAAN,KAAuE,CAC5E,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAM,aAAa,CACjB,QAAAC,EACA,QAAAC,EACA,SAAAC,CACF,EAAgE,CAC9D,GAAI,CACF,MAAMC,EAAY,MAAMC,EAAM,QAAmB,CAC/C,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,IAAI,GAAG,SAC3B,OAAQ,CACN,OAAQ,0BACR,SAAUJ,EACV,UAAWC,CACb,EACA,QAAS,CACP,0BAA2B,kBAAkBI,EAAQ,OAAO,EAC9D,CACF,CAAC,EAED,GAAI,CAACF,EAAU,KAAK,CAAC,EACnB,OAAOG,EAAM,MAAS,EAIxBL,EAAUA,EAAQ,YAAY,EAC9BC,EAAW,KAAKA,EAAS,MAAM,CAAC,EAAE,YAAY,CAAC,GAE/C,KAAM,CAAE,gBAAAK,EAAiB,OAAAC,EAAQ,OAAAC,CAAO,EACtCN,EAAU,KAAK,CAAC,EAAE,KAAK,WAAW,KAAMO,GAAMA,EAAE,UAAYT,CAAO,GAC/D,YAAYC,CAAQ,GAAK,CAAC,EAC1B,CAAE,UAAAS,EAAW,gBAAiBC,CAAe,EACjDT,EAAU,KAAK,CAAC,EAAE,iBAAiBF,CAAO,IAAIC,CAAQ,GAAK,CAAC,EAE9D,GACE,CAACK,GACD,CAACC,GACD,CAACC,GACD,CAACE,GACD,CAACC,EAED,OAAON,EAAM,MAAS,EAGxB,MAAMO,EAAMV,EAAU,KAAK,CAAC,EAAE,OAAOF,CAAO,EAE5C,OAAKY,EAYEP,EAAM,CAAE,gBAR0B,CACvC,OAAAE,EACA,OAAAC,EACA,gBAAAF,EACA,UAAAI,EACA,eAAAC,CACF,EAEgC,IAAAC,CAAI,CAAC,EAX5BP,EAAM,MAAS,CAY1B,MAAiB,CACf,OAAOQ,EACL,IAAI,MACF,yEACF,CACF,CACF,CACF,CACF,EAvEahB,EAANiB,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,IAFjBrB",
|
|
6
|
+
"names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "PACKAGE", "HttpExternalPluginDataSource", "config", "chainId", "address", "selector", "dappInfos", "axios", "PACKAGE", "Right", "erc20OfInterest", "method", "plugin", "c", "signature", "serializedData", "abi", "Left", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import n from"axios";import u from"@/external-plugin/__tests__/abi.json";import{HttpExternalPluginDataSource as d}from"../../external-plugin/data/HttpExternalPluginDataSource";import l from"../../../package.json";jest.mock("axios");const a=t=>({data:t});describe("HttpExternalPuginDataSource",()=>{let t;const i={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"},r={"0x1ef":u,"0x0abc":u},o={"0x1ef":{"0x01ee":{plugin:"plugin",serialized_data:"0x001",signature:"0x002"}},"0x0abc":{"0x01ff":{plugin:"plugin",serialized_data:"0x001",signature:"0x002"}}};beforeAll(()=>{const s={cal:{url:"https://crypto-assets-service.api.ledger.com/v1"}};t=new d(s),jest.clearAllMocks()}),it("should call axios with the ledger client version header",async()=>{const s=`context-module/${l.version}`,e=jest.fn(()=>Promise.resolve({data:[]}));jest.spyOn(n,"request").mockImplementation(e),await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"}),expect(e).toHaveBeenCalledWith(expect.objectContaining({headers:{"X-Ledger-Client-Version":s}}))}),it("should return undefined when no abis is undefined",async()=>{const s=a([{b2c:i,b2c_signatures:o}]);jest.spyOn(n,"request").mockResolvedValue(s);const e=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e.extract()).toEqual(void 0)}),it("should return undefined when no selectors",async()=>{const s=a([{abis:r,b2c_signatures:o}]);jest.spyOn(n,"request").mockResolvedValue(s);const e=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e.extract()).toEqual(void 0)}),it("should return undefined when no abis data",async()=>{const s=a([{abis:{},b2c:i,b2c_signatures:o}]);jest.spyOn(n,"request").mockResolvedValue(s);const e=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e.extract()).toEqual(void 0)}),it("should return undefined when no abis data",async()=>{const s=a([{abis:{},b2c:i,b2c_signatures:o}]);jest.spyOn(n,"request").mockResolvedValue(s);const e=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e.extract()).toEqual(void 0)}),it("should return undefined when no abis data for the contract address",async()=>{const e=a([{abis:{"0x1":u},b2c:i,b2c_signatures:o}]);jest.spyOn(n,"request").mockResolvedValue(e);const c=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(c.extract()).toEqual(void 0)}),it("should return undefined when no b2c signature",async()=>{const s=a([{b2c:i,abis:r}]);jest.spyOn(n,"request").mockResolvedValue(s);const e=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e.extract()).toEqual(void 0)}),it("should return undefined when no ecc20OfInterest",async()=>{const e=a([{b2c:{blockchainName:"ethereum",chainId:1,contracts:[{address:"0x0abc",contractName:"name",selectors:{"0x01ff":{method:"swap",plugin:"plugin"}}}],name:"test"},abis:r,b2c_signatures:o}]);jest.spyOn(n,"request").mockResolvedValue(e);const c=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(c.extract()).toEqual(void 0)}),it("should return undefined when no method",async()=>{const e=a([{b2c:{blockchainName:"ethereum",chainId:1,contracts:[{address:"0x0abc",contractName:"name",selectors:{"0x01ff":{erc20OfInterest:["fromToken"],plugin:"plugin"}}}],name:"test"},abis:r,b2c_signatures:o}]);jest.spyOn(n,"request").mockResolvedValue(e);const c=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(c.extract()).toEqual(void 0)}),it("should return undefined when no plugin",async()=>{const e=a([{b2c:{blockchainName:"ethereum",chainId:1,contracts:[{address:"0x0abc",contractName:"name",selectors:{"0x01ff":{erc20OfInterest:["fromToken"],method:"swap"}}}],name:"test"},abis:r,b2c_signatures:o}]);jest.spyOn(n,"request").mockResolvedValue(e);const c=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(c.extract()).toEqual(void 0)}),it("should return undefined when no method",async()=>{const e=a([{b2c:{blockchainName:"ethereum",chainId:1,contracts:[{address:"0x0abc",contractName:"name",selectors:{"0x01ff":{erc20OfInterest:["fromToken"],plugin:"plugin"}}}],name:"test"},abis:r,b2c_signatures:o}]);jest.spyOn(n,"request").mockResolvedValue(e);const c=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(c.extract()).toEqual(void 0)}),it("should return undefined when no signature",async()=>{const e=a([{b2c:i,abis:r,b2c_signatures:{"0x0abc":{"0x01ff":{plugin:"plugin",serialized_data:"0x001"}}}}]);jest.spyOn(n,"request").mockResolvedValue(e);const c=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(c.extract()).toEqual(void 0)}),it("should return undefined when no serialized data",async()=>{const e=a([{b2c:i,abis:r,b2c_signatures:{"0x0abc":{"0x01ff":{plugin:"plugin",signature:"0x002"}}}}]);jest.spyOn(n,"request").mockResolvedValue(e);const c=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(c.extract()).toEqual(void 0)}),it("should return a correct response",async()=>{const s=a([{b2c:i,abis:r,b2c_signatures:o}]);jest.spyOn(n,"request").mockResolvedValue(s);const e=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e.extract()).toEqual({abi:u,selectorDetails:{erc20OfInterest:["fromToken"],method:"swap",plugin:"plugin",serializedData:"0x001",signature:"0x002"}})}),it("should normalize the address and selector",async()=>{const s=a([{b2c:i,abis:r,b2c_signatures:o}]);jest.spyOn(n,"request").mockResolvedValue(s);const e=await t.getDappInfos({chainId:1,address:"0x0AbC",selector:"0x01Ff"});expect(e.extract()).toEqual({abi:u,selectorDetails:{erc20OfInterest:["fromToken"],method:"swap",plugin:"plugin",serializedData:"0x001",signature:"0x002"}})}),it("should return an error when axios throws an error",async()=>{jest.spyOn(n,"request").mockRejectedValue(new Error("error"));const s=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(s.extract()).toEqual(new Error("[ContextModule] HttpExternalPluginDataSource: Error fetching dapp infos"))})});
|
|
2
|
+
//# sourceMappingURL=HttpExternalPluginDataSource.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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": "AAAA,OAAOA,MAAW,QAGlB,OAAOC,MAAS,uCAQhB,OAAS,gCAAAC,MAAoC,sDAC7C,OAAOC,MAAa,qBAEpB,KAAK,KAAK,OAAO,EAEjB,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,OAC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AAE,QAAQ,CAC/B,IAAKb,EACL,gBAAiB,CACf,gBAAiB,CAAC,WAAW,EAC7B,OAAQ,OACR,OAAQ,SACR,eAAgB,QAChB,UAAW,OACb,CACF,CAAC,CACH,CAAC,EAED,GAAG,oDAAqD,SAAY,CAElE,KAAK,MAAMD,EAAO,SAAS,EAAE,kBAAkB,IAAI,MAAM,OAAO,CAAC,EAGjE,MAAMc,EAAS,MAAMR,EAAW,aAAa,CAC3C,QAAS,EACT,QAAS,SACT,SAAU,QACZ,CAAC,EAGD,OAAOQ,EAAO,QAAQ,CAAC,EAAE,QACvB,IAAI,MACF,yEACF,CACF,CACF,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["axios", "ABI", "HttpExternalPluginDataSource", "PACKAGE", "axiosResponseBuilder", "dto", "datasource", "exampleB2c", "exampleAbis", "exampleB2cSignatures", "config", "version", "requestSpy", "response", "result"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{ContainerModule as r}from"inversify";import{HttpExternalPluginDataSource as e}from"../../external-plugin/data/HttpExternalPluginDataSource";import{externalPluginTypes as o}from"../../external-plugin/di/externalPluginTypes";import{ExternalPluginContextLoader as n}from"../../external-plugin/domain/ExternalPluginContextLoader";const d=()=>new r((t,a,l,i)=>{t(o.ExternalPluginDataSource).to(e),t(o.ExternalPluginContextLoader).to(n)});export{d as externalPluginModuleFactory};
|
|
2
|
+
//# sourceMappingURL=externalPluginModuleFactory.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/external-plugin/di/externalPluginModuleFactory.ts"],
|
|
4
|
+
"sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpExternalPluginDataSource } from \"@/external-plugin/data/HttpExternalPluginDataSource\";\nimport { externalPluginTypes } from \"@/external-plugin/di/externalPluginTypes\";\nimport { ExternalPluginContextLoader } from \"@/external-plugin/domain/ExternalPluginContextLoader\";\n\nexport const externalPluginModuleFactory = () =>\n new ContainerModule((bind, _unbind, _isBound, _rebind) => {\n bind(externalPluginTypes.ExternalPluginDataSource).to(\n HttpExternalPluginDataSource,\n );\n bind(externalPluginTypes.ExternalPluginContextLoader).to(\n ExternalPluginContextLoader,\n );\n });\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,gCAAAC,MAAoC,sDAC7C,OAAS,uBAAAC,MAA2B,2CACpC,OAAS,+BAAAC,MAAmC,uDAErC,MAAMC,EAA8B,IACzC,IAAIJ,EAAgB,CAACK,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAAKH,EAAoB,wBAAwB,EAAE,GACjDD,CACF,EACAI,EAAKH,EAAoB,2BAA2B,EAAE,GACpDC,CACF,CACF,CAAC",
|
|
6
|
+
"names": ["ContainerModule", "HttpExternalPluginDataSource", "externalPluginTypes", "ExternalPluginContextLoader", "externalPluginModuleFactory", "bind", "_unbind", "_isBound", "_rebind"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/external-plugin/di/externalPluginTypes.ts"],
|
|
4
|
+
"sourcesContent": ["export const externalPluginTypes = {\n ExternalPluginDataSource: Symbol.for(\"externalPluginDataSource\"),\n ExternalPluginContextLoader: Symbol.for(\"externalPluginContextLoader\"),\n};\n"],
|
|
5
|
+
"mappings": "AAAO,MAAMA,EAAsB,CACjC,yBAA0B,OAAO,IAAI,0BAA0B,EAC/D,4BAA6B,OAAO,IAAI,6BAA6B,CACvE",
|
|
6
|
+
"names": ["externalPluginTypes"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var C=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var g=(s,e,a,r)=>{for(var t=r>1?void 0:r?S(e,a):e,o=s.length-1,n;o>=0;o--)(n=s[o])&&(t=(r?n(e,a,t):n(t))||t);return r&&t&&C(e,a,t),t},p=(s,e)=>(a,r)=>e(a,r,s);import{isHexaString as x}from"@ledgerhq/device-management-kit";import{Interface as y}from"ethers";import{inject as f,injectable as E}from"inversify";import{EitherAsync as m,Left as R,Right as P}from"purify-ts";import{externalPluginTypes as k}from"../../external-plugin/di/externalPluginTypes";import{ClearSignContextType as i}from"../../shared/model/ClearSignContext";import{tokenTypes as T}from"../../token/di/tokenTypes";let l=class{_externalPluginDataSource;_tokenDataSource;constructor(e,a){this._externalPluginDataSource=e,this._tokenDataSource=a}async load(e){if(!e.to||!e.data||e.data==="0x")return[];const a=e.data.slice(0,10);if(!x(a))return[{type:i.ERROR,error:new Error("Invalid selector")}];const r=await this._externalPluginDataSource.getDappInfos({address:e.to,chainId:e.chainId,selector:a});return m(async({liftEither:t})=>{const o=await t(r);if(!o)return[];const n={type:i.EXTERNAL_PLUGIN,payload:o.selectorDetails.serializedData.concat(o.selectorDetails.signature)},c=this.getDecodedCallData(o.abi,o.selectorDetails.method,e.data);if(c.isLeft())return[{type:i.ERROR,error:c.extract()},n];const D=c.extract(),h=o.selectorDetails.erc20OfInterest.map(async d=>this.getTokenPayload(e,d,D));return[...(await Promise.all(h)).map(d=>d.caseOf({Left:u=>({type:i.ERROR,error:u}),Right:u=>({type:i.TOKEN,payload:u})})),n]}).caseOf({Left:t=>[{type:i.ERROR,error:t}],Right:t=>t})}getTokenPayload(e,a,r){const t=this.getAddressFromPath(a,r);return m(({fromPromise:o})=>o(this._tokenDataSource.getTokenInfosPayload({address:t,chainId:e.chainId})))}getDecodedCallData(e,a,r){try{const t=new y(e);return P(t.decodeFunctionData(a,r))}catch{return R(new Error("[ContextModule] ExternalPluginContextLoader: Unable to parse abi"))}}getAddressFromPath(e,a){let r=a;for(const t of e.split("."))t==="-1"?r=r[r.length-1]:r=r[t];if(!x(r))throw new Error("[ContextModule] ExternalPluginContextLoader: Unable to get address");return r}};l=g([E(),p(0,f(k.ExternalPluginDataSource)),p(1,f(T.TokenDataSource))],l);export{l as ExternalPluginContextLoader};
|
|
2
|
+
//# sourceMappingURL=ExternalPluginContextLoader.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/external-plugin/domain/ExternalPluginContextLoader.ts"],
|
|
4
|
+
"sourcesContent": ["import { HexaString, isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { ethers, Interface } from \"ethers\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, EitherAsync, Left, Right } from \"purify-ts\";\n\nimport type { ExternalPluginDataSource } from \"@/external-plugin/data/ExternalPluginDataSource\";\nimport { externalPluginTypes } from \"@/external-plugin/di/externalPluginTypes\";\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { TransactionContext } from \"@/shared/model/TransactionContext\";\nimport type { TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\n\n@injectable()\nexport class ExternalPluginContextLoader implements ContextLoader {\n private _externalPluginDataSource: ExternalPluginDataSource;\n private _tokenDataSource: TokenDataSource;\n\n constructor(\n @inject(externalPluginTypes.ExternalPluginDataSource)\n externalPluginDataSource: ExternalPluginDataSource,\n @inject(tokenTypes.TokenDataSource) tokenDataSource: TokenDataSource,\n ) {\n this._externalPluginDataSource = externalPluginDataSource;\n this._tokenDataSource = tokenDataSource;\n }\n\n async load(transaction: TransactionContext): Promise<ClearSignContext[]> {\n if (!transaction.to || !transaction.data || transaction.data === \"0x\") {\n return [];\n }\n\n const selector = transaction.data.slice(0, 10);\n\n if (!isHexaString(selector)) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ];\n }\n\n const eitherDappInfos = await this._externalPluginDataSource.getDappInfos({\n address: transaction.to,\n chainId: transaction.chainId,\n selector,\n });\n\n return EitherAsync<Error, ClearSignContext[]>(async ({ liftEither }) => {\n const dappInfos = await liftEither(eitherDappInfos);\n\n // if the dappInfos is null, return an empty array\n // this means that the selector is not a known selector\n if (!dappInfos) {\n return [];\n }\n\n const externalPluginContext: ClearSignContext = {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: dappInfos.selectorDetails.serializedData.concat(\n dappInfos.selectorDetails.signature,\n ),\n };\n\n const decodedCallData = this.getDecodedCallData(\n dappInfos.abi,\n dappInfos.selectorDetails.method,\n transaction.data!, // trasaction.data is not null and not infered correctly\n );\n\n // if the call data cannot be decoded, return the error\n // but also the externalPluginContext because it is still valid\n if (decodedCallData.isLeft()) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: decodedCallData.extract(),\n },\n externalPluginContext,\n ];\n }\n\n // decodedCallData is a Right so we can extract it safely\n const extractedDecodedCallData =\n decodedCallData.extract() as ethers.Result;\n\n // get the token payload for each erc20OfInterest\n // and return the payload or the error\n const promises = dappInfos.selectorDetails.erc20OfInterest.map(\n async (erc20Path) =>\n this.getTokenPayload(\n transaction,\n erc20Path,\n extractedDecodedCallData,\n ),\n );\n\n const tokensPayload = await Promise.all(promises);\n\n // map the payload or the error to a ClearSignContext\n const contexts: ClearSignContext[] = tokensPayload.map((eitherToken) =>\n eitherToken.caseOf<ClearSignContext>({\n Left: (error) => ({ type: ClearSignContextType.ERROR, error }),\n Right: (payload) => ({ type: ClearSignContextType.TOKEN, payload }),\n }),\n );\n\n return [...contexts, externalPluginContext];\n }).caseOf<ClearSignContext[]>({\n // parse all errors into ClearSignContext\n Left: (error) => [{ type: ClearSignContextType.ERROR, error }],\n Right: (contexts) => contexts,\n });\n }\n\n private getTokenPayload(\n transaction: TransactionContext,\n erc20Path: string,\n decodedCallData: ethers.Result,\n ) {\n const address = this.getAddressFromPath(erc20Path, decodedCallData);\n\n return EitherAsync<Error, string>(({ fromPromise }) =>\n fromPromise(\n this._tokenDataSource.getTokenInfosPayload({\n address,\n chainId: transaction.chainId,\n }),\n ),\n );\n }\n\n private getDecodedCallData(\n abi: object[],\n method: string,\n data: string,\n ): Either<Error, ethers.Result> {\n try {\n const contractInterface = new Interface(abi);\n return Right(contractInterface.decodeFunctionData(method, data));\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to parse abi\",\n ),\n );\n }\n }\n\n private getAddressFromPath(\n path: string,\n decodedCallData: ethers.Result,\n ): HexaString {\n // ethers.Result is a record string, any\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let value: any = decodedCallData;\n for (const key of path.split(\".\")) {\n // In Solidity, a struct cannot begin with a number\n // Additionally, when we use -1, it signifies the last element of the array.\n if (key === \"-1\") {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n value = value[value.length - 1];\n } else {\n // This access can throw a RangeError error in case of an invalid key\n // but is correctly caught by the liftEither above\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n value = value[key];\n }\n }\n\n if (!isHexaString(value)) {\n throw new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to get address\",\n );\n }\n\n return value;\n }\n}\n"],
|
|
5
|
+
"mappings": "iOAAA,OAAqB,gBAAAA,MAAoB,kCACzC,OAAiB,aAAAC,MAAiB,SAClC,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,eAAAC,EAAa,QAAAC,EAAM,SAAAC,MAAa,YAGjD,OAAS,uBAAAC,MAA2B,2CAEpC,OAEE,wBAAAC,MACK,kCAGP,OAAS,cAAAC,MAAkB,wBAGpB,IAAMC,EAAN,KAA2D,CACxD,0BACA,iBAER,YAEEC,EACoCC,EACpC,CACA,KAAK,0BAA4BD,EACjC,KAAK,iBAAmBC,CAC1B,CAEA,MAAM,KAAKC,EAA8D,CACvE,GAAI,CAACA,EAAY,IAAM,CAACA,EAAY,MAAQA,EAAY,OAAS,KAC/D,MAAO,CAAC,EAGV,MAAMC,EAAWD,EAAY,KAAK,M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WH,CAAe,EAElE,OAAOJ,EAA2B,CAAC,CAAE,YAAAa,CAAY,IAC/CA,EACE,KAAK,iBAAiB,qBAAqB,CACzC,QAAAD,EACA,QAASjB,EAAY,OACvB,CAAC,CACH,CACF,CACF,CAEQ,mBACNmB,EACAC,EACAC,EAC8B,CAC9B,GAAI,CACF,MAAMC,EAAoB,IAAIC,EAAUJ,CAAG,EAC3C,OAAOK,EAAMF,EAAkB,mBAAmBF,EAAQC,CAAI,CAAC,CACjE,MAAiB,CACf,OAAOI,EACL,IAAI,MACF,kEACF,CACF,CACF,CACF,CAEQ,mBACNC,EACAjB,EACY,CAGZ,IAAIkB,EAAalB,EACjB,UAAWmB,KAAOF,EAAK,MAAM,GAAG,EAG1BE,IAAQ,KAEVD,EAAQA,EAAMA,EAAM,OAAS,CAAC,EAK9BA,EAAQA,EAAMC,CAAG,EAIrB,GAAI,CAAC1B,EAAayB,CAAK,EACrB,MAAM,IAAI,MACR,oEACF,EAGF,OAAOA,CACT,CACF,EArKa9B,EAANgC,EAAA,CADNC,EAAW,EAMPC,EAAA,EAAAC,EAAOC,EAAoB,wBAAwB,GAEnDF,EAAA,EAAAC,EAAOE,EAAW,eAAe,IAPzBrC",
|
|
6
|
+
"names": ["isHexaString", "Interface", "inject", "injectable", "EitherAsync", "Left", "Right", "externalPluginTypes", "ClearSignContextType", "tokenTypes", "ExternalPluginContextLoader", "externalPluginDataSource", "tokenDataSource", "transaction", "selector", "isHexaString", "ClearSignContextType", "eitherDappInfos", "EitherAsync", "liftEither", "dappInfos", "externalPluginContext", "decodedCallData", "extractedDecodedCallData", "promises", "erc20Path", "eitherToken", "error", "payload", "contexts", "address", "fromPromise", "abi", "method", "data", "contractInterface", "Interface", "Right", "Left", "path", "value", "key", "__decorateClass", "injectable", "__decorateParam", "inject", "externalPluginTypes", "tokenTypes"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Interface as u}from"ethers";import{Left as i,Right as c}from"purify-ts";import o from"@/external-plugin/__tests__/abi.json";import{ExternalPluginContextLoader as m}from"../../external-plugin/domain/ExternalPluginContextLoader";import{ClearSignContextType as t}from"../../shared/model/ClearSignContext";const p=({abi:d,selectorDetails:s})=>({abi:d,selectorDetails:{erc20OfInterest:[],method:"",plugin:"",serializedData:"123456",signature:"7890",...s}}),l=(d,s,n)=>({to:"0x0",data:new u(JSON.stringify(d)).encodeFunctionData(s,n)});describe("ExternalPluginContextLoader",()=>{const d={getTokenInfosPayload:jest.fn()},s={getDappInfos:jest.fn()},n=new m(s,d);beforeEach(()=>{jest.clearAllMocks(),jest.spyOn(d,"getTokenInfosPayload").mockImplementation(({address:e})=>Promise.resolve(c(`payload-${e}`)))}),describe("load function",()=>{it("should return an empty array if no destination address is provided",()=>{const e={},a=()=>n.load(e);expect(a()).resolves.toEqual([])}),it("should return an empty array if data is undefined",async()=>{const e={to:"0x0"},a=await n.load(e);expect(a).toEqual([])}),it("should return an empty array if no data provided",async()=>{const e={to:"0x0",data:"0x"},a=await n.load(e);expect(a).toEqual([])}),it("should return an empty array if no dapp info is povided",async()=>{const e=l(o,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);jest.spyOn(s,"getDappInfos").mockResolvedValue(c(void 0));const a=await n.load(e);expect(a).toEqual([])}),it("should return e plugin if no erc20OfInterest is provided",async()=>{const e=p({abi:o,selectorDetails:{erc20OfInterest:[],method:"singleParam"}}),a=l(o,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);jest.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const r=await n.load(a);expect(r).toEqual([{type:t.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return a list of context responses when one erc20OfInterest is provided for a single parameter",async()=>{const e=p({abi:o,selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam"}}),a=l(o,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);jest.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const r=await n.load(a);expect(r).toEqual(expect.arrayContaining([{type:t.EXTERNAL_PLUGIN,payload:"1234567890"},{type:t.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 e=p({abi:o,selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam"}}),a=l(o,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);jest.spyOn(s,"getDappInfos").mockResolvedValue(c(e)),jest.spyOn(d,"getTokenInfosPayload").mockResolvedValue(i(Error("error")));const r=await n.load(a);expect(r).toEqual([{type:t.ERROR,error:new Error("error")},{type:t.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return a list of context responses when two erc20OfInterest are provided for two parameters",async()=>{const e=p({abi:o,selectorDetails:{erc20OfInterest:["fromToken","toToken"],method:"multipleParams"}}),a=l(o,"multipleParams",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7"]);jest.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const r=await n.load(a);expect(r).toEqual(expect.arrayContaining([{type:t.EXTERNAL_PLUGIN,payload:"1234567890"},{type:t.TOKEN,payload:"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{type:t.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"}]))}),it("should return a list of context responses when one erc20OfInterest is an array",async()=>{const e=p({abi:o,selectorDetails:{erc20OfInterest:["fromToken.0","fromToken.1","fromToken.2","fromToken.-1"],method:"arrayParam"}}),a=l(o,"arrayParam",[["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7","0xB8c77482e45F1F44dE1745F52C74426C631bDD52"]]);jest.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const r=await n.load(a);expect(r).toEqual([{type:t.TOKEN,payload:"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{type:t.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"},{type:t.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:t.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:t.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return an error when a token datasource returns an error",async()=>{const e=p({abi:o,selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam"}}),a=l(o,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);jest.spyOn(s,"getDappInfos").mockResolvedValue(c(e)),jest.spyOn(d,"getTokenInfosPayload").mockResolvedValue(i(new Error("error")));const r=await n.load(a);expect(r).toEqual([{type:t.ERROR,error:new Error("error")},{type:t.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return an error when the abi is not conform",async()=>{const e=p({abi:[{fakeabi:"notworking"}],selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam"}}),a=l(o,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);jest.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const r=await n.load(a);expect(r).toEqual([{type:t.ERROR,error:new Error("[ContextModule] ExternalPluginContextLoader: Unable to parse abi")},{type:t.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should throw an error when the erc20OfInterest doest not exist in the transaction",async()=>{const e=p({abi:o,selectorDetails:{erc20OfInterest:["notFound"],method:"singleParam"}}),a=l(o,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);jest.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const r=await n.load(a);expect(r).toEqual([{type:t.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 e=p({abi:o,selectorDetails:{erc20OfInterest:["fromToken.3"],method:"arrayParam"}}),a=l(o,"arrayParam",[["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7","0xB8c77482e45F1F44dE1745F52C74426C631bDD52"]]);jest.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const r=await n.load(a);expect(r).toEqual([{type:t.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 e=p({abi:o,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"}}),a=l(o,"complexStructParam",[{address1:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",param1:{param2:[{param3:{addresses:["0xdAC17F958D2ee523a2206206994597C13D831ec7","0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE"]}},{param3:{addresses:["0xB8c77482e45F1F44dE1745F52C74426C631bDD52"]}}]}}]);jest.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const r=await n.load(a);expect(r).toEqual([{type:t.TOKEN,payload:"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{type:t.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"},{type:t.TOKEN,payload:"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE"},{type:t.TOKEN,payload:"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE"},{type:t.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:t.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:t.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return an error when datasource return a Left",async()=>{const e=l(o,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);jest.spyOn(s,"getDappInfos").mockResolvedValue(i(new Error("error")));const a=await n.load(e);expect(a).toEqual([{type:t.ERROR,error:new Error("error")}])}),it("should return an error when transaction data is not a valid hex string",async()=>{const e={to:"0x0",data:"notAHexString"},a=await n.load(e);expect(a).toEqual([{type:t.ERROR,error:new Error("Invalid selector")}])})})});
|
|
2
|
+
//# sourceMappingURL=ExternalPluginContextLoader.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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": "AAAA,OAAS,aAAAA,MAAiB,SAC1B,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAE5B,OAAOC,MAAS,uCAEhB,OAAS,+BAAAC,MAAmC,uDAG5C,OAAS,wBAAAC,MAA4B,kCAIrC,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,IAAIX,EAAU,KAAK,UAAUO,CAAG,CAAC,EAC5B,mBAAmBG,EAAcC,CAAM,CAI7D,GAGF,SAAS,8BAA+B,IAAM,CAC5C,MAAMC,EAAuC,CAC3C,qBAAsB,KAAK,GAAG,CAChC,EACMC,EAAyD,CAC7D,aAAc,KAAK,GAAG,CACxB,EACMC,EAAS,IAAIV,EACjBS,EACAD,CACF,EAEA,WAAW,IAAM,CACf,KAAK,cAAc,EACnB,KACG,MAAMA,EAAqB,sBAAsB,EACjD,mBAAmB,CAAC,CAAE,QAAAG,CAAQ,IAC7B,QAAQ,QAAQb,EAAM,WAA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AAmBN,EAAK,cAAe,CACzD,4CACF,CAAC,EACD,KACG,MAAMU,EAA8B,cAAc,EAClD,kBAAkBZ,EAAK,IAAI,MAAM,OAAO,CAAC,CAAC,EAG7C,MAAMiB,EAAS,MAAMJ,EAAO,KAAKE,CAAW,EAG5C,OAAOE,CAAM,EAAE,QAAQ,CACrB,CACE,KAAMb,EAAqB,MAC3B,MAAO,IAAI,MAAM,OAAO,CAC1B,CACF,CAAC,CACH,CAAC,EAED,GAAG,yEAA0E,SAAY,CAEvF,MAAMW,EAAc,CAClB,GAAI,MACJ,KAAM,eACR,EAGME,EAAS,MAAMJ,EAAO,KAAKE,CAAW,EAG5C,OAAOE,CAAM,EAAE,QAAQ,CACrB,CACE,KAAMb,EAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["Interface", "Left", "Right", "ABI", "ExternalPluginContextLoader", "ClearSignContextType", "dappInfosBuilder", "abi", "selectorDetails", "transactionBuilder", "functionName", "params", "mockTokenDataSource", "mockExternalPluginDataSource", "loader", "address", "transaction", "promise", "result", "dappInfos"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=DappInfos.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=SelectorDetails.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export*from"./config/model/ContextModuleConfig";export*from"./ContextModule";export*from"./ContextModuleBuilder";export*from"./DefaultContextModule";export*from"./external-plugin/domain/ExternalPluginContextLoader";export*from"./nft/domain/NftContextLoader";export*from"./shared/domain/ContextLoader";export*from"./shared/model/ClearSignContext";export*from"./shared/model/GenericPath";export*from"./shared/model/TransactionContext";export*from"./shared/model/TransactionSubset";export*from"./shared/model/TypedDataClearSignContext";export*from"./shared/model/TypedDataContext";export*from"./token/domain/TokenContextLoader";export*from"./trusted-name/domain/TrustedNameContextLoader";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["export * from \"./config/model/ContextModuleConfig\";\nexport * from \"./ContextModule\";\nexport * from \"./ContextModuleBuilder\";\nexport * from \"./DefaultContextModule\";\nexport * from \"./external-plugin/domain/ExternalPluginContextLoader\";\nexport * from \"./nft/domain/NftContextLoader\";\nexport * from \"./shared/domain/ContextLoader\";\nexport * from \"./shared/model/ClearSignContext\";\nexport * from \"./shared/model/GenericPath\";\nexport * from \"./shared/model/TransactionContext\";\nexport * from \"./shared/model/TransactionSubset\";\nexport * from \"./shared/model/TypedDataClearSignContext\";\nexport * from \"./shared/model/TypedDataContext\";\nexport * from \"./token/domain/TokenContextLoader\";\nexport * from \"./trusted-name/domain/TrustedNameContextLoader\";\n"],
|
|
5
|
+
"mappings": "AAAA,WAAc,qCACd,WAAc,kBACd,WAAc,yBACd,WAAc,yBACd,WAAc,uDACd,WAAc,gCACd,WAAc,gCACd,WAAc,kCACd,WAAc,6BACd,WAAc,oCACd,WAAc,mCACd,WAAc,2CACd,WAAc,kCACd,WAAc,oCACd,WAAc",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var u=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var d=(i,r,o,e)=>{for(var t=e>1?void 0:e?f(r,o):r,s=i.length-1,l;s>=0;s--)(l=i[s])&&(t=(e?l(r,o,t):l(t))||t);return e&&t&&u(r,o,t),t};import m from"axios";import{injectable as g}from"inversify";import{Left as a,Right as p}from"purify-ts";import c from"../../../package.json";let n=class{async getSetPluginPayload({chainId:r,address:o,selector:e}){try{const t=await m.request({method:"GET",url:`https://nft.api.live.ledger.com/v1/ethereum/${r}/contracts/${o}/plugin-selector/${e}`,headers:{"X-Ledger-Client-Version":`context-module/${c.version}`}});return t.data.payload?p(t.data.payload):a(new Error("[ContextModule] HttpNftDataSource: unexpected empty response"))}catch{return a(new Error("[ContextModule] HttpNftDataSource: Failed to fetch set plugin payload"))}}async getNftInfosPayload({chainId:r,address:o}){try{const e=await m.request({method:"GET",url:`https://nft.api.live.ledger.com/v1/ethereum/${r}/contracts/${o}`,headers:{"X-Ledger-Client-Version":`context-module/${c.version}`}});return e.data.payload?p(e.data.payload):a(new Error("[ContextModule] HttpNftDataSource: no nft metadata"))}catch{return a(new Error("[ContextModule] HttpNftDataSource: Failed to fetch nft informations"))}}};n=d([g()],n);export{n as HttpNftDataSource};
|
|
2
|
+
//# sourceMappingURL=HttpNftDataSource.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/nft/data/HttpNftDataSource.ts"],
|
|
4
|
+
"sourcesContent": ["import axios from \"axios\";\nimport { injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport {\n GetNftInformationsParams,\n GetSetPluginPayloadParams,\n NftDataSource,\n} from \"@/nft/data/NftDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\n@injectable()\nexport class HttpNftDataSource implements NftDataSource {\n public async getSetPluginPayload({\n chainId,\n address,\n selector,\n }: GetSetPluginPayloadParams): Promise<Either<Error, string>> {\n try {\n const response = await axios.request<{ payload: string }>({\n method: \"GET\",\n url: `https://nft.api.live.ledger.com/v1/ethereum/${chainId}/contracts/${address}/plugin-selector/${selector}`,\n headers: {\n \"X-Ledger-Client-Version\": `context-module/${PACKAGE.version}`,\n },\n });\n\n return response.data.payload\n ? Right(response.data.payload)\n : Left(\n new Error(\n \"[ContextModule] HttpNftDataSource: unexpected empty response\",\n ),\n );\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpNftDataSource: Failed to fetch set plugin payload\",\n ),\n );\n }\n }\n\n public async getNftInfosPayload({\n chainId,\n address,\n }: GetNftInformationsParams): Promise<Either<Error, string>> {\n try {\n const response = await axios.request<{ payload: string }>({\n method: \"GET\",\n url: `https://nft.api.live.ledger.com/v1/ethereum/${chainId}/contracts/${address}`,\n headers: {\n \"X-Ledger-Client-Version\": `context-module/${PACKAGE.version}`,\n },\n });\n\n return response.data.payload\n ? Right(response.data.payload)\n : Left(new Error(\"[ContextModule] HttpNftDataSource: no nft metadata\"));\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpNftDataSource: Failed to fetch nft informations\",\n ),\n );\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "wMAAA,OAAOA,MAAW,QAClB,OAAS,cAAAC,MAAkB,YAC3B,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAOpC,OAAOC,MAAa,qBAGb,IAAMC,EAAN,KAAiD,CACtD,MAAa,oBAAoB,CAC/B,QAAAC,EACA,QAAAC,EACA,SAAAC,CACF,EAA8D,CAC5D,GAAI,CACF,MAAMC,EAAW,MAAMC,EAAM,QAA6B,CACxD,OAAQ,MACR,IAAK,+CAA+CJ,CAAO,cAAcC,CAAO,oBAAoBC,CAAQ,GAC5G,QAAS,CACP,0BAA2B,kBAAkBG,EAAQ,OAAO,EAC9D,CACF,CAAC,EAED,OAAOF,EAAS,KAAK,QACjBG,EAAMH,EAAS,KAAK,OAAO,EAC3BI,EACE,IAAI,MACF,8DACF,CACF,CACN,MAAiB,CACf,OAAOA,EACL,IAAI,MACF,uEACF,CACF,CACF,CACF,CAEA,MAAa,mBAAmB,CAC9B,QAAAP,EACA,QAAAC,CACF,EAA6D,CAC3D,GAAI,CACF,MAAME,EAAW,MAAMC,EAAM,QAA6B,CACxD,OAAQ,MACR,IAAK,+CAA+CJ,CAAO,cAAcC,CAAO,GAChF,QAAS,CACP,0BAA2B,kBAAkBI,EAAQ,OAAO,EAC9D,CACF,CAAC,EAED,OAAOF,EAAS,KAAK,QACjBG,EAAMH,EAAS,KAAK,OAAO,EAC3BI,EAAK,IAAI,MAAM,oDAAoD,CAAC,CAC1E,MAAiB,CACf,OAAOA,EACL,IAAI,MACF,qEACF,CACF,CACF,CACF,CACF,EAvDaR,EAANS,EAAA,CADNC,EAAW,GACCV",
|
|
6
|
+
"names": ["axios", "injectable", "Left", "Right", "PACKAGE", "HttpNftDataSource", "chainId", "address", "selector", "response", "axios", "PACKAGE", "Right", "Left", "__decorateClass", "injectable"]
|
|
7
|
+
}
|