@ledgerhq/context-module 0.0.0-multisig-20250910160951 → 0.0.0-multisig-20250918154034
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 +1 -1
- package/lib/cjs/src/ContextModule.js +1 -1
- package/lib/cjs/src/ContextModule.js.map +1 -1
- package/lib/cjs/src/ContextModuleBuilder.js +1 -1
- package/lib/cjs/src/ContextModuleBuilder.js.map +3 -3
- package/lib/cjs/src/ContextModuleBuilder.test.js +1 -1
- package/lib/cjs/src/ContextModuleBuilder.test.js.map +3 -3
- package/lib/cjs/src/DefaultContextModule.js +1 -1
- package/lib/cjs/src/DefaultContextModule.js.map +3 -3
- package/lib/cjs/src/DefaultContextModule.test.js +1 -1
- package/lib/cjs/src/DefaultContextModule.test.js.map +3 -3
- package/lib/cjs/src/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 +2 -2
- package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +1 -1
- package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +2 -2
- package/lib/cjs/src/index.js +1 -1
- package/lib/cjs/src/index.js.map +2 -2
- package/lib/cjs/src/nft/domain/NftContextFieldLoader.js +1 -1
- package/lib/cjs/src/nft/domain/NftContextFieldLoader.js.map +2 -2
- package/lib/cjs/src/nft/domain/NftContextFieldLoader.test.js +1 -1
- package/lib/cjs/src/nft/domain/NftContextFieldLoader.test.js.map +3 -3
- package/lib/cjs/src/proxy/data/HttpProxyDataSource.js +1 -1
- package/lib/cjs/src/proxy/data/HttpProxyDataSource.js.map +3 -3
- package/lib/cjs/src/proxy/data/HttpProxyDataSource.test.js +1 -1
- package/lib/cjs/src/proxy/data/HttpProxyDataSource.test.js.map +3 -3
- package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.js +2 -0
- package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.js.map +7 -0
- package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.test.js +2 -0
- package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.test.js.map +7 -0
- package/lib/cjs/src/proxy/data/ProxyDataSource.js +2 -0
- package/lib/cjs/src/proxy/data/ProxyDataSource.js.map +7 -0
- package/lib/cjs/src/proxy/data/dto/SafeProxyImplementationAddressDto.js +2 -0
- package/lib/cjs/src/proxy/data/dto/SafeProxyImplementationAddressDto.js.map +7 -0
- package/lib/cjs/src/proxy/di/proxyModuleFactory.js +1 -1
- package/lib/cjs/src/proxy/di/proxyModuleFactory.js.map +3 -3
- package/lib/cjs/src/proxy/di/proxyModuleFactory.test.js +2 -0
- package/lib/cjs/src/proxy/di/proxyModuleFactory.test.js.map +7 -0
- package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.js +1 -1
- package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.js.map +2 -2
- package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.test.js +1 -1
- package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.test.js.map +3 -3
- package/lib/cjs/src/proxy/model/ProxyDelegateCall.js +1 -1
- package/lib/cjs/src/proxy/model/ProxyDelegateCall.js.map +1 -1
- package/lib/cjs/src/shared/domain/ContextFieldLoader.js +1 -1
- package/lib/cjs/src/shared/domain/ContextFieldLoader.js.map +2 -2
- package/lib/cjs/src/shared/domain/ContextLoader.js +1 -1
- package/lib/cjs/src/shared/domain/ContextLoader.js.map +1 -1
- package/lib/cjs/src/shared/model/TypedDataClearSignContext.js.map +1 -1
- package/lib/cjs/src/shared/model/TypedDataContext.js.map +1 -1
- package/lib/cjs/src/token/domain/TokenContextFieldLoader.js +1 -1
- package/lib/cjs/src/token/domain/TokenContextFieldLoader.js.map +3 -3
- package/lib/cjs/src/token/domain/TokenContextFieldLoader.test.js +1 -1
- package/lib/cjs/src/token/domain/TokenContextFieldLoader.test.js.map +3 -3
- package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js +1 -1
- package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js.map +2 -2
- package/lib/cjs/src/transaction/domain/TransactionContextLoader.js +1 -1
- package/lib/cjs/src/transaction/domain/TransactionContextLoader.js.map +3 -3
- package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js +1 -1
- package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js.map +3 -3
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.js +1 -1
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.js.map +2 -2
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js +1 -1
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js.map +3 -3
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js.map +1 -1
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js +1 -1
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +3 -3
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +3 -3
- package/lib/esm/package.json +1 -1
- package/lib/esm/src/ContextModuleBuilder.js +1 -1
- package/lib/esm/src/ContextModuleBuilder.js.map +3 -3
- package/lib/esm/src/ContextModuleBuilder.test.js +1 -1
- package/lib/esm/src/ContextModuleBuilder.test.js.map +3 -3
- package/lib/esm/src/DefaultContextModule.js +1 -1
- package/lib/esm/src/DefaultContextModule.js.map +3 -3
- package/lib/esm/src/DefaultContextModule.test.js +1 -1
- package/lib/esm/src/DefaultContextModule.test.js.map +3 -3
- package/lib/esm/src/di.js +1 -1
- package/lib/esm/src/di.js.map +2 -2
- package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +1 -1
- package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +2 -2
- package/lib/esm/src/index.js +1 -1
- package/lib/esm/src/index.js.map +2 -2
- package/lib/esm/src/nft/domain/NftContextFieldLoader.js +1 -1
- package/lib/esm/src/nft/domain/NftContextFieldLoader.js.map +3 -3
- package/lib/esm/src/nft/domain/NftContextFieldLoader.test.js +1 -1
- package/lib/esm/src/nft/domain/NftContextFieldLoader.test.js.map +3 -3
- package/lib/esm/src/proxy/data/HttpProxyDataSource.js +1 -1
- package/lib/esm/src/proxy/data/HttpProxyDataSource.js.map +3 -3
- package/lib/esm/src/proxy/data/HttpProxyDataSource.test.js +1 -1
- package/lib/esm/src/proxy/data/HttpProxyDataSource.test.js.map +3 -3
- package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.js +2 -0
- package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.js.map +7 -0
- package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.test.js +2 -0
- package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.test.js.map +7 -0
- package/lib/esm/src/proxy/data/ProxyDataSource.js +1 -0
- package/lib/esm/src/proxy/data/dto/SafeProxyImplementationAddressDto.js +1 -0
- package/lib/esm/src/proxy/data/dto/SafeProxyImplementationAddressDto.js.map +7 -0
- package/lib/esm/src/proxy/di/proxyModuleFactory.js +1 -1
- package/lib/esm/src/proxy/di/proxyModuleFactory.js.map +3 -3
- package/lib/esm/src/proxy/di/proxyModuleFactory.test.js +2 -0
- package/lib/esm/src/proxy/di/proxyModuleFactory.test.js.map +7 -0
- package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.js +1 -1
- package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.js.map +3 -3
- package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.test.js +1 -1
- package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.test.js.map +3 -3
- package/lib/esm/src/shared/domain/ContextFieldLoader.js +1 -1
- package/lib/esm/src/shared/domain/ContextFieldLoader.js.map +2 -2
- package/lib/esm/src/shared/model/TypedDataClearSignContext.js.map +1 -1
- package/lib/esm/src/token/domain/TokenContextFieldLoader.js +1 -1
- package/lib/esm/src/token/domain/TokenContextFieldLoader.js.map +3 -3
- package/lib/esm/src/token/domain/TokenContextFieldLoader.test.js +1 -1
- package/lib/esm/src/token/domain/TokenContextFieldLoader.test.js.map +3 -3
- package/lib/esm/src/transaction/data/HttpTransactionDataSource.js +1 -1
- package/lib/esm/src/transaction/data/HttpTransactionDataSource.js.map +2 -2
- package/lib/esm/src/transaction/domain/TransactionContextLoader.js +1 -1
- package/lib/esm/src/transaction/domain/TransactionContextLoader.js.map +3 -3
- package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js +1 -1
- package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js.map +3 -3
- package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.js +1 -1
- package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.js.map +3 -3
- package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js +1 -1
- package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js.map +3 -3
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js.map +1 -1
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js +1 -1
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +3 -3
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +3 -3
- package/lib/types/src/ContextModule.d.ts +1 -3
- package/lib/types/src/ContextModule.d.ts.map +1 -1
- package/lib/types/src/ContextModuleBuilder.d.ts +8 -1
- package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -1
- package/lib/types/src/DefaultContextModule.d.ts +2 -3
- package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
- package/lib/types/src/config/model/ContextModuleConfig.d.ts +7 -0
- package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -1
- package/lib/types/src/index.d.ts +38 -0
- package/lib/types/src/index.d.ts.map +1 -1
- package/lib/types/src/nft/domain/NftContextFieldLoader.d.ts +9 -4
- package/lib/types/src/nft/domain/NftContextFieldLoader.d.ts.map +1 -1
- package/lib/types/src/proxy/data/HttpProxyDataSource.d.ts +2 -22
- package/lib/types/src/proxy/data/HttpProxyDataSource.d.ts.map +1 -1
- package/lib/types/src/proxy/data/HttpSafeProxyDataSource.d.ts +13 -0
- package/lib/types/src/proxy/data/HttpSafeProxyDataSource.d.ts.map +1 -0
- package/lib/types/src/proxy/data/HttpSafeProxyDataSource.test.d.ts +2 -0
- package/lib/types/src/proxy/data/HttpSafeProxyDataSource.test.d.ts.map +1 -0
- package/lib/types/src/proxy/data/ProxyDataSource.d.ts +15 -0
- package/lib/types/src/proxy/data/ProxyDataSource.d.ts.map +1 -0
- package/lib/types/src/proxy/data/dto/SafeProxyImplementationAddressDto.d.ts +8 -0
- package/lib/types/src/proxy/data/dto/SafeProxyImplementationAddressDto.d.ts.map +1 -0
- package/lib/types/src/proxy/di/proxyModuleFactory.d.ts +2 -1
- package/lib/types/src/proxy/di/proxyModuleFactory.d.ts.map +1 -1
- package/lib/types/src/proxy/di/proxyModuleFactory.test.d.ts +2 -0
- package/lib/types/src/proxy/di/proxyModuleFactory.test.d.ts.map +1 -0
- package/lib/types/src/proxy/domain/ProxyContextFieldLoader.d.ts +14 -5
- package/lib/types/src/proxy/domain/ProxyContextFieldLoader.d.ts.map +1 -1
- package/lib/types/src/proxy/model/ProxyDelegateCall.d.ts +1 -1
- package/lib/types/src/proxy/model/ProxyDelegateCall.d.ts.map +1 -1
- package/lib/types/src/shared/domain/ContextFieldLoader.d.ts +3 -4
- package/lib/types/src/shared/domain/ContextFieldLoader.d.ts.map +1 -1
- package/lib/types/src/shared/domain/ContextLoader.d.ts +0 -2
- package/lib/types/src/shared/domain/ContextLoader.d.ts.map +1 -1
- package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts +1 -1
- package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts.map +1 -1
- package/lib/types/src/shared/model/TypedDataContext.d.ts +1 -1
- package/lib/types/src/shared/model/TypedDataContext.d.ts.map +1 -1
- package/lib/types/src/token/domain/TokenContextFieldLoader.d.ts +8 -4
- package/lib/types/src/token/domain/TokenContextFieldLoader.d.ts.map +1 -1
- package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts.map +1 -1
- package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts +1 -1
- package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts.map +1 -1
- package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.d.ts +12 -4
- package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.d.ts.map +1 -1
- package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts +1 -1
- package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/lib/cjs/src/proxy/model/ProxyImplementationAddress.js +0 -2
- package/lib/cjs/src/proxy/model/ProxyImplementationAddress.js.map +0 -7
- package/lib/esm/src/proxy/model/ProxyImplementationAddress.js +0 -1
- package/lib/types/src/proxy/model/ProxyImplementationAddress.d.ts +0 -4
- package/lib/types/src/proxy/model/ProxyImplementationAddress.d.ts.map +0 -1
- /package/lib/esm/src/proxy/{model/ProxyImplementationAddress.js.map → data/ProxyDataSource.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var U=Object.create;var c=Object.defineProperty;var
|
|
1
|
+
"use strict";var U=Object.create;var c=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var $=(o,e)=>{for(var t in e)c(o,t,{get:e[t],enumerable:!0})},V=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of j(e))!K.call(o,i)&&i!==t&&c(o,i,{get:()=>e[i],enumerable:!(r=E(e,i))||r.enumerable});return o};var g=(o,e,t)=>(t=o!=null?U(w(o)):{},V(e||!o||!o.__esModule?c(t,"default",{value:o,enumerable:!0}):t,o)),B=o=>V(c({},"__esModule",{value:!0}),o),A=(o,e,t,r)=>{for(var i=r>1?void 0:r?E(e,t):e,s=o.length-1,n;s>=0;s--)(n=o[s])&&(i=(r?n(e,t,i):n(i))||i);return r&&i&&c(e,t,i),i},d=(o,e)=>(t,r)=>e(t,r,o);var Y={};$(Y,{HttpTransactionDataSource:()=>u});module.exports=B(Y);var _=g(require("axios")),y=require("inversify"),l=require("purify-ts"),b=require("../../config/di/configTypes"),P=require("../../pki/di/pkiTypes"),v=require("../../pki/model/KeyId"),N=require("../../pki/model/KeyUsage"),C=require("../../shared/constant/HttpHeaders"),a=require("../../shared/model/ClearSignContext"),h=require("../../shared/model/SignatureTags"),m=require("../../shared/utils/HexStringUtils"),I=g(require("../../../package.json"));let u=class{constructor(e,t){this.config=e;this._certificateLoader=t}async getTransactionDescriptors({chainId:e,address:t,selector:r,deviceModelId:i}){let s;try{s=(await _.default.request({method:"GET",url:`${this.config.cal.url}/dapps`,params:{output:"descriptors_calldata",chain_id:e,contracts:t,ref:"commit:cdd7d0f9cec33eb969a12641810cc7b06efeec1c"},headers:{[C.LEDGER_CLIENT_VERSION_HEADER]:`context-module/${I.default.version}`,[C.LEDGER_ORIGIN_TOKEN_HEADER]:this.config.originToken}})).data}catch(n){return(0,l.Left)(new Error(`[ContextModule] HttpTransactionDataSource: Failed to fetch transaction informations: ${n}`))}if(!Array.isArray(s))return(0,l.Left)(new Error("[ContextModule] HttpTransactionDataSource: Response is not an array"));if(s.length===0)return(0,l.Left)(new Error(`[ContextModule] HttpTransactionDataSource: No data for contract ${t} and selector ${r}`));for(const n of s){t=t.toLowerCase(),r=`0x${r.slice(2).toLowerCase()}`;const p=n.descriptors_calldata?.[t]?.[r];if(!p||!this.isCalldataDescriptorV1(p,this.config.cal.mode))continue;const S=p.transaction_info.descriptor.data,M=p.transaction_info.descriptor.signatures[this.config.cal.mode],R={targetDevice:i,keyUsage:N.KeyUsage.Calldata,keyId:v.KeyId.CalCalldataKey},T=await this._certificateLoader.loadCertificate(R),L={type:a.ClearSignContextType.TRANSACTION_INFO,payload:m.HexStringUtils.appendSignatureToPayload(S,M,h.INFO_SIGNATURE_TAG),certificate:T},D=[];for(const[f,O]of Object.entries(p.enums))for(const[F,{data:G,signatures:k}]of Object.entries(O))D.push({type:a.ClearSignContextType.ENUM,id:Number(f),value:Number(F),payload:m.HexStringUtils.appendSignatureToPayload(G,k[this.config.cal.mode],h.INFO_SIGNATURE_TAG),certificate:T});const x=p.fields.map(f=>({type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:f.descriptor,reference:this.getReference(f.param)}));return(0,l.Right)([L,...D,...x])}return(0,l.Left)(new Error(`[ContextModule] HttpTransactionDataSource: Invalid response for contract ${t} and selector ${r}`))}getReference(e){if(e.type==="TOKEN_AMOUNT"&&e.token!==void 0&&e.token.type==="path")return{type:a.ClearSignContextReferenceType.TOKEN,valuePath:this.toGenericPath(e.token.binary_path)};if(e.type==="TOKEN_AMOUNT"&&e.token!==void 0&&e.token.type==="constant")return{type:a.ClearSignContextReferenceType.TOKEN,value:e.token.value};if(e.type==="NFT"&&e.collection.type==="path")return{type:a.ClearSignContextReferenceType.NFT,valuePath:this.toGenericPath(e.collection.binary_path)};if(e.type==="NFT"&&e.collection.type==="constant")return{type:a.ClearSignContextReferenceType.NFT,value:e.collection.value};if(e.type==="TRUSTED_NAME"&&e.value.type==="path")return{type:a.ClearSignContextReferenceType.TRUSTED_NAME,valuePath:this.toGenericPath(e.value.binary_path),types:e.types,sources:e.sources};if(e.type==="ENUM"&&e.value.type==="path")return{type:a.ClearSignContextReferenceType.ENUM,valuePath:this.toGenericPath(e.value.binary_path),id:e.id};if(e.type==="CALLDATA"&&e.value.type==="path"&&e.callee.type==="path")return{type:a.ClearSignContextReferenceType.CALLDATA,valuePath:this.toGenericPath(e.value.binary_path),callee:this.toGenericPath(e.callee.binary_path),selector:e.selector?.type==="path"?this.toGenericPath(e.selector.binary_path):void 0,amount:e.amount?.type==="path"?this.toGenericPath(e.amount.binary_path):void 0,spender:e.spender?.type==="path"?this.toGenericPath(e.spender.binary_path):void 0,chainId:e.chainId?.type==="path"?this.toGenericPath(e.chainId.binary_path):void 0}}toGenericPath(e){return e.type==="CONTAINER"?e.value:e.elements.map(t=>{if(t.type==="ARRAY"){const{weight:r,...i}=t;return{itemSize:r,...i}}else if(t.type==="LEAF"){const{leaf_type:r,...i}=t;return{leafType:r,...i}}return t})}isCalldataDescriptorV1(e,t){return typeof e=="object"&&e.type==="calldata"&&e.version==="v1"&&this.isTransactionInfoV1(e.transaction_info,t)&&this.isEnumV1(e.enums,t)&&Array.isArray(e.fields)&&e.fields.every(r=>this.isFieldV1(r))}isTransactionInfoV1(e,t){return typeof e=="object"&&typeof e.descriptor=="object"&&typeof e.descriptor.data=="string"&&typeof e.descriptor.signatures=="object"&&typeof e.descriptor.signatures[t]=="string"}isEnumV1(e,t){return typeof e=="object"&&Object.entries(e).every(([r,i])=>typeof r=="string"&&typeof i=="object"&&Object.entries(i).every(([s,n])=>typeof s=="string"&&typeof n=="object"&&typeof n.data=="string"&&n.signatures!==void 0&&this.isCalldataSignatures(n.signatures,t)))}isCalldataSignatures(e,t){return typeof e=="object"&&typeof e[t]=="string"}isFieldV1(e){return typeof e=="object"&&typeof e.descriptor=="string"&&typeof e.param=="object"&&typeof e.param.value=="object"&&this.isDescriptorValueV1(e.param.value)&&(e.param.type==="RAW"||e.param.type==="AMOUNT"||e.param.type==="DATETIME"||e.param.type==="DURATION"||e.param.type==="UNIT"||e.param.type==="ENUM"||e.param.type==="NFT"&&this.isDescriptorValueV1(e.param.collection)||e.param.type==="TOKEN_AMOUNT"&&(e.param.token===void 0||this.isDescriptorValueV1(e.param.token))||e.param.type==="TRUSTED_NAME"&&Array.isArray(e.param.types)&&Array.isArray(e.param.sources)&&e.param.types.every(t=>typeof t=="string")&&e.param.sources.every(t=>typeof t=="string")||e.param.type==="CALLDATA"&&this.isDescriptorValueV1(e.param.value)&&this.isDescriptorValueV1(e.param.callee)&&(e.param.selector===void 0||this.isDescriptorValueV1(e.param.selector))&&(e.param.amount===void 0||this.isDescriptorValueV1(e.param.amount))&&(e.param.spender===void 0||this.isDescriptorValueV1(e.param.spender))&&(e.param.chainId===void 0||this.isDescriptorValueV1(e.param.chainId)))}isDescriptorValueV1(e){return typeof e=="object"&&typeof e.type_family=="string"&&["UINT","INT","UFIXED","FIXED","ADDRESS","BOOL","BYTES","STRING"].includes(e.type_family)&&(typeof e.type_size>"u"||typeof e.type_size=="number")&&(e.type==="path"&&this.isCalldataDescriptorValueBinaryPathV1(e)||e.type==="constant"&&this.isCalldataDescriptorValueConstantV1(e))}isCalldataDescriptorValueConstantV1(e){return typeof e=="object"&&e.type==="constant"&&typeof e.value=="string"}isCalldataDescriptorValueBinaryPathV1(e){return typeof e=="object"&&(e.type==="path"&&e.binary_path.type==="CONTAINER"&&["FROM","TO","VALUE"].includes(e.binary_path.value)||e.binary_path.type==="DATA"&&Array.isArray(e.binary_path.elements)&&e.binary_path.elements.every(t=>this.isPathElementV1(t)))}isPathElementV1(e){return typeof e=="object"&&(e.type==="REF"||e.type==="TUPLE"&&typeof e.offset=="number"||e.type==="ARRAY"&&typeof e.weight=="number"&&(typeof e.start>"u"||typeof e.start=="number")&&(typeof e.end>"u"||typeof e.end=="number")||e.type==="LEAF"&&typeof e.leaf_type=="string"&&["ARRAY_LEAF","TUPLE_LEAF","STATIC_LEAF","DYNAMIC_LEAF"].includes(e.leaf_type)||e.type==="SLICE"&&(typeof e.start>"u"||typeof e.start=="number")&&(typeof e.end>"u"||typeof e.end=="number"))}};u=A([(0,y.injectable)(),d(0,(0,y.inject)(b.configTypes.Config)),d(1,(0,y.inject)(P.pkiTypes.PkiCertificateLoader))],u);0&&(module.exports={HttpTransactionDataSource});
|
|
2
2
|
//# sourceMappingURL=HttpTransactionDataSource.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/transaction/data/HttpTransactionDataSource.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 {\n type ContextModuleCalMode,\n type ContextModuleConfig,\n} from \"@/config/model/ContextModuleConfig\";\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport { PkiCertificateInfo } from \"@/pki/model/PkiCertificateInfo\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport {\n ClearSignContextReference,\n ClearSignContextReferenceType,\n ClearSignContextSuccess,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { GenericPath } from \"@/shared/model/GenericPath\";\nimport { INFO_SIGNATURE_TAG } from \"@/shared/model/SignatureTags\";\nimport { HexStringUtils } from \"@/shared/utils/HexStringUtils\";\nimport PACKAGE from \"@root/package.json\";\n\nimport {\n CalldataDescriptor,\n CalldataDescriptorContainerPathV1,\n CalldataDescriptorParam,\n CalldataDescriptorPathElementsV1,\n CalldataDescriptorPathElementV1,\n CalldataDescriptorV1,\n CalldataDescriptorValueBinaryPathV1,\n CalldataDescriptorValueConstantV1,\n CalldataDescriptorValueV1,\n CalldataDto,\n CalldataEnumV1,\n CalldataFieldV1,\n CalldataSignatures,\n CalldataTransactionDescriptor,\n CalldataTransactionInfoV1,\n} from \"./dto/CalldataDto\";\nimport {\n GetTransactionDescriptorsParams,\n TransactionDataSource,\n} from \"./TransactionDataSource\";\n\n@injectable()\nexport class HttpTransactionDataSource implements TransactionDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly _certificateLoader: PkiCertificateLoader,\n ) {}\n\n public async getTransactionDescriptors({\n chainId,\n address,\n selector,\n deviceModelId,\n }: GetTransactionDescriptorsParams): Promise<\n Either<Error, ClearSignContextSuccess[]>\n > {\n let dto: CalldataDto[] | undefined;\n try {\n const response = await axios.request<CalldataDto[]>({\n method: \"GET\",\n url: `${this.config.cal.url}/dapps`,\n params: {\n output: \"descriptors_calldata\",\n chain_id: chainId,\n contracts: address,\n // TODO revert to branch\n ref: `commit:ff75b9427f79c04c09d0b4378d6e01e2e6113e28`,\n },\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n });\n dto = response.data;\n } catch (error) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Failed to fetch transaction informations: ${error}`,\n ),\n );\n }\n\n if (!Array.isArray(dto)) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Response is not an array`,\n ),\n );\n }\n\n if (dto.length === 0) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: No data for contract ${address} and selector ${selector}`,\n ),\n );\n }\n\n for (const calldata of dto) {\n // Normalize the address and selector\n address = address.toLowerCase();\n selector = `0x${selector.slice(2).toLowerCase()}`;\n const calldataDescriptor =\n calldata.descriptors_calldata?.[address]?.[selector];\n\n if (\n !calldataDescriptor ||\n !this.isCalldataDescriptorV1(calldataDescriptor, this.config.cal.mode)\n ) {\n continue;\n }\n\n const infoData = calldataDescriptor.transaction_info.descriptor.data;\n const infoSignature =\n calldataDescriptor.transaction_info.descriptor.signatures[\n this.config.cal.mode\n ];\n\n const certificateInfos: PkiCertificateInfo = {\n targetDevice: deviceModelId,\n keyUsage: KeyUsage.Calldata,\n keyId: KeyId.CalCalldataKey,\n };\n const certificate: PkiCertificate | undefined =\n await this._certificateLoader.loadCertificate(certificateInfos);\n\n const info: ClearSignContextSuccess = {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: HexStringUtils.appendSignatureToPayload(\n infoData,\n infoSignature,\n INFO_SIGNATURE_TAG,\n ),\n certificate,\n };\n\n const enums: ClearSignContextSuccess[] = [];\n for (const [id, values] of Object.entries(calldataDescriptor.enums)) {\n for (const [\n value,\n { data, signatures },\n ] of Object.entries<CalldataTransactionDescriptor>(values)) {\n enums.push({\n type: ClearSignContextType.ENUM,\n id: Number(id),\n value: Number(value),\n payload: HexStringUtils.appendSignatureToPayload(\n data,\n signatures[this.config.cal.mode]!,\n INFO_SIGNATURE_TAG,\n ),\n certificate,\n });\n }\n }\n\n const fields: ClearSignContextSuccess[] = calldataDescriptor.fields.map(\n (field) => ({\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: field.descriptor,\n reference: this.getReference(field.param),\n }),\n );\n return Right([info, ...enums, ...fields]);\n }\n\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Invalid response for contract ${address} and selector ${selector}`,\n ),\n );\n }\n\n private getReference(\n param: CalldataDescriptorParam,\n ): ClearSignContextReference | undefined {\n if (\n param.type === \"TOKEN_AMOUNT\" &&\n param.token !== undefined &&\n param.token.type === \"path\"\n ) {\n return {\n type: ClearSignContextReferenceType.TOKEN,\n valuePath: this.toGenericPath(param.token.binary_path),\n };\n } else if (\n param.type === \"TOKEN_AMOUNT\" &&\n param.token !== undefined &&\n param.token.type === \"constant\"\n ) {\n return {\n type: ClearSignContextReferenceType.TOKEN,\n value: param.token.value,\n };\n } else if (param.type === \"NFT\" && param.collection.type === \"path\") {\n return {\n type: ClearSignContextReferenceType.NFT,\n valuePath: this.toGenericPath(param.collection.binary_path),\n };\n } else if (param.type === \"NFT\" && param.collection.type === \"constant\") {\n return {\n type: ClearSignContextReferenceType.NFT,\n value: param.collection.value,\n };\n } else if (param.type === \"TRUSTED_NAME\" && param.value.type === \"path\") {\n return {\n type: ClearSignContextReferenceType.TRUSTED_NAME,\n valuePath: this.toGenericPath(param.value.binary_path),\n types: param.types,\n sources: param.sources,\n };\n } else if (param.type === \"ENUM\" && param.value.type === \"path\") {\n return {\n type: ClearSignContextReferenceType.ENUM,\n valuePath: this.toGenericPath(param.value.binary_path),\n id: param.id,\n };\n } else if (\n param.type === \"CALLDATA\" &&\n param.value.type === \"path\" &&\n param.callee.type === \"path\"\n ) {\n return {\n type: ClearSignContextReferenceType.CALLDATA,\n valuePath: this.toGenericPath(param.value.binary_path),\n callee: this.toGenericPath(param.callee.binary_path),\n selector:\n param.selector?.type === \"path\"\n ? this.toGenericPath(param.selector.binary_path)\n : undefined,\n amount:\n param.amount?.type === \"path\"\n ? this.toGenericPath(param.amount.binary_path)\n : undefined,\n spender:\n param.spender?.type === \"path\"\n ? this.toGenericPath(param.spender.binary_path)\n : undefined,\n chainId:\n param.chainId?.type === \"path\"\n ? this.toGenericPath(param.chainId.binary_path)\n : undefined,\n };\n }\n return undefined;\n }\n\n private toGenericPath(\n path: CalldataDescriptorContainerPathV1 | CalldataDescriptorPathElementsV1,\n ): GenericPath {\n if (path.type === \"CONTAINER\") {\n return path.value;\n }\n return path.elements.map((element) => {\n if (element.type === \"ARRAY\") {\n const { weight: itemSize, ...rest } = element;\n return {\n itemSize,\n ...rest,\n };\n } else if (element.type === \"LEAF\") {\n const { leaf_type: leafType, ...rest } = element;\n return {\n leafType,\n ...rest,\n };\n }\n return element;\n });\n }\n\n private isCalldataDescriptorV1(\n data: CalldataDescriptor,\n mode: ContextModuleCalMode,\n ): data is CalldataDescriptorV1 & {\n transaction_info: {\n descriptor: {\n signatures: { [_key in ContextModuleCalMode]: string };\n };\n };\n } {\n return (\n typeof data === \"object\" &&\n data.type === \"calldata\" &&\n data.version === \"v1\" &&\n this.isTransactionInfoV1(data.transaction_info, mode) &&\n this.isEnumV1(data.enums, mode) &&\n Array.isArray(data.fields) &&\n data.fields.every((f) => this.isFieldV1(f))\n );\n }\n\n private isTransactionInfoV1(\n data: CalldataTransactionInfoV1,\n mode: ContextModuleCalMode,\n ): data is CalldataTransactionInfoV1 & {\n descriptor: {\n signatures: { [_key in ContextModuleCalMode]: string };\n };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.descriptor === \"object\" &&\n typeof data.descriptor.data === \"string\" &&\n typeof data.descriptor.signatures === \"object\" &&\n typeof data.descriptor.signatures[mode] === \"string\"\n );\n }\n\n private isEnumV1(\n calldata: CalldataEnumV1,\n mode: ContextModuleCalMode,\n ): calldata is CalldataEnumV1 {\n return (\n typeof calldata === \"object\" &&\n Object.entries(calldata).every(\n ([id, values]) =>\n typeof id === \"string\" &&\n typeof values === \"object\" &&\n Object.entries<CalldataTransactionDescriptor>(values).every(\n ([value, obj]) =>\n typeof value === \"string\" &&\n typeof obj === \"object\" &&\n typeof obj.data === \"string\" &&\n obj.signatures !== undefined &&\n this.isCalldataSignatures(obj.signatures, mode),\n ),\n )\n );\n }\n\n private isCalldataSignatures(\n data: CalldataSignatures,\n mode: ContextModuleCalMode,\n ): data is CalldataSignatures & { [_key in ContextModuleCalMode]: string } {\n return typeof data === \"object\" && typeof data[mode] === \"string\";\n }\n\n private isFieldV1(data: CalldataFieldV1): boolean {\n return (\n typeof data === \"object\" &&\n typeof data.descriptor === \"string\" &&\n typeof data.param === \"object\" &&\n typeof data.param.value === \"object\" &&\n this.isDescriptorValueV1(data.param.value) &&\n (data.param.type === \"RAW\" ||\n data.param.type === \"AMOUNT\" ||\n data.param.type === \"DATETIME\" ||\n data.param.type === \"DURATION\" ||\n data.param.type === \"UNIT\" ||\n data.param.type === \"ENUM\" ||\n (data.param.type === \"NFT\" &&\n this.isDescriptorValueV1(data.param.collection)) ||\n (data.param.type === \"TOKEN_AMOUNT\" &&\n (data.param.token === undefined ||\n this.isDescriptorValueV1(data.param.token))) ||\n (data.param.type === \"TRUSTED_NAME\" &&\n Array.isArray(data.param.types) &&\n Array.isArray(data.param.sources) &&\n data.param.types.every((t) => typeof t === \"string\") &&\n data.param.sources.every((t) => typeof t === \"string\")) ||\n (data.param.type === \"CALLDATA\" &&\n this.isDescriptorValueV1(data.param.value) &&\n this.isDescriptorValueV1(data.param.callee) &&\n (data.param.selector === undefined ||\n this.isDescriptorValueV1(data.param.selector)) &&\n (data.param.amount === undefined ||\n this.isDescriptorValueV1(data.param.amount))))\n );\n }\n\n private isDescriptorValueV1(data: CalldataDescriptorValueV1): boolean {\n return (\n typeof data === \"object\" &&\n typeof data.type_family === \"string\" &&\n [\n \"UINT\",\n \"INT\",\n \"UFIXED\",\n \"FIXED\",\n \"ADDRESS\",\n \"BOOL\",\n \"BYTES\",\n \"STRING\",\n ].includes(data.type_family) &&\n (typeof data.type_size === \"undefined\" ||\n typeof data.type_size === \"number\") &&\n ((data.type === \"path\" &&\n this.isCalldataDescriptorValueBinaryPathV1(data)) ||\n (data.type === \"constant\" &&\n this.isCalldataDescriptorValueConstantV1(data)))\n );\n }\n\n private isCalldataDescriptorValueConstantV1(\n data: CalldataDescriptorValueConstantV1,\n ): boolean {\n return (\n typeof data === \"object\" &&\n data.type === \"constant\" &&\n typeof data.value === \"string\"\n );\n }\n\n private isCalldataDescriptorValueBinaryPathV1(\n data: CalldataDescriptorValueBinaryPathV1,\n ): boolean {\n return (\n typeof data === \"object\" &&\n ((data.type === \"path\" &&\n data.binary_path.type === \"CONTAINER\" &&\n [\"FROM\", \"TO\", \"VALUE\"].includes(data.binary_path.value)) ||\n (data.binary_path.type === \"DATA\" &&\n Array.isArray(data.binary_path.elements) &&\n data.binary_path.elements.every((e) => this.isPathElementV1(e))))\n );\n }\n\n private isPathElementV1(data: CalldataDescriptorPathElementV1): boolean {\n return (\n typeof data === \"object\" &&\n (data.type === \"REF\" ||\n (data.type === \"TUPLE\" && typeof data.offset === \"number\") ||\n (data.type === \"ARRAY\" &&\n typeof data.weight === \"number\" &&\n (typeof data.start === \"undefined\" ||\n typeof data.start === \"number\") &&\n (typeof data.end === \"undefined\" || typeof data.end === \"number\")) ||\n (data.type === \"LEAF\" &&\n typeof data.leaf_type === \"string\" &&\n [\"ARRAY_LEAF\", \"TUPLE_LEAF\", \"STATIC_LEAF\", \"DYNAMIC_LEAF\"].includes(\n data.leaf_type,\n )) ||\n (data.type === \"SLICE\" &&\n (typeof data.start === \"undefined\" ||\n typeof data.start === \"number\") &&\n (typeof data.end === \"undefined\" || typeof data.end === \"number\")))\n );\n }\n}\n"],
|
|
5
|
-
"mappings": "qtBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkB,oBAClBC,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAK5BC,EAAyB,6BAEzBC,EAAsB,6BACtBC,EAAyB,gCAGzBC,EAGO,yCACPC,EAKO,2CAEPC,EAAmC,wCACnCC,EAA+B,yCAC/BC,EAAoB,iCAyBb,IAAMC,EAAN,KAAiE,CACtE,YAC+CC,EAE5BC,EACjB,CAH6C,YAAAD,EAE5B,wBAAAC,CAChB,CAEH,MAAa,0BAA0B,CACrC,QAAAC,EACA,QAAAC,EACA,SAAAC,EACA,cAAAC,CACF,EAEE,CACA,IAAIC,EACJ,GAAI,CAgBFA,GAfiB,MAAM,EAAAC,QAAM,QAAuB,CAClD,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,IAAI,GAAG,SAC3B,OAAQ,CACN,OAAQ,uBACR,SAAUL,EACV,UAAWC,EAEX,IAAK,iDACP,EACA,QAAS,CACP,CAAC,8BAA4B,EAAG,kBAAkB,EAAAK,QAAQ,OAAO,GACjE,CAAC,4BAA0B,EAAG,KAAK,OAAO,WAC5C,CACF,CAAC,GACc,IACjB,OAASC,EAAO,CACd,S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KAAK,oBAAoBA,EAAK,MAAM,QAAQ,KAC7CA,EAAK,MAAM,SAAW,QACrB,KAAK,oBAAoBA,EAAK,MAAM,MAAM,
|
|
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 {\n type ContextModuleCalMode,\n type ContextModuleConfig,\n} from \"@/config/model/ContextModuleConfig\";\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport { PkiCertificateInfo } from \"@/pki/model/PkiCertificateInfo\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport {\n ClearSignContextReference,\n ClearSignContextReferenceType,\n ClearSignContextSuccess,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { GenericPath } from \"@/shared/model/GenericPath\";\nimport { INFO_SIGNATURE_TAG } from \"@/shared/model/SignatureTags\";\nimport { HexStringUtils } from \"@/shared/utils/HexStringUtils\";\nimport PACKAGE from \"@root/package.json\";\n\nimport {\n CalldataDescriptor,\n CalldataDescriptorContainerPathV1,\n CalldataDescriptorParam,\n CalldataDescriptorPathElementsV1,\n CalldataDescriptorPathElementV1,\n CalldataDescriptorV1,\n CalldataDescriptorValueBinaryPathV1,\n CalldataDescriptorValueConstantV1,\n CalldataDescriptorValueV1,\n CalldataDto,\n CalldataEnumV1,\n CalldataFieldV1,\n CalldataSignatures,\n CalldataTransactionDescriptor,\n CalldataTransactionInfoV1,\n} from \"./dto/CalldataDto\";\nimport {\n GetTransactionDescriptorsParams,\n TransactionDataSource,\n} from \"./TransactionDataSource\";\n\n@injectable()\nexport class HttpTransactionDataSource implements TransactionDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly _certificateLoader: PkiCertificateLoader,\n ) {}\n\n public async getTransactionDescriptors({\n chainId,\n address,\n selector,\n deviceModelId,\n }: GetTransactionDescriptorsParams): Promise<\n Either<Error, ClearSignContextSuccess[]>\n > {\n let dto: CalldataDto[] | undefined;\n try {\n const response = await axios.request<CalldataDto[]>({\n method: \"GET\",\n url: `${this.config.cal.url}/dapps`,\n params: {\n output: \"descriptors_calldata\",\n chain_id: chainId,\n contracts: address,\n // TODO revert to branch\n ref: `commit:cdd7d0f9cec33eb969a12641810cc7b06efeec1c`,\n },\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n });\n dto = response.data;\n } catch (error) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Failed to fetch transaction informations: ${error}`,\n ),\n );\n }\n\n if (!Array.isArray(dto)) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Response is not an array`,\n ),\n );\n }\n\n if (dto.length === 0) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: No data for contract ${address} and selector ${selector}`,\n ),\n );\n }\n\n for (const calldata of dto) {\n // Normalize the address and selector\n address = address.toLowerCase();\n selector = `0x${selector.slice(2).toLowerCase()}`;\n const calldataDescriptor =\n calldata.descriptors_calldata?.[address]?.[selector];\n\n if (\n !calldataDescriptor ||\n !this.isCalldataDescriptorV1(calldataDescriptor, this.config.cal.mode)\n ) {\n continue;\n }\n\n const infoData = calldataDescriptor.transaction_info.descriptor.data;\n const infoSignature =\n calldataDescriptor.transaction_info.descriptor.signatures[\n this.config.cal.mode\n ];\n\n const certificateInfos: PkiCertificateInfo = {\n targetDevice: deviceModelId,\n keyUsage: KeyUsage.Calldata,\n keyId: KeyId.CalCalldataKey,\n };\n const certificate: PkiCertificate | undefined =\n await this._certificateLoader.loadCertificate(certificateInfos);\n\n const info: ClearSignContextSuccess = {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: HexStringUtils.appendSignatureToPayload(\n infoData,\n infoSignature,\n INFO_SIGNATURE_TAG,\n ),\n certificate,\n };\n\n const enums: ClearSignContextSuccess[] = [];\n for (const [id, values] of Object.entries(calldataDescriptor.enums)) {\n for (const [\n value,\n { data, signatures },\n ] of Object.entries<CalldataTransactionDescriptor>(values)) {\n enums.push({\n type: ClearSignContextType.ENUM,\n id: Number(id),\n value: Number(value),\n payload: HexStringUtils.appendSignatureToPayload(\n data,\n signatures[this.config.cal.mode]!,\n INFO_SIGNATURE_TAG,\n ),\n certificate,\n });\n }\n }\n\n const fields: ClearSignContextSuccess[] = calldataDescriptor.fields.map(\n (field) => ({\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: field.descriptor,\n reference: this.getReference(field.param),\n }),\n );\n return Right([info, ...enums, ...fields]);\n }\n\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Invalid response for contract ${address} and selector ${selector}`,\n ),\n );\n }\n\n private getReference(\n param: CalldataDescriptorParam,\n ): ClearSignContextReference | undefined {\n if (\n param.type === \"TOKEN_AMOUNT\" &&\n param.token !== undefined &&\n param.token.type === \"path\"\n ) {\n return {\n type: ClearSignContextReferenceType.TOKEN,\n valuePath: this.toGenericPath(param.token.binary_path),\n };\n } else if (\n param.type === \"TOKEN_AMOUNT\" &&\n param.token !== undefined &&\n param.token.type === \"constant\"\n ) {\n return {\n type: ClearSignContextReferenceType.TOKEN,\n value: param.token.value,\n };\n } else if (param.type === \"NFT\" && param.collection.type === \"path\") {\n return {\n type: ClearSignContextReferenceType.NFT,\n valuePath: this.toGenericPath(param.collection.binary_path),\n };\n } else if (param.type === \"NFT\" && param.collection.type === \"constant\") {\n return {\n type: ClearSignContextReferenceType.NFT,\n value: param.collection.value,\n };\n } else if (param.type === \"TRUSTED_NAME\" && param.value.type === \"path\") {\n return {\n type: ClearSignContextReferenceType.TRUSTED_NAME,\n valuePath: this.toGenericPath(param.value.binary_path),\n types: param.types,\n sources: param.sources,\n };\n } else if (param.type === \"ENUM\" && param.value.type === \"path\") {\n return {\n type: ClearSignContextReferenceType.ENUM,\n valuePath: this.toGenericPath(param.value.binary_path),\n id: param.id,\n };\n } else if (\n param.type === \"CALLDATA\" &&\n param.value.type === \"path\" &&\n param.callee.type === \"path\"\n ) {\n return {\n type: ClearSignContextReferenceType.CALLDATA,\n valuePath: this.toGenericPath(param.value.binary_path),\n callee: this.toGenericPath(param.callee.binary_path),\n selector:\n param.selector?.type === \"path\"\n ? this.toGenericPath(param.selector.binary_path)\n : undefined,\n amount:\n param.amount?.type === \"path\"\n ? this.toGenericPath(param.amount.binary_path)\n : undefined,\n spender:\n param.spender?.type === \"path\"\n ? this.toGenericPath(param.spender.binary_path)\n : undefined,\n chainId:\n param.chainId?.type === \"path\"\n ? this.toGenericPath(param.chainId.binary_path)\n : undefined,\n };\n }\n return undefined;\n }\n\n private toGenericPath(\n path: CalldataDescriptorContainerPathV1 | CalldataDescriptorPathElementsV1,\n ): GenericPath {\n if (path.type === \"CONTAINER\") {\n return path.value;\n }\n return path.elements.map((element) => {\n if (element.type === \"ARRAY\") {\n const { weight: itemSize, ...rest } = element;\n return {\n itemSize,\n ...rest,\n };\n } else if (element.type === \"LEAF\") {\n const { leaf_type: leafType, ...rest } = element;\n return {\n leafType,\n ...rest,\n };\n }\n return element;\n });\n }\n\n private isCalldataDescriptorV1(\n data: CalldataDescriptor,\n mode: ContextModuleCalMode,\n ): data is CalldataDescriptorV1 & {\n transaction_info: {\n descriptor: {\n signatures: { [_key in ContextModuleCalMode]: string };\n };\n };\n } {\n return (\n typeof data === \"object\" &&\n data.type === \"calldata\" &&\n data.version === \"v1\" &&\n this.isTransactionInfoV1(data.transaction_info, mode) &&\n this.isEnumV1(data.enums, mode) &&\n Array.isArray(data.fields) &&\n data.fields.every((f) => this.isFieldV1(f))\n );\n }\n\n private isTransactionInfoV1(\n data: CalldataTransactionInfoV1,\n mode: ContextModuleCalMode,\n ): data is CalldataTransactionInfoV1 & {\n descriptor: {\n signatures: { [_key in ContextModuleCalMode]: string };\n };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.descriptor === \"object\" &&\n typeof data.descriptor.data === \"string\" &&\n typeof data.descriptor.signatures === \"object\" &&\n typeof data.descriptor.signatures[mode] === \"string\"\n );\n }\n\n private isEnumV1(\n calldata: CalldataEnumV1,\n mode: ContextModuleCalMode,\n ): calldata is CalldataEnumV1 {\n return (\n typeof calldata === \"object\" &&\n Object.entries(calldata).every(\n ([id, values]) =>\n typeof id === \"string\" &&\n typeof values === \"object\" &&\n Object.entries<CalldataTransactionDescriptor>(values).every(\n ([value, obj]) =>\n typeof value === \"string\" &&\n typeof obj === \"object\" &&\n typeof obj.data === \"string\" &&\n obj.signatures !== undefined &&\n this.isCalldataSignatures(obj.signatures, mode),\n ),\n )\n );\n }\n\n private isCalldataSignatures(\n data: CalldataSignatures,\n mode: ContextModuleCalMode,\n ): data is CalldataSignatures & { [_key in ContextModuleCalMode]: string } {\n return typeof data === \"object\" && typeof data[mode] === \"string\";\n }\n\n private isFieldV1(data: CalldataFieldV1): boolean {\n return (\n typeof data === \"object\" &&\n typeof data.descriptor === \"string\" &&\n typeof data.param === \"object\" &&\n typeof data.param.value === \"object\" &&\n this.isDescriptorValueV1(data.param.value) &&\n (data.param.type === \"RAW\" ||\n data.param.type === \"AMOUNT\" ||\n data.param.type === \"DATETIME\" ||\n data.param.type === \"DURATION\" ||\n data.param.type === \"UNIT\" ||\n data.param.type === \"ENUM\" ||\n (data.param.type === \"NFT\" &&\n this.isDescriptorValueV1(data.param.collection)) ||\n (data.param.type === \"TOKEN_AMOUNT\" &&\n (data.param.token === undefined ||\n this.isDescriptorValueV1(data.param.token))) ||\n (data.param.type === \"TRUSTED_NAME\" &&\n Array.isArray(data.param.types) &&\n Array.isArray(data.param.sources) &&\n data.param.types.every((t) => typeof t === \"string\") &&\n data.param.sources.every((t) => typeof t === \"string\")) ||\n (data.param.type === \"CALLDATA\" &&\n this.isDescriptorValueV1(data.param.value) &&\n this.isDescriptorValueV1(data.param.callee) &&\n (data.param.selector === undefined ||\n this.isDescriptorValueV1(data.param.selector)) &&\n (data.param.amount === undefined ||\n this.isDescriptorValueV1(data.param.amount)) &&\n (data.param.spender === undefined ||\n this.isDescriptorValueV1(data.param.spender)) &&\n (data.param.chainId === undefined ||\n this.isDescriptorValueV1(data.param.chainId))))\n );\n }\n\n private isDescriptorValueV1(data: CalldataDescriptorValueV1): boolean {\n return (\n typeof data === \"object\" &&\n typeof data.type_family === \"string\" &&\n [\n \"UINT\",\n \"INT\",\n \"UFIXED\",\n \"FIXED\",\n \"ADDRESS\",\n \"BOOL\",\n \"BYTES\",\n \"STRING\",\n ].includes(data.type_family) &&\n (typeof data.type_size === \"undefined\" ||\n typeof data.type_size === \"number\") &&\n ((data.type === \"path\" &&\n this.isCalldataDescriptorValueBinaryPathV1(data)) ||\n (data.type === \"constant\" &&\n this.isCalldataDescriptorValueConstantV1(data)))\n );\n }\n\n private isCalldataDescriptorValueConstantV1(\n data: CalldataDescriptorValueConstantV1,\n ): boolean {\n return (\n typeof data === \"object\" &&\n data.type === \"constant\" &&\n typeof data.value === \"string\"\n );\n }\n\n private isCalldataDescriptorValueBinaryPathV1(\n data: CalldataDescriptorValueBinaryPathV1,\n ): boolean {\n return (\n typeof data === \"object\" &&\n ((data.type === \"path\" &&\n data.binary_path.type === \"CONTAINER\" &&\n [\"FROM\", \"TO\", \"VALUE\"].includes(data.binary_path.value)) ||\n (data.binary_path.type === \"DATA\" &&\n Array.isArray(data.binary_path.elements) &&\n data.binary_path.elements.every((e) => this.isPathElementV1(e))))\n );\n }\n\n private isPathElementV1(data: CalldataDescriptorPathElementV1): boolean {\n return (\n typeof data === \"object\" &&\n (data.type === \"REF\" ||\n (data.type === \"TUPLE\" && typeof data.offset === \"number\") ||\n (data.type === \"ARRAY\" &&\n typeof data.weight === \"number\" &&\n (typeof data.start === \"undefined\" ||\n typeof data.start === \"number\") &&\n (typeof data.end === \"undefined\" || typeof data.end === \"number\")) ||\n (data.type === \"LEAF\" &&\n typeof data.leaf_type === \"string\" &&\n [\"ARRAY_LEAF\", \"TUPLE_LEAF\", \"STATIC_LEAF\", \"DYNAMIC_LEAF\"].includes(\n data.leaf_type,\n )) ||\n (data.type === \"SLICE\" &&\n (typeof data.start === \"undefined\" ||\n typeof data.start === \"number\") &&\n (typeof data.end === \"undefined\" || typeof data.end === \"number\")))\n );\n }\n}\n"],
|
|
5
|
+
"mappings": "qtBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkB,oBAClBC,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAK5BC,EAAyB,6BAEzBC,EAAsB,6BACtBC,EAAyB,gCAGzBC,EAGO,yCACPC,EAKO,2CAEPC,EAAmC,wCACnCC,EAA+B,yCAC/BC,EAAoB,iCAyBb,IAAMC,EAAN,KAAiE,CACtE,YAC+CC,EAE5BC,EACjB,CAH6C,YAAAD,EAE5B,wBAAAC,CAChB,CAEH,MAAa,0BAA0B,CACrC,QAAAC,EACA,QAAAC,EACA,SAAAC,EACA,cAAAC,CACF,EAEE,CACA,IAAIC,EACJ,GAAI,CAgBFA,GAfiB,MAAM,EAAAC,QAAM,QAAuB,CAClD,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,IAAI,GAAG,SAC3B,OAAQ,CACN,OAAQ,uBACR,SAAUL,EACV,UAAWC,EAEX,IAAK,iDACP,EACA,QAAS,CACP,CAAC,8BAA4B,EAAG,kBAAkB,EAAAK,QAAQ,OAAO,GACjE,CAAC,4BAA0B,EAAG,KAAK,OAAO,WAC5C,CACF,CAAC,GACc,IACjB,OAASC,EAAO,CACd,SAAO,QACL,IAAI,MACF,wFAAwFA,CAAK,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EAAK,SACP,GACDA,EAAK,OAAS,UACZ,OAAOA,EAAK,MAAU,KACrB,OAAOA,EAAK,OAAU,YACvB,OAAOA,EAAK,IAAQ,KAAe,OAAOA,EAAK,KAAQ,UAEhE,CACF,EAlZatB,EAANoC,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,cAAY,MAAM,GACzBA,EAAA,eAAO,WAAS,oBAAoB,IAH5BrC",
|
|
6
6
|
"names": ["HttpTransactionDataSource_exports", "__export", "HttpTransactionDataSource", "__toCommonJS", "import_axios", "import_inversify", "import_purify_ts", "import_configTypes", "import_pkiTypes", "import_KeyId", "import_KeyUsage", "import_HttpHeaders", "import_ClearSignContext", "import_SignatureTags", "import_HexStringUtils", "import_package", "HttpTransactionDataSource", "config", "_certificateLoader", "chainId", "address", "selector", "deviceModelId", "dto", "axios", "PACKAGE", "error", "calldata", "calldataDescriptor", "infoData", "infoSignature", "certificateInfos", "certificate", "info", "enums", "id", "values", "value", "data", "signatures", "fields", "field", "param", "path", "element", "itemSize", "rest", "leafType", "mode", "f", "obj", "e", "__decorateClass", "__decorateParam"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var x=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var h=(o,t)=>{for(var r in t)x(o,r,{get:t[r],enumerable:!0})},P=(o,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of D(t))!R.call(o,e)&&e!==r&&x(o,e,{get:()=>t[e],enumerable:!(a=f(t,e))||a.enumerable});return o};var T=o=>P(x({},"__esModule",{value:!0}),o),S=(o,t,r,a)=>{for(var e=a>1?void 0:a?f(t,r):t,n=o.length-1,s;n>=0;n--)(s=o[n])&&(e=(a?s(t,r,e):s(e))||e);return a&&e&&x(t,r,e),e},u=(o,t)=>(r,a)=>t(r,a,o);var E={};h(E,{TransactionContextLoader:()=>c});module.exports=T(E);var l=require("@ledgerhq/device-management-kit"),d=require("inversify"),C=require("../../proxy/di/proxyTypes"),i=require("../../shared/model/ClearSignContext"),g=require("../../transaction/di/transactionTypes");let c=class{constructor(t,r){this.transactionDataSource=t;this.proxyDataSource=r}async load(t){if(t.deviceModelId===l.DeviceModelId.NANO_S)return[];const{to:r,data:a,selector:e,chainId:n,deviceModelId:s}=t;if(r===void 0)return[];if(!(0,l.isHexaString)(e))return[{type:i.ClearSignContextType.ERROR,error:new Error("Invalid selector")}];const m=await this.transactionDataSource.getTransactionDescriptors({deviceModelId:s,address:r,chainId:n,selector:e});return m.isRight()&&m.extract().length>0?m.extract():(await this.proxyDataSource.getProxyImplementationAddress({calldata:a,proxyAddress:r,chainId:n,challenge:""})).caseOf({Right:async({implementationAddress:p})=>{if(!p)return[{type:i.ClearSignContextType.ERROR,error:new Error(`[ContextModule] TransactionContextLoader: No delegate address found for proxy ${r}`)}];const y=await this.transactionDataSource.getTransactionDescriptors({deviceModelId:s,address:p,chainId:n,selector:e});return y.isRight()&&y.extract().length>0?[{type:i.ClearSignContextType.PROXY_DELEGATE_CALL,payload:"0x"},...y.extract()]:[{type:i.ClearSignContextType.ERROR,error:new Error(`[ContextModule] TransactionContextLoader: Unable to fetch contexts from contract address using proxy delegate call ${p}`)}]},Left:p=>Promise.resolve([{type:i.ClearSignContextType.ERROR,error:new Error(`[ContextModule] TransactionContextLoader: Unable to fetch contexts from contract address ${r}`)}])})}};c=S([(0,d.injectable)(),u(0,(0,d.inject)(g.transactionTypes.TransactionDataSource)),u(1,(0,d.inject)(C.proxyTypes.ProxyDataSource))],c);0&&(module.exports={TransactionContextLoader});
|
|
2
2
|
//# sourceMappingURL=TransactionContextLoader.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/transaction/domain/TransactionContextLoader.ts"],
|
|
4
|
-
"sourcesContent": ["import { DeviceModelId, isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport type {
|
|
5
|
-
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4C,2CAC5CC,EAAmC,
|
|
6
|
-
"names": ["TransactionContextLoader_exports", "__export", "TransactionContextLoader", "__toCommonJS", "import_device_management_kit", "import_inversify", "import_proxyTypes", "import_ClearSignContext", "import_transactionTypes", "TransactionContextLoader", "transactionDataSource", "proxyDataSource", "ctx", "to", "data", "selector", "chainId", "deviceModelId", "
|
|
4
|
+
"sourcesContent": ["import { DeviceModelId, isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport type {\n ProxyDataSource,\n ProxyImplementationAddress,\n} from \"@/proxy/data/ProxyDataSource\";\nimport { proxyTypes } from \"@/proxy/di/proxyTypes\";\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { TransactionContext } from \"@/shared/model/TransactionContext\";\nimport type { TransactionDataSource } from \"@/transaction/data/TransactionDataSource\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\n\n@injectable()\nexport class TransactionContextLoader implements ContextLoader {\n constructor(\n @inject(transactionTypes.TransactionDataSource)\n private transactionDataSource: TransactionDataSource,\n @inject(proxyTypes.ProxyDataSource)\n private proxyDataSource: ProxyDataSource,\n ) {}\n\n async load(ctx: TransactionContext): Promise<ClearSignContext[]> {\n if (ctx.deviceModelId === DeviceModelId.NANO_S) {\n return [];\n }\n\n const { to, data, selector, chainId, deviceModelId } = ctx;\n if (to === undefined) {\n return [];\n }\n\n if (!isHexaString(selector)) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ];\n }\n\n // try to fetch the transaction descriptors from the transaction data source\n // using the smart contract address to\n const transactionContexts =\n await this.transactionDataSource.getTransactionDescriptors({\n deviceModelId,\n address: to,\n chainId,\n selector,\n });\n\n if (\n transactionContexts.isRight() &&\n transactionContexts.extract().length > 0\n ) {\n return transactionContexts.extract();\n }\n\n // if the transaction descriptors are not found, try to fetch the proxy delegate call\n // and return the proxy delegate call context\n const proxyImplementationAddress =\n await this.proxyDataSource.getProxyImplementationAddress({\n calldata: data,\n proxyAddress: to,\n chainId,\n challenge: \"\",\n });\n\n return proxyImplementationAddress.caseOf<Promise<ClearSignContext[]>>({\n Right: async ({ implementationAddress }: ProxyImplementationAddress) => {\n if (!implementationAddress) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n `[ContextModule] TransactionContextLoader: No delegate address found for proxy ${to}`,\n ),\n },\n ];\n }\n\n const transactionProxyContexts =\n await this.transactionDataSource.getTransactionDescriptors({\n deviceModelId,\n address: implementationAddress,\n chainId,\n selector,\n });\n\n if (\n transactionProxyContexts.isRight() &&\n transactionProxyContexts.extract().length > 0\n ) {\n return [\n // This payload is not used as the clear sign context is not used, only the subcontext that will be\n // fetched during the provide, with a correct challenge\n {\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: \"0x\",\n },\n ...transactionProxyContexts.extract(),\n ];\n }\n\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n `[ContextModule] TransactionContextLoader: Unable to fetch contexts from contract address using proxy delegate call ${implementationAddress}`,\n ),\n },\n ];\n },\n Left: (_) => {\n return Promise.resolve([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n `[ContextModule] TransactionContextLoader: Unable to fetch contexts from contract address ${to}`,\n ),\n },\n ]);\n },\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4C,2CAC5CC,EAAmC,qBAMnCC,EAA2B,iCAE3BC,EAGO,2CAGPC,EAAiC,6CAG1B,IAAMC,EAAN,KAAwD,CAC7D,YAEUC,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B,MAAO,IAAI,MACT,4FAA4FR,CAAE,EAChG,CACF,CACF,CAAC,CAEL,CAAC,CACH,CACF,EA/GaJ,EAANa,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,mBAAiB,qBAAqB,GAE7CA,EAAA,eAAO,aAAW,eAAe,IAJzBd",
|
|
6
|
+
"names": ["TransactionContextLoader_exports", "__export", "TransactionContextLoader", "__toCommonJS", "import_device_management_kit", "import_inversify", "import_proxyTypes", "import_ClearSignContext", "import_transactionTypes", "TransactionContextLoader", "transactionDataSource", "proxyDataSource", "ctx", "to", "data", "selector", "chainId", "deviceModelId", "transactionContexts", "implementationAddress", "transactionProxyContexts", "_", "__decorateClass", "__decorateParam"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var o=require("purify-ts"),
|
|
1
|
+
"use strict";var c=require("@ledgerhq/device-management-kit"),o=require("purify-ts"),a=require("../../shared/model/ClearSignContext"),d=require("../../transaction/domain/TransactionContextLoader");describe("TransactionContextLoader",()=>{const r=vi.fn(),s=vi.fn(),l={getTransactionDescriptors:r},i={getProxyImplementationAddress:s},n=new d.TransactionContextLoader(l,i);beforeEach(()=>{vi.resetAllMocks()}),it("should return an empty array if no destination address is provided",async()=>{const e={},t=await n.load(e);expect(t).toEqual([])}),it("should return an empty array if 'to' is undefined",async()=>{const e={to:void 0,data:"0x"},t=await n.load(e);expect(t).toEqual([])}),it("should return an error if selector is invalid",async()=>{const e={to:"0x7",chainId:3,data:"0xzf68b302000000000000000000000000000000000000000000000000000000000002"},t=await n.load(e);expect(t).toEqual([{type:a.ClearSignContextType.ERROR,error:new Error("Invalid selector")}])}),it("should return an error if data source fails",async()=>{s.mockResolvedValue((0,o.Left)(new Error("data source error"))),r.mockResolvedValue((0,o.Left)(new Error("data source error")));const e={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await n.load(e);expect(r).toHaveBeenCalledWith({address:"0x7",chainId:3,selector:"0xaf68b302"}),expect(t).toEqual([{type:a.ClearSignContextType.ERROR,error:new Error("[ContextModule] TransactionContextLoader: Unable to fetch contexts from contract address 0x7")}])}),it("should return the contexts on success",async()=>{r.mockResolvedValue((0,o.Right)([{type:a.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])),s.mockResolvedValue((0,o.Left)(new Error("data source error")));const e={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await n.load(e);expect(t).toEqual([{type:a.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])}),it("should return the proxy delegate call context on success",async()=>{r.mockResolvedValueOnce((0,o.Right)([])),r.mockResolvedValue((0,o.Right)([{type:a.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])),s.mockResolvedValue((0,o.Right)({implementationAddress:"0x1234567890abcdef",signedDescriptor:"0x1234567890abcdef"}));const e={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await n.load(e);expect(t).toEqual([{type:a.ClearSignContextType.PROXY_DELEGATE_CALL,payload:"0x"},{type:a.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])}),it("should return an empty array if device model is NANO_S",async()=>{const e={deviceModelId:c.DeviceModelId.NANO_S,to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await n.load(e);expect(t).toEqual([]),expect(r).not.toHaveBeenCalled(),expect(s).not.toHaveBeenCalled()}),it("should return an error when proxy delegate call succeeds but transaction descriptors for resolved address fail",async()=>{r.mockResolvedValueOnce((0,o.Right)([])),r.mockResolvedValueOnce((0,o.Left)(new Error("data source error"))),s.mockResolvedValue((0,o.Right)({implementationAddress:"0xResolvedAddress",signedDescriptor:"0x1234567890abcdef"}));const e={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await n.load(e);expect(r).toHaveBeenCalledTimes(2),expect(r).toHaveBeenNthCalledWith(2,{address:"0xResolvedAddress",chainId:3,selector:"0xaf68b302"}),expect(t).toEqual([{type:a.ClearSignContextType.ERROR,error:new Error("[ContextModule] TransactionContextLoader: Unable to fetch contexts from contract address using proxy delegate call 0xResolvedAddress")}])})});
|
|
2
2
|
//# sourceMappingURL=TransactionContextLoader.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/transaction/domain/TransactionContextLoader.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport type { ProxyDataSource } from \"@/proxy/data/
|
|
5
|
-
"mappings": "aAAA,IAAAA,EAA4B,qBAG5BC,EAAqC,2CAGrCC,EAAyC,yDAEzC,SAAS,2BAA4B,IAAM,CACzC,MAAMC,EAAgC,GAAG,GAAG,EACtCC,
|
|
6
|
-
"names": ["import_purify_ts", "import_ClearSignContext", "import_TransactionContextLoader", "getTransactionDescriptorsMock", "
|
|
4
|
+
"sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport type { ProxyDataSource } from \"@/proxy/data/ProxyDataSource\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport type { TransactionContext } from \"@/shared/model/TransactionContext\";\nimport type { TransactionDataSource } from \"@/transaction/data/TransactionDataSource\";\nimport { TransactionContextLoader } from \"@/transaction/domain/TransactionContextLoader\";\n\ndescribe(\"TransactionContextLoader\", () => {\n const getTransactionDescriptorsMock = vi.fn();\n const getProxyImplementationAddress = vi.fn();\n const mockTransactionDataSource: TransactionDataSource = {\n getTransactionDescriptors: getTransactionDescriptorsMock,\n };\n const mockProxyDatasource: ProxyDataSource = {\n getProxyImplementationAddress: getProxyImplementationAddress,\n };\n const loader = new TransactionContextLoader(\n mockTransactionDataSource,\n mockProxyDatasource,\n );\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should return an empty array if no destination address is provided\", async () => {\n // GIVEN\n const transaction = {} as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if 'to' is undefined\", async () => {\n // GIVEN\n const transaction = { to: undefined, data: \"0x\" } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an error if selector is invalid\", async () => {\n // GIVEN\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xzf68b302000000000000000000000000000000000000000000000000000000000002\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ]);\n });\n\n it(\"should return an error if data source fails\", async () => {\n // GIVEN\n getProxyImplementationAddress.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n getTransactionDescriptorsMock.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(getTransactionDescriptorsMock).toHaveBeenCalledWith({\n address: \"0x7\",\n chainId: 3,\n selector: \"0xaf68b302\",\n });\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] TransactionContextLoader: Unable to fetch contexts from contract address 0x7\",\n ),\n },\n ]);\n });\n\n it(\"should return the contexts on success\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValue(\n Right([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]),\n );\n getProxyImplementationAddress.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]);\n });\n\n it(\"should return the proxy delegate call context on success\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValueOnce(Right([])); // No transaction descriptors found for the first call\n getTransactionDescriptorsMock.mockResolvedValue(\n Right([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]),\n );\n getProxyImplementationAddress.mockResolvedValue(\n Right({\n implementationAddress: \"0x1234567890abcdef\",\n signedDescriptor: \"0x1234567890abcdef\",\n }),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: \"0x\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]);\n });\n\n it(\"should return an empty array if device model is NANO_S\", async () => {\n // GIVEN\n const transaction = {\n deviceModelId: DeviceModelId.NANO_S,\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n expect(getTransactionDescriptorsMock).not.toHaveBeenCalled();\n expect(getProxyImplementationAddress).not.toHaveBeenCalled();\n });\n\n it(\"should return an error when proxy delegate call succeeds but transaction descriptors for resolved address fail\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValueOnce(Right([])); // No transaction descriptors found for the first call\n getTransactionDescriptorsMock.mockResolvedValueOnce(\n Left(new Error(\"data source error\")),\n ); // Second call fails\n getProxyImplementationAddress.mockResolvedValue(\n Right({\n implementationAddress: \"0xResolvedAddress\",\n signedDescriptor: \"0x1234567890abcdef\",\n }),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(getTransactionDescriptorsMock).toHaveBeenCalledTimes(2);\n expect(getTransactionDescriptorsMock).toHaveBeenNthCalledWith(2, {\n address: \"0xResolvedAddress\",\n chainId: 3,\n selector: \"0xaf68b302\",\n });\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] TransactionContextLoader: Unable to fetch contexts from contract address using proxy delegate call 0xResolvedAddress\",\n ),\n },\n ]);\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAA8B,2CAC9BC,EAA4B,qBAG5BC,EAAqC,2CAGrCC,EAAyC,yDAEzC,SAAS,2BAA4B,IAAM,CACzC,MAAMC,EAAgC,GAAG,GAAG,EACtCC,EAAgC,GAAG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,EAAE,IAAI,iBAAiB,EAC3D,OAAOC,CAA6B,EAAE,IAAI,iBAAiB,CAC7D,CAAC,EAED,GAAG,iHAAkH,SAAY,CAE/HD,EAA8B,yBAAsB,SAAM,CAAC,CAAC,CAAC,EAC7DA,EAA8B,yBAC5B,QAAK,IAAI,MAAM,mBAAmB,CAAC,CACrC,EACAC,EAA8B,qBAC5B,SAAM,CACJ,sBAAuB,oBACvB,iBAAkB,oBACpB,CAAC,CACH,EACA,MAAMI,EAAc,CAClB,GAAI,MACJ,QAAS,EACT,KAAM,yEACN,SAAU,YACZ,EAGMC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOL,CAA6B,EAAE,sBAAsB,CAAC,EAC7D,OAAOA,CAA6B,EAAE,wBAAwB,EAAG,CAC/D,QAAS,oBACT,QAAS,EACT,SAAU,YACZ,CAAC,EACD,OAAOM,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MACT,sIACF,CACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_device_management_kit", "import_purify_ts", "import_ClearSignContext", "import_TransactionContextLoader", "getTransactionDescriptorsMock", "getProxyImplementationAddress", "mockTransactionDataSource", "mockProxyDatasource", "loader", "transaction", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var o=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var C=(t,e)=>{for(var r in e)o(t,r,{get:e[r],enumerable:!0})},h=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of S(e))!T.call(t,n)&&n!==r&&o(t,n,{get:()=>e[n],enumerable:!(a=p(e,n))||a.enumerable});return t};var N=t=>h(o({},"__esModule",{value:!0}),t),m=(t,e,r,a)=>{for(var n=a>1?void 0:a?p(e,r):e,c=t.length-1,d;c>=0;c--)(d=t[c])&&(n=(a?d(e,r,n):d(n))||n);return a&&n&&o(e,r,n),n},l=(t,e)=>(r,a)=>e(r,a,t);var I={};C(I,{TrustedNameContextFieldLoader:()=>s});module.exports=N(I);var i=require("inversify"),g=require("../../shared/domain/ContextFieldLoader"),u=require("../../shared/model/ClearSignContext"),y=require("../../trusted-name/di/trustedNameTypes");let s=class{constructor(e){this._dataSource=e}canHandle(e){return typeof e=="object"&&e!==null&&"kind"in e&&e.kind===g.ContextFieldLoaderKind.TRUSTED_NAME&&"chainId"in e&&"address"in e&&"challenge"in e&&"types"in e&&"sources"in e}async loadField(e){return(await this._dataSource.getTrustedNamePayload({chainId:e.chainId,address:e.address,challenge:e.challenge,types:e.types,sources:e.sources})).caseOf({Left:a=>({type:u.ClearSignContextType.ERROR,error:a}),Right:a=>({type:u.ClearSignContextType.TRUSTED_NAME,payload:a})})}};s=m([(0,i.injectable)(),l(0,(0,i.inject)(y.trustedNameTypes.TrustedNameDataSource))],s);0&&(module.exports={TrustedNameContextFieldLoader});
|
|
2
2
|
//# sourceMappingURL=TrustedNameContextFieldLoader.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/trusted-name/domain/TrustedNameContextFieldLoader.ts"],
|
|
4
|
-
"sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport {\n ContextFieldLoader,\n ContextFieldLoaderKind,\n} from \"@/shared/domain/ContextFieldLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport
|
|
5
|
-
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmC,qBAEnCC,EAGO,8CACPC,EAGO,
|
|
4
|
+
"sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport {\n ContextFieldLoader,\n ContextFieldLoaderKind,\n} from \"@/shared/domain/ContextFieldLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport * as TrustedNameDataSource from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\ntype TrustedNameFieldInput = {\n kind: ContextFieldLoaderKind.TRUSTED_NAME;\n chainId: number;\n address: string;\n challenge: string;\n types: string[];\n sources: string[];\n};\n\n@injectable()\nexport class TrustedNameContextFieldLoader\n implements ContextFieldLoader<TrustedNameFieldInput>\n{\n constructor(\n @inject(trustedNameTypes.TrustedNameDataSource)\n private _dataSource: TrustedNameDataSource.TrustedNameDataSource,\n ) {}\n\n canHandle(field: unknown): field is TrustedNameFieldInput {\n return (\n typeof field === \"object\" &&\n field !== null &&\n \"kind\" in field &&\n field.kind === ContextFieldLoaderKind.TRUSTED_NAME &&\n \"chainId\" in field &&\n \"address\" in field &&\n \"challenge\" in field &&\n \"types\" in field &&\n \"sources\" in field\n );\n }\n\n async loadField(field: TrustedNameFieldInput): Promise<ClearSignContext> {\n const payload = await this._dataSource.getTrustedNamePayload({\n chainId: field.chainId,\n address: field.address,\n challenge: field.challenge,\n types: field.types,\n sources: field.sources,\n });\n return payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: value,\n }),\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmC,qBAEnCC,EAGO,8CACPC,EAGO,2CAEPC,EAAiC,8CAY1B,IAAMC,EAAN,KAEP,CACE,YAEUC,EACR,CADQ,iBAAAA,CACP,CAEH,UAAUC,EAAgD,CACxD,OACE,OAAOA,GAAU,UACjBA,IAAU,MACV,SAAUA,GACVA,EAAM,OAAS,yBAAuB,cACtC,YAAaA,GACb,YAAaA,GACb,cAAeA,GACf,UAAWA,GACX,YAAaA,CAEjB,CAEA,MAAM,UAAUA,EAAyD,CAQvE,OAPgB,MAAM,KAAK,YAAY,sBAAsB,CAC3D,QAASA,EAAM,QACf,QAASA,EAAM,QACf,UAAWA,EAAM,UACjB,MAAOA,EAAM,MACb,QAASA,EAAM,OACjB,CAAC,GACc,OAAO,CACpB,KAAOC,IAA6B,CAClC,KAAM,uBAAqB,MAC3B,MAAAA,CACF,GACA,MAAQC,IAA6B,CACnC,KAAM,uBAAqB,aAC3B,QAASA,CACX,EACF,CAAC,CACH,CACF,EAzCaJ,EAANK,EAAA,IADN,cAAW,EAKPC,EAAA,eAAO,mBAAiB,qBAAqB,IAJrCN",
|
|
6
6
|
"names": ["TrustedNameContextFieldLoader_exports", "__export", "TrustedNameContextFieldLoader", "__toCommonJS", "import_inversify", "import_ContextFieldLoader", "import_ClearSignContext", "import_trustedNameTypes", "TrustedNameContextFieldLoader", "_dataSource", "field", "error", "value", "__decorateClass", "__decorateParam"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var n=require("purify-ts"),o=require("../../shared/domain/ContextFieldLoader"),c=require("../../shared/model/ClearSignContext"),r=require("../../trusted-name/domain/TrustedNameContextFieldLoader");describe("TrustedNameContextFieldLoader",()=>{const t={getTrustedNamePayload:vi.fn(),getDomainNamePayload:vi.fn()},d=new r.TrustedNameContextFieldLoader(t),e={kind:o.ContextFieldLoaderKind.TRUSTED_NAME,chainId:1,address:"0x1234567890abcdef",challenge:"test-challenge",types:["contract","token"],sources:["ledger","ens"]},l="0x123456789abcdef0";beforeEach(()=>{vi.resetAllMocks()}),describe("canHandle",()=>{it("should return true for valid trusted name field",()=>{const a={kind:o.ContextFieldLoaderKind.TRUSTED_NAME,chainId:1,address:"0x1234567890abcdef",challenge:"test-challenge",types:["contract","token"],sources:["ledger","ens"]};expect(d.canHandle(a)).toBe(!0)}),describe("should return false for invalid fields",()=>{const a=[{name:"null",value:null},{name:"undefined",value:void 0},{name:"string",value:"invalid"},{name:"number",value:123},{name:"boolean",value:!0},{name:"array",value:[]},{name:"empty object",value:{}},{name:"object missing kind",value:{chainId:1,address:"0x123",challenge:"test",types:["contract"],sources:["ledger"]}},{name:"object missing chainId",value:{kind:o.ContextFieldLoaderKind.TRUSTED_NAME,address:"0x123",challenge:"test",types:["contract"],sources:["ledger"]}},{name:"object missing address",value:{kind:o.ContextFieldLoaderKind.TRUSTED_NAME,chainId:1,challenge:"test",types:["contract"],sources:["ledger"]}},{name:"object missing challenge",value:{kind:o.ContextFieldLoaderKind.TRUSTED_NAME,chainId:1,address:"0x123",types:["contract"],sources:["ledger"]}},{name:"object missing types",value:{kind:o.ContextFieldLoaderKind.TRUSTED_NAME,chainId:1,address:"0x123",challenge:"test",sources:["ledger"]}},{name:"object missing sources",value:{kind:o.ContextFieldLoaderKind.TRUSTED_NAME,chainId:1,address:"0x123",challenge:"test",types:["contract"]}},{name:"object with wrong kind",value:{kind:o.ContextFieldLoaderKind.TOKEN,chainId:1,address:"0x123",challenge:"test",types:["contract"],sources:["ledger"]}}];test.each(a)("$name",({value:s})=>{expect(d.canHandle(s)).toBe(!1)})})}),describe("loadField",()=>{it("should return error context when trusted name data source fails",async()=>{const a=new Error("Trusted name data source error");vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue((0,n.Left)(a));const s=await d.loadField(e);expect(t.getTrustedNamePayload).toHaveBeenCalledWith({chainId:e.chainId,address:e.address,challenge:e.challenge,types:e.types,sources:e.sources}),expect(s).toEqual({type:c.ClearSignContextType.ERROR,error:a})}),it("should return trusted name context when successful",async()=>{vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue((0,n.Right)(l));const a=await d.loadField(e);expect(t.getTrustedNamePayload).toHaveBeenCalledWith({chainId:e.chainId,address:e.address,challenge:e.challenge,types:e.types,sources:e.sources}),expect(a).toEqual({type:c.ClearSignContextType.TRUSTED_NAME,payload:l})}),it("should handle different chain IDs and addresses correctly",async()=>{const a={...e,chainId:137,address:"0xdeadbeef",challenge:"custom-challenge"};vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue((0,n.Right)(l));const s=await d.loadField(a);expect(t.getTrustedNamePayload).toHaveBeenCalledWith({chainId:137,address:"0xdeadbeef",challenge:"custom-challenge",types:e.types,sources:e.sources}),expect(s).toEqual({type:c.ClearSignContextType.TRUSTED_NAME,payload:l})}),it("should handle different types and sources correctly",async()=>{const a={...e,types:["wallet","exchange"],sources:["coingecko","1inch"]};vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue((0,n.Right)(l));const s=await d.loadField(a);expect(t.getTrustedNamePayload).toHaveBeenCalledWith({chainId:e.chainId,address:e.address,challenge:e.challenge,types:["wallet","exchange"],sources:["coingecko","1inch"]}),expect(s).toEqual({type:c.ClearSignContextType.TRUSTED_NAME,payload:l})}),it("should preserve error message from trusted name data source",async()=>{const a=new Error("Network timeout error");vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue((0,n.Left)(a));const s=await d.loadField(e);expect(s).toEqual({type:c.ClearSignContextType.ERROR,error:a})}),it("should handle empty trusted name payload",async()=>{const a="";vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue((0,n.Right)(a));const s=await d.loadField(e);expect(s).toEqual({type:c.ClearSignContextType.TRUSTED_NAME,payload:a})}),it("should handle empty types and sources arrays",async()=>{const a={...e,types:[],sources:[]};vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue((0,n.Right)(l));const s=await d.loadField(a);expect(t.getTrustedNamePayload).toHaveBeenCalledWith({chainId:e.chainId,address:e.address,challenge:e.challenge,types:[],sources:[]}),expect(s).toEqual({type:c.ClearSignContextType.TRUSTED_NAME,payload:l})}),it("should handle single type and source",async()=>{const a={...e,types:["contract"],sources:["ens"]};vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue((0,n.Right)(l));const s=await d.loadField(a);expect(t.getTrustedNamePayload).toHaveBeenCalledWith({chainId:e.chainId,address:e.address,challenge:e.challenge,types:["contract"],sources:["ens"]}),expect(s).toEqual({type:c.ClearSignContextType.TRUSTED_NAME,payload:l})})})});
|
|
2
2
|
//# sourceMappingURL=TrustedNameContextFieldLoader.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/trusted-name/domain/TrustedNameContextFieldLoader.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ContextFieldLoaderKind } from \"@/shared/domain/ContextFieldLoader\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TransactionFieldContext } from \"@/shared/model/TransactionFieldContext\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { TrustedNameContextFieldLoader } from \"@/trusted-name/domain/TrustedNameContextFieldLoader\";\n\ndescribe(\"TrustedNameContextFieldLoader\", () => {\n const mockTrustedNameDataSource: TrustedNameDataSource = {\n getTrustedNamePayload: vi.fn(),\n getDomainNamePayload: vi.fn(),\n };\n const trustedNameContextFieldLoader = new TrustedNameContextFieldLoader(\n mockTrustedNameDataSource,\n );\n\n const mockTransactionField: TransactionFieldContext<ContextFieldLoaderKind.TRUSTED_NAME> =\n {\n kind: ContextFieldLoaderKind.TRUSTED_NAME,\n chainId: 1,\n address: \"0x1234567890abcdef\",\n challenge: \"test-challenge\",\n types: [\"contract\", \"token\"],\n sources: [\"ledger\", \"ens\"],\n };\n\n const mockTrustedNamePayload = \"0x123456789abcdef0\";\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"constructor\", () => {\n it(\"should initialize with correct kind\", () => {\n // THEN\n expect(trustedNameContextFieldLoader.kind).toBe(\n ContextFieldLoaderKind.TRUSTED_NAME,\n );\n });\n });\n\n describe(\"loadField\", () => {\n it(\"should return error context when trusted name data source fails\", async () => {\n // GIVEN\n const error = new Error(\"Trusted name data source error\");\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Left(error));\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: mockTransactionField.types,\n sources: mockTransactionField.sources,\n });\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: error,\n });\n });\n\n it(\"should return trusted name context when successful\", async () => {\n // GIVEN\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: mockTransactionField.types,\n sources: mockTransactionField.sources,\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload,\n });\n });\n\n it(\"should handle different chain IDs and addresses correctly\", async () => {\n // GIVEN\n const customField = {\n ...mockTransactionField,\n chainId: 137,\n address: \"0xdeadbeef\",\n challenge: \"custom-challenge\",\n };\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n\n // WHEN\n const result = await trustedNameContextFieldLoader.loadField(customField);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: 137,\n address: \"0xdeadbeef\",\n challenge: \"custom-challenge\",\n types: mockTransactionField.types,\n sources: mockTransactionField.sources,\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload,\n });\n });\n\n it(\"should handle different types and sources correctly\", async () => {\n // GIVEN\n const customField = {\n ...mockTransactionField,\n types: [\"wallet\", \"exchange\"],\n sources: [\"coingecko\", \"1inch\"],\n };\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n\n // WHEN\n const result = await trustedNameContextFieldLoader.loadField(customField);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: [\"wallet\", \"exchange\"],\n sources: [\"coingecko\", \"1inch\"],\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload,\n });\n });\n\n it(\"should preserve error message from trusted name data source\", async () => {\n // GIVEN\n const specificError = new Error(\"Network timeout error\");\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Left(specificError));\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: specificError,\n });\n });\n\n it(\"should handle empty trusted name payload\", async () => {\n // GIVEN\n const emptyPayload = \"\";\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(emptyPayload));\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: emptyPayload,\n });\n });\n\n it(\"should handle empty types and sources arrays\", async () => {\n // GIVEN\n const fieldWithEmptyArrays = {\n ...mockTransactionField,\n types: [],\n sources: [],\n };\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(fieldWithEmptyArrays);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: [],\n sources: [],\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload,\n });\n });\n\n it(\"should handle single type and source\", async () => {\n // GIVEN\n const fieldWithSingleElements = {\n ...mockTransactionField,\n types: [\"contract\"],\n sources: [\"ens\"],\n };\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n\n // WHEN\n const result = await trustedNameContextFieldLoader.loadField(\n fieldWithSingleElements,\n );\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: [\"contract\"],\n sources: [\"ens\"],\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload,\n });\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "aAAA,IAAAA,EAA4B,qBAE5BC,EAAuC,8CACvCC,EAAqC,2CAGrCC,EAA8C,+DAE9C,SAAS,gCAAiC,IAAM,CAC9C,MAAMC,EAAmD,CACvD,sBAAuB,GAAG,GAAG,EAC7B,qBAAsB,GAAG,GAAG,CAC9B,EACMC,EAAgC,IAAI,gCACxCD,CACF,EAEME,EACJ,CACE,KAAM,yBAAuB,aAC7B,QAAS,EACT,QAAS,qBACT,UAAW,iBACX,MAAO,CAAC,WAAY,OAAO,EAC3B,QAAS,CAAC,SAAU,KAAK,CAC3B,EAEIC,EAAyB,qBAE/B,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,SAAS,
|
|
6
|
-
"names": ["import_purify_ts", "import_ContextFieldLoader", "import_ClearSignContext", "import_TrustedNameContextFieldLoader", "mockTrustedNameDataSource", "trustedNameContextFieldLoader", "mockTransactionField", "mockTrustedNamePayload", "error", "result", "customField", "specificError", "emptyPayload", "fieldWithEmptyArrays", "fieldWithSingleElements"]
|
|
4
|
+
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ContextFieldLoaderKind } from \"@/shared/domain/ContextFieldLoader\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TransactionFieldContext } from \"@/shared/model/TransactionFieldContext\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { TrustedNameContextFieldLoader } from \"@/trusted-name/domain/TrustedNameContextFieldLoader\";\n\ndescribe(\"TrustedNameContextFieldLoader\", () => {\n const mockTrustedNameDataSource: TrustedNameDataSource = {\n getTrustedNamePayload: vi.fn(),\n getDomainNamePayload: vi.fn(),\n };\n const trustedNameContextFieldLoader = new TrustedNameContextFieldLoader(\n mockTrustedNameDataSource,\n );\n\n const mockTransactionField: TransactionFieldContext<ContextFieldLoaderKind.TRUSTED_NAME> =\n {\n kind: ContextFieldLoaderKind.TRUSTED_NAME,\n chainId: 1,\n address: \"0x1234567890abcdef\",\n challenge: \"test-challenge\",\n types: [\"contract\", \"token\"],\n sources: [\"ledger\", \"ens\"],\n };\n\n const mockTrustedNamePayload = \"0x123456789abcdef0\";\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"canHandle\", () => {\n it(\"should return true for valid trusted name field\", () => {\n // GIVEN\n const validField = {\n kind: ContextFieldLoaderKind.TRUSTED_NAME,\n chainId: 1,\n address: \"0x1234567890abcdef\",\n challenge: \"test-challenge\",\n types: [\"contract\", \"token\"],\n sources: [\"ledger\", \"ens\"],\n };\n\n // THEN\n expect(trustedNameContextFieldLoader.canHandle(validField)).toBe(true);\n });\n\n describe(\"should return false for invalid fields\", () => {\n const invalidFields = [\n { name: \"null\", value: null },\n { name: \"undefined\", value: undefined },\n { name: \"string\", value: \"invalid\" },\n { name: \"number\", value: 123 },\n { name: \"boolean\", value: true },\n { name: \"array\", value: [] },\n { name: \"empty object\", value: {} },\n {\n name: \"object missing kind\",\n value: {\n chainId: 1,\n address: \"0x123\",\n challenge: \"test\",\n types: [\"contract\"],\n sources: [\"ledger\"],\n },\n },\n {\n name: \"object missing chainId\",\n value: {\n kind: ContextFieldLoaderKind.TRUSTED_NAME,\n address: \"0x123\",\n challenge: \"test\",\n types: [\"contract\"],\n sources: [\"ledger\"],\n },\n },\n {\n name: \"object missing address\",\n value: {\n kind: ContextFieldLoaderKind.TRUSTED_NAME,\n chainId: 1,\n challenge: \"test\",\n types: [\"contract\"],\n sources: [\"ledger\"],\n },\n },\n {\n name: \"object missing challenge\",\n value: {\n kind: ContextFieldLoaderKind.TRUSTED_NAME,\n chainId: 1,\n address: \"0x123\",\n types: [\"contract\"],\n sources: [\"ledger\"],\n },\n },\n {\n name: \"object missing types\",\n value: {\n kind: ContextFieldLoaderKind.TRUSTED_NAME,\n chainId: 1,\n address: \"0x123\",\n challenge: \"test\",\n sources: [\"ledger\"],\n },\n },\n {\n name: \"object missing sources\",\n value: {\n kind: ContextFieldLoaderKind.TRUSTED_NAME,\n chainId: 1,\n address: \"0x123\",\n challenge: \"test\",\n types: [\"contract\"],\n },\n },\n {\n name: \"object with wrong kind\",\n value: {\n kind: ContextFieldLoaderKind.TOKEN,\n chainId: 1,\n address: \"0x123\",\n challenge: \"test\",\n types: [\"contract\"],\n sources: [\"ledger\"],\n },\n },\n ];\n\n test.each(invalidFields)(\"$name\", ({ value }) => {\n expect(trustedNameContextFieldLoader.canHandle(value)).toBe(false);\n });\n });\n });\n\n describe(\"loadField\", () => {\n it(\"should return error context when trusted name data source fails\", async () => {\n // GIVEN\n const error = new Error(\"Trusted name data source error\");\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Left(error));\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: mockTransactionField.types,\n sources: mockTransactionField.sources,\n });\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: error,\n });\n });\n\n it(\"should return trusted name context when successful\", async () => {\n // GIVEN\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: mockTransactionField.types,\n sources: mockTransactionField.sources,\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload,\n });\n });\n\n it(\"should handle different chain IDs and addresses correctly\", async () => {\n // GIVEN\n const customField = {\n ...mockTransactionField,\n chainId: 137,\n address: \"0xdeadbeef\",\n challenge: \"custom-challenge\",\n };\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n\n // WHEN\n const result = await trustedNameContextFieldLoader.loadField(customField);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: 137,\n address: \"0xdeadbeef\",\n challenge: \"custom-challenge\",\n types: mockTransactionField.types,\n sources: mockTransactionField.sources,\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload,\n });\n });\n\n it(\"should handle different types and sources correctly\", async () => {\n // GIVEN\n const customField = {\n ...mockTransactionField,\n types: [\"wallet\", \"exchange\"],\n sources: [\"coingecko\", \"1inch\"],\n };\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n\n // WHEN\n const result = await trustedNameContextFieldLoader.loadField(customField);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: [\"wallet\", \"exchange\"],\n sources: [\"coingecko\", \"1inch\"],\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload,\n });\n });\n\n it(\"should preserve error message from trusted name data source\", async () => {\n // GIVEN\n const specificError = new Error(\"Network timeout error\");\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Left(specificError));\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: specificError,\n });\n });\n\n it(\"should handle empty trusted name payload\", async () => {\n // GIVEN\n const emptyPayload = \"\";\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(emptyPayload));\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: emptyPayload,\n });\n });\n\n it(\"should handle empty types and sources arrays\", async () => {\n // GIVEN\n const fieldWithEmptyArrays = {\n ...mockTransactionField,\n types: [],\n sources: [],\n };\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(fieldWithEmptyArrays);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: [],\n sources: [],\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload,\n });\n });\n\n it(\"should handle single type and source\", async () => {\n // GIVEN\n const fieldWithSingleElements = {\n ...mockTransactionField,\n types: [\"contract\"],\n sources: [\"ens\"],\n };\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n\n // WHEN\n const result = await trustedNameContextFieldLoader.loadField(\n fieldWithSingleElements,\n );\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: [\"contract\"],\n sources: [\"ens\"],\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload,\n });\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAA4B,qBAE5BC,EAAuC,8CACvCC,EAAqC,2CAGrCC,EAA8C,+DAE9C,SAAS,gCAAiC,IAAM,CAC9C,MAAMC,EAAmD,CACvD,sBAAuB,GAAG,GAAG,EAC7B,qBAAsB,GAAG,GAAG,CAC9B,EACMC,EAAgC,IAAI,gCACxCD,CACF,EAEME,EACJ,CACE,KAAM,yBAAuB,aAC7B,QAAS,EACT,QAAS,qBACT,UAAW,iBACX,MAAO,CAAC,WAAY,OAAO,EAC3B,QAAS,CAAC,SAAU,KAAK,CAC3B,EAEIC,EAAyB,qBAE/B,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,SAAS,YAAa,IAAM,CAC1B,GAAG,kDAAmD,IAAM,CAE1D,MAAMC,EAAa,CACjB,KAAM,yBAAuB,aAC7B,QAAS,EACT,QAAS,qBACT,UAAW,iBACX,MAAO,CAAC,WAAY,OAAO,EAC3B,QAAS,CAAC,SAAU,KAAK,CAC3B,EAGA,OAAOH,EAA8B,UAAUG,CAAU,CAAC,EAA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E7D,MAAMC,EAAuB,CAC3B,GAAGV,EACH,MAAO,CAAC,EACR,QAAS,CAAC,CACZ,EACA,GAAG,MACDF,EACA,uBACF,EAAE,qBAAkB,SAAMG,CAAsB,CAAC,EAGjD,MAAMK,EACJ,MAAMP,EAA8B,UAAUW,CAAoB,EAGpE,OACEZ,EAA0B,qBAC5B,EAAE,qBAAqB,CACrB,QAASE,EAAqB,QAC9B,QAASA,EAAqB,QAC9B,UAAWA,EAAqB,UAChC,MAAO,CAAC,EACR,QAAS,CAAC,CACZ,CAAC,EACD,OAAOM,CAAM,EAAE,QAAQ,CACrB,KAAM,uBAAqB,aAC3B,QAASL,CACX,CAAC,CACH,CAAC,EAED,GAAG,uCAAwC,SAAY,CAErD,MAAMU,EAA0B,CAC9B,GAAGX,EACH,MAAO,CAAC,UAAU,EAClB,QAAS,CAAC,KAAK,CACjB,EACA,GAAG,MACDF,EACA,uBACF,EAAE,qBAAkB,SAAMG,CAAsB,CAAC,EAGjD,MAAMK,EAAS,MAAMP,EAA8B,UACjDY,CACF,EAGA,OACEb,EAA0B,qBAC5B,EAAE,qBAAqB,CACrB,QAASE,EAAqB,QAC9B,QAASA,EAAqB,QAC9B,UAAWA,EAAqB,UAChC,MAAO,CAAC,UAAU,EAClB,QAAS,CAAC,KAAK,CACjB,CAAC,EACD,OAAOM,CAAM,EAAE,QAAQ,CACrB,KAAM,uBAAqB,aAC3B,QAASL,CACX,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_purify_ts", "import_ContextFieldLoader", "import_ClearSignContext", "import_TrustedNameContextFieldLoader", "mockTrustedNameDataSource", "trustedNameContextFieldLoader", "mockTransactionField", "mockTrustedNamePayload", "validField", "invalidFields", "value", "error", "result", "customField", "specificError", "emptyPayload", "fieldWithEmptyArrays", "fieldWithSingleElements"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var v=Object.create;var f=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var V=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty;var S=(r,e)=>{for(var t in e)f(r,t,{get:e[t],enumerable:!0})},I=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of E(e))!N.call(r,o)&&o!==t&&f(r,o,{get:()=>e[o],enumerable:!(i=C(e,o))||i.enumerable});return r};var _=(r,e,t)=>(t=r!=null?v(V(r)):{},I(e||!r||!r.__esModule?f(t,"default",{value:r,enumerable:!0}):t,r)),j=r=>I(f({},"__esModule",{value:!0}),r),F=(r,e,t,i)=>{for(var o=i>1?void 0:i?C(e,t):e,s=r.length-1,a;s>=0;s--)(a=r[s])&&(o=(i?a(e,t,o):a(o))||o);return i&&o&&f(e,t,o),o},x=(r,e)=>(t,i)=>e(t,i,r);var P={};S(P,{HttpTypedDataDataSource:()=>d});module.exports=j(P);var M=_(require("axios")),D=_(require("crypto-js/sha224")),m=require("inversify"),l=require("purify-ts"),T=require("../../config/di/configTypes"),g=require("../../shared/constant/HttpHeaders"),y=require("../../shared/model/TypedDataClearSignContext"),b=_(require("../../../package.json"));let d=class{constructor(e){this.config=e}async getTypedDataFilters({chainId:e,address:t,schema:i,version:o}){let s;try{const a=await M.default.request({method:"GET",url:`${this.config.cal.url}/dapps`,params:{contracts:t,chain_id:e,output:"descriptors_eip712",descriptors_eip712_version:o,descriptors_eip712:"<set>",ref:"commit:
|
|
1
|
+
"use strict";var v=Object.create;var f=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var V=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty;var S=(r,e)=>{for(var t in e)f(r,t,{get:e[t],enumerable:!0})},I=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of E(e))!N.call(r,o)&&o!==t&&f(r,o,{get:()=>e[o],enumerable:!(i=C(e,o))||i.enumerable});return r};var _=(r,e,t)=>(t=r!=null?v(V(r)):{},I(e||!r||!r.__esModule?f(t,"default",{value:r,enumerable:!0}):t,r)),j=r=>I(f({},"__esModule",{value:!0}),r),F=(r,e,t,i)=>{for(var o=i>1?void 0:i?C(e,t):e,s=r.length-1,a;s>=0;s--)(a=r[s])&&(o=(i?a(e,t,o):a(o))||o);return i&&o&&f(e,t,o),o},x=(r,e)=>(t,i)=>e(t,i,r);var P={};S(P,{HttpTypedDataDataSource:()=>d});module.exports=j(P);var M=_(require("axios")),D=_(require("crypto-js/sha224")),m=require("inversify"),l=require("purify-ts"),T=require("../../config/di/configTypes"),g=require("../../shared/constant/HttpHeaders"),y=require("../../shared/model/TypedDataClearSignContext"),b=_(require("../../../package.json"));let d=class{constructor(e){this.config=e}async getTypedDataFilters({chainId:e,address:t,schema:i,version:o}){let s;try{const a=await M.default.request({method:"GET",url:`${this.config.cal.url}/dapps`,params:{contracts:t,chain_id:e,output:"descriptors_eip712",descriptors_eip712_version:o,descriptors_eip712:"<set>",ref:"commit:cdd7d0f9cec33eb969a12641810cc7b06efeec1c"},headers:{[g.LEDGER_CLIENT_VERSION_HEADER]:`context-module/${b.default.version}`,[g.LEDGER_ORIGIN_TOKEN_HEADER]:this.config.originToken}}),c=(0,D.default)(JSON.stringify(this.sortTypes(i)).replace(" ","")).toString();t=t.toLowerCase();const u=a.data?.[0]?.descriptors_eip712?.[t]?.[c];if(!u)return(0,l.Left)(new Error(`[ContextModule] HttpTypedDataDataSource: no typed data filters for address ${t} on chain ${e} for schema ${c}`));if(!u.schema||!Array.isArray(u.instructions))return(0,l.Left)(new Error(`[ContextModule] HttpTypedDataDataSource: no message info for address ${t} on chain ${e} for schema ${c}`));const p=[],h={};for(const n of u.instructions)if(this.isInstructionContractInfo(n,this.config.cal.mode))s={displayName:n.display_name,signature:n.signatures[this.config.cal.mode],filtersCount:n.field_mappers_count};else if(o==="v1"&&this.isInstructionFieldV1(n,this.config.cal.mode))p.push({type:"raw",displayName:n.display_name,path:n.field_path,signature:n.signatures[this.config.cal.mode]});else if(this.isInstructionFieldV2(n,this.config.cal.mode))p.push({type:n.format,displayName:n.display_name,path:n.field_path,signature:n.signatures[this.config.cal.mode]});else if(this.isInstructionFieldV2WithCoinRef(n,this.config.cal.mode))p.push({type:n.format,displayName:n.display_name,path:n.field_path,signature:n.signatures[this.config.cal.mode],tokenIndex:n.coin_ref});else if(this.isInstructionFieldV2WithName(n,this.config.cal.mode))p.push({type:n.format,displayName:n.display_name,path:n.field_path,signature:n.signatures[this.config.cal.mode],types:n.name_types,sources:n.name_sources,typesAndSourcesPayload:this.formatTrustedNameTypesAndSources(n)});else if(this.isInstructionCalldataInfo(n,this.config.cal.mode))h[n.calldata_index]={displayName:n.display_name,calldataIndex:n.calldata_index,valueFlag:n.value_filter_flag,calleeFlag:this.convertCalldataPresenceFlag(n.callee_filter_flag),amountFlag:n.amount_filter_flag,spenderFlag:this.convertCalldataPresenceFlag(n.spender_filter_flag),chainIdFlag:n.chain_id_filter_flag,selectorFlag:n.selector_filter_flag,signature:n.signatures[this.config.cal.mode]};else if(this.isInstructionFieldV2Calldata(n,this.config.cal.mode))p.push({type:n.format,displayName:n.display_name,path:n.field_path,signature:n.signatures[this.config.cal.mode],calldataIndex:n.calldata_index});else return(0,l.Left)(new Error(`[ContextModule] HttpTypedDataDataSource: invalid typed data field for address ${t} on chain ${e} for schema ${c}`));return s?(0,l.Right)({messageInfo:s,filters:p,calldatasInfos:h}):(0,l.Left)(new Error(`[ContextModule] HttpTypedDataDataSource: no message info for address ${t} on chain ${e} for schema ${c}`))}catch{return(0,l.Left)(new Error("[ContextModule] HttpTypedDataDataSource: Failed to fetch typed data informations"))}}convertCalldataPresenceFlag(e){switch(e){case"none":return y.TypedDataCalldataParamPresence.None;case"present":return y.TypedDataCalldataParamPresence.Present;case"verifying_contract":return y.TypedDataCalldataParamPresence.VerifyingContract;default:{const t=e;throw new Error(`Unhandled flag: ${t}`)}}}formatTrustedNameTypesAndSources(e){const t=e.name_types.length,i=e.name_sources.length,o=e.descriptor.slice((t+i)*2*-1,i*2*-1),s=e.descriptor.slice(i*2*-1),a=t.toString(16).padStart(2,"0"),c=i.toString(16).padStart(2,"0");return a+o+c+s}isInstructionFieldV1(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"}isInstructionFieldV2(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&typeof e.format=="string"&&["raw","datetime"].includes(e.format)&&e.coin_ref===void 0}isInstructionFieldV2WithCoinRef(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&typeof e.format=="string"&&["token","amount"].includes(e.format)&&typeof e.coin_ref=="number"}isInstructionFieldV2WithName(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&typeof e.format=="string"&&e.format==="trusted-name"&&e.coin_ref===void 0&&Array.isArray(e.name_types)&&Array.isArray(e.name_sources)&&e.name_types.every(i=>typeof i=="string")&&e.name_sources.every(i=>typeof i=="string")}isInstructionContractInfo(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_mappers_count=="number"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&e.field_path===void 0}isInstructionCalldataInfo(e,t){return typeof e=="object"&&typeof e.type=="string"&&e.type==="calldata"&&typeof e.display_name=="string"&&typeof e.calldata_index=="number"&&typeof e.value_filter_flag=="boolean"&&typeof e.chain_id_filter_flag=="boolean"&&typeof e.selector_filter_flag=="boolean"&&typeof e.amount_filter_flag=="boolean"&&["none","present","verifying_contract"].includes(e.callee_filter_flag)&&["none","present","verifying_contract"].includes(e.spender_filter_flag)&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"}isInstructionFieldV2Calldata(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&typeof e.format=="string"&&["calldata-value","calldata-callee","calldata-chain-id","calldata-selector","calldata-amount","calldata-spender"].includes(e.format)&&typeof e.calldata_index=="number"}sortTypes(e){return Object.fromEntries(Object.entries(e).sort(([t],[i])=>t.localeCompare(i)).map(([t,i])=>[t,i.map(o=>({name:o.name,type:o.type}))]))}};d=F([(0,m.injectable)(),x(0,(0,m.inject)(T.configTypes.Config))],d);0&&(module.exports={HttpTypedDataDataSource});
|
|
2
2
|
//# sourceMappingURL=HttpTypedDataDataSource.js.map
|