@ledgerhq/context-module 0.0.0-opt-in-result-20250429135049 → 0.0.0-proxy-transport-20250716083628
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/package.json +12 -12
- package/lib/cjs/src/ContextModule.js +1 -1
- package/lib/cjs/src/ContextModule.js.map +1 -1
- package/lib/cjs/src/ContextModuleBuilder.js +1 -1
- package/lib/cjs/src/ContextModuleBuilder.js.map +3 -3
- package/lib/cjs/src/ContextModuleBuilder.test.js +1 -1
- package/lib/cjs/src/ContextModuleBuilder.test.js.map +3 -3
- package/lib/cjs/src/DefaultContextModule.js +1 -1
- package/lib/cjs/src/DefaultContextModule.js.map +3 -3
- package/lib/cjs/src/DefaultContextModule.test.js +1 -1
- package/lib/cjs/src/DefaultContextModule.test.js.map +2 -2
- package/lib/cjs/src/config/di/configModuleFactory.js +1 -1
- package/lib/cjs/src/config/di/configModuleFactory.js.map +3 -3
- package/lib/cjs/src/config/model/ContextModuleConfig.js +1 -1
- package/lib/cjs/src/config/model/ContextModuleConfig.js.map +1 -1
- package/lib/cjs/src/di.js +1 -1
- package/lib/cjs/src/di.js.map +3 -3
- package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js +1 -1
- package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js.map +3 -3
- package/lib/cjs/src/nft/data/HttpNftDataSource.js +1 -1
- package/lib/cjs/src/nft/data/HttpNftDataSource.js.map +3 -3
- package/lib/cjs/src/nft/data/HttpNftDataSource.test.js +1 -1
- package/lib/cjs/src/nft/data/HttpNftDataSource.test.js.map +2 -2
- package/lib/cjs/src/nft/di/nftModuleFactory.js +1 -1
- package/lib/cjs/src/nft/di/nftModuleFactory.js.map +3 -3
- package/lib/cjs/src/pki/di/pkiModuleFactory.js +1 -1
- package/lib/cjs/src/pki/di/pkiModuleFactory.js.map +3 -3
- package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.js +1 -1
- package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.js.map +3 -3
- package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js +1 -1
- package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +3 -3
- package/lib/cjs/src/shared/model/SolanaTransactionContext.js +2 -0
- package/lib/cjs/src/shared/model/SolanaTransactionContext.js.map +7 -0
- package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js +2 -0
- package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +7 -0
- package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +2 -0
- package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +7 -0
- package/lib/cjs/src/solana/data/SolanaDataSource.js +2 -0
- package/lib/cjs/src/solana/data/SolanaDataSource.js.map +7 -0
- package/lib/cjs/src/solana/di/SolanaContextModuleFactory.js +2 -0
- package/lib/cjs/src/solana/di/SolanaContextModuleFactory.js.map +7 -0
- package/lib/cjs/src/solana/di/solanaContextTypes.js +2 -0
- package/lib/cjs/src/solana/di/solanaContextTypes.js.map +7 -0
- package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.js +2 -0
- package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.js.map +7 -0
- package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.test.js +2 -0
- package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.test.js.map +7 -0
- package/lib/cjs/src/solana/domain/SolanaContextLoader.js +2 -0
- package/lib/cjs/src/solana/domain/SolanaContextLoader.js.map +7 -0
- package/lib/cjs/src/solana/domain/solanaContextTypes.js +2 -0
- package/lib/cjs/src/solana/domain/solanaContextTypes.js.map +7 -0
- package/lib/cjs/src/token/di/tokenModuleFactory.js +1 -1
- package/lib/cjs/src/token/di/tokenModuleFactory.js.map +3 -3
- package/lib/cjs/src/transaction/data/HttpProxyDataSource.js +2 -0
- package/lib/cjs/src/transaction/data/HttpProxyDataSource.js.map +7 -0
- package/lib/cjs/src/transaction/data/HttpProxyDataSource.test.js +2 -0
- package/lib/cjs/src/transaction/data/HttpProxyDataSource.test.js.map +7 -0
- package/lib/cjs/src/transaction/data/ProxyDelegateCallDto.js +2 -0
- package/lib/cjs/src/transaction/data/ProxyDelegateCallDto.js.map +7 -0
- package/lib/cjs/src/transaction/data/ProxyImplementationAddressDto.js +2 -0
- package/lib/cjs/src/transaction/data/ProxyImplementationAddressDto.js.map +7 -0
- package/lib/cjs/src/transaction/di/transactionModuleFactory.js +1 -1
- package/lib/cjs/src/transaction/di/transactionModuleFactory.js.map +3 -3
- package/lib/cjs/src/transaction/di/transactionTypes.js +1 -1
- package/lib/cjs/src/transaction/di/transactionTypes.js.map +2 -2
- package/lib/cjs/src/transaction/model/ProxyDelegateCall.js +2 -0
- package/lib/cjs/src/transaction/model/ProxyDelegateCall.js.map +7 -0
- package/lib/cjs/src/transaction/model/ProxyImplementationAddress.js +2 -0
- package/lib/cjs/src/transaction/model/ProxyImplementationAddress.js.map +7 -0
- package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
- package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js.map +2 -2
- package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
- package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +2 -2
- package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
- package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
- package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js +1 -1
- package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js.map +3 -3
- package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js +1 -1
- package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js.map +3 -3
- package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
- package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js.map +2 -2
- package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js +1 -1
- package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js.map +3 -3
- package/lib/esm/package.json +12 -12
- package/lib/esm/src/ContextModuleBuilder.js +1 -1
- package/lib/esm/src/ContextModuleBuilder.js.map +3 -3
- package/lib/esm/src/ContextModuleBuilder.test.js +1 -1
- package/lib/esm/src/ContextModuleBuilder.test.js.map +3 -3
- package/lib/esm/src/DefaultContextModule.js +1 -1
- package/lib/esm/src/DefaultContextModule.js.map +3 -3
- package/lib/esm/src/DefaultContextModule.test.js +1 -1
- package/lib/esm/src/DefaultContextModule.test.js.map +2 -2
- package/lib/esm/src/config/di/configModuleFactory.js +1 -1
- package/lib/esm/src/config/di/configModuleFactory.js.map +3 -3
- package/lib/esm/src/di.js +1 -1
- package/lib/esm/src/di.js.map +3 -3
- package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js +1 -1
- package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js.map +3 -3
- package/lib/esm/src/nft/data/HttpNftDataSource.js +1 -1
- package/lib/esm/src/nft/data/HttpNftDataSource.js.map +3 -3
- package/lib/esm/src/nft/data/HttpNftDataSource.test.js +1 -1
- package/lib/esm/src/nft/data/HttpNftDataSource.test.js.map +2 -2
- package/lib/esm/src/nft/di/nftModuleFactory.js +1 -1
- package/lib/esm/src/nft/di/nftModuleFactory.js.map +3 -3
- package/lib/esm/src/pki/di/pkiModuleFactory.js +1 -1
- package/lib/esm/src/pki/di/pkiModuleFactory.js.map +3 -3
- package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.js +1 -1
- package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.js.map +3 -3
- package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js +1 -1
- package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +3 -3
- package/lib/esm/src/shared/model/SolanaTransactionContext.js +1 -0
- package/lib/esm/src/shared/model/SolanaTransactionContext.js.map +7 -0
- package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js +2 -0
- package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +7 -0
- package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +2 -0
- package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +7 -0
- package/lib/esm/src/solana/data/SolanaDataSource.js +1 -0
- package/lib/esm/src/solana/data/SolanaDataSource.js.map +7 -0
- package/lib/esm/src/solana/di/SolanaContextModuleFactory.js +2 -0
- package/lib/esm/src/solana/di/SolanaContextModuleFactory.js.map +7 -0
- package/lib/esm/src/solana/di/solanaContextTypes.js +2 -0
- package/lib/esm/src/solana/di/solanaContextTypes.js.map +7 -0
- package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.js +2 -0
- package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.js.map +7 -0
- package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.test.js +2 -0
- package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.test.js.map +7 -0
- package/lib/esm/src/solana/domain/SolanaContextLoader.js +1 -0
- package/lib/esm/src/solana/domain/SolanaContextLoader.js.map +7 -0
- package/lib/esm/src/solana/domain/solanaContextTypes.js +1 -0
- package/lib/esm/src/solana/domain/solanaContextTypes.js.map +7 -0
- package/lib/esm/src/token/di/tokenModuleFactory.js +1 -1
- package/lib/esm/src/token/di/tokenModuleFactory.js.map +3 -3
- package/lib/esm/src/transaction/data/HttpProxyDataSource.js +2 -0
- package/lib/esm/src/transaction/data/HttpProxyDataSource.js.map +7 -0
- package/lib/esm/src/transaction/data/HttpProxyDataSource.test.js +2 -0
- package/lib/esm/src/transaction/data/HttpProxyDataSource.test.js.map +7 -0
- package/lib/esm/src/transaction/data/ProxyDelegateCallDto.js +1 -0
- package/lib/esm/src/transaction/data/ProxyDelegateCallDto.js.map +7 -0
- package/lib/esm/src/transaction/data/ProxyImplementationAddressDto.js +1 -0
- package/lib/esm/src/transaction/data/ProxyImplementationAddressDto.js.map +7 -0
- package/lib/esm/src/transaction/di/transactionModuleFactory.js +1 -1
- package/lib/esm/src/transaction/di/transactionModuleFactory.js.map +3 -3
- package/lib/esm/src/transaction/di/transactionTypes.js +1 -1
- package/lib/esm/src/transaction/di/transactionTypes.js.map +2 -2
- package/lib/esm/src/transaction/model/ProxyDelegateCall.js +1 -0
- package/lib/esm/src/transaction/model/ProxyDelegateCall.js.map +7 -0
- package/lib/esm/src/transaction/model/ProxyImplementationAddress.js +1 -0
- package/lib/esm/src/transaction/model/ProxyImplementationAddress.js.map +7 -0
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js.map +2 -2
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +2 -2
- package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
- package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
- package/lib/esm/src/typed-data/di/typedDataModuleFactory.js +1 -1
- package/lib/esm/src/typed-data/di/typedDataModuleFactory.js.map +3 -3
- package/lib/esm/src/uniswap/di/uniswapModuleFactory.js +1 -1
- package/lib/esm/src/uniswap/di/uniswapModuleFactory.js.map +3 -3
- package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
- package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js.map +2 -2
- package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js +1 -1
- package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js.map +3 -3
- package/lib/types/src/ContextModule.d.ts +3 -0
- package/lib/types/src/ContextModule.d.ts.map +1 -1
- package/lib/types/src/ContextModuleBuilder.d.ts +18 -3
- package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -1
- package/lib/types/src/DefaultContextModule.d.ts +5 -0
- package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
- package/lib/types/src/config/di/configModuleFactory.d.ts.map +1 -1
- package/lib/types/src/config/model/ContextModuleConfig.d.ts +6 -0
- package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -1
- package/lib/types/src/di.d.ts.map +1 -1
- package/lib/types/src/nft/data/HttpNftDataSource.d.ts +3 -0
- package/lib/types/src/nft/data/HttpNftDataSource.d.ts.map +1 -1
- package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.d.ts.map +1 -1
- package/lib/types/src/shared/model/SolanaTransactionContext.d.ts +11 -0
- package/lib/types/src/shared/model/SolanaTransactionContext.d.ts.map +1 -0
- package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.d.ts +13 -0
- package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.d.ts.map +1 -0
- package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.test.d.ts +2 -0
- package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.test.d.ts.map +1 -0
- package/lib/types/src/solana/data/SolanaDataSource.d.ts +12 -0
- package/lib/types/src/solana/data/SolanaDataSource.d.ts.map +1 -0
- package/lib/types/src/solana/di/SolanaContextModuleFactory.d.ts +3 -0
- package/lib/types/src/solana/di/SolanaContextModuleFactory.d.ts.map +1 -0
- package/lib/types/src/solana/di/solanaContextTypes.d.ts +5 -0
- package/lib/types/src/solana/di/solanaContextTypes.d.ts.map +1 -0
- package/lib/types/src/solana/domain/DefaultSolanaContextLoader.d.ts +11 -0
- package/lib/types/src/solana/domain/DefaultSolanaContextLoader.d.ts.map +1 -0
- package/lib/types/src/solana/domain/DefaultSolanaContextLoader.test.d.ts +2 -0
- package/lib/types/src/solana/domain/DefaultSolanaContextLoader.test.d.ts.map +1 -0
- package/lib/types/src/solana/domain/SolanaContextLoader.d.ts +5 -0
- package/lib/types/src/solana/domain/SolanaContextLoader.d.ts.map +1 -0
- package/lib/types/src/solana/domain/solanaContextTypes.d.ts +27 -0
- package/lib/types/src/solana/domain/solanaContextTypes.d.ts.map +1 -0
- package/lib/types/src/transaction/data/HttpProxyDataSource.d.ts +32 -0
- package/lib/types/src/transaction/data/HttpProxyDataSource.d.ts.map +1 -0
- package/lib/types/src/transaction/data/HttpProxyDataSource.test.d.ts +2 -0
- package/lib/types/src/transaction/data/HttpProxyDataSource.test.d.ts.map +1 -0
- package/lib/types/src/transaction/data/ProxyDelegateCallDto.d.ts +5 -0
- package/lib/types/src/transaction/data/ProxyDelegateCallDto.d.ts.map +1 -0
- package/lib/types/src/transaction/data/ProxyImplementationAddressDto.d.ts +6 -0
- package/lib/types/src/transaction/data/ProxyImplementationAddressDto.d.ts.map +1 -0
- package/lib/types/src/transaction/di/transactionModuleFactory.d.ts.map +1 -1
- package/lib/types/src/transaction/di/transactionTypes.d.ts +1 -0
- package/lib/types/src/transaction/di/transactionTypes.d.ts.map +1 -1
- package/lib/types/src/transaction/model/ProxyDelegateCall.d.ts +5 -0
- package/lib/types/src/transaction/model/ProxyDelegateCall.d.ts.map +1 -0
- package/lib/types/src/transaction/model/ProxyImplementationAddress.d.ts +4 -0
- package/lib/types/src/transaction/model/ProxyImplementationAddress.d.ts.map +1 -0
- package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +15 -15
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/pki/di/pkiModuleFactory.ts"],
|
|
4
|
-
"sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpPkiCertificateDataSource } from \"@/pki/data/HttpPkiCertificateDataSource\";\nimport { DefaultPkiCertificateLoader } from \"@/pki/domain/DefaultPkiCertificateLoader\";\n\nimport { pkiTypes } from \"./pkiTypes\";\n\nexport const nanoPkiModuleFactory = () =>\n new ContainerModule((bind
|
|
5
|
-
"mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,gCAAAC,MAAoC,0CAC7C,OAAS,+BAAAC,MAAmC,2CAE5C,OAAS,YAAAC,MAAgB,aAElB,MAAMC,EAAuB,IAClC,IAAIJ,EAAgB,
|
|
6
|
-
"names": ["ContainerModule", "HttpPkiCertificateDataSource", "DefaultPkiCertificateLoader", "pkiTypes", "nanoPkiModuleFactory", "bind"
|
|
4
|
+
"sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpPkiCertificateDataSource } from \"@/pki/data/HttpPkiCertificateDataSource\";\nimport { DefaultPkiCertificateLoader } from \"@/pki/domain/DefaultPkiCertificateLoader\";\n\nimport { pkiTypes } from \"./pkiTypes\";\n\nexport const nanoPkiModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(pkiTypes.PkiCertificateDataSource).to(HttpPkiCertificateDataSource);\n bind(pkiTypes.PkiCertificateLoader).to(DefaultPkiCertificateLoader);\n });\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,gCAAAC,MAAoC,0CAC7C,OAAS,+BAAAC,MAAmC,2CAE5C,OAAS,YAAAC,MAAgB,aAElB,MAAMC,EAAuB,IAClC,IAAIJ,EAAgB,CAAC,CAAE,KAAAK,CAAK,IAAM,CAChCA,EAAKF,EAAS,wBAAwB,EAAE,GAAGF,CAA4B,EACvEI,EAAKF,EAAS,oBAAoB,EAAE,GAAGD,CAA2B,CACpE,CAAC",
|
|
6
|
+
"names": ["ContainerModule", "HttpPkiCertificateDataSource", "DefaultPkiCertificateLoader", "pkiTypes", "nanoPkiModuleFactory", "bind"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var p=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var m=(a,i,r,t)=>{for(var e=t>1?void 0:t?s(i,r):i,o=a.length-1,f;o>=0;o--)(f=a[o])&&(e=(t?f(i,r,e):f(e))||e);return t&&e&&p(i,r,e),e},n=(a,i)=>(r,t)=>i(r,t,a);import{inject as C,injectable as k}from"inversify";import{pkiTypes as P}from"../../pki/di/pkiTypes";let c=class{_dataSource;constructor(i){this._dataSource=i}async loadCertificate(i){return(await this._dataSource.fetchCertificate(i)).caseOf({Right:t=>t,Left:t=>{throw t instanceof Error?t:new Error(String(t))}})}};c=m([k(),n(0,C(P.PkiCertificateDataSource))],c);export{c as DefaultPkiCertificateLoader};
|
|
2
2
|
//# sourceMappingURL=DefaultPkiCertificateLoader.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/pki/domain/DefaultPkiCertificateLoader.ts"],
|
|
4
|
-
"sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport { type PkiCertificateDataSource } from \"@/pki/data/PkiCertificateDataSource\";\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport { type PkiCertificateInfo } from \"@/pki/model/PkiCertificateInfo\";\n\nimport { PkiCertificateLoader } from \"./PkiCertificateLoader\";\n\n@injectable()\nexport class DefaultPkiCertificateLoader implements PkiCertificateLoader {\n private _dataSource: PkiCertificateDataSource;\n\n constructor(\n @inject(pkiTypes.PkiCertificateDataSource)\n dataSource: PkiCertificateDataSource,\n ) {\n this._dataSource = dataSource;\n }\n\n async loadCertificate(\n certificateInfos: PkiCertificateInfo,\n ): Promise<PkiCertificate | undefined> {\n const certificate =\n await this._dataSource.fetchCertificate(certificateInfos);\n\n return certificate.
|
|
5
|
-
"mappings": "iOAAA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YAGnC,OAAS,YAAAC,MAAgB,oBAOlB,IAAMC,EAAN,KAAkE,CAC/D,YAER,YAEEC,EACA,CACA,KAAK,YAAcA,CACrB,CAEA,MAAM,gBACJC,EACqC,CAIrC,OAFE,MAAM,KAAK,YAAY,iBAAiBA,CAAgB,GAEvC,
|
|
6
|
-
"names": ["inject", "injectable", "pkiTypes", "DefaultPkiCertificateLoader", "dataSource", "certificateInfos", "__decorateClass", "injectable", "__decorateParam", "inject", "pkiTypes"]
|
|
4
|
+
"sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport { type PkiCertificateDataSource } from \"@/pki/data/PkiCertificateDataSource\";\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport { type PkiCertificateInfo } from \"@/pki/model/PkiCertificateInfo\";\n\nimport { PkiCertificateLoader } from \"./PkiCertificateLoader\";\n\n@injectable()\nexport class DefaultPkiCertificateLoader implements PkiCertificateLoader {\n private _dataSource: PkiCertificateDataSource;\n\n constructor(\n @inject(pkiTypes.PkiCertificateDataSource)\n dataSource: PkiCertificateDataSource,\n ) {\n this._dataSource = dataSource;\n }\n\n async loadCertificate(\n certificateInfos: PkiCertificateInfo,\n ): Promise<PkiCertificate | undefined> {\n const certificate =\n await this._dataSource.fetchCertificate(certificateInfos);\n\n return certificate.caseOf({\n Right: (cert) => cert,\n Left: (err) => {\n throw err instanceof Error ? err : new Error(String(err));\n },\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "iOAAA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YAGnC,OAAS,YAAAC,MAAgB,oBAOlB,IAAMC,EAAN,KAAkE,CAC/D,YAER,YAEEC,EACA,CACA,KAAK,YAAcA,CACrB,CAEA,MAAM,gBACJC,EACqC,CAIrC,OAFE,MAAM,KAAK,YAAY,iBAAiBA,CAAgB,GAEvC,OAAO,CACxB,MAAQC,GAASA,EACjB,KAAOC,GAAQ,CACb,MAAMA,aAAe,MAAQA,EAAM,IAAI,MAAM,OAAOA,CAAG,CAAC,CAC1D,CACF,CAAC,CACH,CACF,EAvBaJ,EAANK,EAAA,CADNC,EAAW,EAKPC,EAAA,EAAAC,EAAOC,EAAS,wBAAwB,IAJhCT",
|
|
6
|
+
"names": ["inject", "injectable", "pkiTypes", "DefaultPkiCertificateLoader", "dataSource", "certificateInfos", "cert", "err", "__decorateClass", "injectable", "__decorateParam", "inject", "pkiTypes"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Right as
|
|
1
|
+
import{Left as l,Right as n}from"purify-ts";import{DefaultPkiCertificateLoader as i}from"../../pki/domain/DefaultPkiCertificateLoader";import{KeyId as o}from"../../pki/model/KeyId";import{KeyUsage as c}from"../../pki/model/KeyUsage";describe("DefaultPkiCertificateLoader",()=>{describe("loadCertificate",()=>{it("should call loadCertificate",async()=>{const e={targetDevice:"targetDevice",keyUsage:c.Calldata,keyId:o.CalNetwork},t={keyUsageNumber:11,payload:new Uint8Array([1,2,3,4,21,4,5,6,7,8])},a={fetchCertificate:vi.fn().mockResolvedValue(n(t))},f=await new i(a).loadCertificate(e);expect(f).toEqual(t),expect(a.fetchCertificate).toHaveBeenCalledWith(e)}),it("throws when the data source returns a Left(error)",async()=>{const e={targetDevice:"targetDevice",keyUsage:c.Calldata,keyId:o.CalNetwork},t=new Error("failed"),a={fetchCertificate:vi.fn().mockResolvedValue(l(t))},r=new i(a);await expect(r.loadCertificate(e)).rejects.toThrow(t),expect(a.fetchCertificate).toHaveBeenCalledWith(e)})})});
|
|
2
2
|
//# sourceMappingURL=DefaultPkiCertificateLoader.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/pki/domain/DefaultPkiCertificateLoader.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { Right } from \"purify-ts\";\n\nimport { DefaultPkiCertificateLoader } from \"@/pki/domain/DefaultPkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { type PkiCertificateInfo } from \"@/pki/model/PkiCertificateInfo\";\n\ndescribe(\"DefaultPkiCertificateLoader\", () => {\n describe(\"loadCertificate\", () => {\n it(\"should call loadCertificate\", async () => {\n // GIVEN\n const certificateInfos: PkiCertificateInfo = {\n targetDevice: \"targetDevice\",\n keyUsage: KeyUsage.Calldata,\n keyId: KeyId.CalNetwork,\n };\n const certificate = {\n keyUsageNumber: 11,\n payload: new Uint8Array([\n 0x01, 0x02, 0x03, 0x04, 0x15, 0x04, 0x05, 0x06, 0x07, 0x08,\n ]),\n };\n const dataSource = {\n fetchCertificate: vi.fn().mockResolvedValue(Right(certificate)),\n };\n\n // WHEN\n const loader = new DefaultPkiCertificateLoader(dataSource);\n const result = await loader.loadCertificate(certificateInfos);\n\n // THEN\n expect(result).toEqual(certificate);\n expect(dataSource.fetchCertificate).toHaveBeenCalledWith(\n certificateInfos,\n );\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,
|
|
6
|
-
"names": ["Right", "DefaultPkiCertificateLoader", "KeyId", "KeyUsage", "certificateInfos", "certificate", "dataSource", "result"]
|
|
4
|
+
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { DefaultPkiCertificateLoader } from \"@/pki/domain/DefaultPkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { type PkiCertificateInfo } from \"@/pki/model/PkiCertificateInfo\";\n\ndescribe(\"DefaultPkiCertificateLoader\", () => {\n describe(\"loadCertificate\", () => {\n it(\"should call loadCertificate\", async () => {\n // GIVEN\n const certificateInfos: PkiCertificateInfo = {\n targetDevice: \"targetDevice\",\n keyUsage: KeyUsage.Calldata,\n keyId: KeyId.CalNetwork,\n };\n const certificate = {\n keyUsageNumber: 11,\n payload: new Uint8Array([\n 0x01, 0x02, 0x03, 0x04, 0x15, 0x04, 0x05, 0x06, 0x07, 0x08,\n ]),\n };\n const dataSource = {\n fetchCertificate: vi.fn().mockResolvedValue(Right(certificate)),\n };\n\n // WHEN\n const loader = new DefaultPkiCertificateLoader(dataSource);\n const result = await loader.loadCertificate(certificateInfos);\n\n // THEN\n expect(result).toEqual(certificate);\n expect(dataSource.fetchCertificate).toHaveBeenCalledWith(\n certificateInfos,\n );\n });\n\n it(\"throws when the data source returns a Left(error)\", async () => {\n // given\n const certificateInfos: PkiCertificateInfo = {\n targetDevice: \"targetDevice\",\n keyUsage: KeyUsage.Calldata,\n keyId: KeyId.CalNetwork,\n };\n const fetchError = new Error(\"failed\");\n const dataSource = {\n fetchCertificate: vi.fn().mockResolvedValue(Left(fetchError)),\n };\n const loader = new DefaultPkiCertificateLoader(dataSource);\n\n // when / then\n await expect(loader.loadCertificate(certificateInfos)).rejects.toThrow(\n fetchError,\n );\n expect(dataSource.fetchCertificate).toHaveBeenCalledWith(\n certificateInfos,\n );\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAE5B,OAAS,+BAAAC,MAAmC,2CAC5C,OAAS,SAAAC,MAAa,oBACtB,OAAS,YAAAC,MAAgB,uBAGzB,SAAS,8BAA+B,IAAM,CAC5C,SAAS,kBAAmB,IAAM,CAChC,GAAG,8BAA+B,SAAY,CAE5C,MAAMC,EAAuC,CAC3C,aAAc,eACd,SAAUD,EAAS,SACnB,MAAOD,EAAM,UACf,EACMG,EAAc,CAClB,eAAgB,GAChB,QAAS,IAAI,WAAW,CACtB,EAAM,EAAM,EAAM,EAAM,GAAM,EAAM,EAAM,EAAM,EAAM,CACxD,CAAC,CACH,EACMC,EAAa,CACjB,iBAAkB,GAAG,GAAG,EAAE,kBAAkBN,EAAMK,CAAW,CAAC,CAChE,EAIME,EAAS,MADA,IAAIN,EAA4BK,CAAU,EAC7B,gBAAgBF,CAAgB,EAG5D,OAAOG,CAAM,EAAE,QAAQF,CAAW,EAClC,OAAOC,EAAW,gBAAgB,EAAE,qBAClCF,CACF,CACF,CAAC,EAED,GAAG,oDAAqD,SAAY,CAElE,MAAMA,EAAuC,CAC3C,aAAc,eACd,SAAUD,EAAS,SACnB,MAAOD,EAAM,UACf,EACMM,EAAa,IAAI,MAAM,QAAQ,EAC/BF,EAAa,CACjB,iBAAkB,GAAG,GAAG,EAAE,kBAAkBP,EAAKS,CAAU,CAAC,CAC9D,EACMC,EAAS,IAAIR,EAA4BK,CAAU,EAGzD,MAAM,OAAOG,EAAO,gBAAgBL,CAAgB,CAAC,EAAE,QAAQ,QAC7DI,CACF,EACA,OAAOF,EAAW,gBAAgB,EAAE,qBAClCF,CACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["Left", "Right", "DefaultPkiCertificateLoader", "KeyId", "KeyUsage", "certificateInfos", "certificate", "dataSource", "result", "fetchError", "loader"]
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=SolanaTransactionContext.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var g=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var u=(s,e,n,t)=>{for(var r=t>1?void 0:t?w(e,n):e,a=s.length-1,o;a>=0;a--)(o=s[a])&&(r=(t?o(e,n,r):o(r))||r);return t&&r&&g(e,n,r),r},f=(s,e)=>(n,t)=>e(n,t,s);import{hexaStringToBuffer as h}from"@ledgerhq/device-management-kit";import p from"axios";import{inject as E,injectable as A}from"inversify";import{Left as i,Right as d}from"purify-ts";import{configTypes as C}from"../../config/di/configTypes";import{LEDGER_CLIENT_VERSION_HEADER as S}from"../../shared/constant/HttpHeaders";import m from"../../../package.json";let c=class{constructor(e){this.config=e;if(!this.config.originToken)throw new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: origin token is required")}isSolanaSPLOwnerInfo(e){return typeof e!="object"||e===null?!1:typeof e.tokenAccount=="string"&&typeof e.owner=="string"&&typeof e.contract=="string"&&typeof e.signedDescriptor=="string"}async fetchAddressMetadata(e,n){return await p.request({method:"GET",url:`${this.config.metadataService.url}/solana/owner/${e}?challenge=${n}`,headers:{[S]:`context-module/${m.version}`,"X-Ledger-Client-Origin":this.config.originToken}}).then(t=>this.isSolanaSPLOwnerInfo(t.data)?d(t.data):i(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid fetchAddressMetadata response shape"))).catch(()=>i(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: Failed to fetch address metadata")))}async computeAddressMetadata(e,n,t){return await p.request({method:"GET",url:`${this.config.metadataService.url}/solana/computed-token-account/${e}/${n}?challenge=${t}`,headers:{[S]:`context-module/${m.version}`,"X-Ledger-Client-Origin":this.config.originToken}}).then(r=>this.isSolanaSPLOwnerInfo(r.data)?d(r.data):i(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid computeAddressMetadata response shape"))).catch(()=>i(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: Failed to compute address metadata")))}async getOwnerInfo(e){const{tokenAddress:n,challenge:t,createATA:r}=e;if(!t)return i(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: challenge is required"));let a;if(n)a=await this.fetchAddressMetadata(n,t);else if(r?.address&&r?.mintAddress)a=await this.computeAddressMetadata(r.address,r.mintAddress,t);else return i(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: either tokenAddress or valid createATA must be provided"));return a.chain(o=>{const l=h(o.signedDescriptor);return l?d({descriptor:l,tokenAccount:o.tokenAccount,owner:o.owner,contract:o.contract}):i(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid base64 descriptor received"))})}};c=u([A(),f(0,E(C.Config))],c);export{c as HttpSolanaOwnerInfoDataSource};
|
|
2
|
+
//# sourceMappingURL=HttpSolanaOwnerInfoDataSource.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/solana/data/HttpSolanaOwnerInfoDataSource.ts"],
|
|
4
|
+
"sourcesContent": ["import { hexaStringToBuffer } from \"@ledgerhq/device-management-kit\";\nimport 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 { LEDGER_CLIENT_VERSION_HEADER } from \"@/shared/constant/HttpHeaders\";\nimport {\n SolanaSPLOwnerInfo,\n type SolanaTransactionContext,\n} from \"@/solana/domain/solanaContextTypes\";\nimport PACKAGE from \"@root/package.json\";\n\nimport {\n HttpSolanaOwnerInfoDataSourceResult,\n SolanaDataSource,\n} from \"./SolanaDataSource\";\n\n@injectable()\nexport class HttpSolanaOwnerInfoDataSource implements SolanaDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {\n if (!this.config.originToken) {\n throw new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: origin token is required\",\n );\n }\n }\n\n private isSolanaSPLOwnerInfo(data: {\n tokenAccount?: unknown;\n owner?: unknown;\n contract?: unknown;\n signedDescriptor?: unknown;\n }): data is SolanaSPLOwnerInfo {\n if (typeof data !== \"object\" || data === null) return false;\n return (\n typeof data.tokenAccount === \"string\" &&\n typeof data.owner === \"string\" &&\n typeof data.contract === \"string\" &&\n typeof data.signedDescriptor === \"string\"\n );\n }\n\n async fetchAddressMetadata(\n tokenAddress: string,\n challenge: string,\n ): Promise<Either<Error, SolanaSPLOwnerInfo>> {\n return await axios\n .request<SolanaSPLOwnerInfo>({\n method: \"GET\",\n url: `${this.config.metadataService.url}/solana/owner/${tokenAddress}?challenge=${challenge}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n \"X-Ledger-Client-Origin\": this.config.originToken,\n },\n })\n .then((res) => {\n if (!this.isSolanaSPLOwnerInfo(res.data))\n return Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid fetchAddressMetadata response shape\",\n ),\n );\n return Right(res.data);\n })\n .catch(() =>\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: Failed to fetch address metadata\",\n ),\n ),\n );\n }\n\n async computeAddressMetadata(\n address: string,\n mintAddress: string,\n challenge: string,\n ): Promise<Either<Error, SolanaSPLOwnerInfo>> {\n return await axios\n .request<SolanaSPLOwnerInfo>({\n method: \"GET\",\n url: `${this.config.metadataService.url}/solana/computed-token-account/${address}/${mintAddress}?challenge=${challenge}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n \"X-Ledger-Client-Origin\": this.config.originToken,\n },\n })\n .then((res) => {\n if (!this.isSolanaSPLOwnerInfo(res.data))\n return Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid computeAddressMetadata response shape\",\n ),\n );\n return Right(res.data);\n })\n .catch(() =>\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: Failed to compute address metadata\",\n ),\n ),\n );\n }\n\n async getOwnerInfo(\n context: SolanaTransactionContext,\n ): Promise<Either<Error, HttpSolanaOwnerInfoDataSourceResult>> {\n const { tokenAddress, challenge, createATA } = context;\n\n if (!challenge) {\n return Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: challenge is required\",\n ),\n );\n }\n\n let ownerInfoResult: Either<Error, SolanaSPLOwnerInfo>;\n\n if (tokenAddress) {\n ownerInfoResult = await this.fetchAddressMetadata(\n tokenAddress,\n challenge,\n );\n } else if (createATA?.address && createATA?.mintAddress) {\n ownerInfoResult = await this.computeAddressMetadata(\n createATA.address,\n createATA.mintAddress,\n challenge,\n );\n } else {\n return Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: either tokenAddress or valid createATA must be provided\",\n ),\n );\n }\n\n return ownerInfoResult.chain((ownerInfo) => {\n const descriptor = hexaStringToBuffer(ownerInfo.signedDescriptor);\n if (!descriptor) {\n return Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid base64 descriptor received\",\n ),\n );\n }\n return Right({\n descriptor,\n tokenAccount: ownerInfo.tokenAccount,\n owner: ownerInfo.owner,\n contract: ownerInfo.contract,\n });\n });\n }\n}\n"],
|
|
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,KAAMC,GACA,KAAK,qBAAqBA,EAAI,IAAI,EAMhCC,EAAMD,EAAI,IAAI,EALZE,EACL,IAAI,MACF,gGACF,CACF,CAEH,EACA,MAAM,IACLA,EACE,IAAI,MACF,qFACF,CACF,CACF,CACJ,CAEA,MAAM,aACJG,EAC6D,CAC7D,KAAM,CAAE,aAAAV,EAAc,UAAAC,EAAW,UAAAU,CAAU,EAAID,EAE/C,GAAI,CAACT,EACH,OAAOM,EACL,IAAI,MACF,wEACF,CACF,EAGF,IAAIK,EAEJ,GAAIZ,EACFY,EAAkB,MAAM,KAAK,qBAC3BZ,EACAC,CACF,UACSU,GAAW,SAAWA,GAAW,YAC1CC,EAAkB,MAAM,KAAK,uBAC3BD,EAAU,QACVA,EAAU,YACVV,CACF,MAEA,QAAOM,EACL,IAAI,MACF,0GACF,CACF,EAGF,OAAOK,EAAgB,MAAOC,GAAc,CAC1C,MAAMC,EAAaC,EAAmBF,EAAU,gBAAgB,EAChE,OAAKC,EAOER,EAAM,CACX,WAAAQ,EACA,aAAcD,EAAU,aACxB,MAAOA,EAAU,MACjB,SAAUA,EAAU,QACtB,CAAC,EAXQN,EACL,IAAI,MACF,qFACF,CACF,CAQJ,CAAC,CACH,CACF,EA5IaV,EAANmB,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,IAFjBvB",
|
|
6
|
+
"names": ["hexaStringToBuffer", "axios", "inject", "injectable", "Left", "Right", "configTypes", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "HttpSolanaOwnerInfoDataSource", "config", "data", "tokenAddress", "challenge", "axios", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "res", "Right", "Left", "address", "mintAddress", "context", "createATA", "ownerInfoResult", "ownerInfo", "descriptor", "hexaStringToBuffer", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{DeviceModelId as r,hexaStringToBuffer as l}from"@ledgerhq/device-management-kit";import s from"axios";import{Left as c}from"purify-ts";import{LEDGER_CLIENT_VERSION_HEADER as u}from"../../shared/constant/HttpHeaders";import{HttpSolanaOwnerInfoDataSource as n}from"../../solana/data/HttpSolanaOwnerInfoDataSource";import m from"../../../package.json";vi.mock("axios");function f(o){const d=new TextEncoder().encode(o);return Array.from(d).map(e=>e.toString(16).padStart(2,"0")).join("")}describe("HttpSolanaOwnerInfoDataSource",()=>{const o={metadataService:{url:"https://some.doma.in"},originToken:"mock-origin-token"},i=f("mock-descriptor"),d={tokenAccount:"token-account",owner:"owner-address",contract:"contract-address",signedDescriptor:i};beforeEach(()=>{vi.resetAllMocks()}),it("should fetch address metadata via tokenAddress",async()=>{const e={deviceModelId:r.FLEX,tokenAddress:"some-token",challenge:"random",createATA:void 0};vi.spyOn(s,"request").mockResolvedValueOnce({data:d});const t=await new n(o).getOwnerInfo(e);expect(t.isRight()).toBe(!0),expect(t.extract()).toEqual({descriptor:l(i),tokenAccount:"token-account",owner:"owner-address",contract:"contract-address"})}),it("should compute address when tokenAddress is not provided",async()=>{const e={deviceModelId:r.FLEX,tokenAddress:void 0,challenge:"random",createATA:{address:"some-address",mintAddress:"some-mint"}};vi.spyOn(s,"request").mockResolvedValueOnce({data:d});const t=await new n(o).getOwnerInfo(e);expect(t.isRight()).toBe(!0),expect(t.extract().tokenAccount).toBe("token-account")}),it("should return an error if both tokenAddress and createATA are missing or invalid",async()=>{const e={deviceModelId:r.FLEX,tokenAddress:void 0,challenge:"random",createATA:void 0},t=await new n(o).getOwnerInfo(e);expect(t).toEqual(c(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: either tokenAddress or valid createATA must be provided")))}),it("should return an error if challenge is missing",async()=>{const e={deviceModelId:r.FLEX,tokenAddress:"some-token",challenge:void 0,createATA:void 0},t=await new n(o).getOwnerInfo(e);expect(t).toEqual(c(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: challenge is required")))}),it("should return an error if the descriptor is not valid base64",async()=>{vi.spyOn(s,"request").mockResolvedValueOnce({data:{...d,signedDescriptor:"!!!not-valid-base64!!!"}});const e={deviceModelId:r.FLEX,tokenAddress:"some-token",challenge:"random",createATA:void 0},t=await new n(o).getOwnerInfo(e);expect(t).toEqual(c(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid base64 descriptor received")))}),it("should return an error if the metadata request fails",async()=>{vi.spyOn(s,"request").mockRejectedValueOnce(new Error("Network error"));const e={deviceModelId:r.FLEX,tokenAddress:"some-token",challenge:"random",createATA:void 0},t=await new n(o).getOwnerInfo(e);expect(t).toEqual(c(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: Failed to fetch address metadata")))}),it("should return an error if axios request return wrong shape for fetchAddressMetadata",async()=>{vi.spyOn(s,"request").mockResolvedValueOnce({data:{wrong:"field"}});const e={deviceModelId:r.FLEX,tokenAddress:"some-token",challenge:"random",createATA:void 0},t=await new n(o).getOwnerInfo(e);expect(t).toEqual(c(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid fetchAddressMetadata response shape")))}),it("should return an error if axios request return wrong shape for computeAddressMetadata",async()=>{vi.spyOn(s,"request").mockResolvedValueOnce({data:{wrong:"field"}});const e={deviceModelId:r.FLEX,tokenAddress:void 0,challenge:"random",createATA:{address:"some-address",mintAddress:"some-mint"}},t=await new n(o).getOwnerInfo(e);expect(t).toEqual(c(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid computeAddressMetadata response shape")))}),it("should throw if originToken is missing",()=>{expect(()=>{new n({...o,originToken:void 0})}).toThrow("[ContextModule] - HttpSolanaOwnerInfoDataSource: origin token is required")}),it("should call axios with correct headers",async()=>{const e={deviceModelId:r.FLEX,tokenAddress:"some-token",challenge:"random",createATA:void 0},a=vi.spyOn(s,"request").mockResolvedValueOnce({data:d});await new n(o).getOwnerInfo(e),expect(a).toHaveBeenCalledWith(expect.objectContaining({headers:{[u]:`context-module/${m.version}`,"X-Ledger-Client-Origin":o.originToken}}))})});
|
|
2
|
+
//# sourceMappingURL=HttpSolanaOwnerInfoDataSource.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/solana/data/HttpSolanaOwnerInfoDataSource.test.ts"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n DeviceModelId,\n hexaStringToBuffer,\n} from \"@ledgerhq/device-management-kit\";\nimport axios from \"axios\";\nimport { Left } from \"purify-ts\";\n\nimport type { ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { LEDGER_CLIENT_VERSION_HEADER } from \"@/shared/constant/HttpHeaders\";\nimport { HttpSolanaOwnerInfoDataSource } from \"@/solana/data/HttpSolanaOwnerInfoDataSource\";\nimport type { SolanaTransactionContext } from \"@/solana/domain/solanaContextTypes\";\nimport PACKAGE from \"@root/package.json\";\n\nvi.mock(\"axios\");\n\nfunction stringToHex(str: string): string {\n const encoder = new TextEncoder();\n const bytes = encoder.encode(str); // Uint8Array\n return Array.from(bytes)\n .map((byte) => byte.toString(16).padStart(2, \"0\"))\n .join(\"\");\n}\n\ndescribe(\"HttpSolanaOwnerInfoDataSource\", () => {\n const config = {\n metadataService: { url: \"https://some.doma.in\" },\n originToken: \"mock-origin-token\",\n } as ContextModuleConfig;\n\n const signedDescriptorHex = stringToHex(\"mock-descriptor\");\n const responseData = {\n tokenAccount: \"token-account\",\n owner: \"owner-address\",\n contract: \"contract-address\",\n signedDescriptor: signedDescriptorHex,\n };\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should fetch address metadata via tokenAddress\", async () => {\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: \"some-token\",\n challenge: \"random\",\n createATA: undefined,\n };\n vi.spyOn(axios, \"request\").mockResolvedValueOnce({ data: responseData });\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n const result = await dataSource.getOwnerInfo(context);\n\n expect(result.isRight()).toBe(true);\n expect(result.extract()).toEqual({\n descriptor: hexaStringToBuffer(signedDescriptorHex),\n tokenAccount: \"token-account\",\n owner: \"owner-address\",\n contract: \"contract-address\",\n });\n });\n\n it(\"should compute address when tokenAddress is not provided\", async () => {\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: undefined,\n challenge: \"random\",\n createATA: {\n address: \"some-address\",\n mintAddress: \"some-mint\",\n },\n };\n vi.spyOn(axios, \"request\").mockResolvedValueOnce({ data: responseData });\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n const result = await dataSource.getOwnerInfo(context);\n\n expect(result.isRight()).toBe(true);\n expect((result.extract() as any).tokenAccount).toBe(\"token-account\");\n });\n\n it(\"should return an error if both tokenAddress and createATA are missing or invalid\", async () => {\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: undefined,\n challenge: \"random\",\n createATA: undefined,\n };\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n const result = await dataSource.getOwnerInfo(context);\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: either tokenAddress or valid createATA must be provided\",\n ),\n ),\n );\n });\n\n it(\"should return an error if challenge is missing\", async () => {\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: \"some-token\",\n challenge: undefined,\n createATA: undefined,\n };\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n const result = await dataSource.getOwnerInfo(context);\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: challenge is required\",\n ),\n ),\n );\n });\n\n it(\"should return an error if the descriptor is not valid base64\", async () => {\n vi.spyOn(axios, \"request\").mockResolvedValueOnce({\n data: { ...responseData, signedDescriptor: \"!!!not-valid-base64!!!\" },\n });\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: \"some-token\",\n challenge: \"random\",\n createATA: undefined,\n };\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n const result = await dataSource.getOwnerInfo(context);\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid base64 descriptor received\",\n ),\n ),\n );\n });\n\n it(\"should return an error if the metadata request fails\", async () => {\n vi.spyOn(axios, \"request\").mockRejectedValueOnce(\n new Error(\"Network error\"),\n );\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: \"some-token\",\n challenge: \"random\",\n createATA: undefined,\n };\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n const result = await dataSource.getOwnerInfo(context);\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: Failed to fetch address metadata\",\n ),\n ),\n );\n });\n\n it(\"should return an error if axios request return wrong shape for fetchAddressMetadata\", async () => {\n vi.spyOn(axios, \"request\").mockResolvedValueOnce({\n data: { wrong: \"field\" },\n });\n\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: \"some-token\",\n challenge: \"random\",\n createATA: undefined,\n };\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n const result = await dataSource.getOwnerInfo(context);\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid fetchAddressMetadata response shape\",\n ),\n ),\n );\n });\n\n it(\"should return an error if axios request return wrong shape for computeAddressMetadata\", async () => {\n vi.spyOn(axios, \"request\").mockResolvedValueOnce({\n data: { wrong: \"field\" },\n });\n\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: undefined,\n challenge: \"random\",\n createATA: {\n address: \"some-address\",\n mintAddress: \"some-mint\",\n },\n };\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n const result = await dataSource.getOwnerInfo(context);\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid computeAddressMetadata response shape\",\n ),\n ),\n );\n });\n\n it(\"should throw if originToken is missing\", () => {\n expect(() => {\n new HttpSolanaOwnerInfoDataSource({\n ...config,\n originToken: undefined,\n } as any);\n }).toThrow(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: origin token is required\",\n );\n });\n\n it(\"should call axios with correct headers\", async () => {\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: \"some-token\",\n challenge: \"random\",\n createATA: undefined,\n };\n const spy = vi\n .spyOn(axios, \"request\")\n .mockResolvedValueOnce({ data: responseData });\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n await dataSource.getOwnerInfo(context);\n\n expect(spy).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n \"X-Ledger-Client-Origin\": config.originToken,\n },\n }),\n );\n });\n});\n"],
|
|
5
|
+
"mappings": "AAEA,OACE,iBAAAA,EACA,sBAAAC,MACK,kCACP,OAAOC,MAAW,QAClB,OAAS,QAAAC,MAAY,YAGrB,OAAS,gCAAAC,MAAoC,gCAC7C,OAAS,iCAAAC,MAAqC,8CAE9C,OAAOC,MAAa,qBAEpB,GAAG,KAAK,OAAO,EAEf,SAASC,EAAYC,EAAqB,CAExC,MAAMC,EADU,IAAI,YAAY,EACV,OAAOD,CAAG,EAChC,OAAO,MAAM,KAAKC,CAAK,EACpB,IAAKC,GAASA,EAAK,SAAS,EAAE,EAAE,SAAS,EAAG,GAAG,CAAC,EAChD,KAAK,EAAE,CACZ,CAEA,SAAS,gCAAiC,IAAM,CAC9C,MAAMC,EAAS,CACb,gBAAiB,CAAE,IAAK,sBAAuB,EAC/C,YAAa,mBACf,EAEMC,EAAsBL,EAAY,iBAAiB,EACnDM,EA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,CAAE,MAAO,OAAQ,CACzB,CAAC,EAED,MAAMY,EAAoC,CACxC,cAAed,EAAc,KAC7B,aAAc,OACd,UAAW,SACX,UAAW,CACT,QAAS,eACT,YAAa,WACf,CACF,EAGMe,EAAS,MADI,IAAIV,EAA8BM,CAAM,EAC3B,aAAaG,CAAO,EAEpD,OAAOC,CAAM,EAAE,QACbZ,EACE,IAAI,MACF,gGACF,CACF,CACF,CACF,CAAC,EAED,GAAG,yCAA0C,IAAM,CACjD,OAAO,IAAM,CACX,IAAIE,EAA8B,CAChC,GAAGM,EACH,YAAa,MACf,CAAQ,CACV,CAAC,EAAE,QACD,2EACF,CACF,CAAC,EAED,GAAG,yCAA0C,SAAY,CACvD,MAAMG,EAAoC,CACxC,cAAed,EAAc,KAC7B,aAAc,aACd,UAAW,SACX,UAAW,MACb,EACMgB,EAAM,GACT,MAAMd,EAAO,SAAS,EACtB,sBAAsB,CAAE,KAAMW,CAAa,CAAC,EAG/C,MADmB,IAAIR,EAA8BM,CAAM,EAC1C,aAAaG,CAAO,EAErC,OAAOE,CAAG,EAAE,qBACV,OAAO,iBAAiB,CACtB,QAAS,CACP,CAACZ,CAA4B,EAAG,kBAAkBE,EAAQ,OAAO,GACjE,yBAA0BK,EAAO,WACnC,CACF,CAAC,CACH,CACF,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["DeviceModelId", "hexaStringToBuffer", "axios", "Left", "LEDGER_CLIENT_VERSION_HEADER", "HttpSolanaOwnerInfoDataSource", "PACKAGE", "stringToHex", "str", "bytes", "byte", "config", "signedDescriptorHex", "responseData", "context", "result", "spy"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=SolanaDataSource.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{ContainerModule as a}from"inversify";import{HttpSolanaOwnerInfoDataSource as e}from"../../solana/data/HttpSolanaOwnerInfoDataSource";import{solanaContextTypes as t}from"../../solana/di/solanaContextTypes";import{DefaultSolanaContextLoader as r}from"../../solana/domain/DefaultSolanaContextLoader";const f=()=>new a(({bind:o})=>{o(t.SolanaDataSource).to(e),o(t.SolanaContextLoader).to(r)});export{f as solanaContextModuleFactory};
|
|
2
|
+
//# sourceMappingURL=SolanaContextModuleFactory.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/solana/di/SolanaContextModuleFactory.ts"],
|
|
4
|
+
"sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpSolanaOwnerInfoDataSource } from \"@/solana/data/HttpSolanaOwnerInfoDataSource\";\nimport { solanaContextTypes } from \"@/solana/di/solanaContextTypes\";\nimport { DefaultSolanaContextLoader } from \"@/solana/domain/DefaultSolanaContextLoader\";\n\nexport const solanaContextModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(solanaContextTypes.SolanaDataSource).to(HttpSolanaOwnerInfoDataSource);\n bind(solanaContextTypes.SolanaContextLoader).to(DefaultSolanaContextLoader);\n });\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,iCAAAC,MAAqC,8CAC9C,OAAS,sBAAAC,MAA0B,iCACnC,OAAS,8BAAAC,MAAkC,6CAEpC,MAAMC,EAA6B,IACxC,IAAIJ,EAAgB,CAAC,CAAE,KAAAK,CAAK,IAAM,CAChCA,EAAKH,EAAmB,gBAAgB,EAAE,GAAGD,CAA6B,EAC1EI,EAAKH,EAAmB,mBAAmB,EAAE,GAAGC,CAA0B,CAC5E,CAAC",
|
|
6
|
+
"names": ["ContainerModule", "HttpSolanaOwnerInfoDataSource", "solanaContextTypes", "DefaultSolanaContextLoader", "solanaContextModuleFactory", "bind"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/solana/di/solanaContextTypes.ts"],
|
|
4
|
+
"sourcesContent": ["export const solanaContextTypes = {\n SolanaDataSource: Symbol.for(\"SolanaDataSource\"),\n SolanaContextLoader: Symbol.for(\"SolanaContextLoader\"),\n};\n"],
|
|
5
|
+
"mappings": "AAAO,MAAMA,EAAqB,CAChC,iBAAkB,OAAO,IAAI,kBAAkB,EAC/C,oBAAqB,OAAO,IAAI,qBAAqB,CACvD",
|
|
6
|
+
"names": ["solanaContextTypes"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var f=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var s=(r,e,t,o)=>{for(var a=o>1?void 0:o?p(e,t):e,i=r.length-1,n;i>=0;i--)(n=r[i])&&(a=(o?n(e,t,a):n(a))||a);return o&&a&&f(e,t,a),a},m=(r,e)=>(t,o)=>e(t,o,r);import{inject as d,injectable as l}from"inversify";import{Left as S}from"purify-ts";import{pkiTypes as u}from"../../pki/di/pkiTypes";import{KeyUsage as y}from"../../pki/model/KeyUsage";import{solanaContextTypes as C}from"../../solana/di/solanaContextTypes";let c=class{constructor(e,t){this._certificateLoader=t;this._dataSource=e}_dataSource;async load(e){const t=await this._certificateLoader.loadCertificate({keyId:"domain_metadata_key",keyUsage:y.TrustedName,targetDevice:e.deviceModelId});return t?(await this._dataSource.getOwnerInfo(e)).map(({descriptor:o,tokenAccount:a,owner:i,contract:n})=>({descriptor:o,tokenAccount:a,owner:i,contract:n,certificate:t})):S(new Error("[ContextModule] - DefaultSolanaContextLoader: CAL certificate is undefined"))}};c=s([l(),m(0,d(C.SolanaDataSource)),m(1,d(u.PkiCertificateLoader))],c);export{c as DefaultSolanaContextLoader};
|
|
2
|
+
//# sourceMappingURL=DefaultSolanaContextLoader.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/solana/domain/DefaultSolanaContextLoader.ts"],
|
|
4
|
+
"sourcesContent": ["import { inject, injectable } from \"inversify\";\nimport { Left } from \"purify-ts\";\n\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { type SolanaDataSource } from \"@/solana/data/SolanaDataSource\";\nimport { solanaContextTypes } from \"@/solana/di/solanaContextTypes\";\n\nimport { SolanaContextLoader } from \"./SolanaContextLoader\";\nimport {\n SolanaTransactionContext,\n SolanaTransactionContextResult,\n} from \"./solanaContextTypes\";\n\n@injectable()\nexport class DefaultSolanaContextLoader implements SolanaContextLoader {\n private _dataSource: SolanaDataSource;\n\n constructor(\n @inject(solanaContextTypes.SolanaDataSource)\n dataSource: SolanaDataSource,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly _certificateLoader: PkiCertificateLoader,\n ) {\n this._dataSource = dataSource;\n }\n\n async load(\n solanaContext: SolanaTransactionContext,\n ): Promise<SolanaTransactionContextResult> {\n // load the CAL certificate\n const certificate = await this._certificateLoader.loadCertificate({\n keyId: \"domain_metadata_key\",\n keyUsage: KeyUsage.TrustedName,\n targetDevice: solanaContext.deviceModelId,\n });\n if (!certificate) {\n return Left(\n new Error(\n \"[ContextModule] - DefaultSolanaContextLoader: CAL certificate is undefined\",\n ),\n );\n }\n\n // fetch the Solana context\n return (await this._dataSource.getOwnerInfo(solanaContext)).map(\n ({ descriptor, tokenAccount, owner, contract }) => ({\n descriptor,\n tokenAccount,\n owner,\n contract,\n certificate,\n }),\n );\n }\n}\n"],
|
|
5
|
+
"mappings": "iOAAA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YACnC,OAAS,QAAAC,MAAY,YAErB,OAAS,YAAAC,MAAgB,oBAEzB,OAAS,YAAAC,MAAgB,uBAEzB,OAAS,sBAAAC,MAA0B,iCAS5B,IAAMC,EAAN,KAAgE,CAGrE,YAEEC,EAEiBC,EACjB,CADiB,wBAAAA,EAEjB,KAAK,YAAcD,CACrB,CATQ,YAWR,MAAM,KACJE,EACyC,CAEzC,MAAMC,EAAc,MAAM,KAAK,mBAAmB,gBAAgB,CAChE,MAAO,sBACP,SAAUC,EAAS,YACnB,aAAcF,EAAc,aAC9B,CAAC,EACD,OAAKC,GASG,MAAM,KAAK,YAAY,aAAaD,CAAa,GAAG,IAC1D,CAAC,CAAE,WAAAG,EAAY,aAAAC,EAAc,MAAAC,EAAO,SAAAC,CAAS,KAAO,CAClD,WAAAH,EACA,aAAAC,EACA,MAAAC,EACA,SAAAC,EACA,YAAAL,CACF,EACF,EAhBSM,EACL,IAAI,MACF,4EACF,CACF,CAaJ,CACF,EAxCaV,EAANW,EAAA,CADNC,EAAW,EAKPC,EAAA,EAAAC,EAAOC,EAAmB,gBAAgB,GAE1CF,EAAA,EAAAC,EAAOE,EAAS,oBAAoB,IAN5BhB",
|
|
6
|
+
"names": ["inject", "injectable", "Left", "pkiTypes", "KeyUsage", "solanaContextTypes", "DefaultSolanaContextLoader", "dataSource", "_certificateLoader", "solanaContext", "certificate", "KeyUsage", "descriptor", "tokenAccount", "owner", "contract", "Left", "__decorateClass", "injectable", "__decorateParam", "inject", "solanaContextTypes", "pkiTypes"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{DeviceModelId as i}from"@ledgerhq/device-management-kit";import{Left as d,Right as l}from"purify-ts";import{KeyUsage as s}from"../../pki/model/KeyUsage";import{DefaultSolanaContextLoader as f}from"../../solana/domain/DefaultSolanaContextLoader";describe("DefaultSolanaContextLoader",()=>{let a,e,r;const o={deviceModelId:i.FLEX,tokenAddress:"token-addr",challenge:"challenge-str"},n={descriptor:"cert-desc",signature:"cert-sig",keyUsageNumber:0,payload:new Uint8Array};beforeEach(()=>{vi.resetAllMocks(),a={getOwnerInfo:vi.fn()},e={loadCertificate:vi.fn()},r=new f(a,e)}),it("should call dataSource.getSolanaContext and certificateLoader.loadCertificate with correct args",async()=>{e.loadCertificate.mockResolvedValue(n),a.getOwnerInfo.mockResolvedValue(l({descriptor:Buffer.from("d"),tokenAccount:"tkn",owner:"own",contract:"ctr"})),await r.load(o),expect(e.loadCertificate).toHaveBeenCalledWith({keyId:"domain_metadata_key",keyUsage:s.TrustedName,targetDevice:o.deviceModelId}),expect(a.getOwnerInfo).toHaveBeenCalledWith(o)}),it("should return Left if certificate loader returns undefined",async()=>{e.loadCertificate.mockResolvedValue(void 0);const t=await r.load(o);expect(t).toEqual(d(new Error("[ContextModule] - DefaultSolanaContextLoader: CAL certificate is undefined")))}),it("should propagate Left from dataSource.getSolanaContext",async()=>{e.loadCertificate.mockResolvedValue(n);const t=new Error("DS failure");a.getOwnerInfo.mockResolvedValue(d(t));const c=await r.load(o);expect(c).toEqual(d(t))}),it("should return Right with merged data and certificate on success",async()=>{e.loadCertificate.mockResolvedValue(n);const t={descriptor:Buffer.from("dd"),tokenAccount:"tokenAcct",owner:"ownerAddr",contract:"contractAddr",certificate:n};a.getOwnerInfo.mockResolvedValue(l(t));const c=await r.load(o);expect(c.isRight()).toBe(!0),expect(c.extract()).toEqual({...t,certificate:n})})});
|
|
2
|
+
//# sourceMappingURL=DefaultSolanaContextLoader.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/solana/domain/DefaultSolanaContextLoader.test.ts"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { DefaultSolanaContextLoader } from \"@/solana/domain/DefaultSolanaContextLoader\";\nimport type {\n SolanaTransactionContext,\n SolanaTransactionContextResultSuccess,\n} from \"@/solana/domain/solanaContextTypes\";\n\ndescribe(\"DefaultSolanaContextLoader\", () => {\n let mockDataSource: {\n getOwnerInfo: any;\n };\n let mockCertLoader: {\n loadCertificate: any;\n };\n let loader: DefaultSolanaContextLoader;\n\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: \"token-addr\",\n challenge: \"challenge-str\",\n } as any;\n\n const fakeCert = {\n descriptor: \"cert-desc\",\n signature: \"cert-sig\",\n keyUsageNumber: 0,\n payload: new Uint8Array(),\n };\n\n beforeEach(() => {\n vi.resetAllMocks();\n mockDataSource = {\n getOwnerInfo: vi.fn(),\n };\n mockCertLoader = {\n loadCertificate: vi.fn(),\n };\n\n loader = new DefaultSolanaContextLoader(\n mockDataSource as any,\n mockCertLoader as any,\n );\n });\n\n it(\"should call dataSource.getSolanaContext and certificateLoader.loadCertificate with correct args\", async () => {\n // given\n mockCertLoader.loadCertificate.mockResolvedValue(fakeCert);\n mockDataSource.getOwnerInfo.mockResolvedValue(\n Right({\n descriptor: Buffer.from(\"d\"),\n tokenAccount: \"tkn\",\n owner: \"own\",\n contract: \"ctr\",\n }),\n );\n\n // when\n await loader.load(context);\n\n // then\n expect(mockCertLoader.loadCertificate).toHaveBeenCalledWith({\n keyId: \"domain_metadata_key\",\n keyUsage: KeyUsage.TrustedName,\n targetDevice: context.deviceModelId,\n });\n expect(mockDataSource.getOwnerInfo).toHaveBeenCalledWith(context);\n });\n\n it(\"should return Left if certificate loader returns undefined\", async () => {\n mockCertLoader.loadCertificate.mockResolvedValue(undefined);\n\n const result = await loader.load(context);\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] - DefaultSolanaContextLoader: CAL certificate is undefined\",\n ),\n ),\n );\n });\n\n it(\"should propagate Left from dataSource.getSolanaContext\", async () => {\n mockCertLoader.loadCertificate.mockResolvedValue(fakeCert);\n const dsError = new Error(\"DS failure\");\n mockDataSource.getOwnerInfo.mockResolvedValue(Left(dsError));\n\n const result = await loader.load(context);\n\n expect(result).toEqual(Left(dsError));\n });\n\n it(\"should return Right with merged data and certificate on success\", async () => {\n mockCertLoader.loadCertificate.mockResolvedValue(fakeCert);\n\n const dsPayload: SolanaTransactionContextResultSuccess = {\n descriptor: Buffer.from(\"dd\"),\n tokenAccount: \"tokenAcct\",\n owner: \"ownerAddr\",\n contract: \"contractAddr\",\n certificate: fakeCert,\n };\n mockDataSource.getOwnerInfo.mockResolvedValue(Right(dsPayload));\n\n const result = await loader.load(context);\n\n expect(result.isRight()).toBe(true);\n expect(result.extract()).toEqual({\n ...dsPayload,\n certificate: fakeCert,\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AACA,OAAS,iBAAAA,MAAqB,kCAC9B,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAE5B,OAAS,YAAAC,MAAgB,uBACzB,OAAS,8BAAAC,MAAkC,6CAM3C,SAAS,6BAA8B,IAAM,CAC3C,IAAIC,EAGAC,EAGAC,EAEJ,MAAMC,EAAoC,CACxC,cAAeR,EAAc,KAC7B,aAAc,aACd,UAAW,eACb,EAEMS,EAAW,CACf,WAAY,YACZ,UAAW,WACX,eAAgB,EAChB,QAAS,IAAI,UACf,EAEA,WAAW,IAAM,CACf,GAAG,cAAc,EACjBJ,EAAiB,CACf,aAAc,GAAG,GAAG,CACtB,EACAC,EAAiB,CACf,gBAAiB,GAAG,GAAG,CACzB,EAEAC,EAAS,IAAIH,EACXC,EACAC,CACF,CACF,CAAC,EAED,GAAG,kGAAmG,SAAY,CAEhHA,EAAe,gBAAgB,kBAAkBG,CAAQ,EACzDJ,EAAe,aAAa,kBAC1BH,EAAM,CACJ,WAAY,OAAO,KAAK,GAAG,EAC3B,aAAc,MACd,MAAO,MACP,SAAU,KACZ,CAAC,CACH,EAGA,MAAMK,EAAO,KAAKC,CAAO,EAGzB,OAAOF,EAAe,eAAe,EAAE,qBAAqB,CAC1D,MAAO,sBACP,SAAUH,EAAS,YACnB,aAAcK,EAAQ,aACxB,CAAC,EACD,OAAOH,EAAe,YAAY,EAAE,qBAAqBG,CAAO,CAClE,CAAC,EAED,GAAG,6DAA8D,SAAY,CAC3EF,EAAe,gBAAgB,kBAAkB,MAAS,EAE1D,MAAMI,EAAS,MAAMH,EAAO,KAAKC,CAAO,EAExC,OAAOE,CAAM,EAAE,QACbT,EACE,IAAI,MACF,4EACF,CACF,CACF,CACF,CAAC,EAED,GAAG,yDAA0D,SAAY,CACvEK,EAAe,gBAAgB,kBAAkBG,CAAQ,EACzD,MAAME,EAAU,IAAI,MAAM,YAAY,EACtCN,EAAe,aAAa,kBAAkBJ,EAAKU,CAAO,CAAC,EAE3D,MAAMD,EAAS,MAAMH,EAAO,KAAKC,CAAO,EAExC,OAAOE,CAAM,EAAE,QAAQT,EAAKU,CAAO,CAAC,CACtC,CAAC,EAED,GAAG,kEAAmE,SAAY,CAChFL,EAAe,gBAAgB,kBAAkBG,CAAQ,EAEzD,MAAMG,EAAmD,CACvD,WAAY,OAAO,KAAK,IAAI,EAC5B,aAAc,YACd,MAAO,YACP,SAAU,eACV,YAAaH,CACf,EACAJ,EAAe,aAAa,kBAAkBH,EAAMU,CAAS,CAAC,EAE9D,MAAMF,EAAS,MAAMH,EAAO,KAAKC,CAAO,EAExC,OAAOE,EAAO,QAAQ,CAAC,EAAE,KAAK,EAAI,EAClC,OAAOA,EAAO,QAAQ,CAAC,EAAE,QAAQ,CAC/B,GAAGE,EACH,YAAaH,CACf,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["DeviceModelId", "Left", "Right", "KeyUsage", "DefaultSolanaContextLoader", "mockDataSource", "mockCertLoader", "loader", "context", "fakeCert", "result", "dsError", "dsPayload"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=SolanaContextLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=solanaContextTypes.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ContainerModule as e}from"inversify";import{HttpTokenDataSource as r}from"../../token/data/HttpTokenDataSource";import{tokenTypes as t}from"../../token/di/tokenTypes";import{TokenContextLoader as n}from"../../token/domain/TokenContextLoader";const T=()=>new e((o
|
|
1
|
+
import{ContainerModule as e}from"inversify";import{HttpTokenDataSource as r}from"../../token/data/HttpTokenDataSource";import{tokenTypes as t}from"../../token/di/tokenTypes";import{TokenContextLoader as n}from"../../token/domain/TokenContextLoader";const T=()=>new e(({bind:o})=>{o(t.TokenDataSource).to(r),o(t.TokenContextLoader).to(n)});export{T as tokenModuleFactory};
|
|
2
2
|
//# sourceMappingURL=tokenModuleFactory.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/token/di/tokenModuleFactory.ts"],
|
|
4
|
-
"sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpTokenDataSource } from \"@/token/data/HttpTokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\nimport { TokenContextLoader } from \"@/token/domain/TokenContextLoader\";\n\nexport const tokenModuleFactory = () =>\n new ContainerModule((bind
|
|
5
|
-
"mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,uBAAAC,MAA2B,mCACpC,OAAS,cAAAC,MAAkB,wBAC3B,OAAS,sBAAAC,MAA0B,oCAE5B,MAAMC,EAAqB,IAChC,IAAIJ,EAAgB,
|
|
6
|
-
"names": ["ContainerModule", "HttpTokenDataSource", "tokenTypes", "TokenContextLoader", "tokenModuleFactory", "bind"
|
|
4
|
+
"sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpTokenDataSource } from \"@/token/data/HttpTokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\nimport { TokenContextLoader } from \"@/token/domain/TokenContextLoader\";\n\nexport const tokenModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(tokenTypes.TokenDataSource).to(HttpTokenDataSource);\n bind(tokenTypes.TokenContextLoader).to(TokenContextLoader);\n });\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,uBAAAC,MAA2B,mCACpC,OAAS,cAAAC,MAAkB,wBAC3B,OAAS,sBAAAC,MAA0B,oCAE5B,MAAMC,EAAqB,IAChC,IAAIJ,EAAgB,CAAC,CAAE,KAAAK,CAAK,IAAM,CAChCA,EAAKH,EAAW,eAAe,EAAE,GAAGD,CAAmB,EACvDI,EAAKH,EAAW,kBAAkB,EAAE,GAAGC,CAAkB,CAC3D,CAAC",
|
|
6
|
+
"names": ["ContainerModule", "HttpTokenDataSource", "tokenTypes", "TokenContextLoader", "tokenModuleFactory", "bind"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var c=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var l=(a,e,o,r)=>{for(var t=r>1?void 0:r?g(e,o):e,i=a.length-1,d;i>=0;i--)(d=a[i])&&(t=(r?d(e,o,t):d(t))||t);return r&&t&&c(e,o,t),t},m=(a,e)=>(o,r)=>e(o,r,a);import p from"axios";import{inject as f,injectable as D}from"inversify";import{Left as n,Right as y}from"purify-ts";import{configTypes as u}from"../../config/di/configTypes";import{LEDGER_CLIENT_VERSION_HEADER as x}from"../../shared/constant/HttpHeaders";import P from"../../../package.json";let s=class{constructor(e){this.config=e}async getProxyDelegateCall({proxyAddress:e,calldata:o,chainId:r}){let t;try{t=(await p.request({method:"POST",url:`${this.config.metadataService.url}/ethereum/${r}/contract/proxy/delegate`,headers:{[x]:`context-module/${P.version}`},data:{proxy:e,data:o}})).data}catch{return n(new Error("[ContextModule] HttpProxyDataSource: Failed to fetch delegate proxy"))}return t?this.isProxyDelegateCallDto(t)?y(t):n(new Error(`[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${e} on chain ${r}`)):n(new Error(`[ContextModule] HttpProxyDataSource: No data received for proxy ${e} on chain ${r}`))}async getProxyImplementationAddress({proxyAddress:e,chainId:o}){let r;try{r=(await p.request({method:"GET",url:`${this.config.metadataService.url}/ethereum/${o}/contract/proxy/${e}`,headers:{[x]:`context-module/${P.version}`}})).data}catch{return n(new Error("[ContextModule] HttpProxyDataSource: Failed to fetch implementation address"))}return r?this.isProxyImplementationAddressDto(r)?y({implementationAddress:r.implementationAddress}):n(new Error(`[ContextModule] HttpProxyDataSource: Invalid proxy implementation address response format for proxy ${e} on chain ${o}`)):n(new Error(`[ContextModule] HttpProxyDataSource: No data received for proxy ${e} on chain ${o}`))}isProxyDelegateCallDto(e){return typeof e=="object"&&e!==null&&"delegateAddresses"in e&&"signedDescriptor"in e&&Array.isArray(e.delegateAddresses)&&e.delegateAddresses.every(o=>typeof o=="string")&&typeof e.signedDescriptor=="string"}isProxyImplementationAddressDto(e){return typeof e=="object"&&e!==null&&"proxyAddress"in e&&"implementationAddress"in e&&"standard"in e&&typeof e.proxyAddress=="string"&&typeof e.implementationAddress=="string"&&typeof e.standard=="string"&&e.standard.length>0}};s=l([D(),m(0,f(u.Config))],s);export{s as HttpProxyDataSource};
|
|
2
|
+
//# sourceMappingURL=HttpProxyDataSource.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/transaction/data/HttpProxyDataSource.ts"],
|
|
4
|
+
"sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { LEDGER_CLIENT_VERSION_HEADER } from \"@/shared/constant/HttpHeaders\";\nimport { type ProxyDelegateCall } from \"@/transaction/model/ProxyDelegateCall\";\nimport { type ProxyImplementationAddress } from \"@/transaction/model/ProxyImplementationAddress\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { type ProxyDelegateCallDto } from \"./ProxyDelegateCallDto\";\nimport { type ProxyImplementationAddressDto } from \"./ProxyImplementationAddressDto\";\n\nexport type GetProxyDelegateCallParam = {\n proxyAddress: string;\n calldata: string;\n chainId: number;\n};\n\nexport type GetProxyImplementationAddressParam = {\n proxyAddress: string;\n chainId: number;\n};\n\nexport interface ProxyDataSource {\n getProxyDelegateCall(\n params: GetProxyDelegateCallParam,\n ): Promise<Either<Error, ProxyDelegateCall>>;\n getProxyImplementationAddress(\n params: GetProxyImplementationAddressParam,\n ): Promise<Either<Error, ProxyImplementationAddress>>;\n}\n\n@injectable()\nexport class HttpProxyDataSource implements ProxyDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n public async getProxyDelegateCall({\n proxyAddress,\n calldata,\n chainId,\n }: GetProxyDelegateCallParam): Promise<Either<Error, ProxyDelegateCall>> {\n let dto: ProxyDelegateCallDto | undefined;\n try {\n const response = await axios.request<ProxyDelegateCallDto>({\n method: \"POST\",\n url: `${this.config.metadataService.url}/ethereum/${chainId}/contract/proxy/delegate`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n },\n data: {\n proxy: proxyAddress,\n data: calldata,\n },\n });\n dto = response.data;\n } catch (_error) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: Failed to fetch delegate proxy`,\n ),\n );\n }\n\n if (!dto) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: No data received for proxy ${proxyAddress} on chain ${chainId}`,\n ),\n );\n }\n\n if (!this.isProxyDelegateCallDto(dto)) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${proxyAddress} on chain ${chainId}`,\n ),\n );\n }\n\n return Right(dto as ProxyDelegateCall);\n }\n\n public async getProxyImplementationAddress({\n proxyAddress,\n chainId,\n }: GetProxyImplementationAddressParam): Promise<\n Either<Error, ProxyImplementationAddress>\n > {\n let dto: ProxyImplementationAddressDto | undefined;\n try {\n const response = await axios.request<ProxyImplementationAddressDto>({\n method: \"GET\",\n url: `${this.config.metadataService.url}/ethereum/${chainId}/contract/proxy/${proxyAddress}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n },\n });\n dto = response.data;\n } catch (_error) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: Failed to fetch implementation address`,\n ),\n );\n }\n\n if (!dto) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: No data received for proxy ${proxyAddress} on chain ${chainId}`,\n ),\n );\n }\n\n if (!this.isProxyImplementationAddressDto(dto)) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: Invalid proxy implementation address response format for proxy ${proxyAddress} on chain ${chainId}`,\n ),\n );\n }\n\n return Right({ implementationAddress: dto.implementationAddress });\n }\n\n /**\n * Type guard to validate ProxyDelegateCallDto\n */\n private isProxyDelegateCallDto(\n value: unknown,\n ): value is ProxyDelegateCallDto {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"delegateAddresses\" in value &&\n \"signedDescriptor\" in value &&\n Array.isArray(value.delegateAddresses) &&\n value.delegateAddresses.every((address) => typeof address === \"string\") &&\n typeof value.signedDescriptor === \"string\"\n );\n }\n\n /**\n * Type guard to validate ProxyImplementationAddressDto\n */\n private isProxyImplementationAddressDto(\n value: unknown,\n ): value is ProxyImplementationAddressDto {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"proxyAddress\" in value &&\n \"implementationAddress\" in value &&\n \"standard\" in value &&\n typeof value.proxyAddress === \"string\" &&\n typeof value.implementationAddress === \"string\" &&\n typeof value.standard === \"string\" &&\n value.standard.length > 0\n );\n }\n}\n"],
|
|
5
|
+
"mappings": "iOAAA,OAAOA,MAAW,QAClB,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAE5B,OAAS,gCAAAC,MAAoC,gCAG7C,OAAOC,MAAa,qBA0Bb,IAAMC,EAAN,KAAqD,CAC1D,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAa,qBAAqB,CAChC,aAAAC,EACA,SAAAC,EACA,QAAAC,CACF,EAAyE,CACvE,IAAIC,E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AAQ,GACtE,OAAOD,EAAM,kBAAqB,QAEtC,CAKQ,gCACNA,EACwC,CACxC,OACE,OAAOA,GAAU,UACjBA,IAAU,MACV,iBAAkBA,GAClB,0BAA2BA,GAC3B,aAAcA,GACd,OAAOA,EAAM,cAAiB,UAC9B,OAAOA,EAAM,uBAA0B,UACvC,OAAOA,EAAM,UAAa,UAC1BA,EAAM,SAAS,OAAS,CAE5B,CACF,EAjIaX,EAANa,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,IAFjBjB",
|
|
6
|
+
"names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "HttpProxyDataSource", "config", "proxyAddress", "calldata", "chainId", "dto", "axios", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "Left", "Right", "value", "address", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import a from"axios";import{Left as n,Right as l}from"purify-ts";import{LEDGER_CLIENT_VERSION_HEADER as c}from"../../shared/constant/HttpHeaders";import p from"../../../package.json";import{HttpProxyDataSource as x}from"./HttpProxyDataSource";vi.mock("axios");describe("HttpProxyDataSource",()=>{let t;const s={proxyAddress:"0x72CBdEaAdddD14Ec95b92995933CeC69566650f0",calldata:"0x6a76120200000000000000000000000072cbdeaadddd14ec95b92995933cec69566650f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000440d582f13000000000000000000000000cfa7eae32032bf431aed95532142a9c2b35715d40000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041000000000000000000000000a0766b65a4f7b1da79a1af79ac695456efa2864400000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000",chainId:1},r={proxyAddress:"0xee6a57ec80ea46401049e92587e52f5ec1c24785",chainId:1},d={delegateAddresses:["0xd9db270c1b5e3bd161e8c8503c55ceabee709552"],signedDescriptor:"0x1234567890abcdef"},m={implementationAddress:"0x91ae842a5ffd8d12023116943e72a606179294f3"},i={implementationAddress:"0x91ae842a5ffd8d12023116943e72a606179294f3",proxyAddress:"0xee6a57ec80ea46401049e92587e52f5ec1c24785",standard:"proxy"};beforeEach(()=>{vi.clearAllMocks(),t=new x({metadataService:{url:"https://nft.api.live.ledger.com/v2"}})}),describe("getDelegateProxy",()=>{it("should call axios with the ledger client version header",async()=>{const e=`context-module/${p.version}`,o=vi.fn(()=>Promise.resolve({data:d}));vi.spyOn(a,"request").mockImplementation(o),await t.getProxyDelegateCall(s),expect(o).toHaveBeenCalledWith(expect.objectContaining({headers:{[c]:e}}))}),it("should return the delegate proxy response on success",async()=>{vi.spyOn(a,"request").mockResolvedValue({data:d});const e=await t.getProxyDelegateCall(s);expect(e).toEqual(l(d))}),it("should return an error when axios throws an error",async()=>{vi.spyOn(a,"request").mockRejectedValue(new Error("fail"));const e=await t.getProxyDelegateCall(s);expect(e).toEqual(n(new Error("[ContextModule] HttpProxyDataSource: Failed to fetch delegate proxy")))}),it("should return an error if response shape is invalid",async()=>{vi.spyOn(a,"request").mockResolvedValue({data:{foo:"bar"}});const e=await t.getProxyDelegateCall(s);expect(e).toEqual(n(new Error("[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy 0x72CBdEaAdddD14Ec95b92995933CeC69566650f0 on chain 1")))}),it("should use the provided chainId in the URL",async()=>{const e=vi.fn(()=>Promise.resolve({data:d}));vi.spyOn(a,"request").mockImplementation(e);const o={proxyAddress:"0x72CBdEaAdddD14Ec95b92995933CeC69566650f0",calldata:"0x6a76120200000000000000000000000072cbdeaadddd14ec95b92995933cec69566650f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000440d582f13000000000000000000000000cfa7eae32032bf431aed95532142a9c2b35715d40000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041000000000000000000000000a0766b65a4f7b1da79a1af79ac695456efa2864400000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000",chainId:137};await t.getProxyDelegateCall(o),expect(e).toHaveBeenCalledWith(expect.objectContaining({method:"POST",url:"https://nft.api.live.ledger.com/v2/ethereum/137/contract/proxy/delegate"}))}),it("should return an error if no dto is returned from the api",async()=>{vi.spyOn(a,"request").mockResolvedValue({data:void 0});const e=await t.getProxyDelegateCall(s);expect(e).toEqual(n(new Error("[ContextModule] HttpProxyDataSource: No data received for proxy 0x72CBdEaAdddD14Ec95b92995933CeC69566650f0 on chain 1")))})}),describe("getImplementAddress",()=>{it("should call axios with the ledger client version header",async()=>{const e=`context-module/${p.version}`,o=vi.fn(()=>Promise.resolve({data:i}));vi.spyOn(a,"request").mockImplementation(o),await t.getProxyImplementationAddress(r),expect(o).toHaveBeenCalledWith(expect.objectContaining({headers:{[c]:e}}))}),it("should make a GET request to the correct URL",async()=>{const e=vi.fn(()=>Promise.resolve({data:i}));vi.spyOn(a,"request").mockImplementation(e),await t.getProxyImplementationAddress(r),expect(e).toHaveBeenCalledWith(expect.objectContaining({method:"GET",url:"https://nft.api.live.ledger.com/v2/ethereum/1/contract/proxy/0xee6a57ec80ea46401049e92587e52f5ec1c24785"}))}),it("should use the provided chainId in the URL",async()=>{const e=vi.fn(()=>Promise.resolve({data:i}));vi.spyOn(a,"request").mockImplementation(e);const o={proxyAddress:"0xee6a57ec80ea46401049e92587e52f5ec1c24785",chainId:137};await t.getProxyImplementationAddress(o),expect(e).toHaveBeenCalledWith(expect.objectContaining({method:"GET",url:"https://nft.api.live.ledger.com/v2/ethereum/137/contract/proxy/0xee6a57ec80ea46401049e92587e52f5ec1c24785"}))}),it("should return the implementation address response on success",async()=>{vi.spyOn(a,"request").mockResolvedValue({data:i});const e=await t.getProxyImplementationAddress(r);expect(e).toEqual(l(m))}),it("should return an error when axios throws an error",async()=>{vi.spyOn(a,"request").mockRejectedValue(new Error("network error"));const e=await t.getProxyImplementationAddress(r);expect(e).toEqual(n(new Error("[ContextModule] HttpProxyDataSource: Failed to fetch implementation address")))}),it("should return an error if response shape is invalid",async()=>{vi.spyOn(a,"request").mockResolvedValue({data:{invalid:"data"}});const e=await t.getProxyImplementationAddress(r);expect(e).toEqual(n(new Error("[ContextModule] HttpProxyDataSource: Invalid proxy implementation address response format for proxy 0xee6a57ec80ea46401049e92587e52f5ec1c24785 on chain 1")))}),it("should return an error if no dto is returned from the api",async()=>{vi.spyOn(a,"request").mockResolvedValue({data:void 0});const e=await t.getProxyImplementationAddress(r);expect(e).toEqual(n(new Error("[ContextModule] HttpProxyDataSource: No data received for proxy 0xee6a57ec80ea46401049e92587e52f5ec1c24785 on chain 1")))})})});
|
|
2
|
+
//# sourceMappingURL=HttpProxyDataSource.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/transaction/data/HttpProxyDataSource.test.ts"],
|
|
4
|
+
"sourcesContent": ["import axios from \"axios\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { LEDGER_CLIENT_VERSION_HEADER } from \"@/shared/constant/HttpHeaders\";\nimport type { ProxyDelegateCall } from \"@/transaction/model/ProxyDelegateCall\";\nimport type { ProxyImplementationAddress } from \"@/transaction/model/ProxyImplementationAddress\";\nimport PACKAGE from \"@root/package.json\";\n\nimport type {\n GetProxyDelegateCallParam,\n GetProxyImplementationAddressParam,\n ProxyDataSource,\n} from \"./HttpProxyDataSource\";\nimport { HttpProxyDataSource } from \"./HttpProxyDataSource\";\nimport { type ProxyImplementationAddressDto } from \"./ProxyImplementationAddressDto\";\n\nvi.mock(\"axios\");\n\ndescribe(\"HttpProxyDataSource\", () => {\n let datasource: ProxyDataSource;\n const defaultParams: GetProxyDelegateCallParam = {\n proxyAddress: \"0x72CBdEaAdddD14Ec95b92995933CeC69566650f0\",\n calldata:\n \"0x6a76120200000000000000000000000072cbdeaadddd14ec95b92995933cec69566650f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000440d582f13000000000000000000000000cfa7eae32032bf431aed95532142a9c2b35715d40000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041000000000000000000000000a0766b65a4f7b1da79a1af79ac695456efa2864400000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000\",\n chainId: 1,\n };\n const defaultImplementAddressParams: GetProxyImplementationAddressParam = {\n proxyAddress: \"0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n chainId: 1,\n };\n const delegateProxyResponse: ProxyDelegateCall = {\n delegateAddresses: [\"0xd9db270c1b5e3bd161e8c8503c55ceabee709552\"],\n signedDescriptor: \"0x1234567890abcdef\",\n };\n const implementationAddressResponse: ProxyImplementationAddress = {\n implementationAddress: \"0x91ae842a5ffd8d12023116943e72a606179294f3\",\n };\n const implementationAddressDto: ProxyImplementationAddressDto = {\n implementationAddress: \"0x91ae842a5ffd8d12023116943e72a606179294f3\",\n proxyAddress: \"0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n standard: \"proxy\",\n };\n\n beforeEach(() => {\n vi.clearAllMocks();\n datasource = new HttpProxyDataSource({\n metadataService: {\n url: \"https://nft.api.live.ledger.com/v2\",\n },\n } as ContextModuleConfig);\n });\n\n describe(\"getDelegateProxy\", () => {\n it(\"should call axios with the ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: delegateProxyResponse }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: { [LEDGER_CLIENT_VERSION_HEADER]: version },\n }),\n );\n });\n\n it(\"should return the delegate proxy response on success\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: delegateProxyResponse,\n });\n\n // WHEN\n const result = await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(result).toEqual(Right(delegateProxyResponse));\n });\n\n it(\"should return an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"fail\"));\n\n // WHEN\n const result = await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: Failed to fetch delegate proxy\",\n ),\n ),\n );\n });\n\n it(\"should return an error if response shape is invalid\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: { foo: \"bar\" } });\n\n // WHEN\n const result = await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy 0x72CBdEaAdddD14Ec95b92995933CeC69566650f0 on chain 1\",\n ),\n ),\n );\n });\n\n it(\"should use the provided chainId in the URL\", async () => {\n // GIVEN\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: delegateProxyResponse }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n const paramsWithDifferentChainId: GetProxyDelegateCallParam = {\n proxyAddress: \"0x72CBdEaAdddD14Ec95b92995933CeC69566650f0\",\n calldata:\n \"0x6a76120200000000000000000000000072cbdeaadddd14ec95b92995933cec69566650f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000440d582f13000000000000000000000000cfa7eae32032bf431aed95532142a9c2b35715d40000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041000000000000000000000000a0766b65a4f7b1da79a1af79ac695456efa2864400000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000\",\n chainId: 137, // Polygon\n };\n\n // WHEN\n await datasource.getProxyDelegateCall(paramsWithDifferentChainId);\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n method: \"POST\",\n url: \"https://nft.api.live.ledger.com/v2/ethereum/137/contract/proxy/delegate\",\n }),\n );\n });\n\n it(\"should return an error if no dto is returned from the api\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: undefined,\n });\n\n // WHEN\n const result = await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: No data received for proxy 0x72CBdEaAdddD14Ec95b92995933CeC69566650f0 on chain 1\",\n ),\n ),\n );\n });\n });\n\n describe(\"getImplementAddress\", () => {\n it(\"should call axios with the ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: implementationAddressDto }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: { [LEDGER_CLIENT_VERSION_HEADER]: version },\n }),\n );\n });\n\n it(\"should make a GET request to the correct URL\", async () => {\n // GIVEN\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: implementationAddressDto }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n method: \"GET\",\n url: \"https://nft.api.live.ledger.com/v2/ethereum/1/contract/proxy/0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n }),\n );\n });\n\n it(\"should use the provided chainId in the URL\", async () => {\n // GIVEN\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: implementationAddressDto }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n const paramsWithDifferentChainId: GetProxyImplementationAddressParam = {\n proxyAddress: \"0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n chainId: 137, // Polygon\n };\n\n // WHEN\n await datasource.getProxyImplementationAddress(\n paramsWithDifferentChainId,\n );\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n method: \"GET\",\n url: \"https://nft.api.live.ledger.com/v2/ethereum/137/contract/proxy/0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n }),\n );\n });\n\n it(\"should return the implementation address response on success\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: implementationAddressDto,\n });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(result).toEqual(Right(implementationAddressResponse));\n });\n\n it(\"should return an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"network error\"));\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: Failed to fetch implementation address\",\n ),\n ),\n );\n });\n\n it(\"should return an error if response shape is invalid\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: { invalid: \"data\" },\n });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: Invalid proxy implementation address response format for proxy 0xee6a57ec80ea46401049e92587e52f5ec1c24785 on chain 1\",\n ),\n ),\n );\n });\n\n it(\"should return an error if no dto is returned from the api\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: undefined,\n });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: No data received for proxy 0xee6a57ec80ea46401049e92587e52f5ec1c24785 on chain 1\",\n ),\n ),\n );\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAOA,MAAW,QAClB,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAG5B,OAAS,gCAAAC,MAAoC,gCAG7C,OAAOC,MAAa,qBAOpB,OAAS,uBAAAC,MAA2B,wBAGpC,GAAG,KAAK,OAAO,EAEf,SAAS,sBAAuB,IAAM,CACpC,IAAIC,EACJ,MAAMC,EAA2C,CAC/C,aAAc,6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CAE1E,GAAG,MAAMD,EAAO,SAAS,EAAE,kBAAkB,CAC3C,KAAM,MACR,CAAC,EAGD,MAAMc,EAAS,MAAMR,EAAW,8BAC9BE,CACF,EAGA,OAAOM,CAAM,EAAE,QACbb,EACE,IAAI,MACF,uHACF,CACF,CACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["axios", "Left", "Right", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "HttpProxyDataSource", "datasource", "defaultParams", "defaultImplementAddressParams", "delegateProxyResponse", "implementationAddressResponse", "implementationAddressDto", "version", "requestSpy", "result", "paramsWithDifferentChainId"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=ProxyDelegateCallDto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=ProxyImplementationAddressDto.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ContainerModule as r}from"inversify";import{HttpTransactionDataSource as n}from"../../transaction/data/HttpTransactionDataSource";import{transactionTypes as t}from"../../transaction/di/transactionTypes";import{TransactionContextLoader as
|
|
1
|
+
import{ContainerModule as r}from"inversify";import{HttpProxyDataSource as a}from"../../transaction/data/HttpProxyDataSource";import{HttpTransactionDataSource as n}from"../../transaction/data/HttpTransactionDataSource";import{transactionTypes as t}from"../../transaction/di/transactionTypes";import{TransactionContextLoader as e}from"../../transaction/domain/TransactionContextLoader";const u=()=>new r(({bind:o})=>{o(t.TransactionDataSource).to(n),o(t.TransactionContextLoader).to(e),o(t.ProxyDataSource).to(a)});export{u as transactionModuleFactory};
|
|
2
2
|
//# sourceMappingURL=transactionModuleFactory.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/transaction/di/transactionModuleFactory.ts"],
|
|
4
|
-
"sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpTransactionDataSource } from \"@/transaction/data/HttpTransactionDataSource\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\nimport { TransactionContextLoader } from \"@/transaction/domain/TransactionContextLoader\";\n\nexport const transactionModuleFactory = () =>\n new ContainerModule((bind
|
|
5
|
-
"mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,6BAAAC,MAAiC,+CAC1C,OAAS,oBAAAC,MAAwB,oCACjC,OAAS,4BAAAC,MAAgC,gDAElC,MAAMC,EAA2B,IACtC,
|
|
6
|
-
"names": ["ContainerModule", "HttpTransactionDataSource", "transactionTypes", "TransactionContextLoader", "transactionModuleFactory", "bind"
|
|
4
|
+
"sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpProxyDataSource } from \"@/transaction/data/HttpProxyDataSource\";\nimport { HttpTransactionDataSource } from \"@/transaction/data/HttpTransactionDataSource\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\nimport { TransactionContextLoader } from \"@/transaction/domain/TransactionContextLoader\";\n\nexport const transactionModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(transactionTypes.TransactionDataSource).to(HttpTransactionDataSource);\n bind(transactionTypes.TransactionContextLoader).to(\n TransactionContextLoader,\n );\n bind(transactionTypes.ProxyDataSource).to(HttpProxyDataSource);\n });\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,uBAAAC,MAA2B,yCACpC,OAAS,6BAAAC,MAAiC,+CAC1C,OAAS,oBAAAC,MAAwB,oCACjC,OAAS,4BAAAC,MAAgC,gDAElC,MAAMC,EAA2B,IACtC,IAAIL,EAAgB,CAAC,CAAE,KAAAM,CAAK,IAAM,CAChCA,EAAKH,EAAiB,qBAAqB,EAAE,GAAGD,CAAyB,EACzEI,EAAKH,EAAiB,wBAAwB,EAAE,GAC9CC,CACF,EACAE,EAAKH,EAAiB,eAAe,EAAE,GAAGF,CAAmB,CAC/D,CAAC",
|
|
6
|
+
"names": ["ContainerModule", "HttpProxyDataSource", "HttpTransactionDataSource", "transactionTypes", "TransactionContextLoader", "transactionModuleFactory", "bind"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const o={TransactionDataSource:Symbol.for("TransactionDataSource"),TransactionContextLoader:Symbol.for("TransactionContextLoader")};export{o as transactionTypes};
|
|
1
|
+
const o={TransactionDataSource:Symbol.for("TransactionDataSource"),TransactionContextLoader:Symbol.for("TransactionContextLoader"),ProxyDataSource:Symbol.for("ProxyDataSource")};export{o as transactionTypes};
|
|
2
2
|
//# sourceMappingURL=transactionTypes.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/transaction/di/transactionTypes.ts"],
|
|
4
|
-
"sourcesContent": ["export const transactionTypes = {\n TransactionDataSource: Symbol.for(\"TransactionDataSource\"),\n TransactionContextLoader: Symbol.for(\"TransactionContextLoader\"),\n};\n"],
|
|
5
|
-
"mappings": "AAAO,MAAMA,EAAmB,CAC9B,sBAAuB,OAAO,IAAI,uBAAuB,EACzD,yBAA0B,OAAO,IAAI,0BAA0B,
|
|
4
|
+
"sourcesContent": ["export const transactionTypes = {\n TransactionDataSource: Symbol.for(\"TransactionDataSource\"),\n TransactionContextLoader: Symbol.for(\"TransactionContextLoader\"),\n ProxyDataSource: Symbol.for(\"ProxyDataSource\"),\n};\n"],
|
|
5
|
+
"mappings": "AAAO,MAAMA,EAAmB,CAC9B,sBAAuB,OAAO,IAAI,uBAAuB,EACzD,yBAA0B,OAAO,IAAI,0BAA0B,EAC/D,gBAAiB,OAAO,IAAI,iBAAiB,CAC/C",
|
|
6
6
|
"names": ["transactionTypes"]
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=ProxyDelegateCall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=ProxyImplementationAddress.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var E=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var f=(n,r,e,o)=>{for(var t=o>1?void 0:o?y(r,e):r,s=n.length-1,a;s>=0;s--)(a=n[s])&&(t=(o?a(r,e,t):a(t))||t);return o&&t&&E(r,e,t),t},l=(n,r)=>(e,o)=>r(e,o,n);import p from"axios";import{inject as N,injectable as T}from"inversify";import{Left as m,Right as c}from"purify-ts";import{configTypes as C}from"../../config/di/configTypes";import{LEDGER_CLIENT_VERSION_HEADER as h}from"../../shared/constant/HttpHeaders";import $ from"../../../package.json";let d=class{constructor(r){this.config=r}async getDomainNamePayload({chainId:r,domain:e,challenge:o}){try{const a=await p.request({method:"GET",url:`${this.config.metadataService.url}/names/ethereum/${r}/forward/${e}?types=eoa&sources=ens&challenge=${o}`,headers:{[h]:`context-module/${$.version}`}});return a.data.signedDescriptor?.data?c(a.data.signedDescriptor.data):m(new Error("[ContextModule] HttpTrustedNameDataSource: error getting domain payload"))}catch{return m(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name"))}}async getTrustedNamePayload({chainId:r,address:e,challenge:o,sources:t,types:s}){try{t=t.filter(g=>g==="ens"||g==="crypto_asset_list");const i=(await p.request({method:"GET",url:`${this.config.metadataService.url}/names/ethereum/${r}/reverse/${e}?types=${s.join(",")}&sources=${t.join(",")}&challenge=${o}`,headers:{[h]:`context-module/${$.version}`}})).data;if(!i?.signedDescriptor?.data)return m(new Error(`[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address ${e}`));const u=i.signedDescriptor.data;if(!i.signedDescriptor.signatures||typeof i.signedDescriptor.signatures[this.config.cal.mode]!="string")return c(u);const D=i.signedDescriptor.signatures[this.config.cal.mode];return c(this.formatTrustedName(u,D))}catch{return m(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name"))}}formatTrustedName(r,e){e.length%2!==0&&(e="0"+e);const o="15",t=(e.length/2).toString(16);return`${r}${o}${t}${e}`}};d=f([T(),l(0,N(C.Config))],d);export{d as HttpTrustedNameDataSource};
|
|
2
2
|
//# sourceMappingURL=HttpTrustedNameDataSource.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/trusted-name/data/HttpTrustedNameDataSource.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 { LEDGER_CLIENT_VERSION_HEADER } from \"@/shared/constant/HttpHeaders\";\nimport {\n GetDomainNameInfosParams,\n GetTrustedNameInfosParams,\n TrustedNameDataSource,\n} from \"@/trusted-name/data/TrustedNameDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { TrustedNameDto } from \"./TrustedNameDto\";\n\n@injectable()\nexport class HttpTrustedNameDataSource implements TrustedNameDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n public async getDomainNamePayload({\n chainId,\n domain,\n challenge,\n }: GetDomainNameInfosParams): Promise<Either<Error, string>> {\n try {\n const type = \"eoa\"; // Externally owned account\n const source = \"ens\"; // Ethereum name service\n const response = await axios.request<TrustedNameDto>({\n method: \"GET\",\n url:
|
|
5
|
-
"mappings": "iOAAA,OAAOA,MAAW,QAClB,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAE5B,OAAS,gCAAAC,MAAoC,gCAM7C,OAAOC,MAAa,qBAKb,IAAMC,EAAN,KAAiE,CACtE,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAa,qBAAqB,CAChC,QAAAC,EACA,OAAAC,EACA,UAAAC,CACF,EAA6D,CAC3D,GAAI,CAGF,MAAMC,EAAW,MAAMC,EAAM,QAAwB,CACnD,OAAQ,MACR,IAAK,
|
|
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 { LEDGER_CLIENT_VERSION_HEADER } from \"@/shared/constant/HttpHeaders\";\nimport {\n GetDomainNameInfosParams,\n GetTrustedNameInfosParams,\n TrustedNameDataSource,\n} from \"@/trusted-name/data/TrustedNameDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { TrustedNameDto } from \"./TrustedNameDto\";\n\n@injectable()\nexport class HttpTrustedNameDataSource implements TrustedNameDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n public async getDomainNamePayload({\n chainId,\n domain,\n challenge,\n }: GetDomainNameInfosParams): Promise<Either<Error, string>> {\n try {\n const type = \"eoa\"; // Externally owned account\n const source = \"ens\"; // Ethereum name service\n const response = await axios.request<TrustedNameDto>({\n method: \"GET\",\n url: `${this.config.metadataService.url}/names/ethereum/${chainId}/forward/${domain}?types=${type}&sources=${source}&challenge=${challenge}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n },\n });\n\n return response.data.signedDescriptor?.data\n ? Right(response.data.signedDescriptor.data)\n : Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: error getting domain payload\",\n ),\n );\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name\",\n ),\n );\n }\n }\n\n public async getTrustedNamePayload({\n chainId,\n address,\n challenge,\n sources,\n types,\n }: GetTrustedNameInfosParams): Promise<Either<Error, string>> {\n try {\n // TODO remove that filtering once https://ledgerhq.atlassian.net/browse/BACK-8075 is done\n // For now we have to filter or trusted names won't work with the generic parser, because transaction\n // fields descriptors can contain unsupported sources.\n sources = sources.filter(\n (source) => source === \"ens\" || source === \"crypto_asset_list\",\n );\n const response = await axios.request<TrustedNameDto>({\n method: \"GET\",\n url: `${this.config.metadataService.url}/names/ethereum/${chainId}/reverse/${address}?types=${types.join(\",\")}&sources=${sources.join(\",\")}&challenge=${challenge}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n },\n });\n const trustedName = response.data;\n if (!trustedName?.signedDescriptor?.data) {\n return Left(\n new Error(\n `[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address ${address}`,\n ),\n );\n }\n const payload = trustedName.signedDescriptor.data;\n\n if (\n !trustedName.signedDescriptor.signatures ||\n typeof trustedName.signedDescriptor.signatures[this.config.cal.mode] !==\n \"string\"\n ) {\n // If we have no separated signature but a valid descriptor, it may mean the descriptor was\n // signed on-the-fly for dynamic sources such as ens\n return Right(payload);\n }\n\n const signature =\n trustedName.signedDescriptor.signatures[this.config.cal.mode]!;\n return Right(this.formatTrustedName(payload, signature));\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name\",\n ),\n );\n }\n }\n\n private formatTrustedName(payload: string, signature: string): string {\n // Ensure correct padding\n if (signature.length % 2 !== 0) {\n signature = \"0\" + signature;\n }\n // TLV encoding as according to trusted name documentation\n const signatureTag = \"15\";\n const signatureLength = (signature.length / 2).toString(16);\n return `${payload}${signatureTag}${signatureLength}${signature}`;\n }\n}\n"],
|
|
5
|
+
"mappings": "iOAAA,OAAOA,MAAW,QAClB,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAE5B,OAAS,gCAAAC,MAAoC,gCAM7C,OAAOC,MAAa,qBAKb,IAAMC,EAAN,KAAiE,CACtE,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAa,qBAAqB,CAChC,QAAAC,E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AAkBO,EAASC,CAAS,CAAC,CACzD,MAAiB,CACf,OAAOP,EACL,IAAI,MACF,yEACF,CACF,CACF,CACF,CAEQ,kBAAkBM,EAAiBC,EAA2B,CAEhEA,EAAU,OAAS,IAAM,IAC3BA,EAAY,IAAMA,GAGpB,MAAMC,EAAe,KACfC,GAAmBF,EAAU,OAAS,GAAG,SAAS,EAAE,EAC1D,MAAO,GAAGD,CAAO,GAAGE,CAAY,GAAGC,CAAe,GAAGF,CAAS,EAChE,CACF,EApGajB,EAANoB,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,IAFjBxB",
|
|
6
6
|
"names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "HttpTrustedNameDataSource", "config", "chainId", "domain", "challenge", "response", "axios", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "Right", "Left", "address", "sources", "types", "source", "trustedName", "payload", "signature", "signatureTag", "signatureLength", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes"]
|
|
7
7
|
}
|