@ledgerhq/context-module 0.0.0-opt-in-result-20250428093422 → 0.0.0-proxy-transport-20250715134556

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 (213) hide show
  1. package/lib/cjs/package.json +12 -12
  2. package/lib/cjs/src/ContextModule.js +1 -1
  3. package/lib/cjs/src/ContextModule.js.map +1 -1
  4. package/lib/cjs/src/ContextModuleBuilder.js +1 -1
  5. package/lib/cjs/src/ContextModuleBuilder.js.map +3 -3
  6. package/lib/cjs/src/ContextModuleBuilder.test.js +1 -1
  7. package/lib/cjs/src/ContextModuleBuilder.test.js.map +3 -3
  8. package/lib/cjs/src/DefaultContextModule.js +1 -1
  9. package/lib/cjs/src/DefaultContextModule.js.map +3 -3
  10. package/lib/cjs/src/DefaultContextModule.test.js +1 -1
  11. package/lib/cjs/src/DefaultContextModule.test.js.map +2 -2
  12. package/lib/cjs/src/config/di/configModuleFactory.js +1 -1
  13. package/lib/cjs/src/config/di/configModuleFactory.js.map +3 -3
  14. package/lib/cjs/src/config/model/ContextModuleConfig.js +1 -1
  15. package/lib/cjs/src/config/model/ContextModuleConfig.js.map +1 -1
  16. package/lib/cjs/src/di.js +1 -1
  17. package/lib/cjs/src/di.js.map +3 -3
  18. package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js +1 -1
  19. package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js.map +3 -3
  20. package/lib/cjs/src/nft/data/HttpNftDataSource.js +1 -1
  21. package/lib/cjs/src/nft/data/HttpNftDataSource.js.map +3 -3
  22. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js +1 -1
  23. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js.map +2 -2
  24. package/lib/cjs/src/nft/di/nftModuleFactory.js +1 -1
  25. package/lib/cjs/src/nft/di/nftModuleFactory.js.map +3 -3
  26. package/lib/cjs/src/pki/di/pkiModuleFactory.js +1 -1
  27. package/lib/cjs/src/pki/di/pkiModuleFactory.js.map +3 -3
  28. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.js +1 -1
  29. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.js.map +3 -3
  30. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js +1 -1
  31. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +3 -3
  32. package/lib/cjs/src/shared/model/SolanaTransactionContext.js +2 -0
  33. package/lib/cjs/src/shared/model/SolanaTransactionContext.js.map +7 -0
  34. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js +2 -0
  35. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +7 -0
  36. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +2 -0
  37. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +7 -0
  38. package/lib/cjs/src/solana/data/SolanaDataSource.js +2 -0
  39. package/lib/cjs/src/solana/data/SolanaDataSource.js.map +7 -0
  40. package/lib/cjs/src/solana/di/SolanaContextModuleFactory.js +2 -0
  41. package/lib/cjs/src/solana/di/SolanaContextModuleFactory.js.map +7 -0
  42. package/lib/cjs/src/solana/di/solanaContextTypes.js +2 -0
  43. package/lib/cjs/src/solana/di/solanaContextTypes.js.map +7 -0
  44. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.js +2 -0
  45. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.js.map +7 -0
  46. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.test.js +2 -0
  47. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.test.js.map +7 -0
  48. package/lib/cjs/src/solana/domain/SolanaContextLoader.js +2 -0
  49. package/lib/cjs/src/solana/domain/SolanaContextLoader.js.map +7 -0
  50. package/lib/cjs/src/solana/domain/solanaContextTypes.js +2 -0
  51. package/lib/cjs/src/solana/domain/solanaContextTypes.js.map +7 -0
  52. package/lib/cjs/src/token/di/tokenModuleFactory.js +1 -1
  53. package/lib/cjs/src/token/di/tokenModuleFactory.js.map +3 -3
  54. package/lib/cjs/src/transaction/data/HttpProxyDataSource.js +2 -0
  55. package/lib/cjs/src/transaction/data/HttpProxyDataSource.js.map +7 -0
  56. package/lib/cjs/src/transaction/data/HttpProxyDataSource.test.js +2 -0
  57. package/lib/cjs/src/transaction/data/HttpProxyDataSource.test.js.map +7 -0
  58. package/lib/cjs/src/transaction/data/ProxyDelegateCallDto.js +2 -0
  59. package/lib/cjs/src/transaction/data/ProxyDelegateCallDto.js.map +7 -0
  60. package/lib/cjs/src/transaction/data/ProxyImplementationAddressDto.js +2 -0
  61. package/lib/cjs/src/transaction/data/ProxyImplementationAddressDto.js.map +7 -0
  62. package/lib/cjs/src/transaction/di/transactionModuleFactory.js +1 -1
  63. package/lib/cjs/src/transaction/di/transactionModuleFactory.js.map +3 -3
  64. package/lib/cjs/src/transaction/di/transactionTypes.js +1 -1
  65. package/lib/cjs/src/transaction/di/transactionTypes.js.map +2 -2
  66. package/lib/cjs/src/transaction/model/ProxyDelegateCall.js +2 -0
  67. package/lib/cjs/src/transaction/model/ProxyDelegateCall.js.map +7 -0
  68. package/lib/cjs/src/transaction/model/ProxyImplementationAddress.js +2 -0
  69. package/lib/cjs/src/transaction/model/ProxyImplementationAddress.js.map +7 -0
  70. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  71. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js.map +2 -2
  72. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  73. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +2 -2
  74. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
  75. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
  76. package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js +1 -1
  77. package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js.map +3 -3
  78. package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js +1 -1
  79. package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js.map +3 -3
  80. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
  81. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js.map +2 -2
  82. package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js +1 -1
  83. package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js.map +3 -3
  84. package/lib/esm/package.json +12 -12
  85. package/lib/esm/src/ContextModuleBuilder.js +1 -1
  86. package/lib/esm/src/ContextModuleBuilder.js.map +3 -3
  87. package/lib/esm/src/ContextModuleBuilder.test.js +1 -1
  88. package/lib/esm/src/ContextModuleBuilder.test.js.map +3 -3
  89. package/lib/esm/src/DefaultContextModule.js +1 -1
  90. package/lib/esm/src/DefaultContextModule.js.map +3 -3
  91. package/lib/esm/src/DefaultContextModule.test.js +1 -1
  92. package/lib/esm/src/DefaultContextModule.test.js.map +2 -2
  93. package/lib/esm/src/config/di/configModuleFactory.js +1 -1
  94. package/lib/esm/src/config/di/configModuleFactory.js.map +3 -3
  95. package/lib/esm/src/di.js +1 -1
  96. package/lib/esm/src/di.js.map +3 -3
  97. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js +1 -1
  98. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js.map +3 -3
  99. package/lib/esm/src/nft/data/HttpNftDataSource.js +1 -1
  100. package/lib/esm/src/nft/data/HttpNftDataSource.js.map +3 -3
  101. package/lib/esm/src/nft/data/HttpNftDataSource.test.js +1 -1
  102. package/lib/esm/src/nft/data/HttpNftDataSource.test.js.map +2 -2
  103. package/lib/esm/src/nft/di/nftModuleFactory.js +1 -1
  104. package/lib/esm/src/nft/di/nftModuleFactory.js.map +3 -3
  105. package/lib/esm/src/pki/di/pkiModuleFactory.js +1 -1
  106. package/lib/esm/src/pki/di/pkiModuleFactory.js.map +3 -3
  107. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.js +1 -1
  108. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.js.map +3 -3
  109. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js +1 -1
  110. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +3 -3
  111. package/lib/esm/src/shared/model/SolanaTransactionContext.js +1 -0
  112. package/lib/esm/src/shared/model/SolanaTransactionContext.js.map +7 -0
  113. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js +2 -0
  114. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +7 -0
  115. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +2 -0
  116. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +7 -0
  117. package/lib/esm/src/solana/data/SolanaDataSource.js +1 -0
  118. package/lib/esm/src/solana/data/SolanaDataSource.js.map +7 -0
  119. package/lib/esm/src/solana/di/SolanaContextModuleFactory.js +2 -0
  120. package/lib/esm/src/solana/di/SolanaContextModuleFactory.js.map +7 -0
  121. package/lib/esm/src/solana/di/solanaContextTypes.js +2 -0
  122. package/lib/esm/src/solana/di/solanaContextTypes.js.map +7 -0
  123. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.js +2 -0
  124. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.js.map +7 -0
  125. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.test.js +2 -0
  126. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.test.js.map +7 -0
  127. package/lib/esm/src/solana/domain/SolanaContextLoader.js +1 -0
  128. package/lib/esm/src/solana/domain/SolanaContextLoader.js.map +7 -0
  129. package/lib/esm/src/solana/domain/solanaContextTypes.js +1 -0
  130. package/lib/esm/src/solana/domain/solanaContextTypes.js.map +7 -0
  131. package/lib/esm/src/token/di/tokenModuleFactory.js +1 -1
  132. package/lib/esm/src/token/di/tokenModuleFactory.js.map +3 -3
  133. package/lib/esm/src/transaction/data/HttpProxyDataSource.js +2 -0
  134. package/lib/esm/src/transaction/data/HttpProxyDataSource.js.map +7 -0
  135. package/lib/esm/src/transaction/data/HttpProxyDataSource.test.js +2 -0
  136. package/lib/esm/src/transaction/data/HttpProxyDataSource.test.js.map +7 -0
  137. package/lib/esm/src/transaction/data/ProxyDelegateCallDto.js +1 -0
  138. package/lib/esm/src/transaction/data/ProxyDelegateCallDto.js.map +7 -0
  139. package/lib/esm/src/transaction/data/ProxyImplementationAddressDto.js +1 -0
  140. package/lib/esm/src/transaction/data/ProxyImplementationAddressDto.js.map +7 -0
  141. package/lib/esm/src/transaction/di/transactionModuleFactory.js +1 -1
  142. package/lib/esm/src/transaction/di/transactionModuleFactory.js.map +3 -3
  143. package/lib/esm/src/transaction/di/transactionTypes.js +1 -1
  144. package/lib/esm/src/transaction/di/transactionTypes.js.map +2 -2
  145. package/lib/esm/src/transaction/model/ProxyDelegateCall.js +1 -0
  146. package/lib/esm/src/transaction/model/ProxyDelegateCall.js.map +7 -0
  147. package/lib/esm/src/transaction/model/ProxyImplementationAddress.js +1 -0
  148. package/lib/esm/src/transaction/model/ProxyImplementationAddress.js.map +7 -0
  149. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  150. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js.map +2 -2
  151. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  152. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +2 -2
  153. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
  154. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
  155. package/lib/esm/src/typed-data/di/typedDataModuleFactory.js +1 -1
  156. package/lib/esm/src/typed-data/di/typedDataModuleFactory.js.map +3 -3
  157. package/lib/esm/src/uniswap/di/uniswapModuleFactory.js +1 -1
  158. package/lib/esm/src/uniswap/di/uniswapModuleFactory.js.map +3 -3
  159. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
  160. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js.map +2 -2
  161. package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js +1 -1
  162. package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js.map +3 -3
  163. package/lib/types/src/ContextModule.d.ts +3 -0
  164. package/lib/types/src/ContextModule.d.ts.map +1 -1
  165. package/lib/types/src/ContextModuleBuilder.d.ts +18 -3
  166. package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -1
  167. package/lib/types/src/DefaultContextModule.d.ts +5 -0
  168. package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
  169. package/lib/types/src/config/di/configModuleFactory.d.ts.map +1 -1
  170. package/lib/types/src/config/model/ContextModuleConfig.d.ts +6 -0
  171. package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -1
  172. package/lib/types/src/di.d.ts.map +1 -1
  173. package/lib/types/src/nft/data/HttpNftDataSource.d.ts +3 -0
  174. package/lib/types/src/nft/data/HttpNftDataSource.d.ts.map +1 -1
  175. package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.d.ts.map +1 -1
  176. package/lib/types/src/shared/model/SolanaTransactionContext.d.ts +11 -0
  177. package/lib/types/src/shared/model/SolanaTransactionContext.d.ts.map +1 -0
  178. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.d.ts +13 -0
  179. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.d.ts.map +1 -0
  180. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.test.d.ts +2 -0
  181. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.test.d.ts.map +1 -0
  182. package/lib/types/src/solana/data/SolanaDataSource.d.ts +12 -0
  183. package/lib/types/src/solana/data/SolanaDataSource.d.ts.map +1 -0
  184. package/lib/types/src/solana/di/SolanaContextModuleFactory.d.ts +3 -0
  185. package/lib/types/src/solana/di/SolanaContextModuleFactory.d.ts.map +1 -0
  186. package/lib/types/src/solana/di/solanaContextTypes.d.ts +5 -0
  187. package/lib/types/src/solana/di/solanaContextTypes.d.ts.map +1 -0
  188. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.d.ts +11 -0
  189. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.d.ts.map +1 -0
  190. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.test.d.ts +2 -0
  191. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.test.d.ts.map +1 -0
  192. package/lib/types/src/solana/domain/SolanaContextLoader.d.ts +5 -0
  193. package/lib/types/src/solana/domain/SolanaContextLoader.d.ts.map +1 -0
  194. package/lib/types/src/solana/domain/solanaContextTypes.d.ts +27 -0
  195. package/lib/types/src/solana/domain/solanaContextTypes.d.ts.map +1 -0
  196. package/lib/types/src/transaction/data/HttpProxyDataSource.d.ts +32 -0
  197. package/lib/types/src/transaction/data/HttpProxyDataSource.d.ts.map +1 -0
  198. package/lib/types/src/transaction/data/HttpProxyDataSource.test.d.ts +2 -0
  199. package/lib/types/src/transaction/data/HttpProxyDataSource.test.d.ts.map +1 -0
  200. package/lib/types/src/transaction/data/ProxyDelegateCallDto.d.ts +5 -0
  201. package/lib/types/src/transaction/data/ProxyDelegateCallDto.d.ts.map +1 -0
  202. package/lib/types/src/transaction/data/ProxyImplementationAddressDto.d.ts +6 -0
  203. package/lib/types/src/transaction/data/ProxyImplementationAddressDto.d.ts.map +1 -0
  204. package/lib/types/src/transaction/di/transactionModuleFactory.d.ts.map +1 -1
  205. package/lib/types/src/transaction/di/transactionTypes.d.ts +1 -0
  206. package/lib/types/src/transaction/di/transactionTypes.d.ts.map +1 -1
  207. package/lib/types/src/transaction/model/ProxyDelegateCall.d.ts +5 -0
  208. package/lib/types/src/transaction/model/ProxyDelegateCall.d.ts.map +1 -0
  209. package/lib/types/src/transaction/model/ProxyImplementationAddress.d.ts +4 -0
  210. package/lib/types/src/transaction/model/ProxyImplementationAddress.d.ts.map +1 -0
  211. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts.map +1 -1
  212. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  213. package/package.json +14 -14
@@ -1,2 +1,2 @@
1
- import o from"axios";import{Left as s,Right as r}from"purify-ts";import{LEDGER_CLIENT_VERSION_HEADER as n}from"../../shared/constant/HttpHeaders";import{HttpTrustedNameDataSource as d}from"../../trusted-name/data/HttpTrustedNameDataSource";import l from"../../../package.json";vi.mock("axios");describe("HttpTrustedNameDataSource",()=>{let t;beforeAll(()=>{const e={cal:{url:"https://crypto-assets-service.api.ledger.com/v1",mode:"prod",branch:"main"}};t=new d(e),vi.clearAllMocks()}),describe("getDomainNamePayload",()=>{it("should call axios with the correct url and ledger client version header",async()=>{const e=`context-module/${l.version}`,a=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(o,"request").mockImplementation(a),await t.getDomainNamePayload({chainId:137,challenge:"9876",domain:"hello.eth"}),expect(a).toHaveBeenCalledWith(expect.objectContaining({url:"https://nft.api.live.ledger.com/v2/names/ethereum/137/forward/hello.eth?types=eoa&sources=ens&challenge=9876",headers:{[n]:e}}))}),it("should throw an error when axios throws an error",async()=>{vi.spyOn(o,"request").mockRejectedValue(new Error);const e=await t.getDomainNamePayload({chainId:137,challenge:"",domain:"hello.eth"});expect(e).toEqual(s(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name")))}),it("should return an error when no payload is returned",async()=>{const e={data:{test:""}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getDomainNamePayload({chainId:137,challenge:"",domain:"hello.eth"});expect(a).toEqual(s(new Error("[ContextModule] HttpTrustedNameDataSource: error getting domain payload")))}),it("should return a payload",async()=>{const e={data:{signedDescriptor:{data:"payload"}}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getDomainNamePayload({chainId:137,challenge:"challenge",domain:"hello.eth"});expect(a).toEqual(r("payload"))})}),describe("getTrustedNamePayload",()=>{it("should call axios with the correct url and ledger client version header",async()=>{const e=`context-module/${l.version}`,a=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(o,"request").mockImplementation(a),await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"5678",sources:["ens","crypto_asset_list"],types:["eoa"]}),expect(a).toHaveBeenCalledWith(expect.objectContaining({url:"https://nft.api.live.ledger.com/v2/names/ethereum/137/reverse/0x1234?types=eoa&sources=ens,crypto_asset_list&challenge=5678",headers:{[n]:e}}))}),it("should throw an error when axios throws an error",async()=>{vi.spyOn(o,"request").mockRejectedValue(new Error);const e=await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(e).toEqual(s(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name")))}),it("should return an error when no payload is returned",async()=>{const e={data:{test:""}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(a).toEqual(s(new Error("[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address 0x1234")))}),it("should return a payload",async()=>{const e={data:{signedDescriptor:{data:"payload"}}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(a).toEqual(r("payload"))}),it("should return a payload with a signature",async()=>{const e={data:{signedDescriptor:{data:"payload",signatures:{prod:"12345"}}}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(a).toEqual(r("payload153012345"))})})});
1
+ import o from"axios";import{Left as r,Right as s}from"purify-ts";import{LEDGER_CLIENT_VERSION_HEADER as n}from"../../shared/constant/HttpHeaders";import{HttpTrustedNameDataSource as d}from"../../trusted-name/data/HttpTrustedNameDataSource";import l from"../../../package.json";vi.mock("axios");describe("HttpTrustedNameDataSource",()=>{let t;beforeAll(()=>{const e={cal:{url:"https://crypto-assets-service.api.ledger.com/v1",mode:"prod",branch:"main"},metadataService:{url:"https://nft.api.live.ledger.com/v2"}};t=new d(e),vi.clearAllMocks()}),describe("getDomainNamePayload",()=>{it("should call axios with the correct url and ledger client version header",async()=>{const e=`context-module/${l.version}`,a=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(o,"request").mockImplementation(a),await t.getDomainNamePayload({chainId:137,challenge:"9876",domain:"hello.eth"}),expect(a).toHaveBeenCalledWith(expect.objectContaining({url:"https://nft.api.live.ledger.com/v2/names/ethereum/137/forward/hello.eth?types=eoa&sources=ens&challenge=9876",headers:{[n]:e}}))}),it("should throw an error when axios throws an error",async()=>{vi.spyOn(o,"request").mockRejectedValue(new Error);const e=await t.getDomainNamePayload({chainId:137,challenge:"",domain:"hello.eth"});expect(e).toEqual(r(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name")))}),it("should return an error when no payload is returned",async()=>{const e={data:{test:""}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getDomainNamePayload({chainId:137,challenge:"",domain:"hello.eth"});expect(a).toEqual(r(new Error("[ContextModule] HttpTrustedNameDataSource: error getting domain payload")))}),it("should return a payload",async()=>{const e={data:{signedDescriptor:{data:"payload"}}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getDomainNamePayload({chainId:137,challenge:"challenge",domain:"hello.eth"});expect(a).toEqual(s("payload"))})}),describe("getTrustedNamePayload",()=>{it("should call axios with the correct url and ledger client version header",async()=>{const e=`context-module/${l.version}`,a=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(o,"request").mockImplementation(a),await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"5678",sources:["ens","crypto_asset_list"],types:["eoa"]}),expect(a).toHaveBeenCalledWith(expect.objectContaining({url:"https://nft.api.live.ledger.com/v2/names/ethereum/137/reverse/0x1234?types=eoa&sources=ens,crypto_asset_list&challenge=5678",headers:{[n]:e}}))}),it("should throw an error when axios throws an error",async()=>{vi.spyOn(o,"request").mockRejectedValue(new Error);const e=await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(e).toEqual(r(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name")))}),it("should return an error when no payload is returned",async()=>{const e={data:{test:""}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(a).toEqual(r(new Error("[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address 0x1234")))}),it("should return a payload",async()=>{const e={data:{signedDescriptor:{data:"payload"}}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(a).toEqual(s("payload"))}),it("should return a payload with a signature",async()=>{const e={data:{signedDescriptor:{data:"payload",signatures:{prod:"12345"}}}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(a).toEqual(s("payload153012345"))})})});
2
2
  //# sourceMappingURL=HttpTrustedNameDataSource.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/trusted-name/data/HttpTrustedNameDataSource.test.ts"],
4
- "sourcesContent": ["import axios from \"axios\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { LEDGER_CLIENT_VERSION_HEADER } from \"@/shared/constant/HttpHeaders\";\nimport { HttpTrustedNameDataSource } from \"@/trusted-name/data/HttpTrustedNameDataSource\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\nvi.mock(\"axios\");\n\ndescribe(\"HttpTrustedNameDataSource\", () => {\n let datasource: TrustedNameDataSource;\n\n beforeAll(() => {\n const config = {\n cal: {\n url: \"https://crypto-assets-service.api.ledger.com/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n } as ContextModuleConfig;\n datasource = new HttpTrustedNameDataSource(config);\n vi.clearAllMocks();\n });\n\n describe(\"getDomainNamePayload\", () => {\n it(\"should call axios with the correct url and ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() => Promise.resolve({ data: [] }));\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"9876\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/137/forward/hello.eth?types=eoa&sources=ens&challenge=9876`,\n headers: { [LEDGER_CLIENT_VERSION_HEADER]: version },\n }),\n );\n });\n\n it(\"should throw an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error());\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name\",\n ),\n ),\n );\n });\n\n it(\"should return an error when no payload is returned\", async () => {\n // GIVEN\n const response = { data: { test: \"\" } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: error getting domain payload\",\n ),\n ),\n );\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const response = { data: { signedDescriptor: { data: \"payload\" } } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"challenge\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(Right(\"payload\"));\n });\n });\n\n describe(\"getTrustedNamePayload\", () => {\n it(\"should call axios with the correct url and ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() => Promise.resolve({ data: [] }));\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"5678\",\n sources: [\"ens\", \"crypto_asset_list\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/137/reverse/0x1234?types=eoa&sources=ens,crypto_asset_list&challenge=5678`,\n headers: { [LEDGER_CLIENT_VERSION_HEADER]: version },\n }),\n );\n });\n\n it(\"should throw an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error());\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name\",\n ),\n ),\n );\n });\n\n it(\"should return an error when no payload is returned\", async () => {\n // GIVEN\n const response = { data: { test: \"\" } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address 0x1234\",\n ),\n ),\n );\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const response = {\n data: {\n signedDescriptor: { data: \"payload\" },\n },\n };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(Right(\"payload\"));\n });\n\n it(\"should return a payload with a signature\", async () => {\n // GIVEN\n const response = {\n data: {\n signedDescriptor: { data: \"payload\", signatures: { prod: \"12345\" } },\n },\n };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(Right(\"payload153012345\"));\n });\n });\n});\n"],
5
- "mappings": "AAAA,OAAOA,MAAW,QAClB,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAG5B,OAAS,gCAAAC,MAAoC,gCAC7C,OAAS,6BAAAC,MAAiC,gDAE1C,OAAOC,MAAa,qBAEpB,GAAG,KAAK,OAAO,EAEf,SAAS,4BAA6B,IAAM,CAC1C,IAAIC,EAEJ,UAAU,IAAM,CACd,MAAMC,EAAS,CACb,IAAK,CACH,IAAK,kDACL,KAAM,OACN,OAAQ,MACV,CACF,EACAD,EAAa,IAAIF,EAA0BG,CAAM,EACjD,GAAG,cAAc,CACnB,CAAC,EAED,SAAS,uBAAwB,IAAM,CACrC,GAAG,0EAA2E,SAAY,CAExF,MAAMC,EAAU,kBAAkBH,EAAQ,OAAO,GAC3CI,EAAa,GAAG,GAAG,IAAM,QAAQ,QAAQ,CAAE,KAAM,CAAC,CAAE,CAAC,CAAC,EAC5D,GAAG,MAAMT,EAAO,SAAS,EAAE,mBAAmBS,CAAU,EAGxD,MAAMH,EAAW,qBAAqB,CACpC,QAAS,IACT,UAAW,OACX,OAAQ,WACV,CAAC,EAGD,OAAOG,CAAU,EAAE,qBACjB,OAAO,iBAAiB,CACtB,IAAK,+GACL,QAAS,CAAE,C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AE,KAAM,UAAW,WAAY,CAAE,KAAM,OAAQ,CAAE,CACrE,CACF,EACA,GAAG,MAAMX,EAAO,SAAS,EAAE,kBAAkBW,CAAQ,EAGrD,MAAMD,EAAS,MAAMJ,EAAW,sBAAsB,CACpD,QAAS,IACT,QAAS,SACT,UAAW,GACX,QAAS,CAAC,KAAK,EACf,MAAO,CAAC,KAAK,CACf,CAAC,EAGD,OAAOI,CAAM,EAAE,QAAQR,EAAM,kBAAkB,CAAC,CAClD,CAAC,CACH,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { LEDGER_CLIENT_VERSION_HEADER } from \"@/shared/constant/HttpHeaders\";\nimport { HttpTrustedNameDataSource } from \"@/trusted-name/data/HttpTrustedNameDataSource\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\nvi.mock(\"axios\");\n\ndescribe(\"HttpTrustedNameDataSource\", () => {\n let datasource: TrustedNameDataSource;\n\n beforeAll(() => {\n const config = {\n cal: {\n url: \"https://crypto-assets-service.api.ledger.com/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n metadataService: {\n url: \"https://nft.api.live.ledger.com/v2\",\n },\n } as ContextModuleConfig;\n datasource = new HttpTrustedNameDataSource(config);\n vi.clearAllMocks();\n });\n\n describe(\"getDomainNamePayload\", () => {\n it(\"should call axios with the correct url and ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() => Promise.resolve({ data: [] }));\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"9876\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/137/forward/hello.eth?types=eoa&sources=ens&challenge=9876`,\n headers: { [LEDGER_CLIENT_VERSION_HEADER]: version },\n }),\n );\n });\n\n it(\"should throw an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error());\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name\",\n ),\n ),\n );\n });\n\n it(\"should return an error when no payload is returned\", async () => {\n // GIVEN\n const response = { data: { test: \"\" } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: error getting domain payload\",\n ),\n ),\n );\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const response = { data: { signedDescriptor: { data: \"payload\" } } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"challenge\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(Right(\"payload\"));\n });\n });\n\n describe(\"getTrustedNamePayload\", () => {\n it(\"should call axios with the correct url and ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() => Promise.resolve({ data: [] }));\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"5678\",\n sources: [\"ens\", \"crypto_asset_list\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/137/reverse/0x1234?types=eoa&sources=ens,crypto_asset_list&challenge=5678`,\n headers: { [LEDGER_CLIENT_VERSION_HEADER]: version },\n }),\n );\n });\n\n it(\"should throw an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error());\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name\",\n ),\n ),\n );\n });\n\n it(\"should return an error when no payload is returned\", async () => {\n // GIVEN\n const response = { data: { test: \"\" } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address 0x1234\",\n ),\n ),\n );\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const response = {\n data: {\n signedDescriptor: { data: \"payload\" },\n },\n };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(Right(\"payload\"));\n });\n\n it(\"should return a payload with a signature\", async () => {\n // GIVEN\n const response = {\n data: {\n signedDescriptor: { data: \"payload\", signatures: { prod: \"12345\" } },\n },\n };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(Right(\"payload153012345\"));\n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,IAAI,MACF,yEACF,CACF,CACF,CACF,CAAC,EAED,GAAG,qDAAsD,SAAY,CAEnE,MAAMU,EAAW,CAAE,KAAM,CAAE,KAAM,EAAG,CAAE,EACtC,GAAG,MAAMX,EAAO,SAAS,EAAE,kBAAkBW,CAAQ,EAGrD,MAAMD,EAAS,MAAMJ,EAAW,sBAAsB,CACpD,QAAS,IACT,QAAS,SACT,UAAW,GACX,QAAS,CAAC,KAAK,EACf,MAAO,CAAC,KAAK,CACf,CAAC,EAGD,OAAOI,CAAM,EAAE,QACbT,EACE,IAAI,MACF,wFACF,CACF,CACF,CACF,CAAC,EAED,GAAG,0BAA2B,SAAY,CAExC,MAAMU,EAAW,CACf,KAAM,CACJ,iBAAkB,CAAE,KAAM,SAAU,CACtC,CACF,EACA,GAAG,MAAMX,EAAO,SAAS,EAAE,kBAAkBW,CAAQ,EAGrD,MAAMD,EAAS,MAAMJ,EAAW,sBAAsB,CACpD,QAAS,IACT,QAAS,SACT,UAAW,GACX,QAAS,CAAC,KAAK,EACf,MAAO,CAAC,KAAK,CACf,CAAC,EAGD,OAAOI,CAAM,EAAE,QAAQR,EAAM,SAAS,CAAC,CACzC,CAAC,EAED,GAAG,2CAA4C,SAAY,CAEzD,MAAMS,EAAW,CACf,KAAM,CACJ,iBAAkB,CAAE,KAAM,UAAW,WAAY,CAAE,KAAM,OAAQ,CAAE,CACrE,CACF,EACA,GAAG,MAAMX,EAAO,SAAS,EAAE,kBAAkBW,CAAQ,EAGrD,MAAMD,EAAS,MAAMJ,EAAW,sBAAsB,CACpD,QAAS,IACT,QAAS,SACT,UAAW,GACX,QAAS,CAAC,KAAK,EACf,MAAO,CAAC,KAAK,CACf,CAAC,EAGD,OAAOI,CAAM,EAAE,QAAQR,EAAM,kBAAkB,CAAC,CAClD,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["axios", "Left", "Right", "LEDGER_CLIENT_VERSION_HEADER", "HttpTrustedNameDataSource", "PACKAGE", "datasource", "config", "version", "requestSpy", "result", "response"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ContainerModule as o}from"inversify";import{HttpTrustedNameDataSource as r}from"../../trusted-name/data/HttpTrustedNameDataSource";import{trustedNameTypes as e}from"../../trusted-name/di/trustedNameTypes";import{TrustedNameContextLoader as a}from"../../trusted-name/domain/TrustedNameContextLoader";const N=()=>new o((t,m,d,u)=>{t(e.TrustedNameDataSource).to(r),t(e.TrustedNameContextLoader).to(a)});export{N as trustedNameModuleFactory};
1
+ import{ContainerModule as o}from"inversify";import{HttpTrustedNameDataSource as r}from"../../trusted-name/data/HttpTrustedNameDataSource";import{trustedNameTypes as e}from"../../trusted-name/di/trustedNameTypes";import{TrustedNameContextLoader as a}from"../../trusted-name/domain/TrustedNameContextLoader";const p=()=>new o(({bind:t})=>{t(e.TrustedNameDataSource).to(r),t(e.TrustedNameContextLoader).to(a)});export{p as trustedNameModuleFactory};
2
2
  //# sourceMappingURL=trustedNameModuleFactory.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/trusted-name/di/trustedNameModuleFactory.ts"],
4
- "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpTrustedNameDataSource } from \"@/trusted-name/data/HttpTrustedNameDataSource\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\nimport { TrustedNameContextLoader } from \"@/trusted-name/domain/TrustedNameContextLoader\";\n\nexport const trustedNameModuleFactory = () =>\n new ContainerModule((bind, _unbind, _isBound, _rebind) => {\n bind(trustedNameTypes.TrustedNameDataSource).to(HttpTrustedNameDataSource);\n bind(trustedNameTypes.TrustedNameContextLoader).to(\n TrustedNameContextLoader,\n );\n });\n"],
5
- "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,6BAAAC,MAAiC,gDAC1C,OAAS,oBAAAC,MAAwB,qCACjC,OAAS,4BAAAC,MAAgC,iDAElC,MAAMC,EAA2B,IACtC,IAAIJ,EAAgB,CAACK,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAAKH,EAAiB,qBAAqB,EAAE,GAAGD,CAAyB,EACzEI,EAAKH,EAAiB,wBAAwB,EAAE,GAC9CC,CACF,CACF,CAAC",
6
- "names": ["ContainerModule", "HttpTrustedNameDataSource", "trustedNameTypes", "TrustedNameContextLoader", "trustedNameModuleFactory", "bind", "_unbind", "_isBound", "_rebind"]
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpTrustedNameDataSource } from \"@/trusted-name/data/HttpTrustedNameDataSource\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\nimport { TrustedNameContextLoader } from \"@/trusted-name/domain/TrustedNameContextLoader\";\n\nexport const trustedNameModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(trustedNameTypes.TrustedNameDataSource).to(HttpTrustedNameDataSource);\n bind(trustedNameTypes.TrustedNameContextLoader).to(\n TrustedNameContextLoader,\n );\n });\n"],
5
+ "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,6BAAAC,MAAiC,gDAC1C,OAAS,oBAAAC,MAAwB,qCACjC,OAAS,4BAAAC,MAAgC,iDAElC,MAAMC,EAA2B,IACtC,IAAIJ,EAAgB,CAAC,CAAE,KAAAK,CAAK,IAAM,CAChCA,EAAKH,EAAiB,qBAAqB,EAAE,GAAGD,CAAyB,EACzEI,EAAKH,EAAiB,wBAAwB,EAAE,GAC9CC,CACF,CACF,CAAC",
6
+ "names": ["ContainerModule", "HttpTrustedNameDataSource", "trustedNameTypes", "TrustedNameContextLoader", "trustedNameModuleFactory", "bind"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ContainerModule as a}from"inversify";import{HttpTypedDataDataSource as e}from"../../typed-data/data/HttpTypedDataDataSource";import{typedDataTypes as o}from"../../typed-data/di/typedDataTypes";import{DefaultTypedDataContextLoader as r}from"../../typed-data/domain/DefaultTypedDataContextLoader";const u=()=>new a((t,p,d,n)=>{t(o.TypedDataDataSource).to(e),t(o.TypedDataContextLoader).to(r)});export{u as typedDataModuleFactory};
1
+ import{ContainerModule as a}from"inversify";import{HttpTypedDataDataSource as e}from"../../typed-data/data/HttpTypedDataDataSource";import{typedDataTypes as o}from"../../typed-data/di/typedDataTypes";import{DefaultTypedDataContextLoader as r}from"../../typed-data/domain/DefaultTypedDataContextLoader";const y=()=>new a(({bind:t})=>{t(o.TypedDataDataSource).to(e),t(o.TypedDataContextLoader).to(r)});export{y as typedDataModuleFactory};
2
2
  //# sourceMappingURL=typedDataModuleFactory.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/typed-data/di/typedDataModuleFactory.ts"],
4
- "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpTypedDataDataSource } from \"@/typed-data/data/HttpTypedDataDataSource\";\nimport { typedDataTypes } from \"@/typed-data/di/typedDataTypes\";\nimport { DefaultTypedDataContextLoader } from \"@/typed-data/domain/DefaultTypedDataContextLoader\";\n\nexport const typedDataModuleFactory = () =>\n new ContainerModule((bind, _unbind, _isBound, _rebind) => {\n bind(typedDataTypes.TypedDataDataSource).to(HttpTypedDataDataSource);\n bind(typedDataTypes.TypedDataContextLoader).to(\n DefaultTypedDataContextLoader,\n );\n });\n"],
5
- "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,2BAAAC,MAA+B,4CACxC,OAAS,kBAAAC,MAAsB,iCAC/B,OAAS,iCAAAC,MAAqC,oDAEvC,MAAMC,EAAyB,IACpC,IAAIJ,EAAgB,CAACK,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAAKH,EAAe,mBAAmB,EAAE,GAAGD,CAAuB,EACnEI,EAAKH,EAAe,sBAAsB,EAAE,GAC1CC,CACF,CACF,CAAC",
6
- "names": ["ContainerModule", "HttpTypedDataDataSource", "typedDataTypes", "DefaultTypedDataContextLoader", "typedDataModuleFactory", "bind", "_unbind", "_isBound", "_rebind"]
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpTypedDataDataSource } from \"@/typed-data/data/HttpTypedDataDataSource\";\nimport { typedDataTypes } from \"@/typed-data/di/typedDataTypes\";\nimport { DefaultTypedDataContextLoader } from \"@/typed-data/domain/DefaultTypedDataContextLoader\";\n\nexport const typedDataModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(typedDataTypes.TypedDataDataSource).to(HttpTypedDataDataSource);\n bind(typedDataTypes.TypedDataContextLoader).to(\n DefaultTypedDataContextLoader,\n );\n });\n"],
5
+ "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,2BAAAC,MAA+B,4CACxC,OAAS,kBAAAC,MAAsB,iCAC/B,OAAS,iCAAAC,MAAqC,oDAEvC,MAAMC,EAAyB,IACpC,IAAIJ,EAAgB,CAAC,CAAE,KAAAK,CAAK,IAAM,CAChCA,EAAKH,EAAe,mBAAmB,EAAE,GAAGD,CAAuB,EACnEI,EAAKH,EAAe,sBAAsB,EAAE,GAC1CC,CACF,CACF,CAAC",
6
+ "names": ["ContainerModule", "HttpTypedDataDataSource", "typedDataTypes", "DefaultTypedDataContextLoader", "typedDataModuleFactory", "bind"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ContainerModule as r}from"inversify";import{DefaultCommandDecoderDataSource as t}from"../../uniswap/data/DefaultCommandDecoderDataSource";import{EthersAbiDecoderDataSource as a}from"../../uniswap/data/EthersAbiDecoderDataSource";import{UniswapContextLoader as m}from"../../uniswap/domain/UniswapContextLoader";import{uniswapTypes as e}from"./uniswapTypes";const f=()=>new r((o,n,i,d)=>{o(e.AbiDecoderDataSource).to(a),o(e.CommandDecoderDataSource).to(t),o(e.UniswapContextLoader).to(m)});export{f as uniswapModuleFactory};
1
+ import{ContainerModule as r}from"inversify";import{DefaultCommandDecoderDataSource as t}from"../../uniswap/data/DefaultCommandDecoderDataSource";import{EthersAbiDecoderDataSource as a}from"../../uniswap/data/EthersAbiDecoderDataSource";import{UniswapContextLoader as m}from"../../uniswap/domain/UniswapContextLoader";import{uniswapTypes as e}from"./uniswapTypes";const D=()=>new r(({bind:o})=>{o(e.AbiDecoderDataSource).to(a),o(e.CommandDecoderDataSource).to(t),o(e.UniswapContextLoader).to(m)});export{D as uniswapModuleFactory};
2
2
  //# sourceMappingURL=uniswapModuleFactory.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/uniswap/di/uniswapModuleFactory.ts"],
4
- "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { DefaultCommandDecoderDataSource } from \"@/uniswap/data/DefaultCommandDecoderDataSource\";\nimport { EthersAbiDecoderDataSource } from \"@/uniswap/data/EthersAbiDecoderDataSource\";\nimport { UniswapContextLoader } from \"@/uniswap/domain/UniswapContextLoader\";\n\nimport { uniswapTypes } from \"./uniswapTypes\";\n\nexport const uniswapModuleFactory = () =>\n new ContainerModule((bind, _unbind, _isBound, _rebind) => {\n bind(uniswapTypes.AbiDecoderDataSource).to(EthersAbiDecoderDataSource);\n bind(uniswapTypes.CommandDecoderDataSource).to(\n DefaultCommandDecoderDataSource,\n );\n bind(uniswapTypes.UniswapContextLoader).to(UniswapContextLoader);\n });\n"],
5
- "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,mCAAAC,MAAuC,iDAChD,OAAS,8BAAAC,MAAkC,4CAC3C,OAAS,wBAAAC,MAA4B,wCAErC,OAAS,gBAAAC,MAAoB,iBAEtB,MAAMC,EAAuB,IAClC,IAAIL,EAAgB,CAACM,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAAKF,EAAa,oBAAoB,EAAE,GAAGF,CAA0B,EACrEI,EAAKF,EAAa,wBAAwB,EAAE,GAC1CH,CACF,EACAK,EAAKF,EAAa,oBAAoB,EAAE,GAAGD,CAAoB,CACjE,CAAC",
6
- "names": ["ContainerModule", "DefaultCommandDecoderDataSource", "EthersAbiDecoderDataSource", "UniswapContextLoader", "uniswapTypes", "uniswapModuleFactory", "bind", "_unbind", "_isBound", "_rebind"]
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { DefaultCommandDecoderDataSource } from \"@/uniswap/data/DefaultCommandDecoderDataSource\";\nimport { EthersAbiDecoderDataSource } from \"@/uniswap/data/EthersAbiDecoderDataSource\";\nimport { UniswapContextLoader } from \"@/uniswap/domain/UniswapContextLoader\";\n\nimport { uniswapTypes } from \"./uniswapTypes\";\n\nexport const uniswapModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(uniswapTypes.AbiDecoderDataSource).to(EthersAbiDecoderDataSource);\n bind(uniswapTypes.CommandDecoderDataSource).to(\n DefaultCommandDecoderDataSource,\n );\n bind(uniswapTypes.UniswapContextLoader).to(UniswapContextLoader);\n });\n"],
5
+ "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,mCAAAC,MAAuC,iDAChD,OAAS,8BAAAC,MAAkC,4CAC3C,OAAS,wBAAAC,MAA4B,wCAErC,OAAS,gBAAAC,MAAoB,iBAEtB,MAAMC,EAAuB,IAClC,IAAIL,EAAgB,CAAC,CAAE,KAAAM,CAAK,IAAM,CAChCA,EAAKF,EAAa,oBAAoB,EAAE,GAAGF,CAA0B,EACrEI,EAAKF,EAAa,wBAAwB,EAAE,GAC1CH,CACF,EACAK,EAAKF,EAAa,oBAAoB,EAAE,GAAGD,CAAoB,CACjE,CAAC",
6
+ "names": ["ContainerModule", "DefaultCommandDecoderDataSource", "EthersAbiDecoderDataSource", "UniswapContextLoader", "uniswapTypes", "uniswapModuleFactory", "bind"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{Interface as r}from"ethers";import{Left as b,Right as l}from"purify-ts";import{ClearSignContextType as p}from"../../shared/model/ClearSignContext";import{UNISWAP_EXECUTE_SELECTOR as f,UNISWAP_UNIVERSAL_ROUTER_ADDRESS as d,UniswapSupportedCommand as s}from"../../uniswap/constants/uniswap";import{DefaultCommandDecoderDataSource as y}from"../../uniswap/data/DefaultCommandDecoderDataSource";import{EthersAbiDecoderDataSource as u}from"../../uniswap/data/EthersAbiDecoderDataSource";import{UniswapContextLoader as x}from"./UniswapContextLoader";describe("UniswapContextLoader",()=>{const a={decode:vi.fn()},t={getTokenInfosPayload:vi.fn()};let n;describe("load",()=>{describe("with tokenDataSourceMock",()=>{beforeEach(()=>{vi.spyOn(t,"getTokenInfosPayload").mockImplementation(({address:e})=>Promise.resolve(l(`payload-${e}`))),n=new x(new y(new u),t)}),it("should return the external plugin context and the decoded contexts",async()=>{const e={chainId:1,data:"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000067a4855b000000000000000000000000000000000000000000000000000000000000000300060c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000a18f07d736b90be5500000000000000000000000000000000000000000000000000000000b0b8122abd8412900000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bb9f599ce614feb2e1bbe58f180f370d05b39344e002710c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000017cc6042605381c158d2adab487434bde79aa61c000000000000000000000000000000000000000000000000000000000000005b000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000b0b8122abd84129c001a053efc49d03b694742500f49aa09df2360bd7e297fa730c745e0d4320b42fc33fa01ca1c85a46c561f624830fffbae2441ba0f2d54eb5b0f17e0e3561d10db0b7ee"},o=await n.load(e);expect(o).toEqual([{type:p.EXTERNAL_PLUGIN,payload:"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935"},{type:"token",payload:"payload-0xb9f599ce614feb2e1bbe58f180f370d05b39344e"},{type:"token",payload:"payload-0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"}])}),it("should return the external plugin context and the decoded contexts with a permit",async()=>{const e={chainId:1,data:"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000669b9ec100000000000000000000000000000000000000000000000000000000000000030a010c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000016000000000000000000000000055747be9f9f5beb232ad59fe7af013b81d95fd5e000000000000000000000000ffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000066c32b0d0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000ef1c6e67703c7bd7107eed8303fbe6ec2554bf6b00000000000000000000000000000000000000000000000000000000669b9ec100000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000410d756f55acf289e9754faf91bba0a704b5c7c0aa4b1dfd551115ccbe4c7f290234e1a14265e1da0bc872a23627d997fe37a689c290d519f7b8c9bdde1b79108e1b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000030ba49cbff5a00000000000000000000000000000000000000000000000089677c957272141800000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc200271055747be9f9f5beb232ad59fe7af013b81d95fd5e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000030ba49cbff5a000c001a0e406d9c91c8b46d959fcd31a28518a77bb248ebb316c5fab7b98335cce922f2aa0462cb970c32a8dbfe71c57b888c43b9ed04fce41d169dbfcc745445587adb771"},o=await n.load(e);expect(o).toEqual([{type:p.EXTERNAL_PLUGIN,payload:"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935"},{type:"token",payload:"payload-0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"},{type:"token",payload:"payload-0x55747be9f9f5beb232ad59fe7af013b81d95fd5e"}])}),it("should return an empty array if the transaction is not supported",async()=>{const e={};vi.spyOn(a,"decode").mockReturnValue([]);const o=await n.load(e);expect(o).toEqual([])}),it("should return an empty array if a command is not supported",async()=>{const e={chainId:1,data:"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000067a4bef600000000000000000000000000000000000000000000000000000000000000050b0105040c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000078e6708e70aed0f000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000059a16770000000000000000000000000000000000000000000000000078e6708e70aed0f00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f4c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000027213e28d7fda5c57fe9e5dd923818dbccf71c4700000000000000000000000000000000000000000000000000000000003938700000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006f939b43d65be049b7533907db08e80ba6969f450000000000000000000000000000000000000000000000000000000059682f0000000000000000000000000000000000000000000000000000000000000000400000000000000000000000006f939b43d65be049b7533907db08e80ba6969f4500000000000000000000000000000000000000000000000000000000000000000cc080a07c86dd5813ec1f3725c402f8bea6105546d1093c59676023b971f1d83f61bd4ea02a353bf3028cabcbe68c5dc8906752bafe55afc86b6344edb3ffd8a3650332e8"},o=await n.load(e);expect(o).toEqual([])})}),describe("with mocked ethers parseTransaction",()=>{beforeEach(()=>{vi.resetAllMocks(),n=new x(a,t)}),it("should return an array with contexts if 2 chain swaps are supported",async()=>{const e={to:d,data:f,chainId:66};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:["0x0809",["0x0001","0x0002"]]}),vi.spyOn(a,"decode").mockReturnValueOnce(["0x01","0x04","0x02"]),vi.spyOn(a,"decode").mockReturnValueOnce(["0x02","0x03"]),vi.spyOn(t,"getTokenInfosPayload").mockImplementation(({address:i})=>Promise.resolve(l(`payload-${i}`)));const c=await n.load(e);expect(a.decode).toHaveBeenNthCalledWith(1,s.V2_SWAP_EXACT_IN,"0x0001",66),expect(a.decode).toHaveBeenNthCalledWith(2,s.V2_SWAP_EXACT_OUT,"0x0002",66),expect(t.getTokenInfosPayload).toHaveBeenNthCalledWith(1,{address:"0x01",chainId:66}),expect(t.getTokenInfosPayload).toHaveBeenNthCalledWith(2,{address:"0x04",chainId:66}),expect(t.getTokenInfosPayload).toHaveBeenNthCalledWith(3,{address:"0x02",chainId:66}),expect(t.getTokenInfosPayload).toHaveBeenNthCalledWith(4,{address:"0x03",chainId:66}),expect(c).toEqual([{type:p.EXTERNAL_PLUGIN,payload:"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935"},{type:"token",payload:"payload-0x01"},{type:"token",payload:"payload-0x04"},{type:"token",payload:"payload-0x02"},{type:"token",payload:"payload-0x03"}])}),it("should return an array with contexts if 1 chain swap with a non swap command",async()=>{const e={to:d,data:f,chainId:66};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:["0x0b0004",["0x0001","0x0002","0x0003"]]}),vi.spyOn(a,"decode").mockReturnValueOnce(["0x01"]),vi.spyOn(a,"decode").mockReturnValueOnce(["0x02","0x03"]),vi.spyOn(a,"decode").mockReturnValueOnce(["0x04"]),vi.spyOn(t,"getTokenInfosPayload").mockImplementation(({address:i})=>Promise.resolve(l(`payload-${i}`)));const c=await n.load(e);expect(a.decode).toHaveBeenNthCalledWith(1,s.WRAP_ETH,"0x0001",66),expect(t.getTokenInfosPayload).toHaveBeenNthCalledWith(1,{address:"0x01",chainId:66}),expect(t.getTokenInfosPayload).toHaveBeenNthCalledWith(2,{address:"0x02",chainId:66}),expect(t.getTokenInfosPayload).toHaveBeenNthCalledWith(3,{address:"0x03",chainId:66}),expect(t.getTokenInfosPayload).toHaveBeenNthCalledWith(4,{address:"0x04",chainId:66}),expect(c).toEqual([{type:p.EXTERNAL_PLUGIN,payload:"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935"},{type:"token",payload:"payload-0x01"},{type:"token",payload:"payload-0x02"},{type:"token",payload:"payload-0x03"},{type:"token",payload:"payload-0x04"}])}),it("should return an array with contexts if one token is not found",async()=>{const e={to:d,data:f,chainId:66};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:["0x0809",["0x0001","0x0002"]]}),vi.spyOn(a,"decode").mockReturnValueOnce(["0x01","0x02"]),vi.spyOn(a,"decode").mockReturnValueOnce(["0x02","0x03"]),vi.spyOn(t,"getTokenInfosPayload").mockResolvedValueOnce(b("error")),vi.spyOn(t,"getTokenInfosPayload").mockImplementation(({address:i})=>Promise.resolve(l(`payload-${i}`)));const c=await n.load(e);expect(a.decode).toHaveBeenNthCalledWith(1,s.V2_SWAP_EXACT_IN,"0x0001",66),expect(a.decode).toHaveBeenNthCalledWith(2,s.V2_SWAP_EXACT_OUT,"0x0002",66),expect(t.getTokenInfosPayload).toHaveBeenNthCalledWith(1,{address:"0x01",chainId:66}),expect(t.getTokenInfosPayload).toHaveBeenNthCalledWith(2,{address:"0x02",chainId:66}),expect(t.getTokenInfosPayload).toHaveBeenNthCalledWith(3,{address:"0x03",chainId:66}),expect(c).toEqual([{type:p.EXTERNAL_PLUGIN,payload:"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935"},{type:"error",error:"error"},{type:"token",payload:"payload-0x02"},{type:"token",payload:"payload-0x03"}])}),it("should return an empty array if the if 2 chain swaps are not supported",async()=>{const e={to:d,data:f,chainId:66};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:["0x0809",["0x0001","0x0002"]]}),vi.spyOn(a,"decode").mockReturnValueOnce(["0x01","0x02"]),vi.spyOn(a,"decode").mockReturnValueOnce(["0x03","0x04"]);const c=await n.load(e);expect(a.decode).toHaveBeenNthCalledWith(1,s.V2_SWAP_EXACT_IN,"0x0001",66),expect(a.decode).toHaveBeenNthCalledWith(2,s.V2_SWAP_EXACT_OUT,"0x0002",66),expect(t.getTokenInfosPayload).not.toHaveBeenCalled(),expect(c).toEqual([])}),it("should return an empty array if no command are returned from parseTransaction",async()=>{const e={to:d,data:f};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:[""]});const o=await n.load(e);expect(a.decode).not.toHaveBeenCalled(),expect(t.getTokenInfosPayload).not.toHaveBeenCalled(),expect(o).toEqual([])}),it("should return an empty array if no inputs are returned from parseTransaction",async()=>{const e={to:d,data:f};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:["0x08",[]]});const o=await n.load(e);expect(t.getTokenInfosPayload).not.toHaveBeenCalled(),expect(o).toEqual([])}),it("should return an empty array if parseTransaction throws an error",async()=>{const e={to:d,data:f};vi.spyOn(r.prototype,"parseTransaction").mockImplementation(()=>{throw new Error});const o=await n.load(e);expect(a.decode).not.toHaveBeenCalled(),expect(t.getTokenInfosPayload).not.toHaveBeenCalled(),expect(o).toEqual([])}),it("should return an empty array if the swap is with multiple pool versions",async()=>{const e={to:d,data:f,chainId:66};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:["0x080900",["0x00","0x01","0x02"]]}),vi.spyOn(a,"decode").mockReturnValue(["0x01","0x02"]);const c=await n.load(e);expect(a.decode).toHaveBeenNthCalledWith(1,s.V2_SWAP_EXACT_IN,"0x00",66),expect(a.decode).toHaveBeenNthCalledWith(2,s.V2_SWAP_EXACT_OUT,"0x01",66),expect(a.decode).toHaveBeenNthCalledWith(3,s.V3_SWAP_EXACT_IN,"0x02",66),expect(t.getTokenInfosPayload).not.toHaveBeenCalled(),expect(c).toEqual([])}),it("should return an empty array if the selector is not supported",async()=>{const e={to:d,data:"0x00000000",chainId:66},o=await n.load(e);expect(a.decode).not.toHaveBeenCalled(),expect(t.getTokenInfosPayload).not.toHaveBeenCalled(),expect(o).toEqual([])}),it("should return an empty array if the length of the commands and inputs are different",async()=>{const e={to:d,data:f,chainId:66};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:["0x0809",["0x0001"]]});const c=await n.load(e);expect(a.decode).not.toHaveBeenCalled(),expect(t.getTokenInfosPayload).not.toHaveBeenCalled(),expect(c).toEqual([])})})})});
1
+ import{Interface as r}from"ethers";import{Left as b,Right as p}from"purify-ts";import{ClearSignContextType as l}from"../../shared/model/ClearSignContext";import{UNISWAP_EXECUTE_SELECTOR as f,UNISWAP_UNIVERSAL_ROUTER_ADDRESS as d,UniswapSupportedCommand as s}from"../../uniswap/constants/uniswap";import{DefaultCommandDecoderDataSource as y}from"../../uniswap/data/DefaultCommandDecoderDataSource";import{EthersAbiDecoderDataSource as u}from"../../uniswap/data/EthersAbiDecoderDataSource";import{UniswapContextLoader as x}from"./UniswapContextLoader";describe("UniswapContextLoader",()=>{const t={decode:vi.fn()},a={getTokenInfosPayload:vi.fn()};let n;describe("load",()=>{describe("with tokenDataSourceMock",()=>{beforeEach(()=>{vi.spyOn(a,"getTokenInfosPayload").mockImplementation(({address:e})=>Promise.resolve(p(`payload-${e}`))),n=new x(new y(new u),a)}),it("should return the external plugin context and the decoded contexts",async()=>{const e={chainId:1,data:"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000067a4855b000000000000000000000000000000000000000000000000000000000000000300060c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000a18f07d736b90be5500000000000000000000000000000000000000000000000000000000b0b8122abd8412900000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bb9f599ce614feb2e1bbe58f180f370d05b39344e002710c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000017cc6042605381c158d2adab487434bde79aa61c000000000000000000000000000000000000000000000000000000000000005b000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000b0b8122abd84129c001a053efc49d03b694742500f49aa09df2360bd7e297fa730c745e0d4320b42fc33fa01ca1c85a46c561f624830fffbae2441ba0f2d54eb5b0f17e0e3561d10db0b7ee"},o=await n.load(e);expect(o).toEqual([{type:l.EXTERNAL_PLUGIN,payload:"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935"},{type:"token",payload:"payload-0xb9f599ce614feb2e1bbe58f180f370d05b39344e"},{type:"token",payload:"payload-0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"}])}),it("should return the external plugin context and the decoded contexts with a permit",async()=>{const e={chainId:1,data:"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000669b9ec100000000000000000000000000000000000000000000000000000000000000030a010c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000016000000000000000000000000055747be9f9f5beb232ad59fe7af013b81d95fd5e000000000000000000000000ffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000066c32b0d0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000ef1c6e67703c7bd7107eed8303fbe6ec2554bf6b00000000000000000000000000000000000000000000000000000000669b9ec100000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000410d756f55acf289e9754faf91bba0a704b5c7c0aa4b1dfd551115ccbe4c7f290234e1a14265e1da0bc872a23627d997fe37a689c290d519f7b8c9bdde1b79108e1b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000030ba49cbff5a00000000000000000000000000000000000000000000000089677c957272141800000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc200271055747be9f9f5beb232ad59fe7af013b81d95fd5e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000030ba49cbff5a000c001a0e406d9c91c8b46d959fcd31a28518a77bb248ebb316c5fab7b98335cce922f2aa0462cb970c32a8dbfe71c57b888c43b9ed04fce41d169dbfcc745445587adb771"},o=await n.load(e);expect(o).toEqual([{type:l.EXTERNAL_PLUGIN,payload:"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935"},{type:"token",payload:"payload-0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"},{type:"token",payload:"payload-0x55747be9f9f5beb232ad59fe7af013b81d95fd5e"}])}),it("should return an empty array if the transaction is not supported",async()=>{const e={};vi.spyOn(t,"decode").mockReturnValue([]);const o=await n.load(e);expect(o).toEqual([])}),it("should return an empty array if a command is not supported",async()=>{const e={chainId:1,data:"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000067a4bef600000000000000000000000000000000000000000000000000000000000000050b0105040c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000078e6708e70aed0f000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000059a16770000000000000000000000000000000000000000000000000078e6708e70aed0f00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f4c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000027213e28d7fda5c57fe9e5dd923818dbccf71c4700000000000000000000000000000000000000000000000000000000003938700000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006f939b43d65be049b7533907db08e80ba6969f450000000000000000000000000000000000000000000000000000000059682f0000000000000000000000000000000000000000000000000000000000000000400000000000000000000000006f939b43d65be049b7533907db08e80ba6969f4500000000000000000000000000000000000000000000000000000000000000000cc080a07c86dd5813ec1f3725c402f8bea6105546d1093c59676023b971f1d83f61bd4ea02a353bf3028cabcbe68c5dc8906752bafe55afc86b6344edb3ffd8a3650332e8"},o=await n.load(e);expect(o).toEqual([])})}),describe("with mocked ethers parseTransaction",()=>{beforeEach(()=>{vi.resetAllMocks(),n=new x(t,a)}),it("should return an array with contexts if 2 chain swaps are supported",async()=>{const e={to:d,data:f,chainId:66};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:["0x0809",["0x0001","0x0002"]]}),vi.spyOn(t,"decode").mockReturnValueOnce(["0x01","0x04","0x02"]).mockReturnValueOnce(["0x02","0x03"]),vi.spyOn(a,"getTokenInfosPayload").mockImplementation(({address:i})=>Promise.resolve(p(`payload-${i}`)));const c=await n.load(e);expect(t.decode).toHaveBeenNthCalledWith(1,s.V2_SWAP_EXACT_IN,"0x0001",66),expect(t.decode).toHaveBeenNthCalledWith(2,s.V2_SWAP_EXACT_OUT,"0x0002",66),expect(a.getTokenInfosPayload).toHaveBeenNthCalledWith(1,{address:"0x01",chainId:66}),expect(a.getTokenInfosPayload).toHaveBeenNthCalledWith(2,{address:"0x04",chainId:66}),expect(a.getTokenInfosPayload).toHaveBeenNthCalledWith(3,{address:"0x02",chainId:66}),expect(a.getTokenInfosPayload).toHaveBeenNthCalledWith(4,{address:"0x03",chainId:66}),expect(c).toEqual([{type:l.EXTERNAL_PLUGIN,payload:"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935"},{type:"token",payload:"payload-0x01"},{type:"token",payload:"payload-0x04"},{type:"token",payload:"payload-0x02"},{type:"token",payload:"payload-0x03"}])}),it("should return an array with contexts if 1 chain swap with a non swap command",async()=>{const e={to:d,data:f,chainId:66};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:["0x0b0004",["0x0001","0x0002","0x0003"]]}),vi.spyOn(t,"decode").mockReturnValueOnce(["0x01"]).mockReturnValueOnce(["0x02","0x03"]).mockReturnValueOnce(["0x04"]),vi.spyOn(a,"getTokenInfosPayload").mockImplementation(({address:i})=>Promise.resolve(p(`payload-${i}`)));const c=await n.load(e);expect(t.decode).toHaveBeenNthCalledWith(1,s.WRAP_ETH,"0x0001",66),expect(a.getTokenInfosPayload).toHaveBeenNthCalledWith(1,{address:"0x01",chainId:66}),expect(a.getTokenInfosPayload).toHaveBeenNthCalledWith(2,{address:"0x02",chainId:66}),expect(a.getTokenInfosPayload).toHaveBeenNthCalledWith(3,{address:"0x03",chainId:66}),expect(a.getTokenInfosPayload).toHaveBeenNthCalledWith(4,{address:"0x04",chainId:66}),expect(c).toEqual([{type:l.EXTERNAL_PLUGIN,payload:"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935"},{type:"token",payload:"payload-0x01"},{type:"token",payload:"payload-0x02"},{type:"token",payload:"payload-0x03"},{type:"token",payload:"payload-0x04"}])}),it("should return an array with contexts if one token is not found",async()=>{const e={to:d,data:f,chainId:66};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:["0x0809",["0x0001","0x0002"]]}),vi.spyOn(t,"decode").mockReturnValueOnce(["0x01","0x02"]).mockReturnValueOnce(["0x02","0x03"]),vi.spyOn(a,"getTokenInfosPayload").mockResolvedValueOnce(b("error")).mockImplementation(({address:i})=>Promise.resolve(p(`payload-${i}`)));const c=await n.load(e);expect(t.decode).toHaveBeenNthCalledWith(1,s.V2_SWAP_EXACT_IN,"0x0001",66),expect(t.decode).toHaveBeenNthCalledWith(2,s.V2_SWAP_EXACT_OUT,"0x0002",66),expect(a.getTokenInfosPayload).toHaveBeenNthCalledWith(1,{address:"0x01",chainId:66}),expect(a.getTokenInfosPayload).toHaveBeenNthCalledWith(2,{address:"0x02",chainId:66}),expect(a.getTokenInfosPayload).toHaveBeenNthCalledWith(3,{address:"0x03",chainId:66}),expect(c).toEqual([{type:l.EXTERNAL_PLUGIN,payload:"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935"},{type:"error",error:"error"},{type:"token",payload:"payload-0x02"},{type:"token",payload:"payload-0x03"}])}),it("should return an empty array if the if 2 chain swaps are not supported",async()=>{const e={to:d,data:f,chainId:66};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:["0x0809",["0x0001","0x0002"]]}),vi.spyOn(t,"decode").mockReturnValueOnce(["0x01","0x02"]),vi.spyOn(t,"decode").mockReturnValueOnce(["0x03","0x04"]);const c=await n.load(e);expect(t.decode).toHaveBeenNthCalledWith(1,s.V2_SWAP_EXACT_IN,"0x0001",66),expect(t.decode).toHaveBeenNthCalledWith(2,s.V2_SWAP_EXACT_OUT,"0x0002",66),expect(a.getTokenInfosPayload).not.toHaveBeenCalled(),expect(c).toEqual([])}),it("should return an empty array if no command are returned from parseTransaction",async()=>{const e={to:d,data:f};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:[""]});const o=await n.load(e);expect(t.decode).not.toHaveBeenCalled(),expect(a.getTokenInfosPayload).not.toHaveBeenCalled(),expect(o).toEqual([])}),it("should return an empty array if no inputs are returned from parseTransaction",async()=>{const e={to:d,data:f};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:["0x08",[]]});const o=await n.load(e);expect(a.getTokenInfosPayload).not.toHaveBeenCalled(),expect(o).toEqual([])}),it("should return an empty array if parseTransaction throws an error",async()=>{const e={to:d,data:f};vi.spyOn(r.prototype,"parseTransaction").mockImplementation(()=>{throw new Error});const o=await n.load(e);expect(t.decode).not.toHaveBeenCalled(),expect(a.getTokenInfosPayload).not.toHaveBeenCalled(),expect(o).toEqual([])}),it("should return an empty array if the swap is with multiple pool versions",async()=>{const e={to:d,data:f,chainId:66};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:["0x080900",["0x00","0x01","0x02"]]}),vi.spyOn(t,"decode").mockReturnValue(["0x01","0x02"]);const c=await n.load(e);expect(t.decode).toHaveBeenNthCalledWith(1,s.V2_SWAP_EXACT_IN,"0x00",66),expect(t.decode).toHaveBeenNthCalledWith(2,s.V2_SWAP_EXACT_OUT,"0x01",66),expect(t.decode).toHaveBeenNthCalledWith(3,s.V3_SWAP_EXACT_IN,"0x02",66),expect(a.getTokenInfosPayload).not.toHaveBeenCalled(),expect(c).toEqual([])}),it("should return an empty array if the selector is not supported",async()=>{const e={to:d,data:"0x00000000",chainId:66},o=await n.load(e);expect(t.decode).not.toHaveBeenCalled(),expect(a.getTokenInfosPayload).not.toHaveBeenCalled(),expect(o).toEqual([])}),it("should return an empty array if the length of the commands and inputs are different",async()=>{const e={to:d,data:f,chainId:66};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:["0x0809",["0x0001"]]});const c=await n.load(e);expect(t.decode).not.toHaveBeenCalled(),expect(a.getTokenInfosPayload).not.toHaveBeenCalled(),expect(c).toEqual([])})})})});
2
2
  //# sourceMappingURL=UniswapContextLoader.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/uniswap/domain/UniswapContextLoader.test.ts"],
4
- "sourcesContent": ["import { Interface, type TransactionDescription } from \"ethers\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TransactionContext } from \"@/shared/model/TransactionContext\";\nimport { type HttpTokenDataSource } from \"@/token/data/HttpTokenDataSource\";\nimport {\n UNISWAP_EXECUTE_SELECTOR,\n UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n UniswapSupportedCommand,\n} from \"@/uniswap/constants/uniswap\";\nimport { type CommandDecoderDataSource } from \"@/uniswap/data/CommandDecoderDataSource\";\nimport { DefaultCommandDecoderDataSource } from \"@/uniswap/data/DefaultCommandDecoderDataSource\";\nimport { EthersAbiDecoderDataSource } from \"@/uniswap/data/EthersAbiDecoderDataSource\";\n\nimport { UniswapContextLoader } from \"./UniswapContextLoader\";\n\ndescribe(\"UniswapContextLoader\", () => {\n const commandDecoderMock: CommandDecoderDataSource = {\n decode: vi.fn(),\n };\n const tokenDataSourceMock = {\n getTokenInfosPayload: vi.fn(),\n };\n let loader: UniswapContextLoader;\n\n describe(\"load\", () => {\n describe(\"with tokenDataSourceMock\", () => {\n beforeEach(() => {\n vi.spyOn(\n tokenDataSourceMock,\n \"getTokenInfosPayload\",\n ).mockImplementation(({ address }) =>\n Promise.resolve(Right(`payload-${address}`)),\n );\n loader = new UniswapContextLoader(\n new DefaultCommandDecoderDataSource(new EthersAbiDecoderDataSource()),\n tokenDataSourceMock as unknown as HttpTokenDataSource,\n );\n });\n\n it(\"should return the external plugin context and the decoded contexts\", async () => {\n // GIVEN\n // https://etherscan.io/getRawTx?tx=0xc9821c32c1782d9ab6baf6f9ca4b2565bce11aaf5146a2d303215bda026f5e48\n const transactionContext = {\n chainId: 1,\n data: \"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000067a4855b000000000000000000000000000000000000000000000000000000000000000300060c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000a18f07d736b90be5500000000000000000000000000000000000000000000000000000000b0b8122abd8412900000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bb9f599ce614feb2e1bbe58f180f370d05b39344e002710c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000017cc6042605381c158d2adab487434bde79aa61c000000000000000000000000000000000000000000000000000000000000005b000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000b0b8122abd84129c001a053efc49d03b694742500f49aa09df2360bd7e297fa730c745e0d4320b42fc33fa01ca1c85a46c561f624830fffbae2441ba0f2d54eb5b0f17e0e3561d10db0b7ee\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload:\n \"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935\",\n },\n {\n type: \"token\",\n payload: \"payload-0xb9f599ce614feb2e1bbe58f180f370d05b39344e\",\n }, // ERC20\n {\n type: \"token\",\n payload: \"payload-0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\",\n }, // WETH\n ]);\n });\n\n it(\"should return the external plugin context and the decoded contexts with a permit\", async () => {\n // GIVEN\n // https://etherscan.io/getRawTx?tx=0xc4df7ccc0527541d0e80856a8f38deedc48c84825e9355469ba02d873502ce2f\n // PERMIT2_PERMIT, V3_SWAP_EXACT_OUT, UNWRAP_ETH\n const transactionContext = {\n chainId: 1,\n data: \"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000669b9ec100000000000000000000000000000000000000000000000000000000000000030a010c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000016000000000000000000000000055747be9f9f5beb232ad59fe7af013b81d95fd5e000000000000000000000000ffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000066c32b0d0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000ef1c6e67703c7bd7107eed8303fbe6ec2554bf6b00000000000000000000000000000000000000000000000000000000669b9ec100000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000410d756f55acf289e9754faf91bba0a704b5c7c0aa4b1dfd551115ccbe4c7f290234e1a14265e1da0bc872a23627d997fe37a689c290d519f7b8c9bdde1b79108e1b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000030ba49cbff5a00000000000000000000000000000000000000000000000089677c957272141800000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc200271055747be9f9f5beb232ad59fe7af013b81d95fd5e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000030ba49cbff5a000c001a0e406d9c91c8b46d959fcd31a28518a77bb248ebb316c5fab7b98335cce922f2aa0462cb970c32a8dbfe71c57b888c43b9ed04fce41d169dbfcc745445587adb771\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload:\n \"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935\",\n },\n {\n type: \"token\",\n payload: \"payload-0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\",\n }, // WETH\n {\n type: \"token\",\n payload: \"payload-0x55747be9f9f5beb232ad59fe7af013b81d95fd5e\",\n }, // ERC20\n ]);\n });\n\n it(\"should return an empty array if the transaction is not supported\", async () => {\n // GIVEN\n const transactionContext = {} as TransactionContext;\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValue([]);\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if a command is not supported\", async () => {\n // GIVEN\n // https://etherscan.io/getRawTx?tx=0xa628c8b3da2ad984aed0354d8ca4b4c3c42941491dc4e0d6a5f423fd65e6c90a\n // The command 0x05 (TRANSFER) is not supported\n const transactionContext = {\n chainId: 1,\n data: \"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000067a4bef600000000000000000000000000000000000000000000000000000000000000050b0105040c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000078e6708e70aed0f000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000059a16770000000000000000000000000000000000000000000000000078e6708e70aed0f00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f4c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000027213e28d7fda5c57fe9e5dd923818dbccf71c4700000000000000000000000000000000000000000000000000000000003938700000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006f939b43d65be049b7533907db08e80ba6969f450000000000000000000000000000000000000000000000000000000059682f0000000000000000000000000000000000000000000000000000000000000000400000000000000000000000006f939b43d65be049b7533907db08e80ba6969f4500000000000000000000000000000000000000000000000000000000000000000cc080a07c86dd5813ec1f3725c402f8bea6105546d1093c59676023b971f1d83f61bd4ea02a353bf3028cabcbe68c5dc8906752bafe55afc86b6344edb3ffd8a3650332e8\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(result).toEqual([]);\n });\n });\n\n describe(\"with mocked ethers parseTransaction\", () => {\n beforeEach(() => {\n vi.resetAllMocks();\n loader = new UniswapContextLoader(\n commandDecoderMock,\n tokenDataSourceMock as unknown as HttpTokenDataSource,\n );\n });\n\n it(\"should return an array with contexts if 2 chain swaps are supported\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n } as TransactionContext;\n const commands = `0x0809`; // V2_SWAP_EXACT_IN, V2_SWAP_EXACT_OUT\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [commands, [\"0x0001\", \"0x0002\"]],\n } as TransactionDescription);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x01\",\n \"0x04\",\n \"0x02\",\n ]);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x02\",\n \"0x03\",\n ]);\n vi.spyOn(\n tokenDataSourceMock,\n \"getTokenInfosPayload\",\n ).mockImplementation(({ address }) =>\n Promise.resolve(Right(`payload-${address}`)),\n );\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 1,\n UniswapSupportedCommand.V2_SWAP_EXACT_IN,\n \"0x0001\",\n 0x42,\n );\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 2,\n UniswapSupportedCommand.V2_SWAP_EXACT_OUT,\n \"0x0002\",\n 0x42,\n );\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(1, { address: \"0x01\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(2, { address: \"0x04\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(3, { address: \"0x02\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(4, { address: \"0x03\", chainId: 0x42 });\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload:\n \"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935\",\n },\n {\n type: \"token\",\n payload: \"payload-0x01\",\n },\n {\n type: \"token\",\n payload: \"payload-0x04\",\n },\n {\n type: \"token\",\n payload: \"payload-0x02\",\n },\n {\n type: \"token\",\n payload: \"payload-0x03\",\n },\n ]);\n });\n\n it(\"should return an array with contexts if 1 chain swap with a non swap command\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n } as TransactionContext;\n const commands = `0x0b0004`; // WRAP_ETH, V3_SWAP_EXACT_IN, SWEEP\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [commands, [\"0x0001\", \"0x0002\", \"0x0003\"]],\n } as TransactionDescription);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValueOnce([\"0x01\"]);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x02\",\n \"0x03\",\n ]);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValueOnce([\"0x04\"]);\n vi.spyOn(\n tokenDataSourceMock,\n \"getTokenInfosPayload\",\n ).mockImplementation(({ address }) =>\n Promise.resolve(Right(`payload-${address}`)),\n );\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 1,\n UniswapSupportedCommand.WRAP_ETH,\n \"0x0001\",\n 0x42,\n );\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(1, { address: \"0x01\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(2, { address: \"0x02\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(3, { address: \"0x03\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(4, { address: \"0x04\", chainId: 0x42 });\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload:\n \"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935\",\n },\n {\n type: \"token\",\n payload: \"payload-0x01\",\n },\n {\n type: \"token\",\n payload: \"payload-0x02\",\n },\n {\n type: \"token\",\n payload: \"payload-0x03\",\n },\n {\n type: \"token\",\n payload: \"payload-0x04\",\n },\n ]);\n });\n\n it(\"should return an array with contexts if one token is not found\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n } as TransactionContext;\n const commands = `0x0809`; // V2_SWAP_EXACT_IN, V2_SWAP_EXACT_OUT\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [commands, [\"0x0001\", \"0x0002\"]],\n } as TransactionDescription);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x01\",\n \"0x02\",\n ]);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x02\",\n \"0x03\",\n ]);\n vi.spyOn(\n tokenDataSourceMock,\n \"getTokenInfosPayload\",\n ).mockResolvedValueOnce(Left(\"error\"));\n vi.spyOn(\n tokenDataSourceMock,\n \"getTokenInfosPayload\",\n ).mockImplementation(({ address }) =>\n Promise.resolve(Right(`payload-${address}`)),\n );\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 1,\n UniswapSupportedCommand.V2_SWAP_EXACT_IN,\n \"0x0001\",\n 0x42,\n );\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 2,\n UniswapSupportedCommand.V2_SWAP_EXACT_OUT,\n \"0x0002\",\n 0x42,\n );\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(1, { address: \"0x01\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(2, { address: \"0x02\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(3, { address: \"0x03\", chainId: 0x42 });\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload:\n \"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935\",\n },\n {\n type: \"error\",\n error: \"error\",\n },\n {\n type: \"token\",\n payload: \"payload-0x02\",\n },\n {\n type: \"token\",\n payload: \"payload-0x03\",\n },\n ]);\n });\n\n it(\"should return an empty array if the if 2 chain swaps are not supported\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n } as TransactionContext;\n const commands = `0x0809`; // V2_SWAP_EXACT_IN, V2_SWAP_EXACT_OUT\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [commands, [\"0x0001\", \"0x0002\"]],\n } as TransactionDescription);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x01\",\n \"0x02\",\n ]);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x03\", // should be 0x02\n \"0x04\",\n ]);\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 1,\n UniswapSupportedCommand.V2_SWAP_EXACT_IN,\n \"0x0001\",\n 0x42,\n );\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 2,\n UniswapSupportedCommand.V2_SWAP_EXACT_OUT,\n \"0x0002\",\n 0x42,\n );\n expect(tokenDataSourceMock.getTokenInfosPayload).not.toHaveBeenCalled();\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if no command are returned from parseTransaction\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n } as TransactionContext;\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [\"\"],\n } as TransactionDescription);\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).not.toHaveBeenCalled();\n expect(tokenDataSourceMock.getTokenInfosPayload).not.toHaveBeenCalled();\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if no inputs are returned from parseTransaction\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n } as TransactionContext;\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [\"0x08\", []],\n } as TransactionDescription);\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(tokenDataSourceMock.getTokenInfosPayload).not.toHaveBeenCalled();\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if parseTransaction throws an error\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n } as TransactionContext;\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockImplementation(\n () => {\n throw new Error();\n },\n );\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).not.toHaveBeenCalled();\n expect(tokenDataSourceMock.getTokenInfosPayload).not.toHaveBeenCalled();\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the swap is with multiple pool versions\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n } as TransactionContext;\n const commands = `0x080900`; // V2_SWAP_EXACT_IN, V2_SWAP_EXACT_OUT, V3_SWAP_EXACT_IN\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [commands, [\"0x00\", \"0x01\", \"0x02\"]],\n } as TransactionDescription);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValue([\n \"0x01\",\n \"0x02\",\n ]);\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 1,\n UniswapSupportedCommand.V2_SWAP_EXACT_IN,\n \"0x00\",\n 0x42,\n );\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 2,\n UniswapSupportedCommand.V2_SWAP_EXACT_OUT,\n \"0x01\",\n 0x42,\n );\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 3,\n UniswapSupportedCommand.V3_SWAP_EXACT_IN,\n \"0x02\",\n 0x42,\n );\n expect(tokenDataSourceMock.getTokenInfosPayload).not.toHaveBeenCalled();\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the selector is not supported\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: \"0x00000000\",\n chainId: 0x42,\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).not.toHaveBeenCalled();\n expect(tokenDataSourceMock.getTokenInfosPayload).not.toHaveBeenCalled();\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the length of the commands and inputs are different\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n } as TransactionContext;\n const commands = `0x0809`; // V2_SWAP_EXACT_IN, V2_SWAP_EXACT_OUT\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [commands, [\"0x0001\"]],\n } as TransactionDescription);\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).not.toHaveBeenCalled();\n expect(tokenDataSourceMock.getTokenInfosPayload).not.toHaveBeenCalled();\n expect(result).toEqual([]);\n });\n });\n });\n});\n"],
5
- "mappings": "AAAA,OAAS,aAAAA,MAA8C,SACvD,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAE5B,OAAS,wBAAAC,MAA4B,kCAGrC,OACE,4BAAAC,EACA,oCAAAC,EACA,2BAAAC,MACK,8BAEP,OAAS,mCAAAC,MAAuC,iDAChD,OAAS,8BAAAC,MAAkC,4CAE3C,OAAS,wBAAAC,MAA4B,yBAErC,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA+C,CACnD,OAAQ,GAAG,GAAG,CAChB,EACMC,EAAsB,CAC1B,qBAAsB,GAAG,GAAG,CAC9B,EACA,IAAIC,EAEJ,SAAS,OAAQ,IAAM,CACrB,SAAS,2BAA4B,IAAM,CACzC,WAAW,IAAM,CACf,GAAG,MACDD,EACA,sBACF,EAAE,mBAAmB,CAAC,CAAE,QAAAE,CAAQ,IAC9B,QAAQ,QAAQX,EAAM,WAAWW,CAAO,EAAE,CAAC,CAC7C,EACAD,EAAS,IAAIH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E,OAAOI,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,EAED,GAAG,sFAAuF,SAAY,CAEpG,MAAMD,EAAqB,CACzB,GAAIT,EACJ,KAAMD,EACN,QAAS,EACX,EAEA,GAAG,MAAMJ,EAAU,UAAW,kBAAkB,EAAE,gBAAgB,CAChE,KAAM,CAFS,SAEE,CAAC,QAAQ,CAAC,CAC7B,CAA2B,EAG3B,MAAMe,EAAS,MAAMH,EAAO,KAAKE,CAAkB,EAGnD,OAAOJ,EAAmB,MAAM,EAAE,IAAI,iBAAiB,EACvD,OAAOC,EAAoB,oBAAoB,EAAE,IAAI,iBAAiB,EACtE,OAAOI,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["import { Interface, type TransactionDescription } from \"ethers\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TransactionContext } from \"@/shared/model/TransactionContext\";\nimport { type HttpTokenDataSource } from \"@/token/data/HttpTokenDataSource\";\nimport {\n UNISWAP_EXECUTE_SELECTOR,\n UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n UniswapSupportedCommand,\n} from \"@/uniswap/constants/uniswap\";\nimport { type CommandDecoderDataSource } from \"@/uniswap/data/CommandDecoderDataSource\";\nimport { DefaultCommandDecoderDataSource } from \"@/uniswap/data/DefaultCommandDecoderDataSource\";\nimport { EthersAbiDecoderDataSource } from \"@/uniswap/data/EthersAbiDecoderDataSource\";\n\nimport { UniswapContextLoader } from \"./UniswapContextLoader\";\n\ndescribe(\"UniswapContextLoader\", () => {\n const commandDecoderMock: CommandDecoderDataSource = {\n decode: vi.fn(),\n };\n const tokenDataSourceMock = {\n getTokenInfosPayload: vi.fn(),\n };\n let loader: UniswapContextLoader;\n\n describe(\"load\", () => {\n describe(\"with tokenDataSourceMock\", () => {\n beforeEach(() => {\n vi.spyOn(\n tokenDataSourceMock,\n \"getTokenInfosPayload\",\n ).mockImplementation(({ address }) =>\n Promise.resolve(Right(`payload-${address}`)),\n );\n loader = new UniswapContextLoader(\n new DefaultCommandDecoderDataSource(new EthersAbiDecoderDataSource()),\n tokenDataSourceMock as unknown as HttpTokenDataSource,\n );\n });\n\n it(\"should return the external plugin context and the decoded contexts\", async () => {\n // GIVEN\n // https://etherscan.io/getRawTx?tx=0xc9821c32c1782d9ab6baf6f9ca4b2565bce11aaf5146a2d303215bda026f5e48\n const transactionContext = {\n chainId: 1,\n data: \"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000067a4855b000000000000000000000000000000000000000000000000000000000000000300060c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000a18f07d736b90be5500000000000000000000000000000000000000000000000000000000b0b8122abd8412900000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bb9f599ce614feb2e1bbe58f180f370d05b39344e002710c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000017cc6042605381c158d2adab487434bde79aa61c000000000000000000000000000000000000000000000000000000000000005b000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000b0b8122abd84129c001a053efc49d03b694742500f49aa09df2360bd7e297fa730c745e0d4320b42fc33fa01ca1c85a46c561f624830fffbae2441ba0f2d54eb5b0f17e0e3561d10db0b7ee\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload:\n \"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935\",\n },\n {\n type: \"token\",\n payload: \"payload-0xb9f599ce614feb2e1bbe58f180f370d05b39344e\",\n }, // ERC20\n {\n type: \"token\",\n payload: \"payload-0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\",\n }, // WETH\n ]);\n });\n\n it(\"should return the external plugin context and the decoded contexts with a permit\", async () => {\n // GIVEN\n // https://etherscan.io/getRawTx?tx=0xc4df7ccc0527541d0e80856a8f38deedc48c84825e9355469ba02d873502ce2f\n // PERMIT2_PERMIT, V3_SWAP_EXACT_OUT, UNWRAP_ETH\n const transactionContext = {\n chainId: 1,\n data: \"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000669b9ec100000000000000000000000000000000000000000000000000000000000000030a010c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000016000000000000000000000000055747be9f9f5beb232ad59fe7af013b81d95fd5e000000000000000000000000ffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000066c32b0d0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000ef1c6e67703c7bd7107eed8303fbe6ec2554bf6b00000000000000000000000000000000000000000000000000000000669b9ec100000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000410d756f55acf289e9754faf91bba0a704b5c7c0aa4b1dfd551115ccbe4c7f290234e1a14265e1da0bc872a23627d997fe37a689c290d519f7b8c9bdde1b79108e1b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000030ba49cbff5a00000000000000000000000000000000000000000000000089677c957272141800000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc200271055747be9f9f5beb232ad59fe7af013b81d95fd5e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000030ba49cbff5a000c001a0e406d9c91c8b46d959fcd31a28518a77bb248ebb316c5fab7b98335cce922f2aa0462cb970c32a8dbfe71c57b888c43b9ed04fce41d169dbfcc745445587adb771\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload:\n \"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935\",\n },\n {\n type: \"token\",\n payload: \"payload-0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\",\n }, // WETH\n {\n type: \"token\",\n payload: \"payload-0x55747be9f9f5beb232ad59fe7af013b81d95fd5e\",\n }, // ERC20\n ]);\n });\n\n it(\"should return an empty array if the transaction is not supported\", async () => {\n // GIVEN\n const transactionContext = {} as TransactionContext;\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValue([]);\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if a command is not supported\", async () => {\n // GIVEN\n // https://etherscan.io/getRawTx?tx=0xa628c8b3da2ad984aed0354d8ca4b4c3c42941491dc4e0d6a5f423fd65e6c90a\n // The command 0x05 (TRANSFER) is not supported\n const transactionContext = {\n chainId: 1,\n data: \"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000067a4bef600000000000000000000000000000000000000000000000000000000000000050b0105040c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000078e6708e70aed0f000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000059a16770000000000000000000000000000000000000000000000000078e6708e70aed0f00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f4c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000027213e28d7fda5c57fe9e5dd923818dbccf71c4700000000000000000000000000000000000000000000000000000000003938700000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006f939b43d65be049b7533907db08e80ba6969f450000000000000000000000000000000000000000000000000000000059682f0000000000000000000000000000000000000000000000000000000000000000400000000000000000000000006f939b43d65be049b7533907db08e80ba6969f4500000000000000000000000000000000000000000000000000000000000000000cc080a07c86dd5813ec1f3725c402f8bea6105546d1093c59676023b971f1d83f61bd4ea02a353bf3028cabcbe68c5dc8906752bafe55afc86b6344edb3ffd8a3650332e8\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(result).toEqual([]);\n });\n });\n\n describe(\"with mocked ethers parseTransaction\", () => {\n beforeEach(() => {\n vi.resetAllMocks();\n loader = new UniswapContextLoader(\n commandDecoderMock,\n tokenDataSourceMock as unknown as HttpTokenDataSource,\n );\n });\n\n it(\"should return an array with contexts if 2 chain swaps are supported\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n } as TransactionContext;\n const commands = `0x0809`; // V2_SWAP_EXACT_IN, V2_SWAP_EXACT_OUT\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [commands, [\"0x0001\", \"0x0002\"]],\n } as TransactionDescription);\n vi.spyOn(commandDecoderMock, \"decode\")\n .mockReturnValueOnce([\"0x01\", \"0x04\", \"0x02\"])\n .mockReturnValueOnce([\"0x02\", \"0x03\"]);\n\n vi.spyOn(\n tokenDataSourceMock,\n \"getTokenInfosPayload\",\n ).mockImplementation(({ address }) =>\n Promise.resolve(Right(`payload-${address}`)),\n );\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 1,\n UniswapSupportedCommand.V2_SWAP_EXACT_IN,\n \"0x0001\",\n 0x42,\n );\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 2,\n UniswapSupportedCommand.V2_SWAP_EXACT_OUT,\n \"0x0002\",\n 0x42,\n );\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(1, { address: \"0x01\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(2, { address: \"0x04\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(3, { address: \"0x02\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(4, { address: \"0x03\", chainId: 0x42 });\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload:\n \"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935\",\n },\n {\n type: \"token\",\n payload: \"payload-0x01\",\n },\n {\n type: \"token\",\n payload: \"payload-0x04\",\n },\n {\n type: \"token\",\n payload: \"payload-0x02\",\n },\n {\n type: \"token\",\n payload: \"payload-0x03\",\n },\n ]);\n });\n\n it(\"should return an array with contexts if 1 chain swap with a non swap command\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n } as TransactionContext;\n const commands = `0x0b0004`; // WRAP_ETH, V3_SWAP_EXACT_IN, SWEEP\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [commands, [\"0x0001\", \"0x0002\", \"0x0003\"]],\n } as TransactionDescription);\n vi.spyOn(commandDecoderMock, \"decode\")\n .mockReturnValueOnce([\"0x01\"])\n .mockReturnValueOnce([\"0x02\", \"0x03\"])\n .mockReturnValueOnce([\"0x04\"]);\n vi.spyOn(\n tokenDataSourceMock,\n \"getTokenInfosPayload\",\n ).mockImplementation(({ address }) =>\n Promise.resolve(Right(`payload-${address}`)),\n );\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 1,\n UniswapSupportedCommand.WRAP_ETH,\n \"0x0001\",\n 0x42,\n );\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(1, { address: \"0x01\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(2, { address: \"0x02\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(3, { address: \"0x03\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(4, { address: \"0x04\", chainId: 0x42 });\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload:\n \"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935\",\n },\n {\n type: \"token\",\n payload: \"payload-0x01\",\n },\n {\n type: \"token\",\n payload: \"payload-0x02\",\n },\n {\n type: \"token\",\n payload: \"payload-0x03\",\n },\n {\n type: \"token\",\n payload: \"payload-0x04\",\n },\n ]);\n });\n\n it(\"should return an array with contexts if one token is not found\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n } as TransactionContext;\n const commands = `0x0809`; // V2_SWAP_EXACT_IN, V2_SWAP_EXACT_OUT\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [commands, [\"0x0001\", \"0x0002\"]],\n } as TransactionDescription);\n vi.spyOn(commandDecoderMock, \"decode\")\n .mockReturnValueOnce([\"0x01\", \"0x02\"])\n .mockReturnValueOnce([\"0x02\", \"0x03\"]);\n vi.spyOn(tokenDataSourceMock, \"getTokenInfosPayload\")\n .mockResolvedValueOnce(Left(\"error\"))\n .mockImplementation(({ address }) =>\n Promise.resolve(Right(`payload-${address}`)),\n );\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 1,\n UniswapSupportedCommand.V2_SWAP_EXACT_IN,\n \"0x0001\",\n 0x42,\n );\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 2,\n UniswapSupportedCommand.V2_SWAP_EXACT_OUT,\n \"0x0002\",\n 0x42,\n );\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(1, { address: \"0x01\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(2, { address: \"0x02\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(3, { address: \"0x03\", chainId: 0x42 });\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload:\n \"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935\",\n },\n {\n type: \"error\",\n error: \"error\",\n },\n {\n type: \"token\",\n payload: \"payload-0x02\",\n },\n {\n type: \"token\",\n payload: \"payload-0x03\",\n },\n ]);\n });\n\n it(\"should return an empty array if the if 2 chain swaps are not supported\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n } as TransactionContext;\n const commands = `0x0809`; // V2_SWAP_EXACT_IN, V2_SWAP_EXACT_OUT\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [commands, [\"0x0001\", \"0x0002\"]],\n } as TransactionDescription);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x01\",\n \"0x02\",\n ]);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x03\", // should be 0x02\n \"0x04\",\n ]);\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 1,\n UniswapSupportedCommand.V2_SWAP_EXACT_IN,\n \"0x0001\",\n 0x42,\n );\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 2,\n UniswapSupportedCommand.V2_SWAP_EXACT_OUT,\n \"0x0002\",\n 0x42,\n );\n expect(tokenDataSourceMock.getTokenInfosPayload).not.toHaveBeenCalled();\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if no command are returned from parseTransaction\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n } as TransactionContext;\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [\"\"],\n } as TransactionDescription);\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).not.toHaveBeenCalled();\n expect(tokenDataSourceMock.getTokenInfosPayload).not.toHaveBeenCalled();\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if no inputs are returned from parseTransaction\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n } as TransactionContext;\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [\"0x08\", []],\n } as TransactionDescription);\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(tokenDataSourceMock.getTokenInfosPayload).not.toHaveBeenCalled();\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if parseTransaction throws an error\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n } as TransactionContext;\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockImplementation(\n () => {\n throw new Error();\n },\n );\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).not.toHaveBeenCalled();\n expect(tokenDataSourceMock.getTokenInfosPayload).not.toHaveBeenCalled();\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the swap is with multiple pool versions\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n } as TransactionContext;\n const commands = `0x080900`; // V2_SWAP_EXACT_IN, V2_SWAP_EXACT_OUT, V3_SWAP_EXACT_IN\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [commands, [\"0x00\", \"0x01\", \"0x02\"]],\n } as TransactionDescription);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValue([\n \"0x01\",\n \"0x02\",\n ]);\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 1,\n UniswapSupportedCommand.V2_SWAP_EXACT_IN,\n \"0x00\",\n 0x42,\n );\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 2,\n UniswapSupportedCommand.V2_SWAP_EXACT_OUT,\n \"0x01\",\n 0x42,\n );\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 3,\n UniswapSupportedCommand.V3_SWAP_EXACT_IN,\n \"0x02\",\n 0x42,\n );\n expect(tokenDataSourceMock.getTokenInfosPayload).not.toHaveBeenCalled();\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the selector is not supported\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: \"0x00000000\",\n chainId: 0x42,\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).not.toHaveBeenCalled();\n expect(tokenDataSourceMock.getTokenInfosPayload).not.toHaveBeenCalled();\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the length of the commands and inputs are different\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n } as TransactionContext;\n const commands = `0x0809`; // V2_SWAP_EXACT_IN, V2_SWAP_EXACT_OUT\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [commands, [\"0x0001\"]],\n } as TransactionDescription);\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).not.toHaveBeenCalled();\n expect(tokenDataSourceMock.getTokenInfosPayload).not.toHaveBeenCalled();\n expect(result).toEqual([]);\n });\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,aAAAA,MAA8C,SACvD,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAE5B,OAAS,wBAAAC,MAA4B,kCAGrC,OACE,4BAAAC,EACA,oCAAAC,EACA,2BAAAC,MACK,8BAEP,OAAS,mCAAAC,MAAuC,iDAChD,OAAS,8BAAAC,MAAkC,4CAE3C,OAAS,wBAAAC,MAA4B,yBAErC,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA+C,CACnD,OAAQ,GAAG,GAAG,CAChB,EACMC,EAAsB,CAC1B,qBAAsB,GAAG,GAAG,CAC9B,EACA,IAAIC,EAEJ,SAAS,OAAQ,IAAM,CACrB,SAAS,2BAA4B,IAAM,CACzC,WAAW,IAAM,CACf,GAAG,MACDD,EACA,sBACF,EAAE,mBAAmB,CAAC,CAAE,QAAAE,CAAQ,IAC9B,QAAQ,QAAQX,EAAM,WAAWW,CAAO,EAAE,CAAC,CAC7C,EACAD,EAAS,IAAIH,EACX,IAAIF,EAAgC,IAAIC,CAA4B,EACpEG,CACF,CACF,CAAC,EAED,GAAG,qEAAsE,SAAY,CAGnF,MAAMG,EAAqB,CACzB,QAAS,EACT,KAAM,otDACR,EAGMC,EAAS,MAAMH,EAAO,KAAKE,CAAkB,EAGnD,OAAOC,CAAM,EAAE,QAAQ,CACrB,CACE,KAAMZ,EAA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D,OAAOC,EAAoB,oBAAoB,EAAE,IAAI,iBAAiB,EACtE,OAAOI,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["Interface", "Left", "Right", "ClearSignContextType", "UNISWAP_EXECUTE_SELECTOR", "UNISWAP_UNIVERSAL_ROUTER_ADDRESS", "UniswapSupportedCommand", "DefaultCommandDecoderDataSource", "EthersAbiDecoderDataSource", "UniswapContextLoader", "commandDecoderMock", "tokenDataSourceMock", "loader", "address", "transactionContext", "result"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ContainerModule as t}from"inversify";import{HttpWeb3CheckDataSource as r}from"../../web3-check/data/HttpWeb3CheckDataSource";import{DefaultWeb3CheckContextLoader as c}from"../../web3-check/domain/DefaultWeb3CheckLoader";import{web3CheckTypes as o}from"./web3CheckTypes";const u=()=>new t((e,a,n,C)=>{e(o.Web3CheckDataSource).to(r),e(o.Web3CheckContextLoader).to(c)});export{u as web3CheckModuleFactory};
1
+ import{ContainerModule as t}from"inversify";import{HttpWeb3CheckDataSource as r}from"../../web3-check/data/HttpWeb3CheckDataSource";import{DefaultWeb3CheckContextLoader as c}from"../../web3-check/domain/DefaultWeb3CheckLoader";import{web3CheckTypes as o}from"./web3CheckTypes";const h=()=>new t(({bind:e})=>{e(o.Web3CheckDataSource).to(r),e(o.Web3CheckContextLoader).to(c)});export{h as web3CheckModuleFactory};
2
2
  //# sourceMappingURL=web3CheckModuleFactory.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/web3-check/di/web3CheckModuleFactory.ts"],
4
- "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpWeb3CheckDataSource } from \"@/web3-check/data/HttpWeb3CheckDataSource\";\nimport { DefaultWeb3CheckContextLoader } from \"@/web3-check/domain/DefaultWeb3CheckLoader\";\n\nimport { web3CheckTypes } from \"./web3CheckTypes\";\n\nexport const web3CheckModuleFactory = () =>\n new ContainerModule((bind, _unbind, _isBound, _rebind) => {\n bind(web3CheckTypes.Web3CheckDataSource).to(HttpWeb3CheckDataSource);\n bind(web3CheckTypes.Web3CheckContextLoader).to(\n DefaultWeb3CheckContextLoader,\n );\n });\n"],
5
- "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,2BAAAC,MAA+B,4CACxC,OAAS,iCAAAC,MAAqC,6CAE9C,OAAS,kBAAAC,MAAsB,mBAExB,MAAMC,EAAyB,IACpC,IAAIJ,EAAgB,CAACK,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAAKF,EAAe,mBAAmB,EAAE,GAAGF,CAAuB,EACnEI,EAAKF,EAAe,sBAAsB,EAAE,GAC1CD,CACF,CACF,CAAC",
6
- "names": ["ContainerModule", "HttpWeb3CheckDataSource", "DefaultWeb3CheckContextLoader", "web3CheckTypes", "web3CheckModuleFactory", "bind", "_unbind", "_isBound", "_rebind"]
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpWeb3CheckDataSource } from \"@/web3-check/data/HttpWeb3CheckDataSource\";\nimport { DefaultWeb3CheckContextLoader } from \"@/web3-check/domain/DefaultWeb3CheckLoader\";\n\nimport { web3CheckTypes } from \"./web3CheckTypes\";\n\nexport const web3CheckModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(web3CheckTypes.Web3CheckDataSource).to(HttpWeb3CheckDataSource);\n bind(web3CheckTypes.Web3CheckContextLoader).to(\n DefaultWeb3CheckContextLoader,\n );\n });\n"],
5
+ "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,2BAAAC,MAA+B,4CACxC,OAAS,iCAAAC,MAAqC,6CAE9C,OAAS,kBAAAC,MAAsB,mBAExB,MAAMC,EAAyB,IACpC,IAAIJ,EAAgB,CAAC,CAAE,KAAAK,CAAK,IAAM,CAChCA,EAAKF,EAAe,mBAAmB,EAAE,GAAGF,CAAuB,EACnEI,EAAKF,EAAe,sBAAsB,EAAE,GAC1CD,CACF,CACF,CAAC",
6
+ "names": ["ContainerModule", "HttpWeb3CheckDataSource", "DefaultWeb3CheckContextLoader", "web3CheckTypes", "web3CheckModuleFactory", "bind"]
7
7
  }
@@ -1,12 +1,15 @@
1
1
  import { type ClearSignContext } from "./shared/model/ClearSignContext";
2
+ import { type SolanaTransactionContext } from "./shared/model/SolanaTransactionContext";
2
3
  import { type TransactionContext, type TransactionFieldContext } from "./shared/model/TransactionContext";
3
4
  import { type TypedDataClearSignContext } from "./shared/model/TypedDataClearSignContext";
4
5
  import { type TypedDataContext } from "./shared/model/TypedDataContext";
6
+ import { type SolanaTransactionContextResult } from "./solana/domain/solanaContextTypes";
5
7
  import { type Web3CheckContext } from "./web3-check/domain/web3CheckTypes";
6
8
  export interface ContextModule {
7
9
  getContext(field: TransactionFieldContext): Promise<ClearSignContext>;
8
10
  getContexts(transaction: TransactionContext): Promise<ClearSignContext[]>;
9
11
  getTypedDataFilters(typedData: TypedDataContext): Promise<TypedDataClearSignContext>;
10
12
  getWeb3Checks(transactionContext: Web3CheckContext): Promise<ClearSignContext | null>;
13
+ getSolanaContext(transactionContext: SolanaTransactionContext): Promise<SolanaTransactionContextResult>;
11
14
  }
12
15
  //# sourceMappingURL=ContextModule.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContextModule.d.ts","sourceRoot":"","sources":["../../../src/ContextModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC7B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AAC1F,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,MAAM,WAAW,aAAa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,kBAAkB,EAAE,wBAAwB,GAC3C,OAAO,CAAC,8BAA8B,CAAC,CAAC;CAC5C"}
@@ -1,6 +1,7 @@
1
1
  import { type ContextModuleConstructorArgs } from "./config/model/ContextModuleBuildArgs";
2
- import { type ContextModuleCalConfig, type ContextModuleConfig, type ContextModuleWeb3ChecksConfig } from "./config/model/ContextModuleConfig";
2
+ import { type ContextModuleCalConfig, type ContextModuleConfig, type ContextModuleMetadataServiceConfig, type ContextModuleWeb3ChecksConfig } from "./config/model/ContextModuleConfig";
3
3
  import { type ContextLoader } from "./shared/domain/ContextLoader";
4
+ import { type SolanaContextLoader } from "./solana/domain/SolanaContextLoader";
4
5
  import { type TypedDataContextLoader } from "./typed-data/domain/TypedDataContextLoader";
5
6
  import { type Web3CheckContextLoader } from "./web3-check/domain/Web3CheckContextLoader";
6
7
  import { type ContextModule } from "./ContextModule";
@@ -37,20 +38,34 @@ export declare class ContextModuleBuilder {
37
38
  * @returns this
38
39
  */
39
40
  addWeb3CheckLoader(loader: Web3CheckContextLoader): this;
41
+ /**
42
+ * Replace the default loader for Solana context
43
+ *
44
+ * @param loader loader to use for Solana context
45
+ * @returns this
46
+ */
47
+ addSolanaLoader(loader: SolanaContextLoader): this;
40
48
  /**
41
49
  * Add a custom CAL configuration
42
50
  *
43
51
  * @param calConfig
44
52
  * @returns this
45
53
  */
46
- addCalConfig(calConfig: ContextModuleCalConfig): this;
54
+ setCalConfig(calConfig: ContextModuleCalConfig): this;
55
+ /**
56
+ * Add a custom metadata service configuration
57
+ *
58
+ * @param metadataServiceConfig
59
+ * @returns this
60
+ */
61
+ setMetadataServiceConfig(metadataServiceConfig: ContextModuleMetadataServiceConfig): this;
47
62
  /**
48
63
  * Add a custom web3 checks configuration
49
64
  *
50
65
  * @param web3ChecksConfig
51
66
  * @returns this
52
67
  */
53
- addWeb3ChecksConfig(web3ChecksConfig: ContextModuleWeb3ChecksConfig): this;
68
+ setWeb3ChecksConfig(web3ChecksConfig: ContextModuleWeb3ChecksConfig): this;
54
69
  /**
55
70
  * Build the context module
56
71
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ContextModuleBuilder.d.ts","sourceRoot":"","sources":["../../../src/ContextModuleBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AAC1F,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,6BAA6B,EACnC,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAMrD,eAAO,MAAM,cAAc,EAAE,mBAY5B,CAAC;AAEF,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAuC;IACrD,OAAO,CAAC,eAAe,CAAiB;IACxC,OAAO,CAAC,WAAW,CAAC,CAAS;gBAEjB,EAAE,WAAW,EAAE,GAAE,4BAAiC;IAI9D;;;;OAIG;IACH,oBAAoB;IAKpB;;;;;OAKG;IACH,SAAS,CAAC,MAAM,EAAE,aAAa;IAK/B;;;;;OAKG;IACH,kBAAkB,CAAC,MAAM,EAAE,sBAAsB;IAKjD;;;;;OAKG;IACH,kBAAkB,CAAC,MAAM,EAAE,sBAAsB;IAMjD;;;;;OAKG;IACH,YAAY,CAAC,SAAS,EAAE,sBAAsB;IAK9C;;;;;OAKG;IACH,mBAAmB,CAAC,gBAAgB,EAAE,6BAA6B;IAQnE;;;;OAIG;IACH,KAAK,IAAI,aAAa;CAQvB"}
1
+ {"version":3,"file":"ContextModuleBuilder.d.ts","sourceRoot":"","sources":["../../../src/ContextModuleBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AAC1F,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,kCAAkC,EACvC,KAAK,6BAA6B,EACnC,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAOrD,eAAO,MAAM,cAAc,EAAE,mBAgB5B,CAAC;AAEF,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAuC;IACrD,OAAO,CAAC,eAAe,CAAiB;IACxC,OAAO,CAAC,WAAW,CAAC,CAAS;gBAEjB,EAAE,WAAW,EAAE,GAAE,4BAAiC;IAI9D;;;;OAIG;IACH,oBAAoB;IAKpB;;;;;OAKG;IACH,SAAS,CAAC,MAAM,EAAE,aAAa;IAK/B;;;;;OAKG;IACH,kBAAkB,CAAC,MAAM,EAAE,sBAAsB;IAKjD;;;;;OAKG;IACH,kBAAkB,CAAC,MAAM,EAAE,sBAAsB;IAMjD;;;;;OAKG;IACH,eAAe,CAAC,MAAM,EAAE,mBAAmB;IAK3C;;;;;OAKG;IACH,YAAY,CAAC,SAAS,EAAE,sBAAsB;IAK9C;;;;;OAKG;IACH,wBAAwB,CACtB,qBAAqB,EAAE,kCAAkC;IAM3D;;;;;OAKG;IACH,mBAAmB,CAAC,gBAAgB,EAAE,6BAA6B;IAKnE;;;;OAIG;IACH,KAAK,IAAI,aAAa;CAQvB"}
@@ -2,7 +2,9 @@ import type { TypedDataClearSignContext } from "./shared/model/TypedDataClearSig
2
2
  import type { TypedDataContext } from "./shared/model/TypedDataContext";
3
3
  import { type ContextModuleConfig } from "./config/model/ContextModuleConfig";
4
4
  import { type ClearSignContext, type ClearSignContextSuccess, ClearSignContextType } from "./shared/model/ClearSignContext";
5
+ import { type SolanaTransactionContext } from "./shared/model/SolanaTransactionContext";
5
6
  import { type TransactionContext, type TransactionFieldContext } from "./shared/model/TransactionContext";
7
+ import { type SolanaTransactionContextResult } from "./solana/domain/solanaContextTypes";
6
8
  import { type Web3CheckContext } from "./web3-check/domain/web3CheckTypes";
7
9
  import { type ContextModule } from "./ContextModule";
8
10
  export declare class DefaultContextModule implements ContextModule {
@@ -10,13 +12,16 @@ export declare class DefaultContextModule implements ContextModule {
10
12
  private _loaders;
11
13
  private _typedDataLoader;
12
14
  private _web3CheckLoader;
15
+ private _solanaLoader;
13
16
  constructor(args: ContextModuleConfig);
14
17
  private _getDefaultLoaders;
15
18
  private _getDefaultTypedDataLoader;
16
19
  private _getWeb3CheckLoader;
20
+ private _getSolanaLoader;
17
21
  getContexts(transaction: TransactionContext): Promise<ClearSignContext[]>;
18
22
  getContext(field: TransactionFieldContext): Promise<ClearSignContext>;
19
23
  getTypedDataFilters(typedData: TypedDataContext): Promise<TypedDataClearSignContext>;
20
24
  getWeb3Checks(transactionContext: Web3CheckContext): Promise<ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null>;
25
+ getSolanaContext(transactionContext: SolanaTransactionContext): Promise<SolanaTransactionContextResult>;
21
26
  }
22
27
  //# sourceMappingURL=DefaultContextModule.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DefaultContextModule.d.ts","sourceRoot":"","sources":["../../../src/DefaultContextModule.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AAC1F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAIxE,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAM9E,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK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,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAI9E,eAAO,MAAM,mBAAmB,WAAY,mBAAmB,oBAG3D,CAAC"}
1
+ {"version":3,"file":"configModuleFactory.d.ts","sourceRoot":"","sources":["../../../../../src/config/di/configModuleFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAI9E,eAAO,MAAM,mBAAmB,GAAI,QAAQ,mBAAmB,oBAG3D,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { type ContextLoader } from "../../shared/domain/ContextLoader";
2
+ import { type SolanaContextLoader } from "../../solana/domain/SolanaContextLoader";
2
3
  import { type TypedDataContextLoader } from "../../typed-data/domain/TypedDataContextLoader";
3
4
  import { type Web3CheckContextLoader } from "../../web3-check/domain/Web3CheckContextLoader";
4
5
  export type ContextModuleCalMode = "prod" | "test";
@@ -11,13 +12,18 @@ export type ContextModuleCalConfig = {
11
12
  export type ContextModuleWeb3ChecksConfig = {
12
13
  url: string;
13
14
  };
15
+ export type ContextModuleMetadataServiceConfig = {
16
+ url: string;
17
+ };
14
18
  export type ContextModuleConfig = {
15
19
  cal: ContextModuleCalConfig;
16
20
  web3checks: ContextModuleWeb3ChecksConfig;
21
+ metadataService: ContextModuleMetadataServiceConfig;
17
22
  defaultLoaders: boolean;
18
23
  customLoaders: ContextLoader[];
19
24
  customTypedDataLoader?: TypedDataContextLoader;
20
25
  customWeb3CheckLoader?: Web3CheckContextLoader;
26
+ customSolanaLoader?: SolanaContextLoader;
21
27
  originToken?: string;
22
28
  };
23
29
  //# sourceMappingURL=ContextModuleConfig.d.ts.map