@ledgerhq/context-module 2.6.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/lib/cjs/package.json +2 -2
  2. package/lib/cjs/src/DefaultContextModule.js +1 -1
  3. package/lib/cjs/src/DefaultContextModule.js.map +3 -3
  4. package/lib/cjs/src/DefaultContextModule.test.js +1 -1
  5. package/lib/cjs/src/DefaultContextModule.test.js.map +3 -3
  6. package/lib/cjs/src/index.js +1 -1
  7. package/lib/cjs/src/index.js.map +2 -2
  8. package/lib/cjs/src/modules/multichain/sign-reporter/data/HttpSignReporterDatasource.js +1 -1
  9. package/lib/cjs/src/modules/multichain/sign-reporter/data/HttpSignReporterDatasource.js.map +2 -2
  10. package/lib/cjs/src/modules/multichain/sign-reporter/data/HttpSignReporterDatasource.test.js +1 -1
  11. package/lib/cjs/src/modules/multichain/sign-reporter/data/HttpSignReporterDatasource.test.js.map +2 -2
  12. package/lib/cjs/src/modules/multichain/sign-reporter/data/dto/SigningEventDto.js.map +1 -1
  13. package/lib/cjs/src/modules/solana/enum-variant/domain/EnumVariantContextLoader.test.js +1 -1
  14. package/lib/cjs/src/modules/solana/enum-variant/domain/EnumVariantContextLoader.test.js.map +2 -2
  15. package/lib/cjs/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.js +1 -1
  16. package/lib/cjs/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.js.map +3 -3
  17. package/lib/cjs/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js +1 -1
  18. package/lib/cjs/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js.map +3 -3
  19. package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoDataSource.js +1 -1
  20. package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoDataSource.js.map +3 -3
  21. package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoDto.js +1 -1
  22. package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoDto.js.map +3 -3
  23. package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoMapper.js +1 -1
  24. package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoMapper.js.map +3 -3
  25. package/lib/cjs/src/modules/solana/instruction-info/di/instructionInfoModuleFactory.js +1 -1
  26. package/lib/cjs/src/modules/solana/instruction-info/di/instructionInfoModuleFactory.js.map +3 -3
  27. package/lib/cjs/src/modules/solana/instruction-info/di/instructionInfoModuleFactory.test.js +2 -0
  28. package/lib/cjs/src/modules/solana/instruction-info/di/instructionInfoModuleFactory.test.js.map +7 -0
  29. package/lib/cjs/src/modules/solana/instruction-info/di/instructionInfoTypes.js +1 -1
  30. package/lib/cjs/src/modules/solana/instruction-info/di/instructionInfoTypes.js.map +2 -2
  31. package/lib/cjs/src/modules/solana/instruction-info/domain/InstructionInfoContextLoader.test.js +1 -1
  32. package/lib/cjs/src/modules/solana/instruction-info/domain/InstructionInfoContextLoader.test.js.map +2 -2
  33. package/lib/cjs/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.js +2 -0
  34. package/lib/cjs/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.js.map +7 -0
  35. package/lib/cjs/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.test.js +2 -0
  36. package/lib/cjs/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.test.js.map +7 -0
  37. package/lib/cjs/src/modules/solana/model/SolanaClearSignContext.js +1 -1
  38. package/lib/cjs/src/modules/solana/model/SolanaClearSignContext.js.map +2 -2
  39. package/lib/cjs/src/modules/solana/model/SolanaContextTypes.js +1 -1
  40. package/lib/cjs/src/modules/solana/model/SolanaContextTypes.js.map +1 -1
  41. package/lib/cjs/src/shared/model/ClearSignContext.js +1 -1
  42. package/lib/cjs/src/shared/model/ClearSignContext.js.map +2 -2
  43. package/lib/esm/package.json +2 -2
  44. package/lib/esm/src/DefaultContextModule.js +1 -1
  45. package/lib/esm/src/DefaultContextModule.js.map +3 -3
  46. package/lib/esm/src/DefaultContextModule.test.js +1 -1
  47. package/lib/esm/src/DefaultContextModule.test.js.map +3 -3
  48. package/lib/esm/src/index.js +1 -1
  49. package/lib/esm/src/index.js.map +2 -2
  50. package/lib/esm/src/modules/multichain/sign-reporter/data/HttpSignReporterDatasource.js +1 -1
  51. package/lib/esm/src/modules/multichain/sign-reporter/data/HttpSignReporterDatasource.js.map +2 -2
  52. package/lib/esm/src/modules/multichain/sign-reporter/data/HttpSignReporterDatasource.test.js +1 -1
  53. package/lib/esm/src/modules/multichain/sign-reporter/data/HttpSignReporterDatasource.test.js.map +2 -2
  54. package/lib/esm/src/modules/solana/enum-variant/domain/EnumVariantContextLoader.test.js +1 -1
  55. package/lib/esm/src/modules/solana/enum-variant/domain/EnumVariantContextLoader.test.js.map +2 -2
  56. package/lib/esm/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.js +1 -1
  57. package/lib/esm/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.js.map +3 -3
  58. package/lib/esm/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js +1 -1
  59. package/lib/esm/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js.map +3 -3
  60. package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoDataSource.js +1 -0
  61. package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoDataSource.js.map +4 -4
  62. package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoDto.js +1 -1
  63. package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoDto.js.map +3 -3
  64. package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoMapper.js +1 -1
  65. package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoMapper.js.map +3 -3
  66. package/lib/esm/src/modules/solana/instruction-info/di/instructionInfoModuleFactory.js +1 -1
  67. package/lib/esm/src/modules/solana/instruction-info/di/instructionInfoModuleFactory.js.map +3 -3
  68. package/lib/esm/src/modules/solana/instruction-info/di/instructionInfoModuleFactory.test.js +2 -0
  69. package/lib/esm/src/modules/solana/instruction-info/di/instructionInfoModuleFactory.test.js.map +7 -0
  70. package/lib/esm/src/modules/solana/instruction-info/di/instructionInfoTypes.js +1 -1
  71. package/lib/esm/src/modules/solana/instruction-info/di/instructionInfoTypes.js.map +2 -2
  72. package/lib/esm/src/modules/solana/instruction-info/domain/InstructionInfoContextLoader.test.js +1 -1
  73. package/lib/esm/src/modules/solana/instruction-info/domain/InstructionInfoContextLoader.test.js.map +2 -2
  74. package/lib/esm/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.js +2 -0
  75. package/lib/esm/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.js.map +7 -0
  76. package/lib/esm/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.test.js +2 -0
  77. package/lib/esm/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.test.js.map +7 -0
  78. package/lib/esm/src/modules/solana/model/SolanaClearSignContext.js +1 -1
  79. package/lib/esm/src/modules/solana/model/SolanaClearSignContext.js.map +2 -2
  80. package/lib/esm/src/shared/model/ClearSignContext.js +1 -1
  81. package/lib/esm/src/shared/model/ClearSignContext.js.map +2 -2
  82. package/lib/types/src/DefaultContextModule.d.ts +1 -0
  83. package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
  84. package/lib/types/src/index.d.ts +1 -0
  85. package/lib/types/src/index.d.ts.map +1 -1
  86. package/lib/types/src/modules/multichain/sign-reporter/data/HttpSignReporterDatasource.d.ts.map +1 -1
  87. package/lib/types/src/modules/multichain/sign-reporter/data/dto/SigningEventDto.d.ts +0 -2
  88. package/lib/types/src/modules/multichain/sign-reporter/data/dto/SigningEventDto.d.ts.map +1 -1
  89. package/lib/types/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.d.ts +3 -0
  90. package/lib/types/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.d.ts.map +1 -1
  91. package/lib/types/src/modules/solana/instruction-info/data/InstructionInfoDataSource.d.ts +20 -0
  92. package/lib/types/src/modules/solana/instruction-info/data/InstructionInfoDataSource.d.ts.map +1 -1
  93. package/lib/types/src/modules/solana/instruction-info/data/InstructionInfoDto.d.ts +26 -0
  94. package/lib/types/src/modules/solana/instruction-info/data/InstructionInfoDto.d.ts.map +1 -1
  95. package/lib/types/src/modules/solana/instruction-info/data/InstructionInfoMapper.d.ts +9 -0
  96. package/lib/types/src/modules/solana/instruction-info/data/InstructionInfoMapper.d.ts.map +1 -1
  97. package/lib/types/src/modules/solana/instruction-info/di/instructionInfoModuleFactory.d.ts.map +1 -1
  98. package/lib/types/src/modules/solana/instruction-info/di/instructionInfoModuleFactory.test.d.ts +2 -0
  99. package/lib/types/src/modules/solana/instruction-info/di/instructionInfoModuleFactory.test.d.ts.map +1 -0
  100. package/lib/types/src/modules/solana/instruction-info/di/instructionInfoTypes.d.ts +1 -0
  101. package/lib/types/src/modules/solana/instruction-info/di/instructionInfoTypes.d.ts.map +1 -1
  102. package/lib/types/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.d.ts +31 -0
  103. package/lib/types/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.d.ts.map +1 -0
  104. package/lib/types/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.test.d.ts +2 -0
  105. package/lib/types/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.test.d.ts.map +1 -0
  106. package/lib/types/src/modules/solana/model/SolanaClearSignContext.d.ts +4 -0
  107. package/lib/types/src/modules/solana/model/SolanaClearSignContext.d.ts.map +1 -1
  108. package/lib/types/src/modules/solana/model/SolanaContextTypes.d.ts +20 -0
  109. package/lib/types/src/modules/solana/model/SolanaContextTypes.d.ts.map +1 -1
  110. package/lib/types/src/shared/model/ClearSignContext.d.ts +1 -0
  111. package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
  112. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  113. package/package.json +6 -6
@@ -1,2 +1,2 @@
1
- import{makeContainer as g}from"./di";import{accountOwnershipTypes as x}from"./modules/concordium/account-ownership/di/accountOwnershipTypes";import{calldataTypes as u}from"./modules/ethereum/calldata/di/calldataTypes";import{dynamicNetworkTypes as f}from"./modules/ethereum/dynamic-network/di/dynamicNetworkTypes";import{externalPluginTypes as L}from"./modules/ethereum/external-plugin/di/externalPluginTypes";import{gatedSigningTypes as p}from"./modules/ethereum/gated-signing/di/gatedSigningTypes";import{nftTypes as l}from"./modules/ethereum/nft/di/nftTypes";import{proxyTypes as y}from"./modules/ethereum/proxy/di/proxyTypes";import{safeTypes as h}from"./modules/ethereum/safe/di/safeTypes";import{tokenTypes as m}from"./modules/ethereum/token/di/tokenTypes";import{trustedNameTypes as C}from"./modules/ethereum/trusted-name/di/trustedNameTypes";import{typedDataTypes as T}from"./modules/ethereum/typed-data/di/typedDataTypes";import{reporterTypes as c}from"./modules/multichain/reporter/di/reporterTypes";import{transactionCheckTypes as s}from"./modules/multichain/transaction-check/di/transactionCheckTypes";import{altResolutionTypes as _}from"./modules/solana/alt-resolution/di/altResolutionTypes";import{enumVariantTypes as S}from"./modules/solana/enum-variant/di/enumVariantTypes";import{instructionInfoTypes as R}from"./modules/solana/instruction-info/di/instructionInfoTypes";import{lifiTypes as D}from"./modules/solana/lifi/di/lifiTypes";import{ownerInfoTypes as k}from"./modules/solana/owner-info/di/ownerInfoTypes";import{tokenTypes as v}from"./modules/solana/token/di/tokenTypes";import{tokenAccountStateTypes as F}from"./modules/solana/token-account-state/di/tokenAccountStateTypes";import{tokenInfoTypes as w}from"./modules/solana/token-info/di/tokenInfoTypes";import{solanaTrustedNameTypes as P}from"./modules/solana/trusted-name/di/trustedNameTypes";import{tokenTypes as B}from"./modules/tron/token/di/tokenTypes";import{ContextModuleChainID as o}from"./shared/domain/ContextModuleChainID";import{ClearSignContextType as i}from"./shared/model/ClearSignContext";class ie{_container;_config;_loaders;_typedDataLoader;_fieldLoaders;_blindSigningReporter;_signReporter;constructor(e){this._config=e,this._container=g({config:e}),this._loaders=e.defaultLoaders?this._getDefaultLoaders():[],this._loaders.push(...e.customLoaders),this._fieldLoaders=e.defaultFieldLoaders?this._getDefaultFieldLoaders():[],this._fieldLoaders.push(...e.customFieldLoaders),this._typedDataLoader=e.customTypedDataLoader??this._getDefaultTypedDataLoader(),this._blindSigningReporter=e.customBlindSigningReporter??this._getBlindSigningReporter(),this._signReporter=null}_getDefaultFieldLoaders(){return this._config.chain!==o.Ethereum?[]:[this._container.get(l.NftContextFieldLoader),this._container.get(m.TokenContextFieldLoader),this._container.get(C.TrustedNameContextFieldLoader),this._container.get(y.ProxyContextFieldLoader)]}_getDefaultLoaders(){const{chain:e}=this._config;switch(e){case o.Ethereum:return[this._container.get(L.ExternalPluginContextLoader),this._container.get(C.TrustedNameContextLoader),this._container.get(l.NftContextLoader),this._container.get(m.TokenContextLoader),this._container.get(u.CalldataContextLoader),this._container.get(f.DynamicNetworkContextLoader),this._container.get(h.SafeAddressLoader),this._container.get(p.GatedSigningContextLoader),this._container.get(p.GatedSigningTypedDataContextLoader),this._container.get(s.TransactionCheckLoader),this._container.get(s.TypedDataCheckLoader)];case o.Solana:return[this._container.get(v.TokenContextLoader),this._container.get(D.LifiContextLoader),this._container.get(k.OwnerInfoContextLoader),this._container.get(s.TransactionCheckLoader),this._container.get(R.InstructionInfoContextLoader),this._container.get(S.EnumVariantContextLoader),this._container.get(w.TokenInfoContextLoader),this._container.get(F.TokenAccountStateContextLoader),this._container.get(_.AltResolutionContextLoader),this._container.get(P.SolanaTrustedNameContextLoader)];case o.Concordium:return[this._container.get(x.AccountOwnershipContextLoader)];case o.Tron:return[this._container.get(B.TokenContextLoader)];default:{const t=e;return[]}}}_getDefaultTypedDataLoader(){return this._config.chain!==o.Ethereum?{load:()=>Promise.reject(new Error("[ContextModule] getTypedDataFilters is not supported for this chain"))}:this._container.get(T.TypedDataContextLoader)}_getBlindSigningReporter(){return this._container.isBound(c.BlindSigningReporter)?this._container.get(c.BlindSigningReporter):null}async getContexts(e,t){const r=Object.values(i),a=this._loaders.filter(d=>d.canHandle(e,t??r)).map(d=>d.load(e));return(await Promise.all(a)).flat()}async getFieldContext(e,t){const r=this._fieldLoaders.filter(n=>n.canHandle(e,t));if(r.length===0)return Promise.resolve({type:i.ERROR,error:new Error(`Loader not found for field: ${e} and expected type: ${t}`)});for(const n of r){const a=await n.loadField(e);if(a.type!==i.ERROR)return a}return{type:i.ERROR,error:new Error(`Loader not found for field: ${e} and expected type: ${t}`)}}async getTypedDataFilters(e){return this._typedDataLoader.load(e)}async report(e){await this._blindSigningReporter?.report(e)}async signReport(e){await this._signReporter?.report(e)}}export{ie as DefaultContextModule};
1
+ import{makeContainer as x}from"./di";import{accountOwnershipTypes as f}from"./modules/concordium/account-ownership/di/accountOwnershipTypes";import{calldataTypes as L}from"./modules/ethereum/calldata/di/calldataTypes";import{dynamicNetworkTypes as y}from"./modules/ethereum/dynamic-network/di/dynamicNetworkTypes";import{externalPluginTypes as h}from"./modules/ethereum/external-plugin/di/externalPluginTypes";import{gatedSigningTypes as p}from"./modules/ethereum/gated-signing/di/gatedSigningTypes";import{nftTypes as l}from"./modules/ethereum/nft/di/nftTypes";import{proxyTypes as _}from"./modules/ethereum/proxy/di/proxyTypes";import{safeTypes as T}from"./modules/ethereum/safe/di/safeTypes";import{tokenTypes as m}from"./modules/ethereum/token/di/tokenTypes";import{trustedNameTypes as C}from"./modules/ethereum/trusted-name/di/trustedNameTypes";import{typedDataTypes as S}from"./modules/ethereum/typed-data/di/typedDataTypes";import{reporterTypes as g}from"./modules/multichain/reporter/di/reporterTypes";import{signReporterTypes as c}from"./modules/multichain/sign-reporter/di/signReporterTypes";import{transactionCheckTypes as s}from"./modules/multichain/transaction-check/di/transactionCheckTypes";import{altResolutionTypes as R}from"./modules/solana/alt-resolution/di/altResolutionTypes";import{enumVariantTypes as D}from"./modules/solana/enum-variant/di/enumVariantTypes";import{instructionInfoTypes as u}from"./modules/solana/instruction-info/di/instructionInfoTypes";import{lifiTypes as k}from"./modules/solana/lifi/di/lifiTypes";import{ownerInfoTypes as v}from"./modules/solana/owner-info/di/ownerInfoTypes";import{tokenTypes as F}from"./modules/solana/token/di/tokenTypes";import{tokenAccountStateTypes as w}from"./modules/solana/token-account-state/di/tokenAccountStateTypes";import{tokenInfoTypes as P}from"./modules/solana/token-info/di/tokenInfoTypes";import{solanaTrustedNameTypes as B}from"./modules/solana/trusted-name/di/trustedNameTypes";import{tokenTypes as E}from"./modules/tron/token/di/tokenTypes";import{ContextModuleChainID as o}from"./shared/domain/ContextModuleChainID";import{ClearSignContextType as a}from"./shared/model/ClearSignContext";class se{_container;_config;_loaders;_typedDataLoader;_fieldLoaders;_blindSigningReporter;_signReporter;constructor(e){this._config=e,this._container=x({config:e}),this._loaders=e.defaultLoaders?this._getDefaultLoaders():[],this._loaders.push(...e.customLoaders),this._fieldLoaders=e.defaultFieldLoaders?this._getDefaultFieldLoaders():[],this._fieldLoaders.push(...e.customFieldLoaders),this._typedDataLoader=e.customTypedDataLoader??this._getDefaultTypedDataLoader(),this._blindSigningReporter=e.customBlindSigningReporter??this._getBlindSigningReporter(),this._signReporter=this._getSignReporter()}_getDefaultFieldLoaders(){return this._config.chain!==o.Ethereum?[]:[this._container.get(l.NftContextFieldLoader),this._container.get(m.TokenContextFieldLoader),this._container.get(C.TrustedNameContextFieldLoader),this._container.get(_.ProxyContextFieldLoader)]}_getDefaultLoaders(){const{chain:e}=this._config;switch(e){case o.Ethereum:return[this._container.get(h.ExternalPluginContextLoader),this._container.get(C.TrustedNameContextLoader),this._container.get(l.NftContextLoader),this._container.get(m.TokenContextLoader),this._container.get(L.CalldataContextLoader),this._container.get(y.DynamicNetworkContextLoader),this._container.get(T.SafeAddressLoader),this._container.get(p.GatedSigningContextLoader),this._container.get(p.GatedSigningTypedDataContextLoader),this._container.get(s.TransactionCheckLoader),this._container.get(s.TypedDataCheckLoader)];case o.Solana:return[this._container.get(F.TokenContextLoader),this._container.get(k.LifiContextLoader),this._container.get(v.OwnerInfoContextLoader),this._container.get(s.TransactionCheckLoader),this._container.get(u.InstructionInfoContextLoader),this._container.get(D.EnumVariantContextLoader),this._container.get(P.TokenInfoContextLoader),this._container.get(w.TokenAccountStateContextLoader),this._container.get(R.AltResolutionContextLoader),this._container.get(B.SolanaTrustedNameContextLoader),this._container.get(u.SolanaBasicFlowRuleContextLoader)];case o.Concordium:return[this._container.get(f.AccountOwnershipContextLoader)];case o.Tron:return[this._container.get(E.TokenContextLoader)];default:{const t=e;return[]}}}_getDefaultTypedDataLoader(){return this._config.chain!==o.Ethereum?{load:()=>Promise.reject(new Error("[ContextModule] getTypedDataFilters is not supported for this chain"))}:this._container.get(S.TypedDataContextLoader)}_getBlindSigningReporter(){return this._container.isBound(g.BlindSigningReporter)?this._container.get(g.BlindSigningReporter):null}_getSignReporter(){return this._container.isBound(c.SignReporter)?this._container.get(c.SignReporter):null}async getContexts(e,t){const r=Object.values(a),i=this._loaders.filter(d=>d.canHandle(e,t??r)).map(d=>d.load(e));return(await Promise.all(i)).flat()}async getFieldContext(e,t){const r=this._fieldLoaders.filter(n=>n.canHandle(e,t));if(r.length===0)return Promise.resolve({type:a.ERROR,error:new Error(`Loader not found for field: ${e} and expected type: ${t}`)});for(const n of r){const i=await n.loadField(e);if(i.type!==a.ERROR)return i}return{type:a.ERROR,error:new Error(`Loader not found for field: ${e} and expected type: ${t}`)}}async getTypedDataFilters(e){return this._typedDataLoader.load(e)}async report(e){await this._blindSigningReporter?.report(e)}async signReport(e){await this._signReporter?.report(e)}}export{se as DefaultContextModule};
2
2
  //# sourceMappingURL=DefaultContextModule.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/DefaultContextModule.ts"],
4
- "sourcesContent": ["import { type Container } from \"inversify\";\n\nimport {\n type ContextModuleLoaderConfig,\n type ContextModuleServiceConfig,\n} from \"@/config/model/ContextModuleConfig\";\nimport { type ContextModule } from \"@/ContextModule\";\nimport { makeContainer } from \"@/di\";\nimport { accountOwnershipTypes } from \"@/modules/concordium/account-ownership/di/accountOwnershipTypes\";\nimport { calldataTypes } from \"@/modules/ethereum/calldata/di/calldataTypes\";\nimport { dynamicNetworkTypes } from \"@/modules/ethereum/dynamic-network/di/dynamicNetworkTypes\";\nimport { externalPluginTypes } from \"@/modules/ethereum/external-plugin/di/externalPluginTypes\";\nimport { gatedSigningTypes } from \"@/modules/ethereum/gated-signing/di/gatedSigningTypes\";\nimport type { TypedDataClearSignContext } from \"@/modules/ethereum/model/TypedDataClearSignContext\";\nimport type { TypedDataContext } from \"@/modules/ethereum/model/TypedDataContext\";\nimport { nftTypes } from \"@/modules/ethereum/nft/di/nftTypes\";\nimport { proxyTypes } from \"@/modules/ethereum/proxy/di/proxyTypes\";\nimport { safeTypes } from \"@/modules/ethereum/safe/di/safeTypes\";\nimport { tokenTypes as ethereumTokenTypes } from \"@/modules/ethereum/token/di/tokenTypes\";\nimport { trustedNameTypes } from \"@/modules/ethereum/trusted-name/di/trustedNameTypes\";\nimport { typedDataTypes } from \"@/modules/ethereum/typed-data/di/typedDataTypes\";\nimport type { TypedDataContextLoader } from \"@/modules/ethereum/typed-data/domain/TypedDataContextLoader\";\nimport { type BlindSigningReportParams } from \"@/modules/multichain/reporter/data/BlindSigningReporterDatasource\";\nimport { reporterTypes } from \"@/modules/multichain/reporter/di/reporterTypes\";\nimport { type BlindSigningReporter } from \"@/modules/multichain/reporter/domain/BlindSigningReporter\";\nimport { type SignReporter } from \"@/modules/multichain/sign-reporter/domain/SignReporter\";\nimport { type SignReportParams } from \"@/modules/multichain/sign-reporter/model/SignReportParams\";\nimport { transactionCheckTypes } from \"@/modules/multichain/transaction-check/di/transactionCheckTypes\";\nimport { altResolutionTypes } from \"@/modules/solana/alt-resolution/di/altResolutionTypes\";\nimport { enumVariantTypes } from \"@/modules/solana/enum-variant/di/enumVariantTypes\";\nimport { instructionInfoTypes } from \"@/modules/solana/instruction-info/di/instructionInfoTypes\";\nimport { lifiTypes } from \"@/modules/solana/lifi/di/lifiTypes\";\nimport { ownerInfoTypes } from \"@/modules/solana/owner-info/di/ownerInfoTypes\";\nimport { tokenTypes as solanaTokenTypes } from \"@/modules/solana/token/di/tokenTypes\";\nimport { tokenAccountStateTypes } from \"@/modules/solana/token-account-state/di/tokenAccountStateTypes\";\nimport { tokenInfoTypes } from \"@/modules/solana/token-info/di/tokenInfoTypes\";\nimport { solanaTrustedNameTypes } from \"@/modules/solana/trusted-name/di/trustedNameTypes\";\nimport { tokenTypes as tronTokenTypes } from \"@/modules/tron/token/di/tokenTypes\";\nimport { type ContextFieldLoader } from \"@/shared/domain/ContextFieldLoader\";\nimport { type ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport { ContextModuleChainID } from \"@/shared/domain/ContextModuleChainID\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\n\nexport class DefaultContextModule implements ContextModule {\n private _container: Container;\n private _config: ContextModuleServiceConfig & ContextModuleLoaderConfig;\n private _loaders: ContextLoader<unknown>[];\n private _typedDataLoader: TypedDataContextLoader;\n private _fieldLoaders: ContextFieldLoader<unknown>[];\n private _blindSigningReporter: BlindSigningReporter | null;\n private _signReporter: SignReporter | null;\n\n constructor(args: ContextModuleServiceConfig & ContextModuleLoaderConfig) {\n this._config = args;\n this._container = makeContainer({ config: args });\n\n this._loaders = args.defaultLoaders ? this._getDefaultLoaders() : [];\n this._loaders.push(...args.customLoaders);\n\n this._fieldLoaders = args.defaultFieldLoaders\n ? this._getDefaultFieldLoaders()\n : [];\n this._fieldLoaders.push(...args.customFieldLoaders);\n\n this._typedDataLoader =\n args.customTypedDataLoader ?? this._getDefaultTypedDataLoader();\n this._blindSigningReporter =\n args.customBlindSigningReporter ?? this._getBlindSigningReporter();\n this._signReporter = null;\n }\n\n private _getDefaultFieldLoaders(): ContextFieldLoader[] {\n if (this._config.chain !== ContextModuleChainID.Ethereum) return [];\n return [\n this._container.get<ContextFieldLoader>(nftTypes.NftContextFieldLoader),\n this._container.get<ContextFieldLoader>(\n ethereumTokenTypes.TokenContextFieldLoader,\n ),\n this._container.get<ContextFieldLoader>(\n trustedNameTypes.TrustedNameContextFieldLoader,\n ),\n this._container.get<ContextFieldLoader>(\n proxyTypes.ProxyContextFieldLoader,\n ),\n ];\n }\n\n private _getDefaultLoaders(): ContextLoader<unknown>[] {\n const { chain } = this._config;\n switch (chain) {\n case ContextModuleChainID.Ethereum:\n return [\n this._container.get<ContextLoader>(\n externalPluginTypes.ExternalPluginContextLoader,\n ),\n this._container.get<ContextLoader>(\n trustedNameTypes.TrustedNameContextLoader,\n ),\n this._container.get<ContextLoader>(nftTypes.NftContextLoader),\n this._container.get<ContextLoader>(\n ethereumTokenTypes.TokenContextLoader,\n ),\n this._container.get<ContextLoader>(\n calldataTypes.CalldataContextLoader,\n ),\n this._container.get<ContextLoader>(\n dynamicNetworkTypes.DynamicNetworkContextLoader,\n ),\n this._container.get<ContextLoader>(safeTypes.SafeAddressLoader),\n this._container.get<ContextLoader>(\n gatedSigningTypes.GatedSigningContextLoader,\n ),\n this._container.get<ContextLoader>(\n gatedSigningTypes.GatedSigningTypedDataContextLoader,\n ),\n this._container.get<ContextLoader>(\n transactionCheckTypes.TransactionCheckLoader,\n ),\n this._container.get<ContextLoader>(\n transactionCheckTypes.TypedDataCheckLoader,\n ),\n ];\n case ContextModuleChainID.Solana:\n return [\n this._container.get<ContextLoader>(\n solanaTokenTypes.TokenContextLoader,\n ),\n this._container.get<ContextLoader>(lifiTypes.LifiContextLoader),\n this._container.get<ContextLoader>(\n ownerInfoTypes.OwnerInfoContextLoader,\n ),\n this._container.get<ContextLoader>(\n transactionCheckTypes.TransactionCheckLoader,\n ),\n this._container.get<ContextLoader>(\n instructionInfoTypes.InstructionInfoContextLoader,\n ),\n this._container.get<ContextLoader>(\n enumVariantTypes.EnumVariantContextLoader,\n ),\n this._container.get<ContextLoader>(\n tokenInfoTypes.TokenInfoContextLoader,\n ),\n this._container.get<ContextLoader>(\n tokenAccountStateTypes.TokenAccountStateContextLoader,\n ),\n this._container.get<ContextLoader>(\n altResolutionTypes.AltResolutionContextLoader,\n ),\n this._container.get<ContextLoader>(\n solanaTrustedNameTypes.SolanaTrustedNameContextLoader,\n ),\n ];\n case ContextModuleChainID.Concordium:\n return [\n this._container.get<ContextLoader>(\n accountOwnershipTypes.AccountOwnershipContextLoader,\n ),\n ];\n case ContextModuleChainID.Tron:\n return [\n this._container.get<ContextLoader>(tronTokenTypes.TokenContextLoader),\n ];\n default: {\n const exhaustiveCheck: never = chain;\n void exhaustiveCheck;\n return [];\n }\n }\n }\n\n private _getDefaultTypedDataLoader(): TypedDataContextLoader {\n if (this._config.chain !== ContextModuleChainID.Ethereum) {\n return {\n load: () =>\n Promise.reject(\n new Error(\n \"[ContextModule] getTypedDataFilters is not supported for this chain\",\n ),\n ),\n };\n }\n return this._container.get<TypedDataContextLoader>(\n typedDataTypes.TypedDataContextLoader,\n );\n }\n\n private _getBlindSigningReporter(): BlindSigningReporter | null {\n if (this._container.isBound(reporterTypes.BlindSigningReporter)) {\n return this._container.get<BlindSigningReporter>(\n reporterTypes.BlindSigningReporter,\n );\n }\n return null;\n }\n\n public async getContexts(\n input: unknown,\n expectedTypes?: ClearSignContextType[],\n ): Promise<ClearSignContext[]> {\n const allContextTypes = Object.values(ClearSignContextType);\n const loaders = this._loaders.filter((l) =>\n l.canHandle(input, expectedTypes ?? allContextTypes),\n );\n const promises = loaders.map((fetcher) => fetcher.load(input));\n const responses = await Promise.all(promises);\n return responses.flat();\n }\n\n public async getFieldContext<TInput>(\n field: TInput,\n expectedType: ClearSignContextType,\n ): Promise<ClearSignContext> {\n const loaders = this._fieldLoaders.filter((l) =>\n l.canHandle(field, expectedType),\n );\n if (loaders.length === 0) {\n return Promise.resolve({\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${field} and expected type: ${expectedType}`,\n ),\n });\n }\n\n for (const loader of loaders) {\n const context = await loader.loadField(field);\n if (context.type !== ClearSignContextType.ERROR) {\n return context;\n }\n }\n\n return {\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${field} and expected type: ${expectedType}`,\n ),\n };\n }\n\n public async getTypedDataFilters(\n typedData: TypedDataContext,\n ): Promise<TypedDataClearSignContext> {\n return this._typedDataLoader.load(typedData);\n }\n\n public async report(params: BlindSigningReportParams): Promise<void> {\n await this._blindSigningReporter?.report(params);\n }\n\n public async signReport(params: SignReportParams): Promise<void> {\n await this._signReporter?.report(params);\n }\n}\n"],
5
- "mappings": "AAOA,OAAS,iBAAAA,MAAqB,OAC9B,OAAS,yBAAAC,MAA6B,kEACtC,OAAS,iBAAAC,MAAqB,+CAC9B,OAAS,uBAAAC,MAA2B,4DACpC,OAAS,uBAAAC,MAA2B,4DACpC,OAAS,qBAAAC,MAAyB,wDAGlC,OAAS,YAAAC,MAAgB,qCACzB,OAAS,cAAAC,MAAkB,yCAC3B,OAAS,aAAAC,MAAiB,uCAC1B,OAAS,cAAcC,MAA0B,yCACjD,OAAS,oBAAAC,MAAwB,sDACjC,OAAS,kBAAAC,MAAsB,kDAG/B,OAAS,iBAAAC,MAAqB,iDAI9B,OAAS,yBAAAC,MAA6B,kEACtC,OAAS,sBAAAC,MAA0B,wDACnC,OAAS,oBAAAC,MAAwB,oDACjC,OAAS,wBAAAC,MAA4B,4DACrC,OAAS,aAAAC,MAAiB,qCAC1B,OAAS,kBAAAC,MAAsB,gDAC/B,OAAS,cAAcC,MAAwB,uCAC/C,OAAS,0BAAAC,MAA8B,iEACvC,OAAS,kBAAAC,MAAsB,gDAC/B,OAAS,0BAAAC,MAA8B,oDACvC,OAAS,cAAcC,MAAsB,qCAG7C,OAAS,wBAAAC,MAA4B,uCACrC,OAEE,wBAAAC,MACK,kCAEA,MAAMC,EAA8C,CACjD,WACA,QACA,SACA,iBACA,cACA,sBACA,cAER,YAAYC,EAA8D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,EACA,GAAIC,EAAQ,SAAW,EACrB,OAAO,QAAQ,QAAQ,CACrB,KAAMb,EAAqB,MAC3B,MAAO,IAAI,MACT,+BAA+BW,CAAK,uBAAuBC,CAAY,EACzE,CACF,CAAC,EAGH,UAAWE,KAAUD,EAAS,CAC5B,MAAME,EAAU,MAAMD,EAAO,UAAUH,CAAK,EAC5C,GAAII,EAAQ,OAASf,EAAqB,MACxC,OAAOe,CAEX,CAEA,MAAO,CACL,KAAMf,EAAqB,MAC3B,MAAO,IAAI,MACT,+BAA+BW,CAAK,uBAAuBC,CAAY,EACzE,CACF,CACF,CAEA,MAAa,oBACXI,EACoC,CACpC,OAAO,KAAK,iBAAiB,KAAKA,CAAS,CAC7C,CAEA,MAAa,OAAOC,EAAiD,CACnE,MAAM,KAAK,uBAAuB,OAAOA,CAAM,CACjD,CAEA,MAAa,WAAWA,EAAyC,CAC/D,MAAM,KAAK,eAAe,OAAOA,CAAM,CACzC,CACF",
6
- "names": ["makeContainer", "accountOwnershipTypes", "calldataTypes", "dynamicNetworkTypes", "externalPluginTypes", "gatedSigningTypes", "nftTypes", "proxyTypes", "safeTypes", "ethereumTokenTypes", "trustedNameTypes", "typedDataTypes", "reporterTypes", "transactionCheckTypes", "altResolutionTypes", "enumVariantTypes", "instructionInfoTypes", "lifiTypes", "ownerInfoTypes", "solanaTokenTypes", "tokenAccountStateTypes", "tokenInfoTypes", "solanaTrustedNameTypes", "tronTokenTypes", "ContextModuleChainID", "ClearSignContextType", "DefaultContextModule", "args", "chain", "exhaustiveCheck", "input", "expectedTypes", "allContextTypes", "promises", "l", "fetcher", "field", "expectedType", "loaders", "loader", "context", "typedData", "params"]
4
+ "sourcesContent": ["import { type Container } from \"inversify\";\n\nimport {\n type ContextModuleLoaderConfig,\n type ContextModuleServiceConfig,\n} from \"@/config/model/ContextModuleConfig\";\nimport { type ContextModule } from \"@/ContextModule\";\nimport { makeContainer } from \"@/di\";\nimport { accountOwnershipTypes } from \"@/modules/concordium/account-ownership/di/accountOwnershipTypes\";\nimport { calldataTypes } from \"@/modules/ethereum/calldata/di/calldataTypes\";\nimport { dynamicNetworkTypes } from \"@/modules/ethereum/dynamic-network/di/dynamicNetworkTypes\";\nimport { externalPluginTypes } from \"@/modules/ethereum/external-plugin/di/externalPluginTypes\";\nimport { gatedSigningTypes } from \"@/modules/ethereum/gated-signing/di/gatedSigningTypes\";\nimport type { TypedDataClearSignContext } from \"@/modules/ethereum/model/TypedDataClearSignContext\";\nimport type { TypedDataContext } from \"@/modules/ethereum/model/TypedDataContext\";\nimport { nftTypes } from \"@/modules/ethereum/nft/di/nftTypes\";\nimport { proxyTypes } from \"@/modules/ethereum/proxy/di/proxyTypes\";\nimport { safeTypes } from \"@/modules/ethereum/safe/di/safeTypes\";\nimport { tokenTypes as ethereumTokenTypes } from \"@/modules/ethereum/token/di/tokenTypes\";\nimport { trustedNameTypes } from \"@/modules/ethereum/trusted-name/di/trustedNameTypes\";\nimport { typedDataTypes } from \"@/modules/ethereum/typed-data/di/typedDataTypes\";\nimport type { TypedDataContextLoader } from \"@/modules/ethereum/typed-data/domain/TypedDataContextLoader\";\nimport { type BlindSigningReportParams } from \"@/modules/multichain/reporter/data/BlindSigningReporterDatasource\";\nimport { reporterTypes } from \"@/modules/multichain/reporter/di/reporterTypes\";\nimport { type BlindSigningReporter } from \"@/modules/multichain/reporter/domain/BlindSigningReporter\";\nimport { signReporterTypes } from \"@/modules/multichain/sign-reporter/di/signReporterTypes\";\nimport { type SignReporter } from \"@/modules/multichain/sign-reporter/domain/SignReporter\";\nimport { type SignReportParams } from \"@/modules/multichain/sign-reporter/model/SignReportParams\";\nimport { transactionCheckTypes } from \"@/modules/multichain/transaction-check/di/transactionCheckTypes\";\nimport { altResolutionTypes } from \"@/modules/solana/alt-resolution/di/altResolutionTypes\";\nimport { enumVariantTypes } from \"@/modules/solana/enum-variant/di/enumVariantTypes\";\nimport { instructionInfoTypes } from \"@/modules/solana/instruction-info/di/instructionInfoTypes\";\nimport { lifiTypes } from \"@/modules/solana/lifi/di/lifiTypes\";\nimport { ownerInfoTypes } from \"@/modules/solana/owner-info/di/ownerInfoTypes\";\nimport { tokenTypes as solanaTokenTypes } from \"@/modules/solana/token/di/tokenTypes\";\nimport { tokenAccountStateTypes } from \"@/modules/solana/token-account-state/di/tokenAccountStateTypes\";\nimport { tokenInfoTypes } from \"@/modules/solana/token-info/di/tokenInfoTypes\";\nimport { solanaTrustedNameTypes } from \"@/modules/solana/trusted-name/di/trustedNameTypes\";\nimport { tokenTypes as tronTokenTypes } from \"@/modules/tron/token/di/tokenTypes\";\nimport { type ContextFieldLoader } from \"@/shared/domain/ContextFieldLoader\";\nimport { type ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport { ContextModuleChainID } from \"@/shared/domain/ContextModuleChainID\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\n\nexport class DefaultContextModule implements ContextModule {\n private _container: Container;\n private _config: ContextModuleServiceConfig & ContextModuleLoaderConfig;\n private _loaders: ContextLoader<unknown>[];\n private _typedDataLoader: TypedDataContextLoader;\n private _fieldLoaders: ContextFieldLoader<unknown>[];\n private _blindSigningReporter: BlindSigningReporter | null;\n private _signReporter: SignReporter | null;\n\n constructor(args: ContextModuleServiceConfig & ContextModuleLoaderConfig) {\n this._config = args;\n this._container = makeContainer({ config: args });\n\n this._loaders = args.defaultLoaders ? this._getDefaultLoaders() : [];\n this._loaders.push(...args.customLoaders);\n\n this._fieldLoaders = args.defaultFieldLoaders\n ? this._getDefaultFieldLoaders()\n : [];\n this._fieldLoaders.push(...args.customFieldLoaders);\n\n this._typedDataLoader =\n args.customTypedDataLoader ?? this._getDefaultTypedDataLoader();\n this._blindSigningReporter =\n args.customBlindSigningReporter ?? this._getBlindSigningReporter();\n this._signReporter = this._getSignReporter();\n }\n\n private _getDefaultFieldLoaders(): ContextFieldLoader[] {\n if (this._config.chain !== ContextModuleChainID.Ethereum) return [];\n return [\n this._container.get<ContextFieldLoader>(nftTypes.NftContextFieldLoader),\n this._container.get<ContextFieldLoader>(\n ethereumTokenTypes.TokenContextFieldLoader,\n ),\n this._container.get<ContextFieldLoader>(\n trustedNameTypes.TrustedNameContextFieldLoader,\n ),\n this._container.get<ContextFieldLoader>(\n proxyTypes.ProxyContextFieldLoader,\n ),\n ];\n }\n\n private _getDefaultLoaders(): ContextLoader<unknown>[] {\n const { chain } = this._config;\n switch (chain) {\n case ContextModuleChainID.Ethereum:\n return [\n this._container.get<ContextLoader>(\n externalPluginTypes.ExternalPluginContextLoader,\n ),\n this._container.get<ContextLoader>(\n trustedNameTypes.TrustedNameContextLoader,\n ),\n this._container.get<ContextLoader>(nftTypes.NftContextLoader),\n this._container.get<ContextLoader>(\n ethereumTokenTypes.TokenContextLoader,\n ),\n this._container.get<ContextLoader>(\n calldataTypes.CalldataContextLoader,\n ),\n this._container.get<ContextLoader>(\n dynamicNetworkTypes.DynamicNetworkContextLoader,\n ),\n this._container.get<ContextLoader>(safeTypes.SafeAddressLoader),\n this._container.get<ContextLoader>(\n gatedSigningTypes.GatedSigningContextLoader,\n ),\n this._container.get<ContextLoader>(\n gatedSigningTypes.GatedSigningTypedDataContextLoader,\n ),\n this._container.get<ContextLoader>(\n transactionCheckTypes.TransactionCheckLoader,\n ),\n this._container.get<ContextLoader>(\n transactionCheckTypes.TypedDataCheckLoader,\n ),\n ];\n case ContextModuleChainID.Solana:\n return [\n this._container.get<ContextLoader>(\n solanaTokenTypes.TokenContextLoader,\n ),\n this._container.get<ContextLoader>(lifiTypes.LifiContextLoader),\n this._container.get<ContextLoader>(\n ownerInfoTypes.OwnerInfoContextLoader,\n ),\n this._container.get<ContextLoader>(\n transactionCheckTypes.TransactionCheckLoader,\n ),\n this._container.get<ContextLoader>(\n instructionInfoTypes.InstructionInfoContextLoader,\n ),\n this._container.get<ContextLoader>(\n enumVariantTypes.EnumVariantContextLoader,\n ),\n this._container.get<ContextLoader>(\n tokenInfoTypes.TokenInfoContextLoader,\n ),\n this._container.get<ContextLoader>(\n tokenAccountStateTypes.TokenAccountStateContextLoader,\n ),\n this._container.get<ContextLoader>(\n altResolutionTypes.AltResolutionContextLoader,\n ),\n this._container.get<ContextLoader>(\n solanaTrustedNameTypes.SolanaTrustedNameContextLoader,\n ),\n this._container.get<ContextLoader>(\n instructionInfoTypes.SolanaBasicFlowRuleContextLoader,\n ),\n ];\n case ContextModuleChainID.Concordium:\n return [\n this._container.get<ContextLoader>(\n accountOwnershipTypes.AccountOwnershipContextLoader,\n ),\n ];\n case ContextModuleChainID.Tron:\n return [\n this._container.get<ContextLoader>(tronTokenTypes.TokenContextLoader),\n ];\n default: {\n const exhaustiveCheck: never = chain;\n void exhaustiveCheck;\n return [];\n }\n }\n }\n\n private _getDefaultTypedDataLoader(): TypedDataContextLoader {\n if (this._config.chain !== ContextModuleChainID.Ethereum) {\n return {\n load: () =>\n Promise.reject(\n new Error(\n \"[ContextModule] getTypedDataFilters is not supported for this chain\",\n ),\n ),\n };\n }\n return this._container.get<TypedDataContextLoader>(\n typedDataTypes.TypedDataContextLoader,\n );\n }\n\n private _getBlindSigningReporter(): BlindSigningReporter | null {\n if (this._container.isBound(reporterTypes.BlindSigningReporter)) {\n return this._container.get<BlindSigningReporter>(\n reporterTypes.BlindSigningReporter,\n );\n }\n return null;\n }\n\n private _getSignReporter(): SignReporter | null {\n if (this._container.isBound(signReporterTypes.SignReporter)) {\n return this._container.get<SignReporter>(signReporterTypes.SignReporter);\n }\n return null;\n }\n\n public async getContexts(\n input: unknown,\n expectedTypes?: ClearSignContextType[],\n ): Promise<ClearSignContext[]> {\n const allContextTypes = Object.values(ClearSignContextType);\n const loaders = this._loaders.filter((l) =>\n l.canHandle(input, expectedTypes ?? allContextTypes),\n );\n const promises = loaders.map((fetcher) => fetcher.load(input));\n const responses = await Promise.all(promises);\n return responses.flat();\n }\n\n public async getFieldContext<TInput>(\n field: TInput,\n expectedType: ClearSignContextType,\n ): Promise<ClearSignContext> {\n const loaders = this._fieldLoaders.filter((l) =>\n l.canHandle(field, expectedType),\n );\n if (loaders.length === 0) {\n return Promise.resolve({\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${field} and expected type: ${expectedType}`,\n ),\n });\n }\n\n for (const loader of loaders) {\n const context = await loader.loadField(field);\n if (context.type !== ClearSignContextType.ERROR) {\n return context;\n }\n }\n\n return {\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${field} and expected type: ${expectedType}`,\n ),\n };\n }\n\n public async getTypedDataFilters(\n typedData: TypedDataContext,\n ): Promise<TypedDataClearSignContext> {\n return this._typedDataLoader.load(typedData);\n }\n\n public async report(params: BlindSigningReportParams): Promise<void> {\n await this._blindSigningReporter?.report(params);\n }\n\n public async signReport(params: SignReportParams): Promise<void> {\n await this._signReporter?.report(params);\n }\n}\n"],
5
+ "mappings": "AAOA,OAAS,iBAAAA,MAAqB,OAC9B,OAAS,yBAAAC,MAA6B,kEACtC,OAAS,iBAAAC,MAAqB,+CAC9B,OAAS,uBAAAC,MAA2B,4DACpC,OAAS,uBAAAC,MAA2B,4DACpC,OAAS,qBAAAC,MAAyB,wDAGlC,OAAS,YAAAC,MAAgB,qCACzB,OAAS,cAAAC,MAAkB,yCAC3B,OAAS,aAAAC,MAAiB,uCAC1B,OAAS,cAAcC,MAA0B,yCACjD,OAAS,oBAAAC,MAAwB,sDACjC,OAAS,kBAAAC,MAAsB,kDAG/B,OAAS,iBAAAC,MAAqB,iDAE9B,OAAS,qBAAAC,MAAyB,0DAGlC,OAAS,yBAAAC,MAA6B,kEACtC,OAAS,sBAAAC,MAA0B,wDACnC,OAAS,oBAAAC,MAAwB,oDACjC,OAAS,wBAAAC,MAA4B,4DACrC,OAAS,aAAAC,MAAiB,qCAC1B,OAAS,kBAAAC,MAAsB,gDAC/B,OAAS,cAAcC,MAAwB,uCAC/C,OAAS,0BAAAC,MAA8B,iEACvC,OAAS,kBAAAC,MAAsB,gDAC/B,OAAS,0BAAAC,MAA8B,oDACvC,OAAS,c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,CAAoB,EAIpDQ,EAHU,KAAK,SAAS,OAAQC,GACpCA,EAAE,UAAUJ,EAAOC,GAAiBC,CAAe,CACrD,EACyB,IAAKG,GAAYA,EAAQ,KAAKL,CAAK,CAAC,EAE7D,OADkB,MAAM,QAAQ,IAAIG,CAAQ,GAC3B,KAAK,CACxB,CAEA,MAAa,gBACXG,EACAC,EAC2B,CAC3B,MAAMC,EAAU,KAAK,cAAc,OAAQJ,GACzCA,EAAE,UAAUE,EAAOC,CAAY,CACjC,EACA,GAAIC,EAAQ,SAAW,EACrB,OAAO,QAAQ,QAAQ,CACrB,KAAMb,EAAqB,MAC3B,MAAO,IAAI,MACT,+BAA+BW,CAAK,uBAAuBC,CAAY,EACzE,CACF,CAAC,EAGH,UAAWE,KAAUD,EAAS,CAC5B,MAAME,EAAU,MAAMD,EAAO,UAAUH,CAAK,EAC5C,GAAII,EAAQ,OAASf,EAAqB,MACxC,OAAOe,CAEX,CAEA,MAAO,CACL,KAAMf,EAAqB,MAC3B,MAAO,IAAI,MACT,+BAA+BW,CAAK,uBAAuBC,CAAY,EACzE,CACF,CACF,CAEA,MAAa,oBACXI,EACoC,CACpC,OAAO,KAAK,iBAAiB,KAAKA,CAAS,CAC7C,CAEA,MAAa,OAAOC,EAAiD,CACnE,MAAM,KAAK,uBAAuB,OAAOA,CAAM,CACjD,CAEA,MAAa,WAAWA,EAAyC,CAC/D,MAAM,KAAK,eAAe,OAAOA,CAAM,CACzC,CACF",
6
+ "names": ["makeContainer", "accountOwnershipTypes", "calldataTypes", "dynamicNetworkTypes", "externalPluginTypes", "gatedSigningTypes", "nftTypes", "proxyTypes", "safeTypes", "ethereumTokenTypes", "trustedNameTypes", "typedDataTypes", "reporterTypes", "signReporterTypes", "transactionCheckTypes", "altResolutionTypes", "enumVariantTypes", "instructionInfoTypes", "lifiTypes", "ownerInfoTypes", "solanaTokenTypes", "tokenAccountStateTypes", "tokenInfoTypes", "solanaTrustedNameTypes", "tronTokenTypes", "ContextModuleChainID", "ClearSignContextType", "DefaultContextModule", "args", "chain", "exhaustiveCheck", "input", "expectedTypes", "allContextTypes", "promises", "l", "fetcher", "field", "expectedType", "loaders", "loader", "context", "typedData", "params"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ContextModuleChainID as E}from"./shared/domain/ContextModuleChainID";import{ClearSignContextType as o}from"./shared/model/ClearSignContext";import{DefaultContextModule as d}from"./DefaultContextModule";const x=()=>({debug:vi.fn(),info:vi.fn(),warn:vi.fn(),error:vi.fn(),subscribers:[]}),u=i=>({load:vi.fn(),canHandle:vi.fn().mockReturnValue(i)}),s=()=>({canHandle:vi.fn(),loadField:vi.fn()});describe("DefaultContextModule",()=>{const i={load:vi.fn()},l={customLoaders:[],defaultLoaders:!1,defaultFieldLoaders:!1,customFieldLoaders:[],customTypedDataLoader:i,cal:{url:"https://cal/v1",mode:"prod",branch:"main"},web3checks:{url:"https://web3checks/v3"},metadataServiceDomain:{url:"https://metadata.com"},reporter:{url:"https://reporter.com"},datasource:{proxy:"default"},appSource:"third-party",chain:E.Ethereum,originToken:"originToken",loggerFactory:x};beforeEach(()=>{vi.restoreAllMocks()}),it("should initialize the context module with all the default loaders",async()=>{const t=await new d(l).getContexts({});expect(t).toEqual([])}),it("should return an empty array when no loaders",async()=>{const t=await new d(l).getContexts({});expect(t).toEqual([])}),it("should call all fetch method from metadata fetcher",async()=>{const e=u(!0);await new d({...l,customLoaders:[e,e]}).getContexts({}),expect(e.canHandle).toHaveBeenCalledTimes(2),expect(e.load).toHaveBeenCalledTimes(2)}),it("should return an array of context response",async()=>{const e=u(!0),t=[[{type:o.ETHEREUM_TOKEN,payload:"payload1"}],[{type:o.ETHEREUM_TOKEN,payload:"payload2"},{type:o.ETHEREUM_PLUGIN,payload:"payload3"}]];vi.spyOn(e,"load").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const a=await new d({...l,customLoaders:[e,e]}).getContexts({});expect(e.canHandle).toHaveBeenCalledTimes(2),expect(e.load).toHaveBeenCalledTimes(2),expect(a).toEqual(t.flat())}),it("should only call loaders that can handle the input",async()=>{const e=u(!0),t=u(!0);vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!1),vi.spyOn(e,"load").mockResolvedValue([{type:o.ETHEREUM_TOKEN,payload:"payload1"}]),vi.spyOn(t,"load").mockResolvedValue([{type:o.ETHEREUM_NFT,payload:"payload2"}]);const n=new d({...l,customLoaders:[e,t]}),a={to:"0x123",selector:"0xabc"},r=await n.getContexts(a);expect(e.canHandle).toHaveBeenCalledWith(a,Object.values(o)),expect(t.canHandle).toHaveBeenCalledWith(a,Object.values(o)),expect(e.load).toHaveBeenCalledWith(a),expect(t.load).not.toHaveBeenCalled(),expect(r).toEqual([{type:"ethereumToken",payload:"payload1"}])}),it("should use expected types if provided",async()=>{const e=u(!0);vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"load").mockResolvedValue([{type:o.ETHEREUM_TOKEN,payload:"payload1"}]);const t=new d({...l,customLoaders:[e]}),n={to:"0x123",selector:"0xabc"};await t.getContexts(n,[o.ETHEREUM_TOKEN]),expect(e.canHandle).toHaveBeenCalledWith(n,[o.ETHEREUM_TOKEN])}),it("should call the typed data loader",async()=>{await new d({...l,customTypedDataLoader:i}).getTypedDataFilters({}),expect(i.load).toHaveBeenCalledTimes(1)}),describe("getFieldContext",()=>{it("should return error when no loader can handle the field",async()=>{const e=s();vi.spyOn(e,"canHandle").mockReturnValue(!1);const t=new d({...l,customFieldLoaders:[e]}),n={type:"unknown"},a=await t.getFieldContext(n,o.ETHEREUM_TOKEN);expect(e.canHandle).toHaveBeenCalledWith(n,o.ETHEREUM_TOKEN),expect(e.loadField).not.toHaveBeenCalled(),expect(a).toEqual({type:o.ERROR,error:new Error(`Loader not found for field: ${n} and expected type: ${o.ETHEREUM_TOKEN}`)})}),it("should return context when a loader can handle the field",async()=>{const e=s(),t={type:o.ETHEREUM_TOKEN,payload:"test-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(t);const n=new d({...l,customFieldLoaders:[e]}),a={type:"token",address:"0x123"},r=await n.getFieldContext(a,o.ETHEREUM_TOKEN);expect(e.canHandle).toHaveBeenCalledWith(a,o.ETHEREUM_TOKEN),expect(e.loadField).toHaveBeenCalledWith(a),expect(r).toEqual(t)}),it("should return first context when multiple loaders can handle the field",async()=>{const e=s(),t=s(),n={type:o.ETHEREUM_TOKEN,payload:"first-payload"},a={type:o.ETHEREUM_NFT,payload:"second-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(n),vi.spyOn(t,"loadField").mockResolvedValue(a);const r=new d({...l,customFieldLoaders:[e,t]}),c={type:"multi",address:"0x123"},p=await r.getFieldContext(c,o.ETHEREUM_TOKEN);expect(e.canHandle).toHaveBeenCalledWith(c,o.ETHEREUM_TOKEN),expect(t.canHandle).toHaveBeenCalledWith(c,o.ETHEREUM_TOKEN),expect(e.loadField).toHaveBeenCalledWith(c),expect(t.loadField).not.toHaveBeenCalled(),expect(p).toEqual(n)}),it("should return second context when first context is an error",async()=>{const e=s(),t=s(),n={type:o.ERROR,error:new Error("first-error")},a={type:o.ETHEREUM_TOKEN,payload:"second-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(n),vi.spyOn(t,"loadField").mockResolvedValue(a);const r=new d({...l,customFieldLoaders:[e,t]}),c={type:"error",address:"0x123"},p=await r.getFieldContext(c,o.ETHEREUM_TOKEN);expect(e.canHandle).toHaveBeenCalledWith(c,o.ETHEREUM_TOKEN),expect(t.canHandle).toHaveBeenCalledWith(c,o.ETHEREUM_TOKEN),expect(e.loadField).toHaveBeenCalledWith(c),expect(t.loadField).toHaveBeenCalledWith(c),expect(p).toEqual(a)}),it("should handle loader rejection gracefully",async()=>{const e=s(),t=new Error("Load field failed");vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockRejectedValue(t);const n=new d({...l,customFieldLoaders:[e]}),a={type:"error",address:"0x123"};await expect(n.getFieldContext(a,o.ETHEREUM_TOKEN)).rejects.toThrow("Load field failed"),expect(e.canHandle).toHaveBeenCalledWith(a,o.ETHEREUM_TOKEN),expect(e.loadField).toHaveBeenCalledWith(a)})})});
1
+ import{Right as m}from"purify-ts";import{DefaultSignReporter as y}from"./modules/multichain/sign-reporter/domain/DefaultSignReporter";import{SolanaBasicFlowRuleContextLoader as E}from"./modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader";import{ContextModuleChainID as i}from"./shared/domain/ContextModuleChainID";import{ClearSignContextType as o}from"./shared/model/ClearSignContext";import{DefaultContextModule as d}from"./DefaultContextModule";const C=()=>({debug:vi.fn(),info:vi.fn(),warn:vi.fn(),error:vi.fn(),subscribers:[]}),u=p=>({load:vi.fn(),canHandle:vi.fn().mockReturnValue(p)}),s=()=>({canHandle:vi.fn(),loadField:vi.fn()});describe("DefaultContextModule",()=>{const p={load:vi.fn()},l={customLoaders:[],defaultLoaders:!1,defaultFieldLoaders:!1,customFieldLoaders:[],customTypedDataLoader:p,cal:{url:"https://cal/v1",mode:"prod",branch:"main"},web3checks:{url:"https://web3checks/v3"},metadataServiceDomain:{url:"https://metadata.com"},reporter:{url:"https://reporter.com"},datasource:{proxy:"default"},appSource:"third-party",chain:i.Ethereum,originToken:"originToken",loggerFactory:C};beforeEach(()=>{vi.restoreAllMocks()}),it("should initialize the context module with all the default loaders",async()=>{const t=await new d(l).getContexts({});expect(t).toEqual([])}),it("should return an empty array when no loaders",async()=>{const t=await new d(l).getContexts({});expect(t).toEqual([])}),it("should call all fetch method from metadata fetcher",async()=>{const e=u(!0);await new d({...l,customLoaders:[e,e]}).getContexts({}),expect(e.canHandle).toHaveBeenCalledTimes(2),expect(e.load).toHaveBeenCalledTimes(2)}),it("should return an array of context response",async()=>{const e=u(!0),t=[[{type:o.ETHEREUM_TOKEN,payload:"payload1"}],[{type:o.ETHEREUM_TOKEN,payload:"payload2"},{type:o.ETHEREUM_PLUGIN,payload:"payload3"}]];vi.spyOn(e,"load").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const n=await new d({...l,customLoaders:[e,e]}).getContexts({});expect(e.canHandle).toHaveBeenCalledTimes(2),expect(e.load).toHaveBeenCalledTimes(2),expect(n).toEqual(t.flat())}),it("should only call loaders that can handle the input",async()=>{const e=u(!0),t=u(!0);vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!1),vi.spyOn(e,"load").mockResolvedValue([{type:o.ETHEREUM_TOKEN,payload:"payload1"}]),vi.spyOn(t,"load").mockResolvedValue([{type:o.ETHEREUM_NFT,payload:"payload2"}]);const a=new d({...l,customLoaders:[e,t]}),n={to:"0x123",selector:"0xabc"},r=await a.getContexts(n);expect(e.canHandle).toHaveBeenCalledWith(n,Object.values(o)),expect(t.canHandle).toHaveBeenCalledWith(n,Object.values(o)),expect(e.load).toHaveBeenCalledWith(n),expect(t.load).not.toHaveBeenCalled(),expect(r).toEqual([{type:"ethereumToken",payload:"payload1"}])}),it("should use expected types if provided",async()=>{const e=u(!0);vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"load").mockResolvedValue([{type:o.ETHEREUM_TOKEN,payload:"payload1"}]);const t=new d({...l,customLoaders:[e]}),a={to:"0x123",selector:"0xabc"};await t.getContexts(a,[o.ETHEREUM_TOKEN]),expect(e.canHandle).toHaveBeenCalledWith(a,[o.ETHEREUM_TOKEN])}),it("should call the typed data loader",async()=>{await new d({...l,customTypedDataLoader:p}).getTypedDataFilters({}),expect(p.load).toHaveBeenCalledTimes(1)}),describe("getFieldContext",()=>{it("should return error when no loader can handle the field",async()=>{const e=s();vi.spyOn(e,"canHandle").mockReturnValue(!1);const t=new d({...l,customFieldLoaders:[e]}),a={type:"unknown"},n=await t.getFieldContext(a,o.ETHEREUM_TOKEN);expect(e.canHandle).toHaveBeenCalledWith(a,o.ETHEREUM_TOKEN),expect(e.loadField).not.toHaveBeenCalled(),expect(n).toEqual({type:o.ERROR,error:new Error(`Loader not found for field: ${a} and expected type: ${o.ETHEREUM_TOKEN}`)})}),it("should return context when a loader can handle the field",async()=>{const e=s(),t={type:o.ETHEREUM_TOKEN,payload:"test-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(t);const a=new d({...l,customFieldLoaders:[e]}),n={type:"token",address:"0x123"},r=await a.getFieldContext(n,o.ETHEREUM_TOKEN);expect(e.canHandle).toHaveBeenCalledWith(n,o.ETHEREUM_TOKEN),expect(e.loadField).toHaveBeenCalledWith(n),expect(r).toEqual(t)}),it("should return first context when multiple loaders can handle the field",async()=>{const e=s(),t=s(),a={type:o.ETHEREUM_TOKEN,payload:"first-payload"},n={type:o.ETHEREUM_NFT,payload:"second-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(a),vi.spyOn(t,"loadField").mockResolvedValue(n);const r=new d({...l,customFieldLoaders:[e,t]}),c={type:"multi",address:"0x123"},x=await r.getFieldContext(c,o.ETHEREUM_TOKEN);expect(e.canHandle).toHaveBeenCalledWith(c,o.ETHEREUM_TOKEN),expect(t.canHandle).toHaveBeenCalledWith(c,o.ETHEREUM_TOKEN),expect(e.loadField).toHaveBeenCalledWith(c),expect(t.loadField).not.toHaveBeenCalled(),expect(x).toEqual(a)}),it("should return second context when first context is an error",async()=>{const e=s(),t=s(),a={type:o.ERROR,error:new Error("first-error")},n={type:o.ETHEREUM_TOKEN,payload:"second-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(a),vi.spyOn(t,"loadField").mockResolvedValue(n);const r=new d({...l,customFieldLoaders:[e,t]}),c={type:"error",address:"0x123"},x=await r.getFieldContext(c,o.ETHEREUM_TOKEN);expect(e.canHandle).toHaveBeenCalledWith(c,o.ETHEREUM_TOKEN),expect(t.canHandle).toHaveBeenCalledWith(c,o.ETHEREUM_TOKEN),expect(e.loadField).toHaveBeenCalledWith(c),expect(t.loadField).toHaveBeenCalledWith(c),expect(x).toEqual(n)}),it("should handle loader rejection gracefully",async()=>{const e=s(),t=new Error("Load field failed");vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockRejectedValue(t);const a=new d({...l,customFieldLoaders:[e]}),n={type:"error",address:"0x123"};await expect(a.getFieldContext(n,o.ETHEREUM_TOKEN)).rejects.toThrow("Load field failed"),expect(e.canHandle).toHaveBeenCalledWith(n,o.ETHEREUM_TOKEN),expect(e.loadField).toHaveBeenCalledWith(n)})}),describe("signReport",()=>{const e={chain:"ETH"};it.each([i.Ethereum,i.Solana])("should delegate to the bound sign reporter for %s",async t=>{const a=vi.spyOn(y.prototype,"report").mockResolvedValue(m(void 0));await new d({...l,chain:t}).signReport(e),expect(a).toHaveBeenCalledWith(e)}),it("should be a no-op when no sign reporter is bound",async()=>{const t=vi.spyOn(y.prototype,"report");await new d({...l,chain:i.Tron}).signReport(e),expect(t).not.toHaveBeenCalled()})}),describe("Solana basic-flow rules",()=>{const e={programIds:["Stake11111111111111111111111111111111111111"],network:"solana-mainnet"},t=[o.SOLANA_BASIC_FLOW_RULE];it("should load them through getContexts on Solana",async()=>{const a=[{type:o.SOLANA_BASIC_FLOW_RULE,payload:{id:"native-staking",required:[],allowed:[]}}],n=vi.spyOn(E.prototype,"load").mockResolvedValue(a),c=await new d({...l,defaultLoaders:!0,chain:i.Solana}).getContexts(e,t);expect(n).toHaveBeenCalledWith(e),expect(c).toEqual(a)}),it("should return no contexts on a non-Solana chain",async()=>{const a=vi.spyOn(E.prototype,"load"),r=await new d({...l,defaultLoaders:!0,chain:i.Ethereum}).getContexts(e,t);expect(a).not.toHaveBeenCalled(),expect(r).toEqual([])})})});
2
2
  //# sourceMappingURL=DefaultContextModule.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/DefaultContextModule.test.ts"],
4
- "sourcesContent": ["import {\n type ContextModuleLoaderConfig,\n type ContextModuleServiceConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { type TypedDataContext } from \"./modules/ethereum/model/TypedDataContext\";\nimport type { TypedDataContextLoader } from \"./modules/ethereum/typed-data/domain/TypedDataContextLoader\";\nimport { type ContextFieldLoader } from \"./shared/domain/ContextFieldLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport { ContextModuleChainID } from \"./shared/domain/ContextModuleChainID\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst mockLoggerFactory = () => ({\n debug: vi.fn(),\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n subscribers: [],\n});\n\nconst contextLoaderStubBuilder = (canHandle: boolean): ContextLoader => {\n return {\n load: vi.fn(),\n canHandle: vi\n .fn()\n .mockReturnValue(canHandle) as unknown as ContextLoader[\"canHandle\"],\n };\n};\n\nconst fieldLoaderStubBuilder = (): ContextFieldLoader => {\n return {\n canHandle: vi.fn() as unknown as ContextFieldLoader[\"canHandle\"],\n loadField: vi.fn(),\n };\n};\n\ndescribe(\"DefaultContextModule\", () => {\n const typedDataLoader: TypedDataContextLoader = { load: vi.fn() };\n const defaultContextModuleConfig: ContextModuleServiceConfig &\n ContextModuleLoaderConfig = {\n customLoaders: [],\n defaultLoaders: false,\n defaultFieldLoaders: false,\n customFieldLoaders: [],\n customTypedDataLoader: typedDataLoader,\n cal: {\n url: \"https://cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n web3checks: {\n url: \"https://web3checks/v3\",\n },\n metadataServiceDomain: {\n url: \"https://metadata.com\",\n },\n reporter: {\n url: \"https://reporter.com\",\n },\n datasource: {\n proxy: \"default\",\n },\n appSource: \"third-party\",\n chain: ContextModuleChainID.Ethereum,\n originToken: \"originToken\",\n loggerFactory: mockLoggerFactory,\n };\n\n beforeEach(() => {\n vi.restoreAllMocks();\n });\n\n it(\"should initialize the context module with all the default loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({});\n\n expect(res).toEqual([]);\n });\n\n it(\"should return an empty array when no loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({});\n\n expect(res).toEqual([]);\n });\n\n it(\"should call all fetch method from metadata fetcher\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n await contextModule.getContexts({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n });\n\n it(\"should return an array of context response\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const responses = [\n [{ type: ClearSignContextType.ETHEREUM_TOKEN, payload: \"payload1\" }],\n [\n { type: ClearSignContextType.ETHEREUM_TOKEN, payload: \"payload2\" },\n { type: ClearSignContextType.ETHEREUM_PLUGIN, payload: \"payload3\" },\n ],\n ] as ClearSignContext[][];\n vi.spyOn(loader, \"load\")\n .mockResolvedValueOnce(responses[0]!)\n .mockResolvedValueOnce(responses[1]!);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n const res = await contextModule.getContexts({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n expect(res).toEqual(responses.flat());\n });\n\n it(\"should only call loaders that can handle the input\", async () => {\n const loader1 = contextLoaderStubBuilder(true);\n const loader2 = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(loader2, \"canHandle\").mockReturnValue(false);\n vi.spyOn(loader1, \"load\").mockResolvedValue([\n { type: ClearSignContextType.ETHEREUM_TOKEN, payload: \"payload1\" },\n ]);\n vi.spyOn(loader2, \"load\").mockResolvedValue([\n { type: ClearSignContextType.ETHEREUM_NFT, payload: \"payload2\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader1, loader2],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n const res = await contextModule.getContexts(testInput);\n\n expect(loader1.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader2.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader1.load).toHaveBeenCalledWith(testInput);\n expect(loader2.load).not.toHaveBeenCalled(); // Should not be called since canHandle returned false\n expect(res).toEqual([{ type: \"ethereumToken\", payload: \"payload1\" }]);\n });\n\n it(\"should use expected types if provided\", async () => {\n const loader = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader, \"canHandle\").mockReturnValue(true);\n\n vi.spyOn(loader, \"load\").mockResolvedValue([\n { type: ClearSignContextType.ETHEREUM_TOKEN, payload: \"payload1\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n await contextModule.getContexts(testInput, [\n ClearSignContextType.ETHEREUM_TOKEN,\n ]);\n\n expect(loader.canHandle).toHaveBeenCalledWith(testInput, [\n ClearSignContextType.ETHEREUM_TOKEN,\n ]);\n });\n\n it(\"should call the typed data loader\", async () => {\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customTypedDataLoader: typedDataLoader,\n });\n\n await contextModule.getTypedDataFilters({} as TypedDataContext);\n\n expect(typedDataLoader.load).toHaveBeenCalledTimes(1);\n });\n\n describe(\"getFieldContext\", () => {\n it(\"should return error when no loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(false);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"unknown\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n );\n expect(fieldLoader.loadField).not.toHaveBeenCalled();\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${testField} and expected type: ${ClearSignContextType.ETHEREUM_TOKEN}`,\n ),\n });\n });\n\n it(\"should return context when a loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const mockContext: ClearSignContext = {\n type: ClearSignContextType.ETHEREUM_TOKEN,\n payload: \"test-payload\",\n };\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockResolvedValue(mockContext);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"token\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext);\n });\n\n it(\"should return first context when multiple loaders can handle the field\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.ETHEREUM_TOKEN,\n payload: \"first-payload\",\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.ETHEREUM_NFT,\n payload: \"second-payload\",\n };\n\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"multi\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).not.toHaveBeenCalled();\n expect(result).toEqual(mockContext1); // Should return first context\n });\n\n it(\"should return second context when first context is an error\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.ERROR,\n error: new Error(\"first-error\"),\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.ETHEREUM_TOKEN,\n payload: \"second-payload\",\n };\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext2);\n });\n\n it(\"should handle loader rejection gracefully\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const loadError = new Error(\"Load field failed\");\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockRejectedValue(loadError);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN & THEN\n await expect(\n contextModule.getFieldContext(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n ),\n ).rejects.toThrow(\"Load field failed\");\n\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n });\n });\n});\n"],
5
- "mappings": "AAQA,OAAS,wBAAAA,MAA4B,uCACrC,OAEE,wBAAAC,MACK,kCACP,OAAS,wBAAAC,MAA4B,yBAErC,MAAMC,EAAoB,KAAO,CAC/B,MAAO,GAAG,GAAG,EACb,KAAM,GAAG,GAAG,EACZ,KAAM,GAAG,GAAG,EACZ,MAAO,GAAG,GAAG,EACb,YAAa,CAAC,CAChB,GAEMC,EAA4BC,IACzB,CACL,KAAM,GAAG,GAAG,EACZ,UAAW,GACR,GAAG,EACH,gBAAgBA,CAAS,CAC9B,GAGIC,EAAyB,KACtB,CACL,UAAW,GAAG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6C,SAAY,CAE1D,MAAMP,EAAcV,EAAuB,EACrCkB,EAAY,IAAI,MAAM,mBAAmB,EAE/C,GAAG,MAAMR,EAAa,WAAW,EAAE,gBAAgB,EAAI,EACvD,GAAG,MAAMA,EAAa,WAAW,EAAE,kBAAkBQ,CAAS,EAE9D,MAAMV,EAAgB,IAAIZ,EAAqB,CAC7C,GAAGM,EACH,mBAAoB,CAACQ,CAAW,CAClC,CAAC,EAEKC,EAAY,CAAE,KAAM,QAAS,QAAS,OAAQ,EAGpD,MAAM,OACJH,EAAc,gBACZG,EACAhB,EAAqB,cACvB,CACF,EAAE,QAAQ,QAAQ,mBAAmB,EAErC,OAAOe,EAAY,SAAS,EAAE,qBAC5BC,EACAhB,EAAqB,cACvB,EACA,OAAOe,EAAY,SAAS,EAAE,qBAAqBC,CAAS,CAC9D,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["ContextModuleChainID", "ClearSignContextType", "DefaultContextModule", "mockLoggerFactory", "contextLoaderStubBuilder", "canHandle", "fieldLoaderStubBuilder", "typedDataLoader", "defaultContextModuleConfig", "res", "loader", "responses", "loader1", "loader2", "contextModule", "testInput", "fieldLoader", "testField", "result", "mockContext", "fieldLoader1", "fieldLoader2", "mockContext1", "mockContext2", "loadError"]
4
+ "sourcesContent": ["import { Right } from \"purify-ts\";\n\nimport {\n type ContextModuleLoaderConfig,\n type ContextModuleServiceConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { type TypedDataContext } from \"./modules/ethereum/model/TypedDataContext\";\nimport type { TypedDataContextLoader } from \"./modules/ethereum/typed-data/domain/TypedDataContextLoader\";\nimport { DefaultSignReporter } from \"./modules/multichain/sign-reporter/domain/DefaultSignReporter\";\nimport { type SignReportParams } from \"./modules/multichain/sign-reporter/model/SignReportParams\";\nimport { SolanaBasicFlowRuleContextLoader } from \"./modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader\";\nimport { type ContextFieldLoader } from \"./shared/domain/ContextFieldLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport { ContextModuleChainID } from \"./shared/domain/ContextModuleChainID\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst mockLoggerFactory = () => ({\n debug: vi.fn(),\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n subscribers: [],\n});\n\nconst contextLoaderStubBuilder = (canHandle: boolean): ContextLoader => {\n return {\n load: vi.fn(),\n canHandle: vi\n .fn()\n .mockReturnValue(canHandle) as unknown as ContextLoader[\"canHandle\"],\n };\n};\n\nconst fieldLoaderStubBuilder = (): ContextFieldLoader => {\n return {\n canHandle: vi.fn() as unknown as ContextFieldLoader[\"canHandle\"],\n loadField: vi.fn(),\n };\n};\n\ndescribe(\"DefaultContextModule\", () => {\n const typedDataLoader: TypedDataContextLoader = { load: vi.fn() };\n const defaultContextModuleConfig: ContextModuleServiceConfig &\n ContextModuleLoaderConfig = {\n customLoaders: [],\n defaultLoaders: false,\n defaultFieldLoaders: false,\n customFieldLoaders: [],\n customTypedDataLoader: typedDataLoader,\n cal: {\n url: \"https://cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n web3checks: {\n url: \"https://web3checks/v3\",\n },\n metadataServiceDomain: {\n url: \"https://metadata.com\",\n },\n reporter: {\n url: \"https://reporter.com\",\n },\n datasource: {\n proxy: \"default\",\n },\n appSource: \"third-party\",\n chain: ContextModuleChainID.Ethereum,\n originToken: \"originToken\",\n loggerFactory: mockLoggerFactory,\n };\n\n beforeEach(() => {\n vi.restoreAllMocks();\n });\n\n it(\"should initialize the context module with all the default loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({});\n\n expect(res).toEqual([]);\n });\n\n it(\"should return an empty array when no loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({});\n\n expect(res).toEqual([]);\n });\n\n it(\"should call all fetch method from metadata fetcher\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n await contextModule.getContexts({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n });\n\n it(\"should return an array of context response\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const responses = [\n [{ type: ClearSignContextType.ETHEREUM_TOKEN, payload: \"payload1\" }],\n [\n { type: ClearSignContextType.ETHEREUM_TOKEN, payload: \"payload2\" },\n { type: ClearSignContextType.ETHEREUM_PLUGIN, payload: \"payload3\" },\n ],\n ] as ClearSignContext[][];\n vi.spyOn(loader, \"load\")\n .mockResolvedValueOnce(responses[0]!)\n .mockResolvedValueOnce(responses[1]!);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n const res = await contextModule.getContexts({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n expect(res).toEqual(responses.flat());\n });\n\n it(\"should only call loaders that can handle the input\", async () => {\n const loader1 = contextLoaderStubBuilder(true);\n const loader2 = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(loader2, \"canHandle\").mockReturnValue(false);\n vi.spyOn(loader1, \"load\").mockResolvedValue([\n { type: ClearSignContextType.ETHEREUM_TOKEN, payload: \"payload1\" },\n ]);\n vi.spyOn(loader2, \"load\").mockResolvedValue([\n { type: ClearSignContextType.ETHEREUM_NFT, payload: \"payload2\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader1, loader2],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n const res = await contextModule.getContexts(testInput);\n\n expect(loader1.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader2.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader1.load).toHaveBeenCalledWith(testInput);\n expect(loader2.load).not.toHaveBeenCalled(); // Should not be called since canHandle returned false\n expect(res).toEqual([{ type: \"ethereumToken\", payload: \"payload1\" }]);\n });\n\n it(\"should use expected types if provided\", async () => {\n const loader = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader, \"canHandle\").mockReturnValue(true);\n\n vi.spyOn(loader, \"load\").mockResolvedValue([\n { type: ClearSignContextType.ETHEREUM_TOKEN, payload: \"payload1\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n await contextModule.getContexts(testInput, [\n ClearSignContextType.ETHEREUM_TOKEN,\n ]);\n\n expect(loader.canHandle).toHaveBeenCalledWith(testInput, [\n ClearSignContextType.ETHEREUM_TOKEN,\n ]);\n });\n\n it(\"should call the typed data loader\", async () => {\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customTypedDataLoader: typedDataLoader,\n });\n\n await contextModule.getTypedDataFilters({} as TypedDataContext);\n\n expect(typedDataLoader.load).toHaveBeenCalledTimes(1);\n });\n\n describe(\"getFieldContext\", () => {\n it(\"should return error when no loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(false);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"unknown\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n );\n expect(fieldLoader.loadField).not.toHaveBeenCalled();\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${testField} and expected type: ${ClearSignContextType.ETHEREUM_TOKEN}`,\n ),\n });\n });\n\n it(\"should return context when a loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const mockContext: ClearSignContext = {\n type: ClearSignContextType.ETHEREUM_TOKEN,\n payload: \"test-payload\",\n };\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockResolvedValue(mockContext);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"token\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext);\n });\n\n it(\"should return first context when multiple loaders can handle the field\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.ETHEREUM_TOKEN,\n payload: \"first-payload\",\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.ETHEREUM_NFT,\n payload: \"second-payload\",\n };\n\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"multi\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).not.toHaveBeenCalled();\n expect(result).toEqual(mockContext1); // Should return first context\n });\n\n it(\"should return second context when first context is an error\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.ERROR,\n error: new Error(\"first-error\"),\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.ETHEREUM_TOKEN,\n payload: \"second-payload\",\n };\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext2);\n });\n\n it(\"should handle loader rejection gracefully\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const loadError = new Error(\"Load field failed\");\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockRejectedValue(loadError);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN & THEN\n await expect(\n contextModule.getFieldContext(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n ),\n ).rejects.toThrow(\"Load field failed\");\n\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.ETHEREUM_TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n });\n });\n\n describe(\"signReport\", () => {\n const params = { chain: \"ETH\" } as SignReportParams;\n\n it.each([ContextModuleChainID.Ethereum, ContextModuleChainID.Solana])(\n \"should delegate to the bound sign reporter for %s\",\n async (chain) => {\n // GIVEN\n const reportSpy = vi\n .spyOn(DefaultSignReporter.prototype, \"report\")\n .mockResolvedValue(Right(undefined));\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n chain,\n });\n\n // WHEN\n await contextModule.signReport(params);\n\n // THEN\n expect(reportSpy).toHaveBeenCalledWith(params);\n },\n );\n\n it(\"should be a no-op when no sign reporter is bound\", async () => {\n // GIVEN\n const reportSpy = vi.spyOn(DefaultSignReporter.prototype, \"report\");\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n chain: ContextModuleChainID.Tron,\n });\n\n // WHEN\n await contextModule.signReport(params);\n\n // THEN\n expect(reportSpy).not.toHaveBeenCalled();\n });\n });\n\n describe(\"Solana basic-flow rules\", () => {\n const input = {\n programIds: [\"Stake11111111111111111111111111111111111111\"],\n network: \"solana-mainnet\",\n };\n const expectedTypes = [ClearSignContextType.SOLANA_BASIC_FLOW_RULE];\n\n it(\"should load them through getContexts on Solana\", async () => {\n // GIVEN\n const contexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.SOLANA_BASIC_FLOW_RULE,\n payload: { id: \"native-staking\", required: [], allowed: [] },\n },\n ];\n const loadSpy = vi\n .spyOn(SolanaBasicFlowRuleContextLoader.prototype, \"load\")\n .mockResolvedValue(contexts);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n defaultLoaders: true,\n chain: ContextModuleChainID.Solana,\n });\n\n // WHEN\n const result = await contextModule.getContexts(input, expectedTypes);\n\n // THEN\n expect(loadSpy).toHaveBeenCalledWith(input);\n expect(result).toEqual(contexts);\n });\n\n it(\"should return no contexts on a non-Solana chain\", async () => {\n // GIVEN\n const loadSpy = vi.spyOn(\n SolanaBasicFlowRuleContextLoader.prototype,\n \"load\",\n );\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n defaultLoaders: true,\n chain: ContextModuleChainID.Ethereum,\n });\n\n // WHEN\n const result = await contextModule.getContexts(input, expectedTypes);\n\n // THEN\n expect(loadSpy).not.toHaveBeenCalled();\n expect(result).toEqual([]);\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,SAAAA,MAAa,YAQtB,OAAS,uBAAAC,MAA2B,gEAEpC,OAAS,oCAAAC,MAAwC,4EAGjD,OAAS,wBAAAC,MAA4B,uCACrC,OAEE,wBAAAC,MACK,kCACP,OAAS,wBAAAC,MAA4B,yBAErC,MAAMC,EAAoB,KAAO,CAC/B,MAAO,GAAG,GAAG,EACb,KAAM,GAAG,GAAG,EACZ,KAAM,GAAG,GAAG,EACZ,MAAO,GAAG,GAAG,EACb,YAAa,CAAC,CAChB,GAEMC,EAA4BC,IACzB,CACL,KAAM,GAAG,GAAG,EACZ,UAAW,GACR,GAAG,EACH,gBAAgBA,CAAS,CAC9B,GAGIC,EAAyB,KACtB,CACL,UAAW,GAAG,GAAG,EACjB,UAAW,GAAG,GAAG,CACnB,GAGF,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA0C,CAAE,KAAM,GAAG,GAAG,CAAE,EAC1DC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,uBAC3B,QAAS,CAAE,GAAI,iBAAkB,SAAU,CAAC,EAAG,QAAS,CAAC,CAAE,CAC7D,CACF,EACM8B,EAAU,GACb,MAAMhC,EAAiC,UAAW,MAAM,EACxD,kBAAkB+B,CAAQ,EAQvBZ,EAAS,MAPO,IAAIhB,EAAqB,CAC7C,GAAGM,EACH,eAAgB,GAChB,MAAOR,EAAqB,MAC9B,CAAC,EAGkC,YAAY4B,EAAOC,CAAa,EAGnE,OAAOE,CAAO,EAAE,qBAAqBH,CAAK,EAC1C,OAAOV,CAAM,EAAE,QAAQY,CAAQ,CACjC,CAAC,EAED,GAAG,kDAAmD,SAAY,CAEhE,MAAMC,EAAU,GAAG,MACjBhC,EAAiC,UACjC,MACF,EAQMmB,EAAS,MAPO,IAAIhB,EAAqB,CAC7C,GAAGM,EACH,eAAgB,GAChB,MAAOR,EAAqB,QAC9B,CAAC,EAGkC,YAAY4B,EAAOC,CAAa,EAGnE,OAAOE,CAAO,EAAE,IAAI,iBAAiB,EACrC,OAAOb,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["Right", "DefaultSignReporter", "SolanaBasicFlowRuleContextLoader", "ContextModuleChainID", "ClearSignContextType", "DefaultContextModule", "mockLoggerFactory", "contextLoaderStubBuilder", "canHandle", "fieldLoaderStubBuilder", "typedDataLoader", "defaultContextModuleConfig", "res", "loader", "responses", "loader1", "loader2", "contextModule", "testInput", "fieldLoader", "testField", "result", "mockContext", "fieldLoader1", "fieldLoader2", "mockContext1", "mockContext2", "loadError", "params", "chain", "reportSpy", "input", "expectedTypes", "contexts", "loadSpy"]
7
7
  }
@@ -1,2 +1,2 @@
1
- export*from"./ContextModule";export*from"./ContextModuleBuilder";export*from"./DefaultContextModule";export*from"./modules/concordium/account-ownership/data/AccountOwnershipDataSource";export*from"./modules/concordium/account-ownership/data/AccountOwnershipError";export*from"./modules/concordium/account-ownership/data/HttpAccountOwnershipDataSource";export*from"./modules/concordium/account-ownership/domain/AccountOwnershipContextLoader";export*from"./modules/ethereum/calldata/data/CalldataDescriptorDataSource";export*from"./modules/ethereum/calldata/data/HttpCalldataDescriptorDataSource";export*from"./modules/ethereum/calldata/domain/CalldataContextLoader";export*from"./modules/ethereum/dynamic-network/data/DynamicNetworkDataSource";export*from"./modules/ethereum/dynamic-network/data/HttpDynamicNetworkDataSource";export*from"./modules/ethereum/dynamic-network/domain/DynamicNetworkContextLoader";export*from"./modules/ethereum/dynamic-network/model/DynamicNetworkConfiguration";export*from"./modules/ethereum/external-plugin/data/ExternalPluginDataSource";export*from"./modules/ethereum/external-plugin/data/HttpExternalPluginDataSource";export*from"./modules/ethereum/external-plugin/domain/ExternalPluginContextLoader";export*from"./modules/ethereum/gated-signing/data/GatedDescriptorDataSource";export*from"./modules/ethereum/gated-signing/data/HttpGatedDescriptorDataSource";export*from"./modules/ethereum/gated-signing/domain/GatedSigningContextLoader";export*from"./modules/ethereum/gated-signing/domain/GatedSigningTypedDataContextLoader";export*from"./modules/ethereum/model/EthereumClearSignContext";export*from"./modules/ethereum/model/TypedDataClearSignContext";export*from"./modules/ethereum/model/TypedDataContext";export*from"./modules/ethereum/nft/data/HttpNftDataSource";export*from"./modules/ethereum/nft/data/NftDataSource";export*from"./modules/ethereum/nft/domain/NftContextFieldLoader";export*from"./modules/ethereum/nft/domain/NftContextLoader";export*from"./modules/ethereum/proxy/data/HttpProxyDataSource";export*from"./modules/ethereum/proxy/data/HttpSafeProxyDataSource";export*from"./modules/ethereum/proxy/data/ProxyDataSource";export*from"./modules/ethereum/proxy/domain/ProxyContextFieldLoader";export*from"./modules/ethereum/token/data/HttpTokenDataSource";export*from"./modules/ethereum/token/data/TokenDataSource";export*from"./modules/ethereum/token/domain/TokenContextFieldLoader";export*from"./modules/ethereum/token/domain/TokenContextLoader";export*from"./modules/ethereum/trusted-name/data/HttpTrustedNameDataSource";export*from"./modules/ethereum/trusted-name/data/TrustedNameDataSource";export*from"./modules/ethereum/trusted-name/domain/TrustedNameContextFieldLoader";export*from"./modules/ethereum/trusted-name/domain/TrustedNameContextLoader";export*from"./modules/ethereum/typed-data/data/HttpTypedDataDataSource";export*from"./modules/ethereum/typed-data/data/TypedDataDataSource";export*from"./modules/ethereum/typed-data/domain/DefaultTypedDataContextLoader";export*from"./modules/ethereum/typed-data/domain/TypedDataContextLoader";export*from"./modules/ethereum/typed-data/utils/getSchemaHash";export*from"./modules/ethereum/uniswap/data/AbiDecoderDataSource";export*from"./modules/ethereum/uniswap/data/CommandDecoderDataSource";export*from"./modules/ethereum/uniswap/data/DefaultCommandDecoderDataSource";export*from"./modules/ethereum/uniswap/data/EthersAbiDecoderDataSource";export*from"./modules/ethereum/uniswap/domain/UniswapContextLoader";export*from"./modules/multichain/pki/data/HttpPkiCertificateDataSource";export*from"./modules/multichain/pki/data/PkiCertificateDataSource";export*from"./modules/multichain/pki/domain/DefaultPkiCertificateLoader";export*from"./modules/multichain/pki/domain/PkiCertificateLoader";export*from"./modules/multichain/pki/model/KeyId";export*from"./modules/multichain/pki/model/KeyUsage";export*from"./modules/multichain/pki/model/PkiCertificate";export*from"./modules/multichain/pki/model/PkiCertificateInfo";export*from"./modules/multichain/reporter/data/BlindSigningReporterDatasource";export*from"./modules/multichain/reporter/data/HttpBlindSigningReporterDatasource";export*from"./modules/multichain/reporter/domain/BlindSigningReporter";export*from"./modules/multichain/reporter/domain/DefaultBlindSigningReporter";export*from"./modules/multichain/reporter/model/BlindSigningEvent";export*from"./modules/multichain/sign-reporter/model/SignReportParams";export*from"./modules/multichain/transaction-check/utils/constants";export*from"./modules/solana/alt-resolution/data/AltResolutionDataSource";export*from"./modules/solana/alt-resolution/data/HttpAltResolutionDataSource";export*from"./modules/solana/alt-resolution/domain/AltResolutionContextLoader";export*from"./modules/solana/enum-variant/domain/EnumVariantContextLoader";export*from"./modules/solana/instruction-info/data/HttpInstructionInfoDataSource";export*from"./modules/solana/instruction-info/data/InstructionInfoDataSource";export*from"./modules/solana/instruction-info/domain/InstructionInfoContextLoader";export*from"./modules/solana/model/SolanaClearSignContext";export*from"./modules/solana/model/SolanaContextTypes";export*from"./modules/solana/model/SolanaTransactionScanChainId";export*from"./modules/solana/owner-info/data/HttpOwnerInfoDataSource";export*from"./modules/solana/owner-info/data/OwnerInfoDataSource";export*from"./modules/solana/owner-info/domain/OwnerInfoContextLoader";export*from"./modules/solana/owner-info/domain/solanaContextTypes";export*from"./modules/solana/token-account-state/data/HttpTokenAccountStateDataSource";export*from"./modules/solana/token-account-state/data/TokenAccountStateDataSource";export*from"./modules/solana/token-account-state/domain/TokenAccountStateContextLoader";export*from"./modules/solana/token-info/data/HttpTokenInfoDataSource";export*from"./modules/solana/token-info/data/TokenInfoDataSource";export*from"./modules/solana/token-info/domain/TokenInfoContextLoader";export*from"./modules/solana/trusted-name/data/HttpTrustedNameDataSource";export*from"./modules/solana/trusted-name/data/TrustedNameDataSource";export*from"./modules/solana/trusted-name/domain/TrustedNameContextLoader";export*from"./modules/tron/model/TronTransactionContext";export*from"./shared/domain/ContextFieldLoader";export*from"./shared/domain/ContextLoader";export*from"./shared/domain/ContextModuleChainID";export*from"./shared/model/BlindSigningModelId";export*from"./shared/model/ClearSignContext";export*from"./shared/model/GenericPath";export*from"./shared/model/TransactionSubset";
1
+ export*from"./ContextModule";export*from"./ContextModuleBuilder";export*from"./DefaultContextModule";export*from"./modules/concordium/account-ownership/data/AccountOwnershipDataSource";export*from"./modules/concordium/account-ownership/data/AccountOwnershipError";export*from"./modules/concordium/account-ownership/data/HttpAccountOwnershipDataSource";export*from"./modules/concordium/account-ownership/domain/AccountOwnershipContextLoader";export*from"./modules/ethereum/calldata/data/CalldataDescriptorDataSource";export*from"./modules/ethereum/calldata/data/HttpCalldataDescriptorDataSource";export*from"./modules/ethereum/calldata/domain/CalldataContextLoader";export*from"./modules/ethereum/dynamic-network/data/DynamicNetworkDataSource";export*from"./modules/ethereum/dynamic-network/data/HttpDynamicNetworkDataSource";export*from"./modules/ethereum/dynamic-network/domain/DynamicNetworkContextLoader";export*from"./modules/ethereum/dynamic-network/model/DynamicNetworkConfiguration";export*from"./modules/ethereum/external-plugin/data/ExternalPluginDataSource";export*from"./modules/ethereum/external-plugin/data/HttpExternalPluginDataSource";export*from"./modules/ethereum/external-plugin/domain/ExternalPluginContextLoader";export*from"./modules/ethereum/gated-signing/data/GatedDescriptorDataSource";export*from"./modules/ethereum/gated-signing/data/HttpGatedDescriptorDataSource";export*from"./modules/ethereum/gated-signing/domain/GatedSigningContextLoader";export*from"./modules/ethereum/gated-signing/domain/GatedSigningTypedDataContextLoader";export*from"./modules/ethereum/model/EthereumClearSignContext";export*from"./modules/ethereum/model/TypedDataClearSignContext";export*from"./modules/ethereum/model/TypedDataContext";export*from"./modules/ethereum/nft/data/HttpNftDataSource";export*from"./modules/ethereum/nft/data/NftDataSource";export*from"./modules/ethereum/nft/domain/NftContextFieldLoader";export*from"./modules/ethereum/nft/domain/NftContextLoader";export*from"./modules/ethereum/proxy/data/HttpProxyDataSource";export*from"./modules/ethereum/proxy/data/HttpSafeProxyDataSource";export*from"./modules/ethereum/proxy/data/ProxyDataSource";export*from"./modules/ethereum/proxy/domain/ProxyContextFieldLoader";export*from"./modules/ethereum/token/data/HttpTokenDataSource";export*from"./modules/ethereum/token/data/TokenDataSource";export*from"./modules/ethereum/token/domain/TokenContextFieldLoader";export*from"./modules/ethereum/token/domain/TokenContextLoader";export*from"./modules/ethereum/trusted-name/data/HttpTrustedNameDataSource";export*from"./modules/ethereum/trusted-name/data/TrustedNameDataSource";export*from"./modules/ethereum/trusted-name/domain/TrustedNameContextFieldLoader";export*from"./modules/ethereum/trusted-name/domain/TrustedNameContextLoader";export*from"./modules/ethereum/typed-data/data/HttpTypedDataDataSource";export*from"./modules/ethereum/typed-data/data/TypedDataDataSource";export*from"./modules/ethereum/typed-data/domain/DefaultTypedDataContextLoader";export*from"./modules/ethereum/typed-data/domain/TypedDataContextLoader";export*from"./modules/ethereum/typed-data/utils/getSchemaHash";export*from"./modules/ethereum/uniswap/data/AbiDecoderDataSource";export*from"./modules/ethereum/uniswap/data/CommandDecoderDataSource";export*from"./modules/ethereum/uniswap/data/DefaultCommandDecoderDataSource";export*from"./modules/ethereum/uniswap/data/EthersAbiDecoderDataSource";export*from"./modules/ethereum/uniswap/domain/UniswapContextLoader";export*from"./modules/multichain/pki/data/HttpPkiCertificateDataSource";export*from"./modules/multichain/pki/data/PkiCertificateDataSource";export*from"./modules/multichain/pki/domain/DefaultPkiCertificateLoader";export*from"./modules/multichain/pki/domain/PkiCertificateLoader";export*from"./modules/multichain/pki/model/KeyId";export*from"./modules/multichain/pki/model/KeyUsage";export*from"./modules/multichain/pki/model/PkiCertificate";export*from"./modules/multichain/pki/model/PkiCertificateInfo";export*from"./modules/multichain/reporter/data/BlindSigningReporterDatasource";export*from"./modules/multichain/reporter/data/HttpBlindSigningReporterDatasource";export*from"./modules/multichain/reporter/domain/BlindSigningReporter";export*from"./modules/multichain/reporter/domain/DefaultBlindSigningReporter";export*from"./modules/multichain/reporter/model/BlindSigningEvent";export*from"./modules/multichain/sign-reporter/model/SignReportParams";export*from"./modules/multichain/transaction-check/utils/constants";export*from"./modules/solana/alt-resolution/data/AltResolutionDataSource";export*from"./modules/solana/alt-resolution/data/HttpAltResolutionDataSource";export*from"./modules/solana/alt-resolution/domain/AltResolutionContextLoader";export*from"./modules/solana/enum-variant/domain/EnumVariantContextLoader";export*from"./modules/solana/instruction-info/data/HttpInstructionInfoDataSource";export*from"./modules/solana/instruction-info/data/InstructionInfoDataSource";export*from"./modules/solana/instruction-info/domain/InstructionInfoContextLoader";export*from"./modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader";export*from"./modules/solana/model/SolanaClearSignContext";export*from"./modules/solana/model/SolanaContextTypes";export*from"./modules/solana/model/SolanaTransactionScanChainId";export*from"./modules/solana/owner-info/data/HttpOwnerInfoDataSource";export*from"./modules/solana/owner-info/data/OwnerInfoDataSource";export*from"./modules/solana/owner-info/domain/OwnerInfoContextLoader";export*from"./modules/solana/owner-info/domain/solanaContextTypes";export*from"./modules/solana/token-account-state/data/HttpTokenAccountStateDataSource";export*from"./modules/solana/token-account-state/data/TokenAccountStateDataSource";export*from"./modules/solana/token-account-state/domain/TokenAccountStateContextLoader";export*from"./modules/solana/token-info/data/HttpTokenInfoDataSource";export*from"./modules/solana/token-info/data/TokenInfoDataSource";export*from"./modules/solana/token-info/domain/TokenInfoContextLoader";export*from"./modules/solana/trusted-name/data/HttpTrustedNameDataSource";export*from"./modules/solana/trusted-name/data/TrustedNameDataSource";export*from"./modules/solana/trusted-name/domain/TrustedNameContextLoader";export*from"./modules/tron/model/TronTransactionContext";export*from"./shared/domain/ContextFieldLoader";export*from"./shared/domain/ContextLoader";export*from"./shared/domain/ContextModuleChainID";export*from"./shared/model/BlindSigningModelId";export*from"./shared/model/ClearSignContext";export*from"./shared/model/GenericPath";export*from"./shared/model/TransactionSubset";
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/index.ts"],
4
- "sourcesContent": ["export type {\n ContextModuleCalBranch,\n ContextModuleCalConfig,\n ContextModuleCalMode,\n ContextModuleConfig,\n ContextModuleDatasourceConfig,\n ContextModuleMetadataServiceConfig,\n ContextModuleReporterConfig,\n ContextModuleWeb3ChecksConfig,\n} from \"./config/model/ContextModuleConfig\";\nexport * from \"./ContextModule\";\nexport * from \"./ContextModuleBuilder\";\nexport * from \"./DefaultContextModule\";\nexport * from \"./modules/concordium/account-ownership/data/AccountOwnershipDataSource\";\nexport * from \"./modules/concordium/account-ownership/data/AccountOwnershipError\";\nexport * from \"./modules/concordium/account-ownership/data/HttpAccountOwnershipDataSource\";\nexport * from \"./modules/concordium/account-ownership/domain/AccountOwnershipContextLoader\";\nexport * from \"./modules/ethereum/calldata/data/CalldataDescriptorDataSource\";\nexport * from \"./modules/ethereum/calldata/data/HttpCalldataDescriptorDataSource\";\nexport * from \"./modules/ethereum/calldata/domain/CalldataContextLoader\";\nexport * from \"./modules/ethereum/dynamic-network/data/DynamicNetworkDataSource\";\nexport * from \"./modules/ethereum/dynamic-network/data/HttpDynamicNetworkDataSource\";\nexport * from \"./modules/ethereum/dynamic-network/domain/DynamicNetworkContextLoader\";\nexport * from \"./modules/ethereum/dynamic-network/model/DynamicNetworkConfiguration\";\nexport * from \"./modules/ethereum/external-plugin/data/ExternalPluginDataSource\";\nexport * from \"./modules/ethereum/external-plugin/data/HttpExternalPluginDataSource\";\nexport * from \"./modules/ethereum/external-plugin/domain/ExternalPluginContextLoader\";\nexport * from \"./modules/ethereum/gated-signing/data/GatedDescriptorDataSource\";\nexport * from \"./modules/ethereum/gated-signing/data/HttpGatedDescriptorDataSource\";\nexport * from \"./modules/ethereum/gated-signing/domain/GatedSigningContextLoader\";\nexport * from \"./modules/ethereum/gated-signing/domain/GatedSigningTypedDataContextLoader\";\nexport * from \"./modules/ethereum/model/EthereumClearSignContext\";\nexport * from \"./modules/ethereum/model/TypedDataClearSignContext\";\nexport * from \"./modules/ethereum/model/TypedDataContext\";\nexport * from \"./modules/ethereum/nft/data/HttpNftDataSource\";\nexport * from \"./modules/ethereum/nft/data/NftDataSource\";\nexport * from \"./modules/ethereum/nft/domain/NftContextFieldLoader\";\nexport * from \"./modules/ethereum/nft/domain/NftContextLoader\";\nexport * from \"./modules/ethereum/proxy/data/HttpProxyDataSource\";\nexport * from \"./modules/ethereum/proxy/data/HttpSafeProxyDataSource\";\nexport * from \"./modules/ethereum/proxy/data/ProxyDataSource\";\nexport * from \"./modules/ethereum/proxy/domain/ProxyContextFieldLoader\";\nexport * from \"./modules/ethereum/token/data/HttpTokenDataSource\";\nexport * from \"./modules/ethereum/token/data/TokenDataSource\";\nexport * from \"./modules/ethereum/token/domain/TokenContextFieldLoader\";\nexport * from \"./modules/ethereum/token/domain/TokenContextLoader\";\nexport * from \"./modules/ethereum/trusted-name/data/HttpTrustedNameDataSource\";\nexport * from \"./modules/ethereum/trusted-name/data/TrustedNameDataSource\";\nexport * from \"./modules/ethereum/trusted-name/domain/TrustedNameContextFieldLoader\";\nexport * from \"./modules/ethereum/trusted-name/domain/TrustedNameContextLoader\";\nexport * from \"./modules/ethereum/typed-data/data/HttpTypedDataDataSource\";\nexport * from \"./modules/ethereum/typed-data/data/TypedDataDataSource\";\nexport * from \"./modules/ethereum/typed-data/domain/DefaultTypedDataContextLoader\";\nexport * from \"./modules/ethereum/typed-data/domain/TypedDataContextLoader\";\nexport * from \"./modules/ethereum/typed-data/utils/getSchemaHash\";\nexport * from \"./modules/ethereum/uniswap/data/AbiDecoderDataSource\";\nexport * from \"./modules/ethereum/uniswap/data/CommandDecoderDataSource\";\nexport * from \"./modules/ethereum/uniswap/data/DefaultCommandDecoderDataSource\";\nexport * from \"./modules/ethereum/uniswap/data/EthersAbiDecoderDataSource\";\nexport * from \"./modules/ethereum/uniswap/domain/UniswapContextLoader\";\nexport * from \"./modules/multichain/pki/data/HttpPkiCertificateDataSource\";\nexport * from \"./modules/multichain/pki/data/PkiCertificateDataSource\";\nexport * from \"./modules/multichain/pki/domain/DefaultPkiCertificateLoader\";\nexport * from \"./modules/multichain/pki/domain/PkiCertificateLoader\";\nexport * from \"./modules/multichain/pki/model/KeyId\";\nexport * from \"./modules/multichain/pki/model/KeyUsage\";\nexport * from \"./modules/multichain/pki/model/PkiCertificate\";\nexport * from \"./modules/multichain/pki/model/PkiCertificateInfo\";\nexport * from \"./modules/multichain/reporter/data/BlindSigningReporterDatasource\";\nexport * from \"./modules/multichain/reporter/data/HttpBlindSigningReporterDatasource\";\nexport * from \"./modules/multichain/reporter/domain/BlindSigningReporter\";\nexport * from \"./modules/multichain/reporter/domain/DefaultBlindSigningReporter\";\nexport * from \"./modules/multichain/reporter/model/BlindSigningEvent\";\nexport * from \"./modules/multichain/sign-reporter/model/SignReportParams\";\nexport * from \"./modules/multichain/transaction-check/utils/constants\";\nexport * from \"./modules/solana/alt-resolution/data/AltResolutionDataSource\";\nexport * from \"./modules/solana/alt-resolution/data/HttpAltResolutionDataSource\";\nexport * from \"./modules/solana/alt-resolution/domain/AltResolutionContextLoader\";\nexport * from \"./modules/solana/enum-variant/domain/EnumVariantContextLoader\";\nexport * from \"./modules/solana/instruction-info/data/HttpInstructionInfoDataSource\";\nexport * from \"./modules/solana/instruction-info/data/InstructionInfoDataSource\";\nexport * from \"./modules/solana/instruction-info/domain/InstructionInfoContextLoader\";\nexport * from \"./modules/solana/model/SolanaClearSignContext\";\nexport * from \"./modules/solana/model/SolanaContextTypes\";\nexport * from \"./modules/solana/model/SolanaTransactionScanChainId\";\nexport * from \"./modules/solana/owner-info/data/HttpOwnerInfoDataSource\";\nexport * from \"./modules/solana/owner-info/data/OwnerInfoDataSource\";\nexport * from \"./modules/solana/owner-info/domain/OwnerInfoContextLoader\";\nexport * from \"./modules/solana/owner-info/domain/solanaContextTypes\";\nexport * from \"./modules/solana/token-account-state/data/HttpTokenAccountStateDataSource\";\nexport * from \"./modules/solana/token-account-state/data/TokenAccountStateDataSource\";\nexport * from \"./modules/solana/token-account-state/domain/TokenAccountStateContextLoader\";\nexport * from \"./modules/solana/token-info/data/HttpTokenInfoDataSource\";\nexport * from \"./modules/solana/token-info/data/TokenInfoDataSource\";\nexport * from \"./modules/solana/token-info/domain/TokenInfoContextLoader\";\nexport * from \"./modules/solana/trusted-name/data/HttpTrustedNameDataSource\";\nexport * from \"./modules/solana/trusted-name/data/TrustedNameDataSource\";\nexport * from \"./modules/solana/trusted-name/domain/TrustedNameContextLoader\";\nexport * from \"./modules/tron/model/TronTransactionContext\";\nexport * from \"./shared/domain/ContextFieldLoader\";\nexport * from \"./shared/domain/ContextLoader\";\nexport * from \"./shared/domain/ContextModuleChainID\";\nexport * from \"./shared/model/BlindSigningModelId\";\nexport * from \"./shared/model/ClearSignContext\";\nexport * from \"./shared/model/GenericPath\";\nexport * from \"./shared/model/TransactionSubset\";\n"],
5
- "mappings": "AAUA,WAAc,kBACd,WAAc,yBACd,WAAc,yBACd,WAAc,yEACd,WAAc,oEACd,WAAc,6EACd,WAAc,8EACd,WAAc,gEACd,WAAc,oEACd,WAAc,2DACd,WAAc,mEACd,WAAc,uEACd,WAAc,wEACd,WAAc,uEACd,WAAc,mEACd,WAAc,uEACd,WAAc,wEACd,WAAc,kEACd,WAAc,sEACd,WAAc,oEACd,WAAc,6EACd,WAAc,oDACd,WAAc,qDACd,WAAc,4CACd,WAAc,gDACd,WAAc,4CACd,WAAc,sDACd,WAAc,iDACd,WAAc,oDACd,WAAc,wDACd,WAAc,gDACd,WAAc,0DACd,WAAc,oDACd,WAAc,gDACd,WAAc,0DACd,WAAc,qDACd,WAAc,iEACd,WAAc,6DACd,WAAc,uEACd,WAAc,kEACd,WAAc,6DACd,WAAc,yDACd,WAAc,qEACd,WAAc,8DACd,WAAc,oDACd,WAAc,uDACd,WAAc,2DACd,WAAc,kEACd,WAAc,6DACd,WAAc,yDACd,WAAc,6DACd,WAAc,yDACd,WAAc,8DACd,WAAc,uDACd,WAAc,uCACd,WAAc,0CACd,WAAc,gDACd,WAAc,oDACd,WAAc,oEACd,WAAc,wEACd,WAAc,4DACd,WAAc,mEACd,WAAc,wDACd,WAAc,4DACd,WAAc,yDACd,WAAc,+DACd,WAAc,mEACd,WAAc,oEACd,WAAc,gEACd,WAAc,uEACd,WAAc,mEACd,WAAc,wEACd,WAAc,gDACd,WAAc,4CACd,WAAc,sDACd,WAAc,2DACd,WAAc,uDACd,WAAc,4DACd,WAAc,wDACd,WAAc,4EACd,WAAc,wEACd,WAAc,6EACd,WAAc,2DACd,WAAc,uDACd,WAAc,4DACd,WAAc,+DACd,WAAc,2DACd,WAAc,gEACd,WAAc,8CACd,WAAc,qCACd,WAAc,gCACd,WAAc,uCACd,WAAc,qCACd,WAAc,kCACd,WAAc,6BACd,WAAc",
4
+ "sourcesContent": ["export type {\n ContextModuleCalBranch,\n ContextModuleCalConfig,\n ContextModuleCalMode,\n ContextModuleConfig,\n ContextModuleDatasourceConfig,\n ContextModuleMetadataServiceConfig,\n ContextModuleReporterConfig,\n ContextModuleWeb3ChecksConfig,\n} from \"./config/model/ContextModuleConfig\";\nexport * from \"./ContextModule\";\nexport * from \"./ContextModuleBuilder\";\nexport * from \"./DefaultContextModule\";\nexport * from \"./modules/concordium/account-ownership/data/AccountOwnershipDataSource\";\nexport * from \"./modules/concordium/account-ownership/data/AccountOwnershipError\";\nexport * from \"./modules/concordium/account-ownership/data/HttpAccountOwnershipDataSource\";\nexport * from \"./modules/concordium/account-ownership/domain/AccountOwnershipContextLoader\";\nexport * from \"./modules/ethereum/calldata/data/CalldataDescriptorDataSource\";\nexport * from \"./modules/ethereum/calldata/data/HttpCalldataDescriptorDataSource\";\nexport * from \"./modules/ethereum/calldata/domain/CalldataContextLoader\";\nexport * from \"./modules/ethereum/dynamic-network/data/DynamicNetworkDataSource\";\nexport * from \"./modules/ethereum/dynamic-network/data/HttpDynamicNetworkDataSource\";\nexport * from \"./modules/ethereum/dynamic-network/domain/DynamicNetworkContextLoader\";\nexport * from \"./modules/ethereum/dynamic-network/model/DynamicNetworkConfiguration\";\nexport * from \"./modules/ethereum/external-plugin/data/ExternalPluginDataSource\";\nexport * from \"./modules/ethereum/external-plugin/data/HttpExternalPluginDataSource\";\nexport * from \"./modules/ethereum/external-plugin/domain/ExternalPluginContextLoader\";\nexport * from \"./modules/ethereum/gated-signing/data/GatedDescriptorDataSource\";\nexport * from \"./modules/ethereum/gated-signing/data/HttpGatedDescriptorDataSource\";\nexport * from \"./modules/ethereum/gated-signing/domain/GatedSigningContextLoader\";\nexport * from \"./modules/ethereum/gated-signing/domain/GatedSigningTypedDataContextLoader\";\nexport * from \"./modules/ethereum/model/EthereumClearSignContext\";\nexport * from \"./modules/ethereum/model/TypedDataClearSignContext\";\nexport * from \"./modules/ethereum/model/TypedDataContext\";\nexport * from \"./modules/ethereum/nft/data/HttpNftDataSource\";\nexport * from \"./modules/ethereum/nft/data/NftDataSource\";\nexport * from \"./modules/ethereum/nft/domain/NftContextFieldLoader\";\nexport * from \"./modules/ethereum/nft/domain/NftContextLoader\";\nexport * from \"./modules/ethereum/proxy/data/HttpProxyDataSource\";\nexport * from \"./modules/ethereum/proxy/data/HttpSafeProxyDataSource\";\nexport * from \"./modules/ethereum/proxy/data/ProxyDataSource\";\nexport * from \"./modules/ethereum/proxy/domain/ProxyContextFieldLoader\";\nexport * from \"./modules/ethereum/token/data/HttpTokenDataSource\";\nexport * from \"./modules/ethereum/token/data/TokenDataSource\";\nexport * from \"./modules/ethereum/token/domain/TokenContextFieldLoader\";\nexport * from \"./modules/ethereum/token/domain/TokenContextLoader\";\nexport * from \"./modules/ethereum/trusted-name/data/HttpTrustedNameDataSource\";\nexport * from \"./modules/ethereum/trusted-name/data/TrustedNameDataSource\";\nexport * from \"./modules/ethereum/trusted-name/domain/TrustedNameContextFieldLoader\";\nexport * from \"./modules/ethereum/trusted-name/domain/TrustedNameContextLoader\";\nexport * from \"./modules/ethereum/typed-data/data/HttpTypedDataDataSource\";\nexport * from \"./modules/ethereum/typed-data/data/TypedDataDataSource\";\nexport * from \"./modules/ethereum/typed-data/domain/DefaultTypedDataContextLoader\";\nexport * from \"./modules/ethereum/typed-data/domain/TypedDataContextLoader\";\nexport * from \"./modules/ethereum/typed-data/utils/getSchemaHash\";\nexport * from \"./modules/ethereum/uniswap/data/AbiDecoderDataSource\";\nexport * from \"./modules/ethereum/uniswap/data/CommandDecoderDataSource\";\nexport * from \"./modules/ethereum/uniswap/data/DefaultCommandDecoderDataSource\";\nexport * from \"./modules/ethereum/uniswap/data/EthersAbiDecoderDataSource\";\nexport * from \"./modules/ethereum/uniswap/domain/UniswapContextLoader\";\nexport * from \"./modules/multichain/pki/data/HttpPkiCertificateDataSource\";\nexport * from \"./modules/multichain/pki/data/PkiCertificateDataSource\";\nexport * from \"./modules/multichain/pki/domain/DefaultPkiCertificateLoader\";\nexport * from \"./modules/multichain/pki/domain/PkiCertificateLoader\";\nexport * from \"./modules/multichain/pki/model/KeyId\";\nexport * from \"./modules/multichain/pki/model/KeyUsage\";\nexport * from \"./modules/multichain/pki/model/PkiCertificate\";\nexport * from \"./modules/multichain/pki/model/PkiCertificateInfo\";\nexport * from \"./modules/multichain/reporter/data/BlindSigningReporterDatasource\";\nexport * from \"./modules/multichain/reporter/data/HttpBlindSigningReporterDatasource\";\nexport * from \"./modules/multichain/reporter/domain/BlindSigningReporter\";\nexport * from \"./modules/multichain/reporter/domain/DefaultBlindSigningReporter\";\nexport * from \"./modules/multichain/reporter/model/BlindSigningEvent\";\nexport * from \"./modules/multichain/sign-reporter/model/SignReportParams\";\nexport * from \"./modules/multichain/transaction-check/utils/constants\";\nexport * from \"./modules/solana/alt-resolution/data/AltResolutionDataSource\";\nexport * from \"./modules/solana/alt-resolution/data/HttpAltResolutionDataSource\";\nexport * from \"./modules/solana/alt-resolution/domain/AltResolutionContextLoader\";\nexport * from \"./modules/solana/enum-variant/domain/EnumVariantContextLoader\";\nexport * from \"./modules/solana/instruction-info/data/HttpInstructionInfoDataSource\";\nexport * from \"./modules/solana/instruction-info/data/InstructionInfoDataSource\";\nexport * from \"./modules/solana/instruction-info/domain/InstructionInfoContextLoader\";\nexport * from \"./modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader\";\nexport * from \"./modules/solana/model/SolanaClearSignContext\";\nexport * from \"./modules/solana/model/SolanaContextTypes\";\nexport * from \"./modules/solana/model/SolanaTransactionScanChainId\";\nexport * from \"./modules/solana/owner-info/data/HttpOwnerInfoDataSource\";\nexport * from \"./modules/solana/owner-info/data/OwnerInfoDataSource\";\nexport * from \"./modules/solana/owner-info/domain/OwnerInfoContextLoader\";\nexport * from \"./modules/solana/owner-info/domain/solanaContextTypes\";\nexport * from \"./modules/solana/token-account-state/data/HttpTokenAccountStateDataSource\";\nexport * from \"./modules/solana/token-account-state/data/TokenAccountStateDataSource\";\nexport * from \"./modules/solana/token-account-state/domain/TokenAccountStateContextLoader\";\nexport * from \"./modules/solana/token-info/data/HttpTokenInfoDataSource\";\nexport * from \"./modules/solana/token-info/data/TokenInfoDataSource\";\nexport * from \"./modules/solana/token-info/domain/TokenInfoContextLoader\";\nexport * from \"./modules/solana/trusted-name/data/HttpTrustedNameDataSource\";\nexport * from \"./modules/solana/trusted-name/data/TrustedNameDataSource\";\nexport * from \"./modules/solana/trusted-name/domain/TrustedNameContextLoader\";\nexport * from \"./modules/tron/model/TronTransactionContext\";\nexport * from \"./shared/domain/ContextFieldLoader\";\nexport * from \"./shared/domain/ContextLoader\";\nexport * from \"./shared/domain/ContextModuleChainID\";\nexport * from \"./shared/model/BlindSigningModelId\";\nexport * from \"./shared/model/ClearSignContext\";\nexport * from \"./shared/model/GenericPath\";\nexport * from \"./shared/model/TransactionSubset\";\n"],
5
+ "mappings": "AAUA,WAAc,kBACd,WAAc,yBACd,WAAc,yBACd,WAAc,yEACd,WAAc,oEACd,WAAc,6EACd,WAAc,8EACd,WAAc,gEACd,WAAc,oEACd,WAAc,2DACd,WAAc,mEACd,WAAc,uEACd,WAAc,wEACd,WAAc,uEACd,WAAc,mEACd,WAAc,uEACd,WAAc,wEACd,WAAc,kEACd,WAAc,sEACd,WAAc,oEACd,WAAc,6EACd,WAAc,oDACd,WAAc,qDACd,WAAc,4CACd,WAAc,gDACd,WAAc,4CACd,WAAc,sDACd,WAAc,iDACd,WAAc,oDACd,WAAc,wDACd,WAAc,gDACd,WAAc,0DACd,WAAc,oDACd,WAAc,gDACd,WAAc,0DACd,WAAc,qDACd,WAAc,iEACd,WAAc,6DACd,WAAc,uEACd,WAAc,kEACd,WAAc,6DACd,WAAc,yDACd,WAAc,qEACd,WAAc,8DACd,WAAc,oDACd,WAAc,uDACd,WAAc,2DACd,WAAc,kEACd,WAAc,6DACd,WAAc,yDACd,WAAc,6DACd,WAAc,yDACd,WAAc,8DACd,WAAc,uDACd,WAAc,uCACd,WAAc,0CACd,WAAc,gDACd,WAAc,oDACd,WAAc,oEACd,WAAc,wEACd,WAAc,4DACd,WAAc,mEACd,WAAc,wDACd,WAAc,4DACd,WAAc,yDACd,WAAc,+DACd,WAAc,mEACd,WAAc,oEACd,WAAc,gEACd,WAAc,uEACd,WAAc,mEACd,WAAc,wEACd,WAAc,4EACd,WAAc,gDACd,WAAc,4CACd,WAAc,sDACd,WAAc,2DACd,WAAc,uDACd,WAAc,4DACd,WAAc,wDACd,WAAc,4EACd,WAAc,wEACd,WAAc,6EACd,WAAc,2DACd,WAAc,uDACd,WAAc,4DACd,WAAc,+DACd,WAAc,2DACd,WAAc,gEACd,WAAc,8CACd,WAAc,qCACd,WAAc,gCACd,WAAc,uCACd,WAAc,qCACd,WAAc,kCACd,WAAc,6BACd,WAAc",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var u=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var c=(o,e,n,t)=>{for(var i=t>1?void 0:t?f(e,n):e,d=o.length-1,l;d>=0;d--)(l=o[d])&&(i=(t?l(e,n,i):l(i))||i);return t&&i&&u(e,n,i),i},r=(o,e)=>(n,t)=>e(n,t,o);import{inject as s,injectable as h}from"inversify";import{Left as S,Right as a}from"purify-ts";import{configTypes as p}from"../../../../config/di/configTypes";import{networkTypes as v}from"../../../../shared/network/di/networkTypes";import{networkClientFactory as y}from"../../../../shared/network/networkClientFactory";let g=class{constructor(e,n,t){this.config=e;this.http=t??y(e),this.logger=n("HttpSignReporterDatasource")}http;logger;async report(e){try{const n=this.buildDto(e,this.config.appSource);this.logger.debug("[report] Posting signing event",{data:n}),await this.http.post(`${this.config.reporter.url}/v2/blind-signing-events`,n,{responseType:"void"})}catch{return S(new Error("[ContextModule] HttpSignReporterDatasource: Failed to report signing event"))}return a(void 0)}buildDto(e,n){const t={isBlindSign:e.isBlindSign,sessionId:e.sessionId??null,envData:{modelId:e.modelId,signerAppVersion:e.signerAppVersion,deviceVersion:e.deviceVersion,source:n,...e.platform!==void 0&&{platform:e.platform},...e.appVersion!==void 0&&{appVersion:e.appVersion},...e.platformOS!==void 0&&{platformOS:e.platformOS},...e.platformVersion!==void 0&&{platformVersion:e.platformVersion},...e.liveAppContext!==void 0&&{liveAppContext:e.liveAppContext}}};switch(e.chain){case"ETH":return{...t,chain:"ETH",chainData:{chain:"ETH",signatureId:e.signatureId,signingMethod:e.signingMethod,targetAddress:e.targetAddress,chainId:e.chainId,blindSignReason:e.blindSignReason,...e.selectorId!==void 0&&{selectorId:e.selectorId},...e.clearSigningType!==void 0&&{clearSigningType:e.clearSigningType},...e.partialContextErrors!==void 0&&{partialContextErrors:e.partialContextErrors}}};case"SOL":return{...t,chain:"SOL",chainData:{chain:"SOL",signatureId:e.signatureId,signingMethod:e.signingMethod,targetAddress:e.targetAddress,blindSignReason:e.blindSignReason,programIds:e.programIds,unrecognizedPrograms:e.unrecognizedPrograms,...e.transactionSignature!==void 0&&{transactionSignature:e.transactionSignature}}}}}};g=c([h(),r(0,s(p.Config)),r(1,s(p.ContextModuleLoggerFactory)),r(2,s(v.NetworkClient))],g);export{g as HttpSignReporterDatasource};
1
+ var u=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var c=(o,e,t,n)=>{for(var i=n>1?void 0:n?f(e,t):e,d=o.length-1,l;d>=0;d--)(l=o[d])&&(i=(n?l(e,t,i):l(i))||i);return n&&i&&u(e,t,i),i},r=(o,e)=>(t,n)=>e(t,n,o);import{inject as s,injectable as h}from"inversify";import{Left as S,Right as v}from"purify-ts";import{configTypes as p}from"../../../../config/di/configTypes";import{networkTypes as a}from"../../../../shared/network/di/networkTypes";import{networkClientFactory as y}from"../../../../shared/network/networkClientFactory";let g=class{constructor(e,t,n){this.config=e;this.http=n??y(e),this.logger=t("HttpSignReporterDatasource")}http;logger;async report(e){try{const t=this.buildDto(e,this.config.appSource);this.logger.debug("[report] Posting signing event",{data:t}),await this.http.post(`${this.config.reporter.url}/v2/blind-signing-events`,t,{responseType:"void"})}catch{return S(new Error("[ContextModule] HttpSignReporterDatasource: Failed to report signing event"))}return v(void 0)}buildDto(e,t){const n={isBlindSign:e.isBlindSign,sessionId:e.sessionId??null,envData:{modelId:e.modelId,signerAppVersion:e.signerAppVersion,deviceVersion:e.deviceVersion,source:t,...e.platform!==void 0&&{platform:e.platform},...e.appVersion!==void 0&&{appVersion:e.appVersion},...e.platformOS!==void 0&&{platformOS:e.platformOS},...e.platformVersion!==void 0&&{platformVersion:e.platformVersion},...e.liveAppContext!==void 0&&{liveAppContext:e.liveAppContext}}};switch(e.chain){case"ETH":return{...n,chain:"ETH",chainData:{signatureId:e.signatureId,signingMethod:e.signingMethod,targetAddress:e.targetAddress,chainId:e.chainId,blindSignReason:e.blindSignReason,...e.selectorId!==void 0&&{selectorId:e.selectorId},...e.clearSigningType!==void 0&&{clearSigningType:e.clearSigningType},...e.partialContextErrors!==void 0&&{partialContextErrors:e.partialContextErrors}}};case"SOL":return{...n,chain:"SOL",chainData:{signatureId:e.signatureId,signingMethod:e.signingMethod,targetAddress:e.targetAddress,blindSignReason:e.blindSignReason,programIds:e.programIds,unrecognizedPrograms:e.unrecognizedPrograms,...e.transactionSignature!==void 0&&{transactionSignature:e.transactionSignature}}}}}};g=c([h(),r(0,s(p.Config)),r(1,s(p.ContextModuleLoggerFactory)),r(2,s(a.NetworkClient))],g);export{g as HttpSignReporterDatasource};
2
2
  //# sourceMappingURL=HttpSignReporterDatasource.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/modules/multichain/sign-reporter/data/HttpSignReporterDatasource.ts"],
4
- "sourcesContent": ["import {\n type DmkNetworkClient,\n type LoggerPublisherService,\n} from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { type Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { type SignReportParams } from \"@/modules/multichain/sign-reporter/model/SignReportParams\";\nimport { networkTypes } from \"@/shared/network/di/networkTypes\";\nimport { networkClientFactory } from \"@/shared/network/networkClientFactory\";\n\nimport { type SigningEventDto } from \"./dto/SigningEventDto\";\nimport { type SignReporterDatasource } from \"./SignReporterDatasource\";\n\n@injectable()\nexport class HttpSignReporterDatasource implements SignReporterDatasource {\n private readonly http: DmkNetworkClient;\n private readonly logger: LoggerPublisherService;\n\n constructor(\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(configTypes.ContextModuleLoggerFactory)\n loggerFactory: (tag: string) => LoggerPublisherService,\n @inject(networkTypes.NetworkClient)\n networkClient?: DmkNetworkClient,\n ) {\n this.http = networkClient ?? networkClientFactory(config);\n this.logger = loggerFactory(\"HttpSignReporterDatasource\");\n }\n\n async report(params: SignReportParams): Promise<Either<Error, void>> {\n try {\n const dto = this.buildDto(params, this.config.appSource);\n this.logger.debug(\"[report] Posting signing event\", { data: dto });\n await this.http.post(\n `${this.config.reporter.url}/v2/blind-signing-events`,\n dto,\n { responseType: \"void\" },\n );\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpSignReporterDatasource: Failed to report signing event\",\n ),\n );\n }\n\n return Right(undefined);\n }\n\n private buildDto(params: SignReportParams, source: string): SigningEventDto {\n const base = {\n isBlindSign: params.isBlindSign,\n sessionId: params.sessionId ?? null,\n envData: {\n modelId: params.modelId,\n signerAppVersion: params.signerAppVersion,\n deviceVersion: params.deviceVersion,\n source,\n ...(params.platform !== undefined && { platform: params.platform }),\n ...(params.appVersion !== undefined && {\n appVersion: params.appVersion,\n }),\n ...(params.platformOS !== undefined && {\n platformOS: params.platformOS,\n }),\n ...(params.platformVersion !== undefined && {\n platformVersion: params.platformVersion,\n }),\n ...(params.liveAppContext !== undefined && {\n liveAppContext: params.liveAppContext,\n }),\n },\n };\n\n switch (params.chain) {\n case \"ETH\":\n return {\n ...base,\n chain: \"ETH\",\n chainData: {\n chain: \"ETH\",\n signatureId: params.signatureId,\n signingMethod: params.signingMethod,\n targetAddress: params.targetAddress,\n chainId: params.chainId,\n blindSignReason: params.blindSignReason,\n ...(params.selectorId !== undefined && {\n selectorId: params.selectorId,\n }),\n ...(params.clearSigningType !== undefined && {\n clearSigningType: params.clearSigningType,\n }),\n ...(params.partialContextErrors !== undefined && {\n partialContextErrors: params.partialContextErrors,\n }),\n },\n };\n case \"SOL\":\n return {\n ...base,\n chain: \"SOL\",\n chainData: {\n chain: \"SOL\",\n signatureId: params.signatureId,\n signingMethod: params.signingMethod,\n targetAddress: params.targetAddress,\n blindSignReason: params.blindSignReason,\n programIds: params.programIds,\n unrecognizedPrograms: params.unrecognizedPrograms,\n ...(params.transactionSignature !== undefined && {\n transactionSignature: params.transactionSignature,\n }),\n },\n };\n }\n }\n}\n"],
5
- "mappings": "iOAIA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YACnC,OAAsB,QAAAC,EAAM,SAAAC,MAAa,YAEzC,OAAS,eAAAC,MAAmB,0BAG5B,OAAS,gBAAAC,MAAoB,mCAC7B,OAAS,wBAAAC,MAA4B,wCAM9B,IAAMC,EAAN,KAAmE,CAIxE,YAEmBC,EAEjBC,EAEAC,EACA,CALiB,YAAAF,EAMjB,KAAK,KAAOE,GAAiBC,EAAqBH,CAAM,EACxD,KAAK,OAASC,EAAc,4BAA4B,CAC1D,CAbiB,KACA,OAcjB,MAAM,OAAOG,EAAwD,CACnE,GAAI,CACF,MAAMC,EAAM,KAAK,SAASD,EAAQ,KAAK,OAAO,SAAS,EACvD,KAAK,OAAO,MAAM,iCAAkC,CAAE,KAAMC,CAAI,CAAC,EACjE,MAAM,KAAK,KAAK,KACd,GAAG,KAAK,OAAO,SAAS,GAAG,2BAC3BA,EACA,CAAE,aAAc,MAAO,CACzB,CACF,MAAiB,CACf,OAAOC,EACL,IAAI,MACF,4EACF,CACF,CACF,CAEA,OAAOC,EAAM,MAAS,CACxB,CAEQ,SAASH,EAA0BI,EAAiC,CAC1E,MAAMC,EAAO,CACX,YAAaL,EAAO,YACpB,UAAWA,EAAO,WAAa,KAC/B,QAAS,CACP,QAASA,EAAO,QAChB,iBAAkBA,EAAO,iBACzB,cAAeA,EAAO,cACtB,OAAAI,EACA,GAAIJ,EAAO,WAAa,QAAa,CAAE,SAAUA,EAAO,QAAS,EACjE,GAAIA,EAAO,aAAe,QAAa,CACrC,WAAYA,EAAO,UACrB,EACA,GAAIA,EAAO,aAAe,QAAa,CACrC,WAAYA,EAAO,UACrB,EACA,GAAIA,EAAO,kBAAoB,QAAa,CAC1C,gBAAiBA,EAAO,eAC1B,EACA,GAAIA,EAAO,iBAAmB,QAAa,CACzC,eAAgBA,EAAO,cACzB,CACF,CACF,EAEA,OAAQA,EAAO,MAAO,CACpB,IAAK,MACH,MAAO,CACL,GAAGK,EACH,MAAO,MACP,UAAW,CACT,MAAO,MACP,YAAaL,EAAO,YACpB,cAAeA,EAAO,cACtB,cAAeA,EAAO,cACtB,QAASA,EAAO,QAChB,gBAAiBA,EAAO,gBACxB,GAAIA,EAAO,aAAe,QAAa,CACrC,WAAYA,EAAO,UACrB,EACA,GAAIA,EAAO,mBAAqB,QAAa,CAC3C,iBAAkBA,EAAO,gBAC3B,EACA,GAAIA,EAAO,uBAAyB,QAAa,CAC/C,qBAAsBA,EAAO,oBAC/B,CACF,CACF,EACF,IAAK,MACH,MAAO,CACL,GAAGK,EACH,MAAO,MACP,UAAW,CACT,MAAO,MACP,YAAaL,EAAO,YACpB,cAAeA,EAAO,cACtB,cAAeA,EAAO,cACtB,gBAAiBA,EAAO,gBACxB,WAAYA,EAAO,WACnB,qBAAsBA,EAAO,qBAC7B,GAAIA,EAAO,uBAAyB,QAAa,CAC/C,qBAAsBA,EAAO,oBAC/B,CACF,CACF,CACJ,CACF,CACF,EAvGaL,EAANW,EAAA,CADNC,EAAW,EAMPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,GAEzBF,EAAA,EAAAC,EAAOC,EAAY,0BAA0B,GAE7CF,EAAA,EAAAC,EAAOE,EAAa,aAAa,IATzBhB",
4
+ "sourcesContent": ["import {\n type DmkNetworkClient,\n type LoggerPublisherService,\n} from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { type Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { type SignReportParams } from \"@/modules/multichain/sign-reporter/model/SignReportParams\";\nimport { networkTypes } from \"@/shared/network/di/networkTypes\";\nimport { networkClientFactory } from \"@/shared/network/networkClientFactory\";\n\nimport { type SigningEventDto } from \"./dto/SigningEventDto\";\nimport { type SignReporterDatasource } from \"./SignReporterDatasource\";\n\n@injectable()\nexport class HttpSignReporterDatasource implements SignReporterDatasource {\n private readonly http: DmkNetworkClient;\n private readonly logger: LoggerPublisherService;\n\n constructor(\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(configTypes.ContextModuleLoggerFactory)\n loggerFactory: (tag: string) => LoggerPublisherService,\n @inject(networkTypes.NetworkClient)\n networkClient?: DmkNetworkClient,\n ) {\n this.http = networkClient ?? networkClientFactory(config);\n this.logger = loggerFactory(\"HttpSignReporterDatasource\");\n }\n\n async report(params: SignReportParams): Promise<Either<Error, void>> {\n try {\n const dto = this.buildDto(params, this.config.appSource);\n this.logger.debug(\"[report] Posting signing event\", { data: dto });\n await this.http.post(\n `${this.config.reporter.url}/v2/blind-signing-events`,\n dto,\n { responseType: \"void\" },\n );\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpSignReporterDatasource: Failed to report signing event\",\n ),\n );\n }\n\n return Right(undefined);\n }\n\n private buildDto(params: SignReportParams, source: string): SigningEventDto {\n const base = {\n isBlindSign: params.isBlindSign,\n sessionId: params.sessionId ?? null,\n envData: {\n modelId: params.modelId,\n signerAppVersion: params.signerAppVersion,\n deviceVersion: params.deviceVersion,\n source,\n ...(params.platform !== undefined && { platform: params.platform }),\n ...(params.appVersion !== undefined && {\n appVersion: params.appVersion,\n }),\n ...(params.platformOS !== undefined && {\n platformOS: params.platformOS,\n }),\n ...(params.platformVersion !== undefined && {\n platformVersion: params.platformVersion,\n }),\n ...(params.liveAppContext !== undefined && {\n liveAppContext: params.liveAppContext,\n }),\n },\n };\n\n switch (params.chain) {\n case \"ETH\":\n return {\n ...base,\n chain: \"ETH\",\n chainData: {\n signatureId: params.signatureId,\n signingMethod: params.signingMethod,\n targetAddress: params.targetAddress,\n chainId: params.chainId,\n blindSignReason: params.blindSignReason,\n ...(params.selectorId !== undefined && {\n selectorId: params.selectorId,\n }),\n ...(params.clearSigningType !== undefined && {\n clearSigningType: params.clearSigningType,\n }),\n ...(params.partialContextErrors !== undefined && {\n partialContextErrors: params.partialContextErrors,\n }),\n },\n };\n case \"SOL\":\n return {\n ...base,\n chain: \"SOL\",\n chainData: {\n signatureId: params.signatureId,\n signingMethod: params.signingMethod,\n targetAddress: params.targetAddress,\n blindSignReason: params.blindSignReason,\n programIds: params.programIds,\n unrecognizedPrograms: params.unrecognizedPrograms,\n ...(params.transactionSignature !== undefined && {\n transactionSignature: params.transactionSignature,\n }),\n },\n };\n }\n }\n}\n"],
5
+ "mappings": "iOAIA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YACnC,OAAsB,QAAAC,EAAM,SAAAC,MAAa,YAEzC,OAAS,eAAAC,MAAmB,0BAG5B,OAAS,gBAAAC,MAAoB,mCAC7B,OAAS,wBAAAC,MAA4B,wCAM9B,IAAMC,EAAN,KAAmE,CAIxE,YAEmBC,EAEjBC,EAEAC,EACA,CALiB,YAAAF,EAMjB,KAAK,KAAOE,GAAiBC,EAAqBH,CAAM,EACxD,KAAK,OAASC,EAAc,4BAA4B,CAC1D,CAbiB,KACA,OAcjB,MAAM,OAAOG,EAAwD,CACnE,GAAI,CACF,MAAMC,EAAM,KAAK,SAASD,EAAQ,KAAK,OAAO,SAAS,EACvD,KAAK,OAAO,MAAM,iCAAkC,CAAE,KAAMC,CAAI,CAAC,EACjE,MAAM,KAAK,KAAK,KACd,GAAG,KAAK,OAAO,SAAS,GAAG,2BAC3BA,EACA,CAAE,aAAc,MAAO,CACzB,CACF,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EAMPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,GAEzBF,EAAA,EAAAC,EAAOC,EAAY,0BAA0B,GAE7CF,EAAA,EAAAC,EAAOE,EAAa,aAAa,IATzBhB",
6
6
  "names": ["inject", "injectable", "Left", "Right", "configTypes", "networkTypes", "networkClientFactory", "HttpSignReporterDatasource", "config", "loggerFactory", "networkClient", "networkClientFactory", "params", "dto", "Left", "Right", "source", "base", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes", "networkTypes"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{Left as c,Right as l}from"purify-ts";import{BlindSignReason as p}from"../../../../modules/multichain/reporter/model/BlindSigningEvent";import{BlindSigningModelId as a}from"../../../../shared/model/BlindSigningModelId";import{HttpSignReporterDatasource as g}from"./HttpSignReporterDatasource";describe("HttpSignReporterDatasource",()=>{const s={reporter:{url:"https://reporter.test"},appSource:"third-party",originToken:"originToken"},d={modelId:a.NANO_X,signerAppVersion:"1.4.0",deviceVersion:"2.2.3"},t={...d,chain:"SOL",signatureId:"abc123-1738850400000",signingMethod:"sol_signTransaction",isBlindSign:!0,targetAddress:"JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4",blindSignReason:p.UNRECOGNIZED_PROGRAM,programIds:["JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4","TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"],unrecognizedPrograms:["JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"]},i={...d,chain:"ETH",signatureId:"def456-1738850400000",signingMethod:"eth_signTransaction",isBlindSign:!1,chainId:1,targetAddress:"0xdAC17F958D2ee523a2206206994597C13D831ec7",blindSignReason:null};let e,n;beforeEach(()=>{vi.resetAllMocks(),e={post:vi.fn()},n=new g(s,()=>({debug:vi.fn(),info:vi.fn(),warn:vi.fn(),error:vi.fn()}),e)}),describe("report",()=>{it("should return Right(undefined) on success",async()=>{e.post.mockResolvedValueOnce(void 0);const r=await n.report(t);expect(r).toEqual(l(void 0))}),it("should return Left(Error) when the request fails",async()=>{e.post.mockRejectedValueOnce(new Error("network error"));const r=await n.report(t);expect(r).toEqual(c(new Error("[ContextModule] HttpSignReporterDatasource: Failed to report signing event")))}),it("should call the v2 endpoint with the correct URL",async()=>{e.post.mockResolvedValueOnce(void 0),await n.report(t),expect(e.post).toHaveBeenCalledWith(`${s.reporter.url}/v2/blind-signing-events`,expect.anything(),{responseType:"void"})}),it("should build correct three-layer body for SOL params",async()=>{e.post.mockResolvedValueOnce(void 0),await n.report(t),expect(e.post).toHaveBeenCalledWith(expect.any(String),{chain:"SOL",isBlindSign:!0,sessionId:null,chainData:{chain:"SOL",signatureId:t.signatureId,signingMethod:"sol_signTransaction",targetAddress:t.targetAddress,blindSignReason:p.UNRECOGNIZED_PROGRAM,programIds:t.programIds,unrecognizedPrograms:t.unrecognizedPrograms},envData:{modelId:a.NANO_X,signerAppVersion:"1.4.0",deviceVersion:"2.2.3",source:"third-party"}},{responseType:"void"})}),it("should build correct three-layer body for ETH params",async()=>{e.post.mockResolvedValueOnce(void 0),await n.report(i),expect(e.post).toHaveBeenCalledWith(expect.any(String),{chain:"ETH",isBlindSign:!1,sessionId:null,chainData:{chain:"ETH",signatureId:i.signatureId,signingMethod:"eth_signTransaction",targetAddress:i.targetAddress,chainId:1,blindSignReason:null},envData:{modelId:a.NANO_X,signerAppVersion:"1.4.0",deviceVersion:"2.2.3",source:"third-party"}},{responseType:"void"})}),it("should include optional env fields when provided",async()=>{e.post.mockResolvedValueOnce(void 0);const r={...t,platform:"desktop",appVersion:"2.80.0",platformOS:"macOS",platformVersion:"14.5",liveAppContext:"swap",sessionId:"session-abc"};await n.report(r);const o=e.post.mock.calls[0][1];expect(o.envData.platform).toBe("desktop"),expect(o.envData.appVersion).toBe("2.80.0"),expect(o.envData.platformOS).toBe("macOS"),expect(o.envData.platformVersion).toBe("14.5"),expect(o.envData.liveAppContext).toBe("swap"),expect(o.sessionId).toBe("session-abc")}),it("should include transactionSignature in SOL chainData when provided",async()=>{e.post.mockResolvedValueOnce(void 0);const r={...t,transactionSignature:"5yJ9..."};await n.report(r);const o=e.post.mock.calls[0][1];expect(o.chainData.transactionSignature).toBe("5yJ9...")})})});
1
+ import{Left as c,Right as l}from"purify-ts";import{BlindSignReason as p}from"../../../../modules/multichain/reporter/model/BlindSigningEvent";import{BlindSigningModelId as a}from"../../../../shared/model/BlindSigningModelId";import{HttpSignReporterDatasource as g}from"./HttpSignReporterDatasource";describe("HttpSignReporterDatasource",()=>{const s={reporter:{url:"https://reporter.test"},appSource:"third-party",originToken:"originToken"},d={modelId:a.NANO_X,signerAppVersion:"1.4.0",deviceVersion:"2.2.3"},t={...d,chain:"SOL",signatureId:"abc123-1738850400000",signingMethod:"sol_signTransaction",isBlindSign:!0,targetAddress:"JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4",blindSignReason:p.UNRECOGNIZED_PROGRAM,programIds:["JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4","TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"],unrecognizedPrograms:["JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"]},i={...d,chain:"ETH",signatureId:"def456-1738850400000",signingMethod:"eth_signTransaction",isBlindSign:!1,chainId:1,targetAddress:"0xdAC17F958D2ee523a2206206994597C13D831ec7",blindSignReason:null};let e,n;beforeEach(()=>{vi.resetAllMocks(),e={post:vi.fn()},n=new g(s,()=>({debug:vi.fn(),info:vi.fn(),warn:vi.fn(),error:vi.fn()}),e)}),describe("report",()=>{it("should return Right(undefined) on success",async()=>{e.post.mockResolvedValueOnce(void 0);const r=await n.report(t);expect(r).toEqual(l(void 0))}),it("should return Left(Error) when the request fails",async()=>{e.post.mockRejectedValueOnce(new Error("network error"));const r=await n.report(t);expect(r).toEqual(c(new Error("[ContextModule] HttpSignReporterDatasource: Failed to report signing event")))}),it("should call the v2 endpoint with the correct URL",async()=>{e.post.mockResolvedValueOnce(void 0),await n.report(t),expect(e.post).toHaveBeenCalledWith(`${s.reporter.url}/v2/blind-signing-events`,expect.anything(),{responseType:"void"})}),it("should build correct three-layer body for SOL params",async()=>{e.post.mockResolvedValueOnce(void 0),await n.report(t),expect(e.post).toHaveBeenCalledWith(expect.any(String),{chain:"SOL",isBlindSign:!0,sessionId:null,chainData:{signatureId:t.signatureId,signingMethod:"sol_signTransaction",targetAddress:t.targetAddress,blindSignReason:p.UNRECOGNIZED_PROGRAM,programIds:t.programIds,unrecognizedPrograms:t.unrecognizedPrograms},envData:{modelId:a.NANO_X,signerAppVersion:"1.4.0",deviceVersion:"2.2.3",source:"third-party"}},{responseType:"void"})}),it("should build correct three-layer body for ETH params",async()=>{e.post.mockResolvedValueOnce(void 0),await n.report(i),expect(e.post).toHaveBeenCalledWith(expect.any(String),{chain:"ETH",isBlindSign:!1,sessionId:null,chainData:{signatureId:i.signatureId,signingMethod:"eth_signTransaction",targetAddress:i.targetAddress,chainId:1,blindSignReason:null},envData:{modelId:a.NANO_X,signerAppVersion:"1.4.0",deviceVersion:"2.2.3",source:"third-party"}},{responseType:"void"})}),it("should include optional env fields when provided",async()=>{e.post.mockResolvedValueOnce(void 0);const r={...t,platform:"desktop",appVersion:"2.80.0",platformOS:"macOS",platformVersion:"14.5",liveAppContext:"swap",sessionId:"session-abc"};await n.report(r);const o=e.post.mock.calls[0][1];expect(o.envData.platform).toBe("desktop"),expect(o.envData.appVersion).toBe("2.80.0"),expect(o.envData.platformOS).toBe("macOS"),expect(o.envData.platformVersion).toBe("14.5"),expect(o.envData.liveAppContext).toBe("swap"),expect(o.sessionId).toBe("session-abc")}),it("should include transactionSignature in SOL chainData when provided",async()=>{e.post.mockResolvedValueOnce(void 0);const r={...t,transactionSignature:"5yJ9..."};await n.report(r);const o=e.post.mock.calls[0][1];expect(o.chainData.transactionSignature).toBe("5yJ9...")})})});
2
2
  //# sourceMappingURL=HttpSignReporterDatasource.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/modules/multichain/sign-reporter/data/HttpSignReporterDatasource.test.ts"],
4
- "sourcesContent": ["import {\n type DmkNetworkClient,\n type LoggerPublisherService,\n} from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { BlindSignReason } from \"@/modules/multichain/reporter/model/BlindSigningEvent\";\nimport {\n type EthSignReportParams,\n type SolSignReportParams,\n} from \"@/modules/multichain/sign-reporter/model/SignReportParams\";\nimport { BlindSigningModelId } from \"@/shared/model/BlindSigningModelId\";\n\nimport { HttpSignReporterDatasource } from \"./HttpSignReporterDatasource\";\n\ndescribe(\"HttpSignReporterDatasource\", () => {\n const config = {\n reporter: { url: \"https://reporter.test\" },\n appSource: \"third-party\",\n originToken: \"originToken\",\n } as ContextModuleServiceConfig;\n\n const envFields = {\n modelId: BlindSigningModelId.NANO_X,\n signerAppVersion: \"1.4.0\",\n deviceVersion: \"2.2.3\",\n };\n\n const solParams: SolSignReportParams = {\n ...envFields,\n chain: \"SOL\",\n signatureId: \"abc123-1738850400000\",\n signingMethod: \"sol_signTransaction\",\n isBlindSign: true,\n targetAddress: \"JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4\",\n blindSignReason: BlindSignReason.UNRECOGNIZED_PROGRAM,\n programIds: [\n \"JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4\",\n \"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA\",\n ],\n unrecognizedPrograms: [\"JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4\"],\n };\n\n const ethParams: EthSignReportParams = {\n ...envFields,\n chain: \"ETH\",\n signatureId: \"def456-1738850400000\",\n signingMethod: \"eth_signTransaction\",\n isBlindSign: false,\n chainId: 1,\n targetAddress: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n blindSignReason: null,\n };\n\n let httpMock: { post: ReturnType<typeof vi.fn> };\n let dataSource: HttpSignReporterDatasource;\n\n beforeEach(() => {\n vi.resetAllMocks();\n httpMock = { post: vi.fn() };\n dataSource = new HttpSignReporterDatasource(\n config,\n () =>\n ({\n debug: vi.fn(),\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n }) as unknown as LoggerPublisherService,\n httpMock as unknown as DmkNetworkClient,\n );\n });\n\n describe(\"report\", () => {\n it(\"should return Right(undefined) on success\", async () => {\n // GIVEN\n httpMock.post.mockResolvedValueOnce(undefined);\n\n // WHEN\n const result = await dataSource.report(solParams);\n\n // THEN\n expect(result).toEqual(Right(undefined));\n });\n\n it(\"should return Left(Error) when the request fails\", async () => {\n // GIVEN\n httpMock.post.mockRejectedValueOnce(new Error(\"network error\"));\n\n // WHEN\n const result = await dataSource.report(solParams);\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpSignReporterDatasource: Failed to report signing event\",\n ),\n ),\n );\n });\n\n it(\"should call the v2 endpoint with the correct URL\", async () => {\n // GIVEN\n httpMock.post.mockResolvedValueOnce(undefined);\n\n // WHEN\n await dataSource.report(solParams);\n\n // THEN\n expect(httpMock.post).toHaveBeenCalledWith(\n `${config.reporter.url}/v2/blind-signing-events`,\n expect.anything(),\n { responseType: \"void\" },\n );\n });\n\n it(\"should build correct three-layer body for SOL params\", async () => {\n // GIVEN\n httpMock.post.mockResolvedValueOnce(undefined);\n\n // WHEN\n await dataSource.report(solParams);\n\n // THEN\n expect(httpMock.post).toHaveBeenCalledWith(\n expect.any(String),\n {\n chain: \"SOL\",\n isBlindSign: true,\n sessionId: null,\n chainData: {\n chain: \"SOL\",\n signatureId: solParams.signatureId,\n signingMethod: \"sol_signTransaction\",\n targetAddress: solParams.targetAddress,\n blindSignReason: BlindSignReason.UNRECOGNIZED_PROGRAM,\n programIds: solParams.programIds,\n unrecognizedPrograms: solParams.unrecognizedPrograms,\n },\n envData: {\n modelId: BlindSigningModelId.NANO_X,\n signerAppVersion: \"1.4.0\",\n deviceVersion: \"2.2.3\",\n source: \"third-party\",\n },\n },\n { responseType: \"void\" },\n );\n });\n\n it(\"should build correct three-layer body for ETH params\", async () => {\n // GIVEN\n httpMock.post.mockResolvedValueOnce(undefined);\n\n // WHEN\n await dataSource.report(ethParams);\n\n // THEN\n expect(httpMock.post).toHaveBeenCalledWith(\n expect.any(String),\n {\n chain: \"ETH\",\n isBlindSign: false,\n sessionId: null,\n chainData: {\n chain: \"ETH\",\n signatureId: ethParams.signatureId,\n signingMethod: \"eth_signTransaction\",\n targetAddress: ethParams.targetAddress,\n chainId: 1,\n blindSignReason: null,\n },\n envData: {\n modelId: BlindSigningModelId.NANO_X,\n signerAppVersion: \"1.4.0\",\n deviceVersion: \"2.2.3\",\n source: \"third-party\",\n },\n },\n { responseType: \"void\" },\n );\n });\n\n it(\"should include optional env fields when provided\", async () => {\n // GIVEN\n httpMock.post.mockResolvedValueOnce(undefined);\n const paramsWithOptional: SolSignReportParams = {\n ...solParams,\n platform: \"desktop\",\n appVersion: \"2.80.0\",\n platformOS: \"macOS\",\n platformVersion: \"14.5\",\n liveAppContext: \"swap\",\n sessionId: \"session-abc\",\n };\n\n // WHEN\n await dataSource.report(paramsWithOptional);\n\n // THEN\n const body = httpMock.post.mock.calls[0]![1];\n expect(body.envData.platform).toBe(\"desktop\");\n expect(body.envData.appVersion).toBe(\"2.80.0\");\n expect(body.envData.platformOS).toBe(\"macOS\");\n expect(body.envData.platformVersion).toBe(\"14.5\");\n expect(body.envData.liveAppContext).toBe(\"swap\");\n expect(body.sessionId).toBe(\"session-abc\");\n });\n\n it(\"should include transactionSignature in SOL chainData when provided\", async () => {\n // GIVEN\n httpMock.post.mockResolvedValueOnce(undefined);\n const paramsWithSig: SolSignReportParams = {\n ...solParams,\n transactionSignature: \"5yJ9...\",\n };\n\n // WHEN\n await dataSource.report(paramsWithSig);\n\n // THEN\n const body = httpMock.post.mock.calls[0]![1];\n expect(body.chainData.transactionSignature).toBe(\"5yJ9...\");\n });\n });\n});\n"],
5
- "mappings": "AAIA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAG5B,OAAS,mBAAAC,MAAuB,wDAKhC,OAAS,uBAAAC,MAA2B,qCAEpC,OAAS,8BAAAC,MAAkC,+BAE3C,SAAS,6BAA8B,IAAM,CAC3C,MAAMC,EAAS,CACb,SAAU,CAAE,IAAK,uBAAwB,EACzC,UAAW,cACX,YAAa,aACf,EAEMC,EAAY,CAChB,QAASH,EAAoB,OAC7B,iBAAkB,QAClB,cAAe,OACjB,EAEMI,EAAiC,CACrC,GAAGD,EACH,MAAO,MACP,YAAa,uBACb,cAAe,sBACf,YAAa,GACb,cAAe,8CACf,gBAAiBJ,EAAgB,qBACjC,WAAY,CACV,8CACA,6CACF,EACA,qBAAsB,CAAC,6CAA6C,CACtE,EAEMM,EAAiC,CACrC,GAAGF,EACH,MAAO,MACP,YAAa,uBACb,cAAe,sBACf,YAAa,GACb,QAAS,EACT,cAAe,6CACf,gBAAiB,IACnB,EAEA,IAAIG,EACAC,EAEJ,WAAW,IAAM,CACf,GAAG,cAAc,EACjBD,EAAW,CAAE,KAAM,GAAG,GAAG,CAAE,EAC3BC,EAAa,IAAIN,EACfC,EACA,KACG,CACC,MAAO,GAAG,GAAG,EACb,KAAM,GAAG,GAAG,EACZ,KAAM,GAAG,GAAG,EACZ,MAAO,GAAG,GAAG,CACf,GACFI,CACF,CACF,CAAC,EAED,SAAS,SAAU,IAAM,CACvB,GAAG,4CAA6C,SAAY,CAE1DA,EAAS,KAAK,sBAAsB,MAAS,EAG7C,MAAME,EAAS,MAAMD,EAAW,OAAOH,CAAS,EAGhD,OAAOI,CAAM,EAAE,QAAQV,EAAM,MAAS,CAAC,CACzC,CAAC,EAED,GAAG,mDAAoD,SAAY,CAEjEQ,EAAS,KAAK,sBAAsB,IAAI,MAAM,e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AY,CAEjEM,EAAS,KAAK,sBAAsB,MAAS,EAC7C,MAAMG,EAA0C,CAC9C,GAAGL,EACH,SAAU,UACV,WAAY,SACZ,WAAY,QACZ,gBAAiB,OACjB,eAAgB,OAChB,UAAW,aACb,EAGA,MAAMG,EAAW,OAAOE,CAAkB,EAG1C,MAAMC,EAAOJ,EAAS,KAAK,KAAK,MAAM,CAAC,EAAG,CAAC,EAC3C,OAAOI,EAAK,QAAQ,QAAQ,EAAE,KAAK,SAAS,EAC5C,OAAOA,EAAK,QAAQ,UAAU,EAAE,KAAK,QAAQ,EAC7C,OAAOA,EAAK,QAAQ,UAAU,EAAE,KAAK,OAAO,EAC5C,OAAOA,EAAK,QAAQ,eAAe,EAAE,KAAK,MAAM,EAChD,OAAOA,EAAK,QAAQ,cAAc,EAAE,KAAK,MAAM,EAC/C,OAAOA,EAAK,SAAS,EAAE,KAAK,aAAa,CAC3C,CAAC,EAED,GAAG,qEAAsE,SAAY,CAEnFJ,EAAS,KAAK,sBAAsB,MAAS,EAC7C,MAAMK,EAAqC,CACzC,GAAGP,EACH,qBAAsB,SACxB,EAGA,MAAMG,EAAW,OAAOI,CAAa,EAGrC,MAAMD,EAAOJ,EAAS,KAAK,KAAK,MAAM,CAAC,EAAG,CAAC,EAC3C,OAAOI,EAAK,UAAU,oBAAoB,EAAE,KAAK,SAAS,CAC5D,CAAC,CACH,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["import {\n type DmkNetworkClient,\n type LoggerPublisherService,\n} from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { BlindSignReason } from \"@/modules/multichain/reporter/model/BlindSigningEvent\";\nimport {\n type EthSignReportParams,\n type SolSignReportParams,\n} from \"@/modules/multichain/sign-reporter/model/SignReportParams\";\nimport { BlindSigningModelId } from \"@/shared/model/BlindSigningModelId\";\n\nimport { HttpSignReporterDatasource } from \"./HttpSignReporterDatasource\";\n\ndescribe(\"HttpSignReporterDatasource\", () => {\n const config = {\n reporter: { url: \"https://reporter.test\" },\n appSource: \"third-party\",\n originToken: \"originToken\",\n } as ContextModuleServiceConfig;\n\n const envFields = {\n modelId: BlindSigningModelId.NANO_X,\n signerAppVersion: \"1.4.0\",\n deviceVersion: \"2.2.3\",\n };\n\n const solParams: SolSignReportParams = {\n ...envFields,\n chain: \"SOL\",\n signatureId: \"abc123-1738850400000\",\n signingMethod: \"sol_signTransaction\",\n isBlindSign: true,\n targetAddress: \"JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4\",\n blindSignReason: BlindSignReason.UNRECOGNIZED_PROGRAM,\n programIds: [\n \"JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4\",\n \"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA\",\n ],\n unrecognizedPrograms: [\"JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4\"],\n };\n\n const ethParams: EthSignReportParams = {\n ...envFields,\n chain: \"ETH\",\n signatureId: \"def456-1738850400000\",\n signingMethod: \"eth_signTransaction\",\n isBlindSign: false,\n chainId: 1,\n targetAddress: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n blindSignReason: null,\n };\n\n let httpMock: { post: ReturnType<typeof vi.fn> };\n let dataSource: HttpSignReporterDatasource;\n\n beforeEach(() => {\n vi.resetAllMocks();\n httpMock = { post: vi.fn() };\n dataSource = new HttpSignReporterDatasource(\n config,\n () =>\n ({\n debug: vi.fn(),\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n }) as unknown as LoggerPublisherService,\n httpMock as unknown as DmkNetworkClient,\n );\n });\n\n describe(\"report\", () => {\n it(\"should return Right(undefined) on success\", async () => {\n // GIVEN\n httpMock.post.mockResolvedValueOnce(undefined);\n\n // WHEN\n const result = await dataSource.report(solParams);\n\n // THEN\n expect(result).toEqual(Right(undefined));\n });\n\n it(\"should return Left(Error) when the request fails\", async () => {\n // GIVEN\n httpMock.post.mockRejectedValueOnce(new Error(\"network error\"));\n\n // WHEN\n const result = await dataSource.report(solParams);\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpSignReporterDatasource: Failed to report signing event\",\n ),\n ),\n );\n });\n\n it(\"should call the v2 endpoint with the correct URL\", async () => {\n // GIVEN\n httpMock.post.mockResolvedValueOnce(undefined);\n\n // WHEN\n await dataSource.report(solParams);\n\n // THEN\n expect(httpMock.post).toHaveBeenCalledWith(\n `${config.reporter.url}/v2/blind-signing-events`,\n expect.anything(),\n { responseType: \"void\" },\n );\n });\n\n it(\"should build correct three-layer body for SOL params\", async () => {\n // GIVEN\n httpMock.post.mockResolvedValueOnce(undefined);\n\n // WHEN\n await dataSource.report(solParams);\n\n // THEN\n expect(httpMock.post).toHaveBeenCalledWith(\n expect.any(String),\n {\n chain: \"SOL\",\n isBlindSign: true,\n sessionId: null,\n chainData: {\n signatureId: solParams.signatureId,\n signingMethod: \"sol_signTransaction\",\n targetAddress: solParams.targetAddress,\n blindSignReason: BlindSignReason.UNRECOGNIZED_PROGRAM,\n programIds: solParams.programIds,\n unrecognizedPrograms: solParams.unrecognizedPrograms,\n },\n envData: {\n modelId: BlindSigningModelId.NANO_X,\n signerAppVersion: \"1.4.0\",\n deviceVersion: \"2.2.3\",\n source: \"third-party\",\n },\n },\n { responseType: \"void\" },\n );\n });\n\n it(\"should build correct three-layer body for ETH params\", async () => {\n // GIVEN\n httpMock.post.mockResolvedValueOnce(undefined);\n\n // WHEN\n await dataSource.report(ethParams);\n\n // THEN\n expect(httpMock.post).toHaveBeenCalledWith(\n expect.any(String),\n {\n chain: \"ETH\",\n isBlindSign: false,\n sessionId: null,\n chainData: {\n signatureId: ethParams.signatureId,\n signingMethod: \"eth_signTransaction\",\n targetAddress: ethParams.targetAddress,\n chainId: 1,\n blindSignReason: null,\n },\n envData: {\n modelId: BlindSigningModelId.NANO_X,\n signerAppVersion: \"1.4.0\",\n deviceVersion: \"2.2.3\",\n source: \"third-party\",\n },\n },\n { responseType: \"void\" },\n );\n });\n\n it(\"should include optional env fields when provided\", async () => {\n // GIVEN\n httpMock.post.mockResolvedValueOnce(undefined);\n const paramsWithOptional: SolSignReportParams = {\n ...solParams,\n platform: \"desktop\",\n appVersion: \"2.80.0\",\n platformOS: \"macOS\",\n platformVersion: \"14.5\",\n liveAppContext: \"swap\",\n sessionId: \"session-abc\",\n };\n\n // WHEN\n await dataSource.report(paramsWithOptional);\n\n // THEN\n const body = httpMock.post.mock.calls[0]![1];\n expect(body.envData.platform).toBe(\"desktop\");\n expect(body.envData.appVersion).toBe(\"2.80.0\");\n expect(body.envData.platformOS).toBe(\"macOS\");\n expect(body.envData.platformVersion).toBe(\"14.5\");\n expect(body.envData.liveAppContext).toBe(\"swap\");\n expect(body.sessionId).toBe(\"session-abc\");\n });\n\n it(\"should include transactionSignature in SOL chainData when provided\", async () => {\n // GIVEN\n httpMock.post.mockResolvedValueOnce(undefined);\n const paramsWithSig: SolSignReportParams = {\n ...solParams,\n transactionSignature: \"5yJ9...\",\n };\n\n // WHEN\n await dataSource.report(paramsWithSig);\n\n // THEN\n const body = httpMock.post.mock.calls[0]![1];\n expect(body.chainData.transactionSignature).toBe(\"5yJ9...\");\n });\n });\n});\n"],
5
+ "mappings": "AAIA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAG5B,OAAS,mBAAAC,MAAuB,wDAKhC,OAAS,uBAAAC,MAA2B,qCAEpC,OAAS,8BAAAC,MAAkC,+BAE3C,SAAS,6BAA8B,IAAM,CAC3C,MAAMC,EAAS,CACb,SAAU,CAAE,IAAK,uBAAwB,EACzC,UAAW,cACX,YAAa,aACf,EAEMC,EAAY,CAChB,QAASH,EAAoB,OAC7B,iBAAkB,QAClB,cAAe,OACjB,EAEMI,EAAiC,CACrC,GAAGD,EACH,MAAO,MACP,YAAa,uBACb,cAAe,sBACf,YAAa,GACb,cAAe,8CACf,gBAAiBJ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AK,aAAa,CAC3C,CAAC,EAED,GAAG,qEAAsE,SAAY,CAEnFJ,EAAS,KAAK,sBAAsB,MAAS,EAC7C,MAAMK,EAAqC,CACzC,GAAGP,EACH,qBAAsB,SACxB,EAGA,MAAMG,EAAW,OAAOI,CAAa,EAGrC,MAAMD,EAAOJ,EAAS,KAAK,KAAK,MAAM,CAAC,EAAG,CAAC,EAC3C,OAAOI,EAAK,UAAU,oBAAoB,EAAE,KAAK,SAAS,CAC5D,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["Left", "Right", "BlindSignReason", "BlindSigningModelId", "HttpSignReporterDatasource", "config", "envFields", "solParams", "ethParams", "httpMock", "dataSource", "result", "paramsWithOptional", "body", "paramsWithSig"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{DeviceModelId as d}from"@ledgerhq/device-management-kit";import{Left as f,Right as l}from"purify-ts";import{beforeEach as y,describe as p,expect as a,it as s,vi as n}from"vitest";import{ClearSignContextType as c}from"../../../../shared/model/ClearSignContext";import{EnumVariantContextLoader as R}from"./EnumVariantContextLoader";const N=()=>({debug:n.fn(),info:n.fn(),warn:n.fn(),error:n.fn(),subscribers:[]}),v={keyUsageNumber:8,payload:new Uint8Array([66])},u={cal:{url:"https://global.api.prd.ledger.com/cal/v1",mode:"prod",branch:"main"}},t="JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4",A="OtherProgram111111111111111111111111111111";function I(){return{programId:t,descriptors:{},enumVariants:[{enumId:"swap",variantIndex:46,descriptor:{data:"01_raydium_tlv",signature:"prodsig_v46"}},{enumId:"swap",variantIndex:12,descriptor:{data:"01_orca_tlv",signature:"prodsig_v12"}}]}}p("EnumVariantContextLoader",()=>{let i,m;y(()=>{n.restoreAllMocks(),i={getInstructionInfo:n.fn()},m={loadCertificate:n.fn().mockResolvedValue(v)}});const o=(e=u)=>new R(i,e,m,N);p("canHandle",()=>{s("returns true when SOLANA_ENUM_VARIANT is requested and selections are valid",()=>{a(o().canHandle({deviceModelId:d.NANO_X,selections:[{programId:t,enumId:"swap",variantIndex:46}]},[c.SOLANA_ENUM_VARIANT])).toBe(!0)}),s("returns false when SOLANA_ENUM_VARIANT is not requested",()=>{a(o().canHandle({deviceModelId:d.NANO_X,selections:[{programId:t,enumId:"swap",variantIndex:46}]},[c.SOLANA_INSTRUCTION_INFO])).toBe(!1)}),s.each([-1,65536,1.5,"46",null])("rejects non-u16 variantIndex: %s",e=>{const r=o();a(r.canHandle({deviceModelId:d.NANO_X,selections:[{programId:t,enumId:"swap",variantIndex:e}]},[c.SOLANA_ENUM_VARIANT])).toBe(!1)}),s("rejects empty programId / enumId / selections",()=>{const e=o(),r=[c.SOLANA_ENUM_VARIANT];a(e.canHandle({selections:[]},r)).toBe(!1),a(e.canHandle({selections:[{programId:"",enumId:"swap",variantIndex:1}]},r)).toBe(!1),a(e.canHandle({selections:[{programId:t,enumId:"",variantIndex:1}]},r)).toBe(!1)})}),p("load",()=>{s("emits one SOLANA_ENUM_VARIANT per selection with certificate",async()=>{n.spyOn(i,"getInstructionInfo").mockResolvedValue(l(I()));const e=await o().load({deviceModelId:d.NANO_X,selections:[{programId:t,enumId:"swap",variantIndex:46},{programId:t,enumId:"swap",variantIndex:12}]});a(e).toHaveLength(2),a(e[0]).toMatchObject({type:c.SOLANA_ENUM_VARIANT,payload:{programId:t,enumId:"swap",variantIndex:46,descriptor:{data:"01_raydium_tlv",signature:"prodsig_v46"}},certificate:v}),a(e[1]).toMatchObject({payload:{variantIndex:12,descriptor:{data:"01_orca_tlv",signature:"prodsig_v12"}}})}),s("dedups CAL fetches across selections that share a programId",async()=>{const e=n.spyOn(i,"getInstructionInfo").mockResolvedValue(l(I()));await o().load({deviceModelId:d.NANO_X,selections:[{programId:t,enumId:"swap",variantIndex:46},{programId:t,enumId:"swap",variantIndex:12}]}),a(e).toHaveBeenCalledTimes(1)}),s("resolves a variant index > 255 (u16, disc_kind U16 enums)",async()=>{const e={programId:t,descriptors:{},enumVariants:[{enumId:"swap",variantIndex:300,descriptor:{data:"01_big_tlv",signature:"prodsig_v300"}}]};n.spyOn(i,"getInstructionInfo").mockResolvedValue(l(e));const r=await o().load({deviceModelId:d.NANO_X,selections:[{programId:t,enumId:"swap",variantIndex:300}]});a(r).toHaveLength(1),a(r[0]?.type).toBe(c.SOLANA_ENUM_VARIANT),a(r[0].payload).toMatchObject({variantIndex:300,descriptor:{data:"01_big_tlv",signature:"prodsig_v300"}})}),s("emits ERROR when CAL has no matching variant for a selection",async()=>{n.spyOn(i,"getInstructionInfo").mockResolvedValue(l(I()));const e=await o().load({deviceModelId:d.NANO_X,selections:[{programId:t,enumId:"swap",variantIndex:99}]});a(e).toHaveLength(1),a(e[0]?.type).toBe(c.ERROR),a(e[0].error.message).toMatch(/no enum variant/)}),s("emits ERROR when CAL fetch fails",async()=>{n.spyOn(i,"getInstructionInfo").mockResolvedValue(f(new Error("upstream-500")));const e=await o().load({deviceModelId:d.NANO_X,selections:[{programId:A,enumId:"x",variantIndex:0}]});a(e[0]?.type).toBe(c.ERROR),a(e[0].error.message).toBe("upstream-500")}),s("emits ERROR when configured signature mode is missing",async()=>{const e={programId:t,descriptors:{},enumVariants:[{enumId:"swap",variantIndex:46,descriptor:{data:"01_raydium_tlv",signature:""}}]};n.spyOn(i,"getInstructionInfo").mockResolvedValue(l(e));const g=await o({...u,cal:{...u.cal,mode:"test"}}).load({deviceModelId:d.NANO_X,selections:[{programId:t,enumId:"swap",variantIndex:46}]});a(g[0]?.type).toBe(c.ERROR),a(g[0].error.message).toMatch(/missing 'test' signature/)}),s("degrades every selection to ERROR when certificate loading fails",async()=>{n.spyOn(m,"loadCertificate").mockRejectedValue(new Error("pki-down")),n.spyOn(i,"getInstructionInfo").mockResolvedValue(l(I()));const e=await o().load({deviceModelId:d.NANO_X,selections:[{programId:t,enumId:"swap",variantIndex:46},{programId:t,enumId:"swap",variantIndex:12}]});a(e).toHaveLength(2),a(e.every(r=>r.type===c.ERROR)).toBe(!0)}),s("falls back to default network when input.network is empty / missing",async()=>{const e=n.spyOn(i,"getInstructionInfo").mockResolvedValue(l(I()));await o().load({deviceModelId:d.NANO_X,selections:[{programId:t,enumId:"swap",variantIndex:46}],network:""}),a(e).toHaveBeenCalledWith({programId:t,network:"solana-mainnet"})})})});
1
+ import{DeviceModelId as d}from"@ledgerhq/device-management-kit";import{Left as f,Right as l}from"purify-ts";import{beforeEach as y,describe as p,expect as a,it as s,vi as n}from"vitest";import{ClearSignContextType as c}from"../../../../shared/model/ClearSignContext";import{EnumVariantContextLoader as R}from"./EnumVariantContextLoader";const N=()=>({debug:n.fn(),info:n.fn(),warn:n.fn(),error:n.fn(),subscribers:[]}),v={keyUsageNumber:8,payload:new Uint8Array([66])},u={cal:{url:"https://global.api.prd.ledger.com/cal/v1",mode:"prod",branch:"main"}},t="JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4",A="OtherProgram111111111111111111111111111111";function I(){return{programId:t,descriptors:{},basicFlowTags:[],enumVariants:[{enumId:"swap",variantIndex:46,descriptor:{data:"01_raydium_tlv",signature:"prodsig_v46"}},{enumId:"swap",variantIndex:12,descriptor:{data:"01_orca_tlv",signature:"prodsig_v12"}}]}}p("EnumVariantContextLoader",()=>{let i,m;y(()=>{n.restoreAllMocks(),i={getInstructionInfo:n.fn()},m={loadCertificate:n.fn().mockResolvedValue(v)}});const o=(e=u)=>new R(i,e,m,N);p("canHandle",()=>{s("returns true when SOLANA_ENUM_VARIANT is requested and selections are valid",()=>{a(o().canHandle({deviceModelId:d.NANO_X,selections:[{programId:t,enumId:"swap",variantIndex:46}]},[c.SOLANA_ENUM_VARIANT])).toBe(!0)}),s("returns false when SOLANA_ENUM_VARIANT is not requested",()=>{a(o().canHandle({deviceModelId:d.NANO_X,selections:[{programId:t,enumId:"swap",variantIndex:46}]},[c.SOLANA_INSTRUCTION_INFO])).toBe(!1)}),s.each([-1,65536,1.5,"46",null])("rejects non-u16 variantIndex: %s",e=>{const r=o();a(r.canHandle({deviceModelId:d.NANO_X,selections:[{programId:t,enumId:"swap",variantIndex:e}]},[c.SOLANA_ENUM_VARIANT])).toBe(!1)}),s("rejects empty programId / enumId / selections",()=>{const e=o(),r=[c.SOLANA_ENUM_VARIANT];a(e.canHandle({selections:[]},r)).toBe(!1),a(e.canHandle({selections:[{programId:"",enumId:"swap",variantIndex:1}]},r)).toBe(!1),a(e.canHandle({selections:[{programId:t,enumId:"",variantIndex:1}]},r)).toBe(!1)})}),p("load",()=>{s("emits one SOLANA_ENUM_VARIANT per selection with certificate",async()=>{n.spyOn(i,"getInstructionInfo").mockResolvedValue(l(I()));const e=await o().load({deviceModelId:d.NANO_X,selections:[{programId:t,enumId:"swap",variantIndex:46},{programId:t,enumId:"swap",variantIndex:12}]});a(e).toHaveLength(2),a(e[0]).toMatchObject({type:c.SOLANA_ENUM_VARIANT,payload:{programId:t,enumId:"swap",variantIndex:46,descriptor:{data:"01_raydium_tlv",signature:"prodsig_v46"}},certificate:v}),a(e[1]).toMatchObject({payload:{variantIndex:12,descriptor:{data:"01_orca_tlv",signature:"prodsig_v12"}}})}),s("dedups CAL fetches across selections that share a programId",async()=>{const e=n.spyOn(i,"getInstructionInfo").mockResolvedValue(l(I()));await o().load({deviceModelId:d.NANO_X,selections:[{programId:t,enumId:"swap",variantIndex:46},{programId:t,enumId:"swap",variantIndex:12}]}),a(e).toHaveBeenCalledTimes(1)}),s("resolves a variant index > 255 (u16, disc_kind U16 enums)",async()=>{const e={programId:t,descriptors:{},basicFlowTags:[],enumVariants:[{enumId:"swap",variantIndex:300,descriptor:{data:"01_big_tlv",signature:"prodsig_v300"}}]};n.spyOn(i,"getInstructionInfo").mockResolvedValue(l(e));const r=await o().load({deviceModelId:d.NANO_X,selections:[{programId:t,enumId:"swap",variantIndex:300}]});a(r).toHaveLength(1),a(r[0]?.type).toBe(c.SOLANA_ENUM_VARIANT),a(r[0].payload).toMatchObject({variantIndex:300,descriptor:{data:"01_big_tlv",signature:"prodsig_v300"}})}),s("emits ERROR when CAL has no matching variant for a selection",async()=>{n.spyOn(i,"getInstructionInfo").mockResolvedValue(l(I()));const e=await o().load({deviceModelId:d.NANO_X,selections:[{programId:t,enumId:"swap",variantIndex:99}]});a(e).toHaveLength(1),a(e[0]?.type).toBe(c.ERROR),a(e[0].error.message).toMatch(/no enum variant/)}),s("emits ERROR when CAL fetch fails",async()=>{n.spyOn(i,"getInstructionInfo").mockResolvedValue(f(new Error("upstream-500")));const e=await o().load({deviceModelId:d.NANO_X,selections:[{programId:A,enumId:"x",variantIndex:0}]});a(e[0]?.type).toBe(c.ERROR),a(e[0].error.message).toBe("upstream-500")}),s("emits ERROR when configured signature mode is missing",async()=>{const e={programId:t,descriptors:{},basicFlowTags:[],enumVariants:[{enumId:"swap",variantIndex:46,descriptor:{data:"01_raydium_tlv",signature:""}}]};n.spyOn(i,"getInstructionInfo").mockResolvedValue(l(e));const g=await o({...u,cal:{...u.cal,mode:"test"}}).load({deviceModelId:d.NANO_X,selections:[{programId:t,enumId:"swap",variantIndex:46}]});a(g[0]?.type).toBe(c.ERROR),a(g[0].error.message).toMatch(/missing 'test' signature/)}),s("degrades every selection to ERROR when certificate loading fails",async()=>{n.spyOn(m,"loadCertificate").mockRejectedValue(new Error("pki-down")),n.spyOn(i,"getInstructionInfo").mockResolvedValue(l(I()));const e=await o().load({deviceModelId:d.NANO_X,selections:[{programId:t,enumId:"swap",variantIndex:46},{programId:t,enumId:"swap",variantIndex:12}]});a(e).toHaveLength(2),a(e.every(r=>r.type===c.ERROR)).toBe(!0)}),s("falls back to default network when input.network is empty / missing",async()=>{const e=n.spyOn(i,"getInstructionInfo").mockResolvedValue(l(I()));await o().load({deviceModelId:d.NANO_X,selections:[{programId:t,enumId:"swap",variantIndex:46}],network:""}),a(e).toHaveBeenCalledWith({programId:t,network:"solana-mainnet"})})})});
2
2
  //# sourceMappingURL=EnumVariantContextLoader.test.js.map