@ledgerhq/context-module 0.0.0-20250214001047 → 0.0.0-20250215001044

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 (90) hide show
  1. package/lib/cjs/src/DefaultContextModule.js +1 -1
  2. package/lib/cjs/src/DefaultContextModule.js.map +3 -3
  3. package/lib/cjs/src/di.js +1 -1
  4. package/lib/cjs/src/di.js.map +3 -3
  5. package/lib/cjs/src/uniswap/constants/plugin.js +2 -0
  6. package/lib/cjs/src/uniswap/constants/plugin.js.map +7 -0
  7. package/lib/cjs/src/uniswap/constants/uniswap.js +2 -0
  8. package/lib/cjs/src/uniswap/constants/uniswap.js.map +7 -0
  9. package/lib/cjs/src/uniswap/constants/weth.js +2 -0
  10. package/lib/cjs/src/uniswap/constants/weth.js.map +7 -0
  11. package/lib/cjs/src/uniswap/data/AbiDecoderDataSource.js +2 -0
  12. package/lib/cjs/src/uniswap/data/AbiDecoderDataSource.js.map +7 -0
  13. package/lib/cjs/src/uniswap/data/CommandDecoderDataSource.js +2 -0
  14. package/lib/cjs/src/uniswap/data/CommandDecoderDataSource.js.map +7 -0
  15. package/lib/cjs/src/uniswap/data/DefaultCommandDecoderDataSource.js +2 -0
  16. package/lib/cjs/src/uniswap/data/DefaultCommandDecoderDataSource.js.map +7 -0
  17. package/lib/cjs/src/uniswap/data/DefaultCommandDecoderDataSource.test.js +2 -0
  18. package/lib/cjs/src/uniswap/data/DefaultCommandDecoderDataSource.test.js.map +7 -0
  19. package/lib/cjs/src/uniswap/data/EthersAbiDecoderDataSource.js +2 -0
  20. package/lib/cjs/src/uniswap/data/EthersAbiDecoderDataSource.js.map +7 -0
  21. package/lib/cjs/src/uniswap/data/EthersAbiDecoderDataSource.test.js +2 -0
  22. package/lib/cjs/src/uniswap/data/EthersAbiDecoderDataSource.test.js.map +7 -0
  23. package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js +2 -0
  24. package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js.map +7 -0
  25. package/lib/cjs/src/uniswap/di/uniswapTypes.js +2 -0
  26. package/lib/cjs/src/uniswap/di/uniswapTypes.js.map +7 -0
  27. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js +2 -0
  28. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js.map +7 -0
  29. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js +2 -0
  30. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js.map +7 -0
  31. package/lib/esm/src/DefaultContextModule.js +1 -1
  32. package/lib/esm/src/DefaultContextModule.js.map +3 -3
  33. package/lib/esm/src/di.js +1 -1
  34. package/lib/esm/src/di.js.map +3 -3
  35. package/lib/esm/src/uniswap/constants/plugin.js +2 -0
  36. package/lib/esm/src/uniswap/constants/plugin.js.map +7 -0
  37. package/lib/esm/src/uniswap/constants/uniswap.js +2 -0
  38. package/lib/esm/src/uniswap/constants/uniswap.js.map +7 -0
  39. package/lib/esm/src/uniswap/constants/weth.js +2 -0
  40. package/lib/esm/src/uniswap/constants/weth.js.map +7 -0
  41. package/lib/esm/src/uniswap/data/AbiDecoderDataSource.js +1 -0
  42. package/lib/esm/src/uniswap/data/AbiDecoderDataSource.js.map +7 -0
  43. package/lib/esm/src/uniswap/data/CommandDecoderDataSource.js +1 -0
  44. package/lib/esm/src/uniswap/data/CommandDecoderDataSource.js.map +7 -0
  45. package/lib/esm/src/uniswap/data/DefaultCommandDecoderDataSource.js +2 -0
  46. package/lib/esm/src/uniswap/data/DefaultCommandDecoderDataSource.js.map +7 -0
  47. package/lib/esm/src/uniswap/data/DefaultCommandDecoderDataSource.test.js +2 -0
  48. package/lib/esm/src/uniswap/data/DefaultCommandDecoderDataSource.test.js.map +7 -0
  49. package/lib/esm/src/uniswap/data/EthersAbiDecoderDataSource.js +2 -0
  50. package/lib/esm/src/uniswap/data/EthersAbiDecoderDataSource.js.map +7 -0
  51. package/lib/esm/src/uniswap/data/EthersAbiDecoderDataSource.test.js +2 -0
  52. package/lib/esm/src/uniswap/data/EthersAbiDecoderDataSource.test.js.map +7 -0
  53. package/lib/esm/src/uniswap/di/uniswapModuleFactory.js +2 -0
  54. package/lib/esm/src/uniswap/di/uniswapModuleFactory.js.map +7 -0
  55. package/lib/esm/src/uniswap/di/uniswapTypes.js +2 -0
  56. package/lib/esm/src/uniswap/di/uniswapTypes.js.map +7 -0
  57. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js +2 -0
  58. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js.map +7 -0
  59. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js +2 -0
  60. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js.map +7 -0
  61. package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
  62. package/lib/types/src/di.d.ts.map +1 -1
  63. package/lib/types/src/uniswap/constants/plugin.d.ts +3 -0
  64. package/lib/types/src/uniswap/constants/plugin.d.ts.map +1 -0
  65. package/lib/types/src/uniswap/constants/uniswap.d.ts +21 -0
  66. package/lib/types/src/uniswap/constants/uniswap.d.ts.map +1 -0
  67. package/lib/types/src/uniswap/constants/weth.d.ts +20 -0
  68. package/lib/types/src/uniswap/constants/weth.d.ts.map +1 -0
  69. package/lib/types/src/uniswap/data/AbiDecoderDataSource.d.ts +5 -0
  70. package/lib/types/src/uniswap/data/AbiDecoderDataSource.d.ts.map +1 -0
  71. package/lib/types/src/uniswap/data/CommandDecoderDataSource.d.ts +6 -0
  72. package/lib/types/src/uniswap/data/CommandDecoderDataSource.d.ts.map +1 -0
  73. package/lib/types/src/uniswap/data/DefaultCommandDecoderDataSource.d.ts +14 -0
  74. package/lib/types/src/uniswap/data/DefaultCommandDecoderDataSource.d.ts.map +1 -0
  75. package/lib/types/src/uniswap/data/DefaultCommandDecoderDataSource.test.d.ts +2 -0
  76. package/lib/types/src/uniswap/data/DefaultCommandDecoderDataSource.test.d.ts.map +1 -0
  77. package/lib/types/src/uniswap/data/EthersAbiDecoderDataSource.d.ts +5 -0
  78. package/lib/types/src/uniswap/data/EthersAbiDecoderDataSource.d.ts.map +1 -0
  79. package/lib/types/src/uniswap/data/EthersAbiDecoderDataSource.test.d.ts +2 -0
  80. package/lib/types/src/uniswap/data/EthersAbiDecoderDataSource.test.d.ts.map +1 -0
  81. package/lib/types/src/uniswap/di/uniswapModuleFactory.d.ts +3 -0
  82. package/lib/types/src/uniswap/di/uniswapModuleFactory.d.ts.map +1 -0
  83. package/lib/types/src/uniswap/di/uniswapTypes.d.ts +6 -0
  84. package/lib/types/src/uniswap/di/uniswapTypes.d.ts.map +1 -0
  85. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts +105 -0
  86. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts.map +1 -0
  87. package/lib/types/src/uniswap/domain/UniswapContextLoader.test.d.ts +2 -0
  88. package/lib/types/src/uniswap/domain/UniswapContextLoader.test.d.ts.map +1 -0
  89. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  90. package/package.json +5 -5
@@ -1,2 +1,2 @@
1
- "use strict";var n=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var L=(o,t)=>{for(var a in t)n(o,a,{get:t[a],enumerable:!0})},u=(o,t,a,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of f(t))!T.call(o,e)&&e!==a&&n(o,e,{get:()=>t[e],enumerable:!(r=y(t,e))||r.enumerable});return o};var c=o=>u(n({},"__esModule",{value:!0}),o);var g={};L(g,{DefaultContextModule:()=>D});module.exports=c(g);var i=require("./transaction/di/transactionTypes"),p=require("./trusted-name/di/trustedNameTypes"),d=require("./external-plugin/di/externalPluginTypes"),s=require("./nft/di/nftTypes"),m=require("./shared/model/ClearSignContext"),C=require("./token/di/tokenTypes"),l=require("./typed-data/di/typedDataTypes"),x=require("./di");class D{_container;_loaders;_typedDataLoader;constructor(t){this._container=(0,x.makeContainer)({config:t}),this._loaders=t.defaultLoaders?this._getDefaultLoaders():[],this._loaders.push(...t.customLoaders),this._typedDataLoader=t.customTypedDataLoader??this._getDefaultTypedDataLoader()}_getDefaultLoaders(){return[this._container.get(d.externalPluginTypes.ExternalPluginContextLoader),this._container.get(p.trustedNameTypes.TrustedNameContextLoader),this._container.get(s.nftTypes.NftContextLoader),this._container.get(C.tokenTypes.TokenContextLoader),this._container.get(i.transactionTypes.TransactionContextLoader)]}_getDefaultTypedDataLoader(){return this._container.get(l.typedDataTypes.TypedDataContextLoader)}async getContexts(t){const a=this._loaders.map(e=>e.load(t));return(await Promise.all(a)).flat()}async getContext(t){const a=this._loaders.filter(e=>e.loadField).map(e=>e.loadField(t));return(await Promise.all(a)).find(e=>e!==null)||{type:m.ClearSignContextType.ERROR,error:new Error(`Field type not supported: ${t.type}`)}}async getTypedDataFilters(t){return this._typedDataLoader.load(t)}}0&&(module.exports={DefaultContextModule});
1
+ "use strict";var n=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var u=(o,t)=>{for(var a in t)n(o,a,{get:t[a],enumerable:!0})},c=(o,t,a,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of L(t))!T.call(o,e)&&e!==a&&n(o,e,{get:()=>t[e],enumerable:!(r=f(t,e))||r.enumerable});return o};var g=o=>c(n({},"__esModule",{value:!0}),o);var _={};u(_,{DefaultContextModule:()=>D});module.exports=g(_);var i=require("./transaction/di/transactionTypes"),p=require("./trusted-name/di/trustedNameTypes"),d=require("./external-plugin/di/externalPluginTypes"),s=require("./nft/di/nftTypes"),m=require("./shared/model/ClearSignContext"),C=require("./token/di/tokenTypes"),l=require("./typed-data/di/typedDataTypes"),x=require("./uniswap/di/uniswapTypes"),y=require("./di");class D{_container;_loaders;_typedDataLoader;constructor(t){this._container=(0,y.makeContainer)({config:t}),this._loaders=t.defaultLoaders?this._getDefaultLoaders():[],this._loaders.push(...t.customLoaders),this._typedDataLoader=t.customTypedDataLoader??this._getDefaultTypedDataLoader()}_getDefaultLoaders(){return[this._container.get(d.externalPluginTypes.ExternalPluginContextLoader),this._container.get(p.trustedNameTypes.TrustedNameContextLoader),this._container.get(s.nftTypes.NftContextLoader),this._container.get(C.tokenTypes.TokenContextLoader),this._container.get(i.transactionTypes.TransactionContextLoader),this._container.get(x.uniswapTypes.UniswapContextLoader)]}_getDefaultTypedDataLoader(){return this._container.get(l.typedDataTypes.TypedDataContextLoader)}async getContexts(t){const a=this._loaders.map(e=>e.load(t));return(await Promise.all(a)).flat()}async getContext(t){const a=this._loaders.filter(e=>e.loadField).map(e=>e.loadField(t));return(await Promise.all(a)).find(e=>e!==null)||{type:m.ClearSignContextType.ERROR,error:new Error(`Field type not supported: ${t.type}`)}}async getTypedDataFilters(t){return this._typedDataLoader.load(t)}}0&&(module.exports={DefaultContextModule});
2
2
  //# sourceMappingURL=DefaultContextModule.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/DefaultContextModule.ts"],
4
- "sourcesContent": ["import { type Container } from \"inversify\";\n\nimport type { TypedDataClearSignContext } from \"@/shared/model/TypedDataClearSignContext\";\nimport type { TypedDataContext } from \"@/shared/model/TypedDataContext\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\nimport { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { externalPluginTypes } from \"./external-plugin/di/externalPluginTypes\";\nimport { type ExternalPluginContextLoader } from \"./external-plugin/domain/ExternalPluginContextLoader\";\nimport { nftTypes } from \"./nft/di/nftTypes\";\nimport { type NftContextLoader } from \"./nft/domain/NftContextLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"./shared/model/TransactionContext\";\nimport { tokenTypes } from \"./token/di/tokenTypes\";\nimport { type TokenContextLoader } from \"./token/domain/TokenContextLoader\";\nimport { type TransactionContextLoader } from \"./transaction/domain/TransactionContextLoader\";\nimport { type TrustedNameContextLoader } from \"./trusted-name/domain/TrustedNameContextLoader\";\nimport { typedDataTypes } from \"./typed-data/di/typedDataTypes\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { makeContainer } from \"./di\";\n\nexport class DefaultContextModule implements ContextModule {\n private _container: Container;\n private _loaders: ContextLoader[];\n private _typedDataLoader: TypedDataContextLoader;\n\n constructor(args: ContextModuleConfig) {\n this._container = makeContainer({ config: args });\n this._loaders = args.defaultLoaders ? this._getDefaultLoaders() : [];\n this._loaders.push(...args.customLoaders);\n this._typedDataLoader =\n args.customTypedDataLoader ?? this._getDefaultTypedDataLoader();\n }\n\n private _getDefaultLoaders(): ContextLoader[] {\n return [\n this._container.get<ExternalPluginContextLoader>(\n externalPluginTypes.ExternalPluginContextLoader,\n ),\n this._container.get<TrustedNameContextLoader>(\n trustedNameTypes.TrustedNameContextLoader,\n ),\n this._container.get<NftContextLoader>(nftTypes.NftContextLoader),\n this._container.get<TokenContextLoader>(tokenTypes.TokenContextLoader),\n this._container.get<TransactionContextLoader>(\n transactionTypes.TransactionContextLoader,\n ),\n ];\n }\n\n private _getDefaultTypedDataLoader(): TypedDataContextLoader {\n return this._container.get<TypedDataContextLoader>(\n typedDataTypes.TypedDataContextLoader,\n );\n }\n\n public async getContexts(\n transaction: TransactionContext,\n ): Promise<ClearSignContext[]> {\n const promises = this._loaders.map((fetcher) => fetcher.load(transaction));\n const responses = await Promise.all(promises);\n return responses.flat();\n }\n\n public async getContext(\n field: TransactionFieldContext,\n ): Promise<ClearSignContext> {\n const promises = this._loaders\n .filter((fetcher) => fetcher.loadField)\n .map((fetcher) => fetcher.loadField!(field));\n const responses = await Promise.all(promises);\n return (\n responses.find((resp) => resp !== null) || {\n type: ClearSignContextType.ERROR,\n error: new Error(`Field type not supported: ${field.type}`),\n }\n );\n }\n\n public async getTypedDataFilters(\n typedData: TypedDataContext,\n ): Promise<TypedDataClearSignContext> {\n return this._typedDataLoader.load(typedData);\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GAIA,IAAAI,EAAiC,6CACjCC,EAAiC,8CAGjCC,EAAoC,oDAEpCC,EAAyB,6BAGzBC,EAGO,2CAKPC,EAA2B,iCAI3BC,EAA+B,0CAG/BC,EAA8B,gBAEvB,MAAMT,CAA8C,CACjD,WACA,SACA,iBAER,YAAYU,EAA2B,CACrC,KAAK,cAAa,iBAAc,CAAE,OAAQA,CAAK,CAAC,EAChD,KAAK,SAAWA,EAAK,eAAiB,KAAK,mBAAmB,EAAI,CAAC,EACnE,KAAK,SAAS,KAAK,GAAGA,EAAK,aAAa,EACxC,KAAK,iBACHA,EAAK,uBAAyB,KAAK,2BAA2B,CAClE,CAEQ,oBAAsC,CAC5C,MAAO,CACL,KAAK,WAAW,IACd,sBAAoB,2BACtB,EACA,KAAK,WAAW,IACd,mBAAiB,wBACnB,EACA,KAAK,WAAW,IAAsB,WAAS,gBAAgB,EAC/D,KAAK,WAAW,IAAwB,aAAW,kBAAkB,EACrE,KAAK,WAAW,IACd,mBAAiB,wBACnB,CACF,CACF,CAEQ,4BAAqD,CAC3D,OAAO,KAAK,WAAW,IACrB,iBAAe,sBACjB,CACF,CAEA,MAAa,YACXC,EAC6B,CAC7B,MAAMC,EAAW,KAAK,SAAS,IAAKC,GAAYA,EAAQ,KAAKF,CAAW,CAAC,EAEzE,OADkB,MAAM,QAAQ,IAAIC,CAAQ,GAC3B,KAAK,CACxB,CAEA,MAAa,WACXE,EAC2B,CAC3B,MAAMF,EAAW,KAAK,SACnB,OAAQC,GAAYA,EAAQ,SAAS,EACrC,IAAKA,GAAYA,EAAQ,UAAWC,CAAK,CAAC,EAE7C,OADkB,MAAM,QAAQ,IAAIF,CAAQ,GAEhC,KAAMG,GAASA,IAAS,IAAI,GAAK,CACzC,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,6BAA6BD,EAAM,IAAI,EAAE,CAC5D,CAEJ,CAEA,MAAa,oBACXE,EACoC,CACpC,OAAO,KAAK,iBAAiB,KAAKA,CAAS,CAC7C,CACF",
6
- "names": ["DefaultContextModule_exports", "__export", "DefaultContextModule", "__toCommonJS", "import_transactionTypes", "import_trustedNameTypes", "import_externalPluginTypes", "import_nftTypes", "import_ClearSignContext", "import_tokenTypes", "import_typedDataTypes", "import_di", "args", "transaction", "promises", "fetcher", "field", "resp", "typedData"]
4
+ "sourcesContent": ["import { type Container } from \"inversify\";\n\nimport type { TypedDataClearSignContext } from \"@/shared/model/TypedDataClearSignContext\";\nimport type { TypedDataContext } from \"@/shared/model/TypedDataContext\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\nimport { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { externalPluginTypes } from \"./external-plugin/di/externalPluginTypes\";\nimport { type ExternalPluginContextLoader } from \"./external-plugin/domain/ExternalPluginContextLoader\";\nimport { nftTypes } from \"./nft/di/nftTypes\";\nimport { type NftContextLoader } from \"./nft/domain/NftContextLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"./shared/model/TransactionContext\";\nimport { tokenTypes } from \"./token/di/tokenTypes\";\nimport { type TokenContextLoader } from \"./token/domain/TokenContextLoader\";\nimport { type TransactionContextLoader } from \"./transaction/domain/TransactionContextLoader\";\nimport { type TrustedNameContextLoader } from \"./trusted-name/domain/TrustedNameContextLoader\";\nimport { typedDataTypes } from \"./typed-data/di/typedDataTypes\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { uniswapTypes } from \"./uniswap/di/uniswapTypes\";\nimport { type UniswapContextLoader } from \"./uniswap/domain/UniswapContextLoader\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { makeContainer } from \"./di\";\n\nexport class DefaultContextModule implements ContextModule {\n private _container: Container;\n private _loaders: ContextLoader[];\n private _typedDataLoader: TypedDataContextLoader;\n\n constructor(args: ContextModuleConfig) {\n this._container = makeContainer({ config: args });\n this._loaders = args.defaultLoaders ? this._getDefaultLoaders() : [];\n this._loaders.push(...args.customLoaders);\n this._typedDataLoader =\n args.customTypedDataLoader ?? this._getDefaultTypedDataLoader();\n }\n\n private _getDefaultLoaders(): ContextLoader[] {\n return [\n this._container.get<ExternalPluginContextLoader>(\n externalPluginTypes.ExternalPluginContextLoader,\n ),\n this._container.get<TrustedNameContextLoader>(\n trustedNameTypes.TrustedNameContextLoader,\n ),\n this._container.get<NftContextLoader>(nftTypes.NftContextLoader),\n this._container.get<TokenContextLoader>(tokenTypes.TokenContextLoader),\n this._container.get<TransactionContextLoader>(\n transactionTypes.TransactionContextLoader,\n ),\n this._container.get<UniswapContextLoader>(\n uniswapTypes.UniswapContextLoader,\n ),\n ];\n }\n\n private _getDefaultTypedDataLoader(): TypedDataContextLoader {\n return this._container.get<TypedDataContextLoader>(\n typedDataTypes.TypedDataContextLoader,\n );\n }\n\n public async getContexts(\n transaction: TransactionContext,\n ): Promise<ClearSignContext[]> {\n const promises = this._loaders.map((fetcher) => fetcher.load(transaction));\n const responses = await Promise.all(promises);\n return responses.flat();\n }\n\n public async getContext(\n field: TransactionFieldContext,\n ): Promise<ClearSignContext> {\n const promises = this._loaders\n .filter((fetcher) => fetcher.loadField)\n .map((fetcher) => fetcher.loadField!(field));\n const responses = await Promise.all(promises);\n return (\n responses.find((resp) => resp !== null) || {\n type: ClearSignContextType.ERROR,\n error: new Error(`Field type not supported: ${field.type}`),\n }\n );\n }\n\n public async getTypedDataFilters(\n typedData: TypedDataContext,\n ): Promise<T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,IAAS,IAAI,GAAK,CACzC,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,6BAA6BD,EAAM,IAAI,EAAE,CAC5D,CAEJ,CAEA,MAAa,oBACXE,EACoC,CACpC,OAAO,KAAK,iBAAiB,KAAKA,CAAS,CAC7C,CACF",
6
+ "names": ["DefaultContextModule_exports", "__export", "DefaultContextModule", "__toCommonJS", "import_transactionTypes", "import_trustedNameTypes", "import_externalPluginTypes", "import_nftTypes", "import_ClearSignContext", "import_tokenTypes", "import_typedDataTypes", "import_uniswapTypes", "import_di", "args", "transaction", "promises", "fetcher", "field", "resp", "typedData"]
7
7
  }
package/lib/cjs/src/di.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var n=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var g=(t,o)=>{for(var e in o)n(t,e,{get:o[e],enumerable:!0})},s=(t,o,e,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of C(o))!F.call(t,r)&&r!==e&&n(t,r,{get:()=>o[r],enumerable:!(a=y(o,r))||a.enumerable});return t};var k=t=>s(n({},"__esModule",{value:!0}),t);var A={};g(A,{makeContainer:()=>x});module.exports=k(A);var i=require("inversify"),m=require("./config/di/configModuleFactory"),f=require("./external-plugin/di/externalPluginModuleFactory"),c=require("./nft/di/nftModuleFactory"),p=require("./pki/di/pkiModuleFactory"),d=require("./token/di/tokenModuleFactory"),l=require("./transaction/di/transactionModuleFactory"),u=require("./trusted-name/di/trustedNameModuleFactory"),M=require("./typed-data/di/typedDataModuleFactory");const x=({config:t})=>{const o=new i.Container;return o.load((0,m.configModuleFactory)(t),(0,f.externalPluginModuleFactory)(),(0,c.nftModuleFactory)(),(0,d.tokenModuleFactory)(),(0,l.transactionModuleFactory)(),(0,u.trustedNameModuleFactory)(),(0,M.typedDataModuleFactory)(),(0,p.nanoPkiModuleFactory)()),o};0&&(module.exports={makeContainer});
1
+ "use strict";var n=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var s=(r,o)=>{for(var e in o)n(r,e,{get:o[e],enumerable:!0})},k=(r,o,e,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of C(o))!g.call(r,t)&&t!==e&&n(r,t,{get:()=>o[t],enumerable:!(a=F(o,t))||a.enumerable});return r};var x=r=>k(n({},"__esModule",{value:!0}),r);var A={};s(A,{makeContainer:()=>w});module.exports=x(A);var i=require("inversify"),m=require("./config/di/configModuleFactory"),f=require("./external-plugin/di/externalPluginModuleFactory"),p=require("./nft/di/nftModuleFactory"),c=require("./pki/di/pkiModuleFactory"),u=require("./token/di/tokenModuleFactory"),d=require("./transaction/di/transactionModuleFactory"),l=require("./trusted-name/di/trustedNameModuleFactory"),M=require("./typed-data/di/typedDataModuleFactory"),y=require("./uniswap/di/uniswapModuleFactory");const w=({config:r})=>{const o=new i.Container;return o.load((0,m.configModuleFactory)(r),(0,f.externalPluginModuleFactory)(),(0,p.nftModuleFactory)(),(0,u.tokenModuleFactory)(),(0,d.transactionModuleFactory)(),(0,l.trustedNameModuleFactory)(),(0,M.typedDataModuleFactory)(),(0,c.nanoPkiModuleFactory)(),(0,y.uniswapModuleFactory)()),o};0&&(module.exports={makeContainer});
2
2
  //# sourceMappingURL=di.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/di.ts"],
4
- "sourcesContent": ["import { Container } from \"inversify\";\n\nimport { configModuleFactory } from \"@/config/di/configModuleFactory\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { externalPluginModuleFactory } from \"@/external-plugin/di/externalPluginModuleFactory\";\nimport { nftModuleFactory } from \"@/nft/di/nftModuleFactory\";\nimport { nanoPkiModuleFactory } from \"@/pki/di/pkiModuleFactory\";\nimport { tokenModuleFactory } from \"@/token/di/tokenModuleFactory\";\nimport { transactionModuleFactory } from \"@/transaction/di/transactionModuleFactory\";\nimport { trustedNameModuleFactory } from \"@/trusted-name/di/trustedNameModuleFactory\";\nimport { typedDataModuleFactory } from \"@/typed-data/di/typedDataModuleFactory\";\n\ntype MakeContainerArgs = {\n config: ContextModuleConfig;\n};\n\nexport const makeContainer = ({ config }: MakeContainerArgs) => {\n const container = new Container();\n\n container.load(\n configModuleFactory(config),\n externalPluginModuleFactory(),\n nftModuleFactory(),\n tokenModuleFactory(),\n transactionModuleFactory(),\n trustedNameModuleFactory(),\n typedDataModuleFactory(),\n nanoPkiModuleFactory(),\n );\n\n return container;\n};\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA0B,qBAE1BC,EAAoC,2CAEpCC,EAA4C,4DAC5CC,EAAiC,qCACjCC,EAAqC,qCACrCC,EAAmC,yCACnCC,EAAyC,qDACzCC,EAAyC,sDACzCC,EAAuC,kDAMhC,MAAMV,EAAgB,CAAC,CAAE,OAAAW,CAAO,IAAyB,CAC9D,MAAMC,EAAY,IAAI,YAEtB,OAAAA,EAAU,QACR,uBAAoBD,CAAM,KAC1B,+BAA4B,KAC5B,oBAAiB,KACjB,sBAAmB,KACnB,4BAAyB,KACzB,4BAAyB,KACzB,0BAAuB,KACvB,wBAAqB,CACvB,EAEOC,CACT",
6
- "names": ["di_exports", "__export", "makeContainer", "__toCommonJS", "import_inversify", "import_configModuleFactory", "import_externalPluginModuleFactory", "import_nftModuleFactory", "import_pkiModuleFactory", "import_tokenModuleFactory", "import_transactionModuleFactory", "import_trustedNameModuleFactory", "import_typedDataModuleFactory", "config", "container"]
4
+ "sourcesContent": ["import { Container } from \"inversify\";\n\nimport { configModuleFactory } from \"@/config/di/configModuleFactory\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { externalPluginModuleFactory } from \"@/external-plugin/di/externalPluginModuleFactory\";\nimport { nftModuleFactory } from \"@/nft/di/nftModuleFactory\";\nimport { nanoPkiModuleFactory } from \"@/pki/di/pkiModuleFactory\";\nimport { tokenModuleFactory } from \"@/token/di/tokenModuleFactory\";\nimport { transactionModuleFactory } from \"@/transaction/di/transactionModuleFactory\";\nimport { trustedNameModuleFactory } from \"@/trusted-name/di/trustedNameModuleFactory\";\nimport { typedDataModuleFactory } from \"@/typed-data/di/typedDataModuleFactory\";\nimport { uniswapModuleFactory } from \"@/uniswap/di/uniswapModuleFactory\";\n\ntype MakeContainerArgs = {\n config: ContextModuleConfig;\n};\n\nexport const makeContainer = ({ config }: MakeContainerArgs) => {\n const container = new Container();\n\n container.load(\n configModuleFactory(config),\n externalPluginModuleFactory(),\n nftModuleFactory(),\n tokenModuleFactory(),\n transactionModuleFactory(),\n trustedNameModuleFactory(),\n typedDataModuleFactory(),\n nanoPkiModuleFactory(),\n uniswapModuleFactory(),\n );\n\n return container;\n};\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA0B,qBAE1BC,EAAoC,2CAEpCC,EAA4C,4DAC5CC,EAAiC,qCACjCC,EAAqC,qCACrCC,EAAmC,yCACnCC,EAAyC,qDACzCC,EAAyC,sDACzCC,EAAuC,kDACvCC,EAAqC,6CAM9B,MAAMX,EAAgB,CAAC,CAAE,OAAAY,CAAO,IAAyB,CAC9D,MAAMC,EAAY,IAAI,YAEtB,OAAAA,EAAU,QACR,uBAAoBD,CAAM,KAC1B,+BAA4B,KAC5B,oBAAiB,KACjB,sBAAmB,KACnB,4BAAyB,KACzB,4BAAyB,KACzB,0BAAuB,KACvB,wBAAqB,KACrB,wBAAqB,CACvB,EAEOC,CACT",
6
+ "names": ["di_exports", "__export", "makeContainer", "__toCommonJS", "import_inversify", "import_configModuleFactory", "import_externalPluginModuleFactory", "import_nftModuleFactory", "import_pkiModuleFactory", "import_tokenModuleFactory", "import_transactionModuleFactory", "import_trustedNameModuleFactory", "import_typedDataModuleFactory", "import_uniswapModuleFactory", "config", "container"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ "use strict";var d=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var o=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0})},t=(c,a,b,e)=>{if(a&&typeof a=="object"||typeof a=="function")for(let f of U(a))!I.call(c,f)&&f!==b&&d(c,f,{get:()=>a[f],enumerable:!(e=N(a,f))||e.enumerable});return c};var A=c=>t(d({},"__esModule",{value:!0}),c);var n={};o(n,{UNISWAP_PLUGIN_NAME:()=>_,UNISWAP_PLUGIN_SIGNATURE:()=>P});module.exports=A(n);const P="0x3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935",_="Uniswap";0&&(module.exports={UNISWAP_PLUGIN_NAME,UNISWAP_PLUGIN_SIGNATURE});
2
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/uniswap/constants/plugin.ts"],
4
+ "sourcesContent": ["export const UNISWAP_PLUGIN_SIGNATURE =\n \"0x3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935\";\nexport const UNISWAP_PLUGIN_NAME = \"Uniswap\";\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,EAAA,6BAAAC,IAAA,eAAAC,EAAAJ,GAAO,MAAMG,EACX,iJACWD,EAAsB",
6
+ "names": ["plugin_exports", "__export", "UNISWAP_PLUGIN_NAME", "UNISWAP_PLUGIN_SIGNATURE", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var R=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var t=(A,T)=>{for(var P in T)R(A,P,{get:T[P],enumerable:!0})},o=(A,T,P,S)=>{if(T&&typeof T=="object"||typeof T=="function")for(let E of W(T))!a.call(A,E)&&E!==P&&R(A,E,{get:()=>T[E],enumerable:!(S=C(T,E))||S.enumerable});return A};var p=A=>o(R({},"__esModule",{value:!0}),A);var d={};t(d,{UNISWAP_COMMANDS:()=>n,UNISWAP_EXECUTE_ABI:()=>M,UNISWAP_EXECUTE_SELECTOR:()=>e,UNISWAP_SWAP_COMMANDS:()=>U,UNISWAP_UNIVERSAL_ROUTER_ADDRESS:()=>N,UniswapSupportedCommand:()=>I});module.exports=p(d);const M=["function execute(bytes calldata commands, bytes[] calldata inputs, uint256 deadline) external payable"],N="0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",e="0x3593564c";var I=(_=>(_.V2_SWAP_EXACT_IN="V2_SWAP_EXACT_IN",_.V2_SWAP_EXACT_OUT="V2_SWAP_EXACT_OUT",_.V3_SWAP_EXACT_IN="V3_SWAP_EXACT_IN",_.V3_SWAP_EXACT_OUT="V3_SWAP_EXACT_OUT",_.WRAP_ETH="WRAP_ETH",_.UNWRAP_ETH="UNWRAP_ETH",_.PERMIT2_PERMIT="PERMIT2_PERMIT",_.PERMIT2_TRANSFER_FROM="PERMIT2_TRANSFER_FROM",_.PERMIT2_PERMIT_BATCH="PERMIT2_PERMIT_BATCH",_.PERMIT2_TRANSFER_FROM_BATCH="PERMIT2_TRANSFER_FROM_BATCH",_.PAY_PORTION="PAY_PORTION",_.SWEEP="SWEEP",_))(I||{});const n={"0x08":"V2_SWAP_EXACT_IN","0x09":"V2_SWAP_EXACT_OUT","0x00":"V3_SWAP_EXACT_IN","0x01":"V3_SWAP_EXACT_OUT","0x0b":"WRAP_ETH","0x0c":"UNWRAP_ETH","0x0a":"PERMIT2_PERMIT","0x0d":"PERMIT2_TRANSFER_FROM","0x02":"PERMIT2_PERMIT_BATCH","0x03":"PERMIT2_TRANSFER_FROM_BATCH","0x06":"PAY_PORTION","0x04":"SWEEP"},U=["V2_SWAP_EXACT_IN","V2_SWAP_EXACT_OUT","V3_SWAP_EXACT_IN","V3_SWAP_EXACT_OUT"];0&&(module.exports={UNISWAP_COMMANDS,UNISWAP_EXECUTE_ABI,UNISWAP_EXECUTE_SELECTOR,UNISWAP_SWAP_COMMANDS,UNISWAP_UNIVERSAL_ROUTER_ADDRESS,UniswapSupportedCommand});
2
+ //# sourceMappingURL=uniswap.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/uniswap/constants/uniswap.ts"],
4
+ "sourcesContent": ["import { type HexaString } from \"@ledgerhq/device-management-kit\";\n\nexport const UNISWAP_EXECUTE_ABI = [\n \"function execute(bytes calldata commands, bytes[] calldata inputs, uint256 deadline) external payable\",\n];\n\nexport const UNISWAP_UNIVERSAL_ROUTER_ADDRESS =\n \"0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad\";\nexport const UNISWAP_EXECUTE_SELECTOR = \"0x3593564c\";\n\nexport enum UniswapSupportedCommand {\n V2_SWAP_EXACT_IN = \"V2_SWAP_EXACT_IN\",\n V2_SWAP_EXACT_OUT = \"V2_SWAP_EXACT_OUT\",\n V3_SWAP_EXACT_IN = \"V3_SWAP_EXACT_IN\",\n V3_SWAP_EXACT_OUT = \"V3_SWAP_EXACT_OUT\",\n WRAP_ETH = \"WRAP_ETH\",\n UNWRAP_ETH = \"UNWRAP_ETH\",\n PERMIT2_PERMIT = \"PERMIT2_PERMIT\",\n PERMIT2_TRANSFER_FROM = \"PERMIT2_TRANSFER_FROM\",\n PERMIT2_PERMIT_BATCH = \"PERMIT2_PERMIT_BATCH\",\n PERMIT2_TRANSFER_FROM_BATCH = \"PERMIT2_TRANSFER_FROM_BATCH\",\n PAY_PORTION = \"PAY_PORTION\",\n SWEEP = \"SWEEP\",\n}\n\nexport const UNISWAP_COMMANDS: Record<HexaString, UniswapSupportedCommand> = {\n \"0x08\": UniswapSupportedCommand.V2_SWAP_EXACT_IN,\n \"0x09\": UniswapSupportedCommand.V2_SWAP_EXACT_OUT,\n \"0x00\": UniswapSupportedCommand.V3_SWAP_EXACT_IN,\n \"0x01\": UniswapSupportedCommand.V3_SWAP_EXACT_OUT,\n \"0x0b\": UniswapSupportedCommand.WRAP_ETH,\n \"0x0c\": UniswapSupportedCommand.UNWRAP_ETH,\n \"0x0a\": UniswapSupportedCommand.PERMIT2_PERMIT,\n \"0x0d\": UniswapSupportedCommand.PERMIT2_TRANSFER_FROM,\n \"0x02\": UniswapSupportedCommand.PERMIT2_PERMIT_BATCH,\n \"0x03\": UniswapSupportedCommand.PERMIT2_TRANSFER_FROM_BATCH,\n \"0x06\": UniswapSupportedCommand.PAY_PORTION,\n \"0x04\": UniswapSupportedCommand.SWEEP,\n};\n\nexport const UNISWAP_SWAP_COMMANDS: UniswapSupportedCommand[] = [\n UniswapSupportedCommand.V2_SWAP_EXACT_IN,\n UniswapSupportedCommand.V2_SWAP_EXACT_OUT,\n UniswapSupportedCommand.V3_SWAP_EXACT_IN,\n UniswapSupportedCommand.V3_SWAP_EXACT_OUT,\n];\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,EAAA,wBAAAC,EAAA,6BAAAC,EAAA,0BAAAC,EAAA,qCAAAC,EAAA,4BAAAC,IAAA,eAAAC,EAAAR,GAEO,MAAMG,EAAsB,CACjC,uGACF,EAEaG,EACX,6CACWF,EAA2B,aAEjC,IAAKG,OACVA,EAAA,iBAAmB,mBACnBA,EAAA,kBAAoB,oBACpBA,EAAA,iBAAmB,mBACnBA,EAAA,kBAAoB,oBACpBA,EAAA,SAAW,WACXA,EAAA,WAAa,aACbA,EAAA,eAAiB,iBACjBA,EAAA,sBAAwB,wBACxBA,EAAA,qBAAuB,uBACvBA,EAAA,4BAA8B,8BAC9BA,EAAA,YAAc,cACdA,EAAA,MAAQ,QAZEA,OAAA,IAeL,MAAML,EAAgE,CAC3E,OAAQ,mBACR,OAAQ,oBACR,OAAQ,mBACR,OAAQ,oBACR,OAAQ,WACR,OAAQ,aACR,OAAQ,iBACR,OAAQ,wBACR,OAAQ,uBACR,OAAQ,8BACR,OAAQ,cACR,OAAQ,OACV,EAEaG,EAAmD,CAC9D,mBACA,oBACA,mBACA,mBACF",
6
+ "names": ["uniswap_exports", "__export", "UNISWAP_COMMANDS", "UNISWAP_EXECUTE_ABI", "UNISWAP_EXECUTE_SELECTOR", "UNISWAP_SWAP_COMMANDS", "UNISWAP_UNIVERSAL_ROUTER_ADDRESS", "UniswapSupportedCommand", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var M=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var b=(B,E)=>{for(var R in E)M(B,R,{get:E[R],enumerable:!0})},N=(B,E,R,O)=>{if(E&&typeof E=="object"||typeof E=="function")for(let _ of x(E))!L.call(B,_)&&_!==R&&M(B,_,{get:()=>E[_],enumerable:!(O=I(E,_))||O.enumerable});return B};var f=B=>N(M({},"__esModule",{value:!0}),B);var C={};b(C,{WETHSupportedChainIds:()=>D,WETH_ADDRESS_BY_CHAIN_ID:()=>F});module.exports=f(C);var D=(A=>(A[A.ETHEREUM_MAINNET=1]="ETHEREUM_MAINNET",A[A.ETHEREUM_GOERLI=5]="ETHEREUM_GOERLI",A[A.ETHEREUM_SEPOLIA=11155111]="ETHEREUM_SEPOLIA",A[A.ARBITRUM_ONE=42161]="ARBITRUM_ONE",A[A.ARBITRUM_GOERLI=421613]="ARBITRUM_GOERLI",A[A.AVALANCHE_C_CHAIN=43114]="AVALANCHE_C_CHAIN",A[A.BSC=56]="BSC",A[A.BASE=8453]="BASE",A[A.BASE_GOERLI=84531]="BASE_GOERLI",A[A.BLAST=23888]="BLAST",A[A.OPTIMISM=10]="OPTIMISM",A[A.OPTIMISM_GOERLI=420]="OPTIMISM_GOERLI",A[A.POLYGON=137]="POLYGON",A[A.POLYGON_MUMBAI=80001]="POLYGON_MUMBAI",A))(D||{});const F={1:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",5:"0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",11155111:"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14",42161:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",421613:"0xe39Ab88f8A4777030A534146A9Ca3B52bd5D43A3",43114:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",56:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",8453:"0x4200000000000000000000000000000000000006",84531:"0x44D627f900da8AdaC7561bD73aA745F132450798",23888:"0x4300000000000000000000000000000000000004",10:"0x4200000000000000000000000000000000000006",420:"0x4200000000000000000000000000000000000006",137:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",80001:"0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889"};0&&(module.exports={WETHSupportedChainIds,WETH_ADDRESS_BY_CHAIN_ID});
2
+ //# sourceMappingURL=weth.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/uniswap/constants/weth.ts"],
4
+ "sourcesContent": ["import { type HexaString } from \"@ledgerhq/device-management-kit\";\n\nexport enum WETHSupportedChainIds {\n ETHEREUM_MAINNET = 1,\n ETHEREUM_GOERLI = 5,\n ETHEREUM_SEPOLIA = 11155111,\n ARBITRUM_ONE = 42161,\n ARBITRUM_GOERLI = 421613,\n AVALANCHE_C_CHAIN = 43114,\n BSC = 56,\n BASE = 8453,\n BASE_GOERLI = 84531,\n BLAST = 23888,\n OPTIMISM = 10,\n OPTIMISM_GOERLI = 420,\n POLYGON = 137,\n POLYGON_MUMBAI = 80001,\n}\n\nexport type WETHSupportedChainId = keyof typeof WETH_ADDRESS_BY_CHAIN_ID;\n\nexport const WETH_ADDRESS_BY_CHAIN_ID: Record<\n WETHSupportedChainIds,\n HexaString\n> = {\n [WETHSupportedChainIds.ETHEREUM_MAINNET]:\n \"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\",\n [WETHSupportedChainIds.ETHEREUM_GOERLI]:\n \"0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6\",\n [WETHSupportedChainIds.ETHEREUM_SEPOLIA]:\n \"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14\",\n [WETHSupportedChainIds.ARBITRUM_ONE]:\n \"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1\",\n [WETHSupportedChainIds.ARBITRUM_GOERLI]:\n \"0xe39Ab88f8A4777030A534146A9Ca3B52bd5D43A3\",\n [WETHSupportedChainIds.AVALANCHE_C_CHAIN]:\n \"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7\",\n [WETHSupportedChainIds.BSC]: \"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c\",\n [WETHSupportedChainIds.BASE]: \"0x4200000000000000000000000000000000000006\",\n [WETHSupportedChainIds.BASE_GOERLI]:\n \"0x44D627f900da8AdaC7561bD73aA745F132450798\",\n [WETHSupportedChainIds.BLAST]: \"0x4300000000000000000000000000000000000004\",\n [WETHSupportedChainIds.OPTIMISM]:\n \"0x4200000000000000000000000000000000000006\",\n [WETHSupportedChainIds.OPTIMISM_GOERLI]:\n \"0x4200000000000000000000000000000000000006\",\n [WETHSupportedChainIds.POLYGON]: \"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270\",\n [WETHSupportedChainIds.POLYGON_MUMBAI]:\n \"0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889\",\n};\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,2BAAAE,EAAA,6BAAAC,IAAA,eAAAC,EAAAJ,GAEO,IAAKE,OACVA,IAAA,iBAAmB,GAAnB,mBACAA,IAAA,gBAAkB,GAAlB,kBACAA,IAAA,iBAAmB,UAAnB,mBACAA,IAAA,aAAe,OAAf,eACAA,IAAA,gBAAkB,QAAlB,kBACAA,IAAA,kBAAoB,OAApB,oBACAA,IAAA,IAAM,IAAN,MACAA,IAAA,KAAO,MAAP,OACAA,IAAA,YAAc,OAAd,cACAA,IAAA,MAAQ,OAAR,QACAA,IAAA,SAAW,IAAX,WACAA,IAAA,gBAAkB,KAAlB,kBACAA,IAAA,QAAU,KAAV,UACAA,IAAA,eAAiB,OAAjB,iBAdUA,OAAA,IAmBL,MAAMC,EAGT,CACD,EACC,6CACD,EACC,6CACD,SACC,6CACD,MACC,6CACD,OACC,6CACD,MACC,6CACD,GAA4B,6CAC5B,KAA6B,6CAC7B,MACC,6CACD,MAA8B,6CAC9B,GACC,6CACD,IACC,6CACD,IAAgC,6CAChC,MACC,4CACJ",
6
+ "names": ["weth_exports", "__export", "WETHSupportedChainIds", "WETH_ADDRESS_BY_CHAIN_ID", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var n=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var p=(t,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of c(e))!d.call(t,r)&&r!==o&&n(t,r,{get:()=>e[r],enumerable:!(a=i(e,r))||a.enumerable});return t};var g=t=>p(n({},"__esModule",{value:!0}),t);var x={};module.exports=g(x);
2
+ //# sourceMappingURL=AbiDecoderDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/uniswap/data/AbiDecoderDataSource.ts"],
4
+ "sourcesContent": ["import { type HexaString } from \"@ledgerhq/device-management-kit\";\n\nexport interface AbiDecoderDataSource {\n decode(types: string[], data: HexaString): unknown[];\n}\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["AbiDecoderDataSource_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var m=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var i=(o,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of p(e))!d.call(o,r)&&r!==n&&m(o,r,{get:()=>e[r],enumerable:!(a=t(e,r))||a.enumerable});return o};var c=o=>i(m({},"__esModule",{value:!0}),o);var S={};module.exports=c(S);
2
+ //# sourceMappingURL=CommandDecoderDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/uniswap/data/CommandDecoderDataSource.ts"],
4
+ "sourcesContent": ["import { type HexaString } from \"@ledgerhq/device-management-kit\";\n\nimport { type UniswapSupportedCommand } from \"@/uniswap/constants/uniswap\";\n\nexport interface CommandDecoderDataSource {\n decode(\n command: UniswapSupportedCommand,\n input: HexaString,\n chainId: number,\n ): HexaString[];\n}\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["CommandDecoderDataSource_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var d=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var R=(s,r)=>{for(var e in r)d(s,e,{get:r[e],enumerable:!0})},m=(s,r,e,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of g(r))!x.call(s,t)&&t!==e&&d(s,t,{get:()=>r[t],enumerable:!(a=E(r,t))||a.enumerable});return s};var w=s=>m(d({},"__esModule",{value:!0}),s),H=(s,r,e,a)=>{for(var t=a>1?void 0:a?E(r,e):r,S=s.length-1,_;S>=0;S--)(_=s[S])&&(t=(a?_(r,e,t):_(t))||t);return a&&t&&d(r,e,t),t},T=(s,r)=>(e,a)=>r(e,a,s);var b={};R(b,{DefaultCommandDecoderDataSource:()=>o});module.exports=w(b);var n=require("@ledgerhq/device-management-kit"),p=require("inversify"),i=require("../../uniswap/constants/uniswap"),c=require("../../uniswap/constants/weth"),A=require("../../uniswap/di/uniswapTypes");const u=20*2,h=3*2;let o=class{constructor(r){this.abiDecoder=r}decode(r,e,a){switch(r){case i.UniswapSupportedCommand.V2_SWAP_EXACT_IN:return this._decodeSwapV2(e);case i.UniswapSupportedCommand.V2_SWAP_EXACT_OUT:return this._decodeSwapV2(e);case i.UniswapSupportedCommand.V3_SWAP_EXACT_IN:return this._decodeSwapV3(e);case i.UniswapSupportedCommand.V3_SWAP_EXACT_OUT:return this._decodeSwapV3(e);case i.UniswapSupportedCommand.WRAP_ETH:return this._decodeWrappedEth(e,a);case i.UniswapSupportedCommand.UNWRAP_ETH:return this._decodeWrappedEth(e,a);case i.UniswapSupportedCommand.SWEEP:return this._decodeSweep(e);case i.UniswapSupportedCommand.PERMIT2_PERMIT:case i.UniswapSupportedCommand.PERMIT2_TRANSFER_FROM:case i.UniswapSupportedCommand.PERMIT2_PERMIT_BATCH:case i.UniswapSupportedCommand.PERMIT2_TRANSFER_FROM_BATCH:case i.UniswapSupportedCommand.PAY_PORTION:return[];default:return[]}}_decodeSwapV2(r){const[,,,e]=this.abiDecoder.decode(["address","uint256","uint256","address[]","bool"],r);return!Array.isArray(e)||!e.every(n.isHexaString)?[]:e.map(a=>a.toLowerCase())}_decodeSwapV3(r){const[,,,e]=this.abiDecoder.decode(["address","uint256","uint256","bytes","bool"],r);if(typeof e!="string"||!(0,n.isHexaString)(e)||e.length<2+u*2+h)return[];const a=[];for(let t=2;t<e.length;t+=u+h)a.push(e.slice(t,t+u));return a.map(t=>t.toLowerCase()).map(t=>`0x${t}`)}_isSupportedChainId(r){return Object.values(c.WETHSupportedChainIds).includes(r)}_decodeWrappedEth(r,e){return this._isSupportedChainId(e)?[c.WETH_ADDRESS_BY_CHAIN_ID[e].toLowerCase()]:[]}_decodeSweep=r=>{const[e]=this.abiDecoder.decode(["address","address","uint256"],r);return typeof e!="string"||!(0,n.isHexaString)(e)?[]:[e.toLowerCase()]}};o=H([(0,p.injectable)(),T(0,(0,p.inject)(A.uniswapTypes.AbiDecoderDataSource))],o);0&&(module.exports={DefaultCommandDecoderDataSource});
2
+ //# sourceMappingURL=DefaultCommandDecoderDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/uniswap/data/DefaultCommandDecoderDataSource.ts"],
4
+ "sourcesContent": ["import { type HexaString, isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { UniswapSupportedCommand } from \"@/uniswap/constants/uniswap\";\nimport {\n WETH_ADDRESS_BY_CHAIN_ID,\n WETHSupportedChainId,\n WETHSupportedChainIds,\n} from \"@/uniswap/constants/weth\";\nimport { uniswapTypes } from \"@/uniswap/di/uniswapTypes\";\n\nimport { type AbiDecoderDataSource } from \"./AbiDecoderDataSource\";\n\nconst ADDRESS_LENGTH = 20 * 2;\nconst FEE_LENGTH = 3 * 2;\n\n@injectable()\nexport class DefaultCommandDecoderDataSource {\n constructor(\n @inject(uniswapTypes.AbiDecoderDataSource)\n private abiDecoder: AbiDecoderDataSource,\n ) {}\n\n decode(\n command: UniswapSupportedCommand,\n input: HexaString,\n chainId: number,\n ): HexaString[] {\n switch (command) {\n case UniswapSupportedCommand.V2_SWAP_EXACT_IN:\n return this._decodeSwapV2(input);\n case UniswapSupportedCommand.V2_SWAP_EXACT_OUT:\n return this._decodeSwapV2(input);\n case UniswapSupportedCommand.V3_SWAP_EXACT_IN:\n return this._decodeSwapV3(input);\n case UniswapSupportedCommand.V3_SWAP_EXACT_OUT:\n return this._decodeSwapV3(input);\n case UniswapSupportedCommand.WRAP_ETH:\n return this._decodeWrappedEth(input, chainId);\n case UniswapSupportedCommand.UNWRAP_ETH:\n return this._decodeWrappedEth(input, chainId);\n case UniswapSupportedCommand.SWEEP:\n return this._decodeSweep(input);\n case UniswapSupportedCommand.PERMIT2_PERMIT:\n case UniswapSupportedCommand.PERMIT2_TRANSFER_FROM:\n case UniswapSupportedCommand.PERMIT2_PERMIT_BATCH:\n case UniswapSupportedCommand.PERMIT2_TRANSFER_FROM_BATCH:\n case UniswapSupportedCommand.PAY_PORTION:\n return [];\n default:\n return [];\n }\n }\n\n private _decodeSwapV2(input: HexaString): HexaString[] {\n const [, , , addresses] = this.abiDecoder.decode(\n [\"address\", \"uint256\", \"uint256\", \"address[]\", \"bool\"],\n input,\n );\n\n if (!Array.isArray(addresses) || !addresses.every(isHexaString)) {\n return [];\n }\n\n return addresses.map(\n (address: HexaString) => address.toLowerCase() as HexaString,\n );\n }\n\n private _decodeSwapV3(input: HexaString): HexaString[] {\n const [, , , path] = this.abiDecoder.decode(\n [\"address\", \"uint256\", \"uint256\", \"bytes\", \"bool\"],\n input,\n );\n // Path is at least 43 bytes long for 2 times 20B addresses + 3B fee in between\n // Example: 0x -> 20B address -> 3B fee -> 20B address -> 3B fee -> 20B address\n if (\n typeof path !== \"string\" ||\n !isHexaString(path) ||\n path.length < 2 + ADDRESS_LENGTH * 2 + FEE_LENGTH\n ) {\n return [];\n }\n\n // Get all the addresses, skip the 0x prefix\n const tokens: string[] = [];\n for (let i = 2; i < path.length; i += ADDRESS_LENGTH + FEE_LENGTH) {\n tokens.push(path.slice(i, i + ADDRESS_LENGTH));\n }\n\n return tokens\n .map((token) => token.toLowerCase())\n .map((token) => `0x${token}` as HexaString);\n }\n\n private _isSupportedChainId(\n chainId: number,\n ): chainId is WETHSupportedChainId {\n return Object.values(WETHSupportedChainIds).includes(chainId);\n }\n\n private _decodeWrappedEth(_input: HexaString, chainId: number): HexaString[] {\n if (!this._isSupportedChainId(chainId)) {\n return [];\n }\n\n return [WETH_ADDRESS_BY_CHAIN_ID[chainId].toLowerCase() as HexaString];\n }\n\n private _decodeSweep = (input: HexaString): HexaString[] => {\n const [token] = this.abiDecoder.decode(\n [\"address\", \"address\", \"uint256\"],\n input,\n );\n\n if (typeof token !== \"string\" || !isHexaString(token)) {\n return [];\n }\n\n return [token.toLowerCase() as HexaString];\n };\n}\n"],
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AAW,OACnC,CAAC,UAAW,UAAW,UAAW,QAAS,MAAM,EACjDJ,CACF,EAGA,GACE,OAAOI,GAAS,UAChB,IAAC,gBAAaA,CAAI,GAClBA,EAAK,OAAS,EAAIT,EAAiB,EAAIC,EAEvC,MAAO,CAAC,EAIV,MAAMS,EAAmB,CAAC,EAC1B,QAASC,EAAI,EAAGA,EAAIF,EAAK,OAAQE,GAAKX,EAAiBC,EACrDS,EAAO,KAAKD,EAAK,MAAME,EAAGA,EAAIX,CAAc,CAAC,EAG/C,OAAOU,EACJ,IAAKE,GAAUA,EAAM,YAAY,CAAC,EAClC,IAAKA,GAAU,KAAKA,CAAK,EAAgB,CAC9C,CAEQ,oBACNN,EACiC,CACjC,OAAO,OAAO,OAAO,uBAAqB,EAAE,SAASA,CAAO,CAC9D,CAEQ,kBAAkBO,EAAoBP,EAA+B,CAC3E,OAAK,KAAK,oBAAoBA,CAAO,EAI9B,CAAC,2BAAyBA,CAAO,EAAE,YAAY,CAAe,EAH5D,CAAC,CAIZ,CAEQ,aAAgBD,GAAoC,CAC1D,KAAM,CAACO,CAAK,EAAI,KAAK,WAAW,OAC9B,CAAC,UAAW,UAAW,SAAS,EAChCP,CACF,EAEA,OAAI,OAAOO,GAAU,UAAY,IAAC,gBAAaA,CAAK,EAC3C,CAAC,EAGH,CAACA,EAAM,YAAY,CAAe,CAC3C,CACF,EAxGaV,EAANY,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,eAAa,oBAAoB,IAFhCb",
6
+ "names": ["DefaultCommandDecoderDataSource_exports", "__export", "DefaultCommandDecoderDataSource", "__toCommonJS", "import_device_management_kit", "import_inversify", "import_uniswap", "import_weth", "import_uniswapTypes", "ADDRESS_LENGTH", "FEE_LENGTH", "DefaultCommandDecoderDataSource", "abiDecoder", "command", "input", "chainId", "addresses", "address", "path", "tokens", "i", "token", "_input", "__decorateClass", "__decorateParam"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var o=require("../../uniswap/constants/uniswap"),s=require("../../uniswap/constants/weth"),x=require("./DefaultCommandDecoderDataSource"),p=require("./EthersAbiDecoderDataSource");describe("DefaultCommandDecoderDataSource",()=>{const r={decode:vi.fn()};let c;describe("decode with mocked apiDecoder",()=>{beforeEach(()=>{c=new x.DefaultCommandDecoderDataSource(r)}),describe.each([[o.UniswapSupportedCommand.V2_SWAP_EXACT_IN],[o.UniswapSupportedCommand.V2_SWAP_EXACT_OUT]])("%s",a=>{it("should return the correct command data",()=>{const e="0x";vi.spyOn(r,"decode").mockReturnValueOnce(["0x","0x","0x",["0x0102030405060708090a0b0c0d0e0f1011121314"],!1]);const t=c.decode(a,e,1);expect(t).toEqual(["0x0102030405060708090a0b0c0d0e0f1011121314"])}),it("should return the correct command data with multiple addresses",()=>{const e="0x";vi.spyOn(r,"decode").mockReturnValueOnce(["0x","0x","0x",["0x0102030405060708090a0b0c0d0e0f1011121314","0x0102030405060708090a0b0c0d0e0f1011121315"],!1]);const t=c.decode(a,e,1);expect(t).toEqual(["0x0102030405060708090a0b0c0d0e0f1011121314","0x0102030405060708090a0b0c0d0e0f1011121315"])}),it("should return an empty array if an address is not valid",()=>{const e="0x";vi.spyOn(r,"decode").mockReturnValueOnce(["0x","0x","0x",["0x0102030405060708090a0b0c0d0e0f1011121314","invalid"],!1]);const t=c.decode(a,e,1);expect(t).toEqual([])}),it("should return an empty array if the addresses are not an array",()=>{const e="0x";vi.spyOn(r,"decode").mockReturnValueOnce(["0x","0x","0x","invalid",!1]);const t=c.decode(a,e,1);expect(t).toEqual([])}),it("should return an empty array if the addresses are not an array of hexa strings",()=>{const e="0x";vi.spyOn(r,"decode").mockReturnValueOnce(["0x","0x","0x",["invalid"],!1]);const t=c.decode(a,e,1);expect(t).toEqual([])})}),describe.each([[o.UniswapSupportedCommand.V3_SWAP_EXACT_IN],[o.UniswapSupportedCommand.V3_SWAP_EXACT_OUT]])("%s",a=>{it("should return the correct command data",()=>{const e="0x",d=["0102030405060708090a0b0c0d0e0f1011121314","0102030405060708090a0b0c0d0e0f1011121315"].reduce((i,u)=>i.length===0?`0x${u}`:`${i}999999${u}`,"");vi.spyOn(r,"decode").mockReturnValueOnce(["0x","0x","0x",d,!1]);const n=c.decode(a,e,1);expect(n).toEqual(["0x0102030405060708090a0b0c0d0e0f1011121314","0x0102030405060708090a0b0c0d0e0f1011121315"])}),it("should return the correct command data with multiple addresses",()=>{const e="0x",d=["0102030405060708090a0b0c0d0e0f1011121314","0102030405060708090a0b0c0d0e0f1011121315","0102030405060708090a0b0c0d0e0f1011121316","0102030405060708090a0b0c0d0e0f1011121317"].reduce((i,u)=>i.length===0?`0x${u}`:`${i}999999${u}`,"");vi.spyOn(r,"decode").mockReturnValueOnce(["0x","0x","0x",d,!1]);const n=c.decode(a,e,1);expect(n).toEqual(["0x0102030405060708090a0b0c0d0e0f1011121314","0x0102030405060708090a0b0c0d0e0f1011121315","0x0102030405060708090a0b0c0d0e0f1011121316","0x0102030405060708090a0b0c0d0e0f1011121317"])}),it("should return an empty array if the path is not valid",()=>{const e="0x";vi.spyOn(r,"decode").mockReturnValueOnce(["0x","0x","0x","invalid",!1]);const t=c.decode(a,e,1);expect(t).toEqual([])}),it("should return an empty array if the path is not a string",()=>{const e="0x";vi.spyOn(r,"decode").mockReturnValueOnce(["0x","0x","0x",123,!1]);const t=c.decode(a,e,1);expect(t).toEqual([])}),it("should return an empty array if the path is not a hexa string",()=>{const e="0x";vi.spyOn(r,"decode").mockReturnValueOnce(["0x","0x","0x","invalid",!1]);const t=c.decode(a,e,1);expect(t).toEqual([])}),it("should return an empty array if the path is too short",()=>{const e="0x",d=["0102030405060708090a0b0c0d0e0f1011121314","0102030405060708090a0b0c0d0e0f101112131"].reduce((i,u)=>i.length===0?`0x${u}`:`${i}999999${u}`,"");vi.spyOn(r,"decode").mockReturnValueOnce(["0x","0x","0x",d,!1]);const n=c.decode(a,e,1);expect(n).toEqual([])})}),describe.each([o.UniswapSupportedCommand.WRAP_ETH,o.UniswapSupportedCommand.UNWRAP_ETH])("%s",a=>{it.each([s.WETHSupportedChainIds.ARBITRUM_GOERLI,s.WETHSupportedChainIds.ARBITRUM_ONE,s.WETHSupportedChainIds.AVALANCHE_C_CHAIN,s.WETHSupportedChainIds.BASE,s.WETHSupportedChainIds.BASE_GOERLI,s.WETHSupportedChainIds.BLAST,s.WETHSupportedChainIds.BSC,s.WETHSupportedChainIds.ETHEREUM_GOERLI,s.WETHSupportedChainIds.ETHEREUM_MAINNET,s.WETHSupportedChainIds.ETHEREUM_SEPOLIA,s.WETHSupportedChainIds.OPTIMISM,s.WETHSupportedChainIds.OPTIMISM_GOERLI,s.WETHSupportedChainIds.POLYGON,s.WETHSupportedChainIds.POLYGON_MUMBAI])("should return the correct command data for chainId %s",e=>{const d=c.decode(a,"0x",e);expect(d).toEqual([s.WETH_ADDRESS_BY_CHAIN_ID[e].toLowerCase()])}),it("should return an empty array if the chainId is not supported",()=>{const t=c.decode(o.UniswapSupportedCommand.WRAP_ETH,"0x",123);expect(t).toEqual([])})}),describe("SWEEP",()=>{it("should return the correct command data",()=>{const a="0x";vi.spyOn(r,"decode").mockReturnValueOnce(["0x0102030405060708090a0b0c0d0e0f1011121314","0x","0x","0x"]);const e=c.decode(o.UniswapSupportedCommand.SWEEP,a,1);expect(e).toEqual(["0x0102030405060708090a0b0c0d0e0f1011121314"])}),it("should return an empty array if the address is not valid",()=>{const a="0x";vi.spyOn(r,"decode").mockReturnValueOnce(["invalid","0x","0x","0x"]);const e=c.decode(o.UniswapSupportedCommand.SWEEP,a,1);expect(e).toEqual([])}),it("should return an empty array if the address is not a hexa string",()=>{const a="0x";vi.spyOn(r,"decode").mockReturnValueOnce([123,"0x","0x","0x"]);const e=c.decode(o.UniswapSupportedCommand.SWEEP,a,1);expect(e).toEqual([])})}),describe.each([o.UniswapSupportedCommand.PERMIT2_PERMIT,o.UniswapSupportedCommand.PERMIT2_TRANSFER_FROM,o.UniswapSupportedCommand.PERMIT2_PERMIT_BATCH,o.UniswapSupportedCommand.PERMIT2_TRANSFER_FROM_BATCH,o.UniswapSupportedCommand.PAY_PORTION,"invalid"])("%s",a=>{it("should return an empty array",()=>{const t=c.decode(a,"0x",1);expect(t).toEqual([])})})}),describe("decode with real apiDecoder",()=>{beforeEach(()=>{const a=new p.EthersAbiDecoderDataSource;c=new x.DefaultCommandDecoderDataSource(a)}),describe("V3_SWAP_EXACT_IN -> PAY_PORTION -> UNWRAP_ETH",()=>{const a=["0x00","0x06","0x0c"],e=["0x00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000a18f07d736b90be5500000000000000000000000000000000000000000000000000000000b0b8122abd8412900000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bb9f599ce614feb2e1bbe58f180f370d05b39344e002710c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000017cc6042605381c158d2adab487434bde79aa61c000000000000000000000000000000000000000000000000000000000000005b","0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000b0b8122abd84129"];it("V3_SWAP_EXACT_IN",()=>{const t=a[0],d=e[0],n=c.decode(o.UNISWAP_COMMANDS[t],d,1);expect(n).toEqual(["0xb9f599ce614feb2e1bbe58f180f370d05b39344e","0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"])}),it("PAY_PORTION",()=>{const t=a[1],d=e[1],n=c.decode(o.UNISWAP_COMMANDS[t],d,1);expect(n).toEqual([])}),it("UNWRAP_ETH",()=>{const t=a[2],d=e[2],n=c.decode(o.UNISWAP_COMMANDS[t],d,1);expect(n).toEqual(["0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"])})}),describe("WRAP_ETH -> V3_SWAP_EXACT_OUT -> TRANSFERT -> SWEEP -> UNWRAP_ETH",()=>{const a=["0x0b","0x01","0x05","0x04","0x0c"],e=["0x0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000078e6708e70aed0f","0x00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000059a16770000000000000000000000000000000000000000000000000078e6708e70aed0f00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f4c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000027213e28d7fda5c57fe9e5dd923818dbccf71c470000000000000000000000000000000000000000000000000000000000393870","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006f939b43d65be049b7533907db08e80ba6969f450000000000000000000000000000000000000000000000000000000059682f00","0x0000000000000000000000006f939b43d65be049b7533907db08e80ba6969f450000000000000000000000000000000000000000000000000000000000000000"];it("WRAP_ETH",()=>{const t=a[0],d=e[0],n=c.decode(o.UNISWAP_COMMANDS[t],d,1);expect(n).toEqual(["0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"])}),it("V3_SWAP_EXACT_OUT",()=>{const t=a[1],d=e[1],n=c.decode(o.UNISWAP_COMMANDS[t],d,1);expect(n).toEqual(["0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"])}),it("TRANSFERT",()=>{const t=a[2],d=e[2],n=c.decode(o.UNISWAP_COMMANDS[t],d,1);expect(n).toEqual([])}),it("SWEEP",()=>{const t=a[3],d=e[3],n=c.decode(o.UNISWAP_COMMANDS[t],d,1);expect(n).toEqual(["0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"])}),it("UNWRAP_ETH",()=>{const t=a[4],d=e[4],n=c.decode(o.UNISWAP_COMMANDS[t],d,1);expect(n).toEqual(["0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"])})}),describe("V2_SWAP_EXACT_IN -> PAY_PORTION -> UNWRAP_ETH",()=>{const a=["0x08","0x06","0x0c"],e=["0x0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000003ebb8addda849d38caed0000000000000000000000000000000000000000000000000f238e04a7ccbf5100000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000003b991130eae3cca364406d718da22fa1c3e7c256000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c0000000000000000000000000000000000000000000000000000000000000019","0x00000000000000000000000002573c689ddedddd450e6c947f5bb67de70e80b50000000000000000000000000000000000000000000000000f19dda9c38a50c1"];it("V2_SWAP_EXACT_IN",()=>{const t=a[0],d=e[0],n=c.decode(o.UNISWAP_COMMANDS[t],d,1);expect(n).toEqual(["0x3b991130eae3cca364406d718da22fa1c3e7c256","0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"])}),it("PAY_PORTION",()=>{const t=a[1],d=e[1],n=c.decode(o.UNISWAP_COMMANDS[t],d,1);expect(n).toEqual([])}),it("UNWRAP_ETH",()=>{const t=a[2],d=e[2],n=c.decode(o.UNISWAP_COMMANDS[t],d,1);expect(n).toEqual(["0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"])})})})});
2
+ //# sourceMappingURL=DefaultCommandDecoderDataSource.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/uniswap/data/DefaultCommandDecoderDataSource.test.ts"],
4
+ "sourcesContent": ["import { type HexaString } from \"@ledgerhq/device-management-kit\";\n\nimport {\n UNISWAP_COMMANDS,\n UniswapSupportedCommand,\n} from \"@/uniswap/constants/uniswap\";\nimport {\n WETH_ADDRESS_BY_CHAIN_ID,\n WETHSupportedChainIds,\n} from \"@/uniswap/constants/weth\";\n\nimport { type AbiDecoderDataSource } from \"./AbiDecoderDataSource\";\nimport { DefaultCommandDecoderDataSource } from \"./DefaultCommandDecoderDataSource\";\nimport { EthersAbiDecoderDataSource } from \"./EthersAbiDecoderDataSource\";\n\ndescribe(\"DefaultCommandDecoderDataSource\", () => {\n const apiDecoderMock: AbiDecoderDataSource = {\n decode: vi.fn(),\n };\n let dataSource: DefaultCommandDecoderDataSource;\n\n describe(\"decode with mocked apiDecoder\", () => {\n beforeEach(() => {\n dataSource = new DefaultCommandDecoderDataSource(apiDecoderMock);\n });\n\n describe.each([\n [UniswapSupportedCommand.V2_SWAP_EXACT_IN],\n [UniswapSupportedCommand.V2_SWAP_EXACT_OUT],\n ])(\"%s\", (command) => {\n it(\"should return the correct command data\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x\",\n \"0x\",\n \"0x\",\n [\"0x0102030405060708090a0b0c0d0e0f1011121314\"],\n false,\n ]);\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([\"0x0102030405060708090a0b0c0d0e0f1011121314\"]);\n });\n\n it(\"should return the correct command data with multiple addresses\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x\",\n \"0x\",\n \"0x\",\n [\n \"0x0102030405060708090a0b0c0d0e0f1011121314\",\n \"0x0102030405060708090a0b0c0d0e0f1011121315\",\n ],\n false,\n ]);\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([\n \"0x0102030405060708090a0b0c0d0e0f1011121314\",\n \"0x0102030405060708090a0b0c0d0e0f1011121315\",\n ]);\n });\n\n it(\"should return an empty array if an address is not valid\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x\",\n \"0x\",\n \"0x\",\n [\"0x0102030405060708090a0b0c0d0e0f1011121314\", \"invalid\"],\n false,\n ]);\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the addresses are not an array\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x\",\n \"0x\",\n \"0x\",\n \"invalid\",\n false,\n ]);\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the addresses are not an array of hexa strings\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x\",\n \"0x\",\n \"0x\",\n [\"invalid\"],\n false,\n ]);\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([]);\n });\n });\n describe.each([\n [UniswapSupportedCommand.V3_SWAP_EXACT_IN],\n [UniswapSupportedCommand.V3_SWAP_EXACT_OUT],\n ])(\"%s\", (command) => {\n it(\"should return the correct command data\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n const addresses = [\n \"0102030405060708090a0b0c0d0e0f1011121314\",\n \"0102030405060708090a0b0c0d0e0f1011121315\",\n ];\n const path = addresses.reduce(\n (acc, address) =>\n acc.length === 0 ? `0x${address}` : `${acc}999999${address}`,\n \"\",\n );\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x\",\n \"0x\",\n \"0x\",\n path,\n false,\n ]);\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([\n \"0x0102030405060708090a0b0c0d0e0f1011121314\",\n \"0x0102030405060708090a0b0c0d0e0f1011121315\",\n ]);\n });\n\n it(\"should return the correct command data with multiple addresses\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n const addresses = [\n \"0102030405060708090a0b0c0d0e0f1011121314\",\n \"0102030405060708090a0b0c0d0e0f1011121315\",\n \"0102030405060708090a0b0c0d0e0f1011121316\",\n \"0102030405060708090a0b0c0d0e0f1011121317\",\n ];\n const path = addresses.reduce(\n (acc, address) =>\n acc.length === 0 ? `0x${address}` : `${acc}999999${address}`,\n \"\",\n );\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x\",\n \"0x\",\n \"0x\",\n path,\n false,\n ]);\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([\n \"0x0102030405060708090a0b0c0d0e0f1011121314\",\n \"0x0102030405060708090a0b0c0d0e0f1011121315\",\n \"0x0102030405060708090a0b0c0d0e0f1011121316\",\n \"0x0102030405060708090a0b0c0d0e0f1011121317\",\n ]);\n });\n\n it(\"should return an empty array if the path is not valid\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x\",\n \"0x\",\n \"0x\",\n \"invalid\",\n false,\n ]);\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the path is not a string\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x\",\n \"0x\",\n \"0x\",\n 123,\n false,\n ]);\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the path is not a hexa string\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x\",\n \"0x\",\n \"0x\",\n \"invalid\",\n false,\n ]);\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the path is too short\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n\n const addresses = [\n \"0102030405060708090a0b0c0d0e0f1011121314\",\n \"0102030405060708090a0b0c0d0e0f101112131\", // 1 char missing\n ];\n const path = addresses.reduce(\n (acc, address) =>\n acc.length === 0 ? `0x${address}` : `${acc}999999${address}`,\n \"\",\n );\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x\",\n \"0x\",\n \"0x\",\n path,\n false,\n ]);\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([]);\n });\n });\n\n describe.each([\n UniswapSupportedCommand.WRAP_ETH,\n UniswapSupportedCommand.UNWRAP_ETH,\n ])(\"%s\", (command) => {\n it.each([\n WETHSupportedChainIds.ARBITRUM_GOERLI,\n WETHSupportedChainIds.ARBITRUM_ONE,\n WETHSupportedChainIds.AVALANCHE_C_CHAIN,\n WETHSupportedChainIds.BASE,\n WETHSupportedChainIds.BASE_GOERLI,\n WETHSupportedChainIds.BLAST,\n WETHSupportedChainIds.BSC,\n WETHSupportedChainIds.ETHEREUM_GOERLI,\n WETHSupportedChainIds.ETHEREUM_MAINNET,\n WETHSupportedChainIds.ETHEREUM_SEPOLIA,\n WETHSupportedChainIds.OPTIMISM,\n WETHSupportedChainIds.OPTIMISM_GOERLI,\n WETHSupportedChainIds.POLYGON,\n WETHSupportedChainIds.POLYGON_MUMBAI,\n ])(\"should return the correct command data for chainId %s\", (chainId) => {\n // GIVEN\n const input: HexaString = \"0x\";\n\n // WHEN\n const result = dataSource.decode(command, input, chainId);\n\n // THEN\n expect(result).toEqual([\n WETH_ADDRESS_BY_CHAIN_ID[chainId].toLowerCase(),\n ]);\n });\n\n it(\"should return an empty array if the chainId is not supported\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n\n // WHEN\n const result = dataSource.decode(\n UniswapSupportedCommand.WRAP_ETH,\n input,\n 123,\n );\n\n // THEN\n expect(result).toEqual([]);\n });\n });\n\n describe(\"SWEEP\", () => {\n it(\"should return the correct command data\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x0102030405060708090a0b0c0d0e0f1011121314\",\n \"0x\",\n \"0x\",\n \"0x\",\n ]);\n\n // WHEN\n const result = dataSource.decode(\n UniswapSupportedCommand.SWEEP,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([\"0x0102030405060708090a0b0c0d0e0f1011121314\"]);\n });\n\n it(\"should return an empty array if the address is not valid\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"invalid\",\n \"0x\",\n \"0x\",\n \"0x\",\n ]);\n\n // WHEN\n const result = dataSource.decode(\n UniswapSupportedCommand.SWEEP,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the address is not a hexa string\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n 123,\n \"0x\",\n \"0x\",\n \"0x\",\n ]);\n\n // WHEN\n const result = dataSource.decode(\n UniswapSupportedCommand.SWEEP,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([]);\n });\n });\n\n describe.each([\n UniswapSupportedCommand.PERMIT2_PERMIT,\n UniswapSupportedCommand.PERMIT2_TRANSFER_FROM,\n UniswapSupportedCommand.PERMIT2_PERMIT_BATCH,\n UniswapSupportedCommand.PERMIT2_TRANSFER_FROM_BATCH,\n UniswapSupportedCommand.PAY_PORTION,\n \"invalid\" as UniswapSupportedCommand,\n ])(\"%s\", (command) => {\n it(\"should return an empty array\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([]);\n });\n });\n });\n\n describe(\"decode with real apiDecoder\", () => {\n beforeEach(() => {\n const abiDecoder = new EthersAbiDecoderDataSource();\n dataSource = new DefaultCommandDecoderDataSource(abiDecoder);\n });\n\n describe(\"V3_SWAP_EXACT_IN -> PAY_PORTION -> UNWRAP_ETH\", () => {\n // https://etherscan.io/tx/0xc9821c32c1782d9ab6baf6f9ca4b2565bce11aaf5146a2d303215bda026f5e48\n const commands: HexaString[] = [\"0x00\", \"0x06\", \"0x0c\"];\n const inputs: HexaString[] = [\n \"0x00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000a18f07d736b90be5500000000000000000000000000000000000000000000000000000000b0b8122abd8412900000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bb9f599ce614feb2e1bbe58f180f370d05b39344e002710c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000\",\n \"0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000017cc6042605381c158d2adab487434bde79aa61c000000000000000000000000000000000000000000000000000000000000005b\",\n \"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000b0b8122abd84129\",\n ];\n\n it(\"V3_SWAP_EXACT_IN\", () => {\n // GIVEN\n const command = commands[0]!;\n const input = inputs[0]!;\n\n // WHEN\n const result = dataSource.decode(\n UNISWAP_COMMANDS[command] as UniswapSupportedCommand,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([\n \"0xb9f599ce614feb2e1bbe58f180f370d05b39344e\", // ERC20\n \"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\", // WETH\n ]);\n });\n\n it(\"PAY_PORTION\", () => {\n // GIVEN\n const command = commands[1]!;\n const input = inputs[1]!;\n\n // WHEN\n const result = dataSource.decode(\n UNISWAP_COMMANDS[command] as UniswapSupportedCommand,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"UNWRAP_ETH\", () => {\n // GIVEN\n const command = commands[2]!;\n const input = inputs[2]!;\n\n // WHEN\n const result = dataSource.decode(\n UNISWAP_COMMANDS[command] as UniswapSupportedCommand,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([\"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\"]); // WETH\n });\n });\n\n describe(\"WRAP_ETH -> V3_SWAP_EXACT_OUT -> TRANSFERT -> SWEEP -> UNWRAP_ETH\", () => {\n // https://etherscan.io/tx/0xa628c8b3da2ad984aed0354d8ca4b4c3c42941491dc4e0d6a5f423fd65e6c90a\n const commands: HexaString[] = [\"0x0b\", \"0x01\", \"0x05\", \"0x04\", \"0x0c\"];\n const inputs: HexaString[] = [\n \"0x0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000078e6708e70aed0f\",\n \"0x00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000059a16770000000000000000000000000000000000000000000000000078e6708e70aed0f00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f4c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000\",\n \"0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000027213e28d7fda5c57fe9e5dd923818dbccf71c470000000000000000000000000000000000000000000000000000000000393870\",\n \"0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006f939b43d65be049b7533907db08e80ba6969f450000000000000000000000000000000000000000000000000000000059682f00\",\n \"0x0000000000000000000000006f939b43d65be049b7533907db08e80ba6969f450000000000000000000000000000000000000000000000000000000000000000\",\n ];\n\n it(\"WRAP_ETH\", () => {\n // GIVEN\n const command = commands[0]!;\n const input = inputs[0]!;\n\n // WHEN\n const result = dataSource.decode(\n UNISWAP_COMMANDS[command] as UniswapSupportedCommand,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([\"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\"]); // WETH\n });\n\n it(\"V3_SWAP_EXACT_OUT\", () => {\n // GIVEN\n const command = commands[1]!;\n const input = inputs[1]!;\n\n // WHEN\n const result = dataSource.decode(\n UNISWAP_COMMANDS[command] as UniswapSupportedCommand,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([\n \"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48\", // USDC\n \"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\", // WETH\n ]);\n });\n\n it(\"TRANSFERT\", () => {\n // GIVEN\n const command = commands[2]!;\n const input = inputs[2]!;\n\n // WHEN\n const result = dataSource.decode(\n UNISWAP_COMMANDS[command] as UniswapSupportedCommand,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"SWEEP\", () => {\n // GIVEN\n const command = commands[3]!;\n const input = inputs[3]!;\n\n // WHEN\n const result = dataSource.decode(\n UNISWAP_COMMANDS[command] as UniswapSupportedCommand,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([\"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48\"]); // USDC\n });\n\n it(\"UNWRAP_ETH\", () => {\n // GIVEN\n const command = commands[4]!;\n const input = inputs[4]!;\n\n // WHEN\n const result = dataSource.decode(\n UNISWAP_COMMANDS[command] as UniswapSupportedCommand,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([\"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\"]); // WETH\n });\n });\n\n describe(\"V2_SWAP_EXACT_IN -> PAY_PORTION -> UNWRAP_ETH\", () => {\n // https://etherscan.io/tx/0x78bc5732213e09d9ead8cabc269b7c426b0301dfe543c37d0a920e25eaa9447f\n const commands: HexaString[] = [\"0x08\", \"0x06\", \"0x0c\"];\n const inputs: HexaString[] = [\n \"0x0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000003ebb8addda849d38caed0000000000000000000000000000000000000000000000000f238e04a7ccbf5100000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000003b991130eae3cca364406d718da22fa1c3e7c256000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\",\n \"0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c0000000000000000000000000000000000000000000000000000000000000019\",\n \"0x00000000000000000000000002573c689ddedddd450e6c947f5bb67de70e80b50000000000000000000000000000000000000000000000000f19dda9c38a50c1\",\n ];\n\n it(\"V2_SWAP_EXACT_IN\", () => {\n // GIVEN\n const command = commands[0]!;\n const input = inputs[0]!;\n\n // WHEN\n const result = dataSource.decode(\n UNISWAP_COMMANDS[command] as UniswapSupportedCommand,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([\n \"0x3b991130eae3cca364406d718da22fa1c3e7c256\", // ERC20\n \"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\", // WETH\n ]);\n });\n\n it(\"PAY_PORTION\", () => {\n // GIVEN\n const command = commands[1]!;\n const input = inputs[1]!;\n\n // WHEN\n const result = dataSource.decode(\n UNISWAP_COMMANDS[command] as UniswapSupportedCommand,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"UNWRAP_ETH\", () => {\n // GIVEN\n const command = commands[2]!;\n const input = inputs[2]!;\n\n // WHEN\n const result = dataSource.decode(\n UNISWAP_COMMANDS[command] as UniswapSupportedCommand,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([\"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\"]); // WETH\n });\n });\n });\n});\n"],
5
+ "mappings": "aAEA,IAAAA,EAGO,uCACPC,EAGO,oCAGPC,EAAgD,6CAChDC,EAA2C,wCAE3C,SAAS,kCAAmC,IAAM,CAChD,MAAMC,EAAuC,CAC3C,OAAQ,GAAG,GAAG,CAChB,EACA,IAAIC,EAEJ,SAAS,gCAAiC,IAAM,CAC9C,WAAW,IAAM,CACfA,EAAa,IAAI,kCAAgCD,CAAc,CACjE,CAAC,E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AC,EAGhBP,EAASH,EAAW,OACxB,mBAAiBC,CAAO,EACxBC,EACA,CACF,EAGA,OAAOC,CAAM,EAAE,QAAQ,CACrB,6CACA,4CACF,CAAC,CACH,CAAC,EAED,GAAG,cAAe,IAAM,CAEtB,MAAMF,EAAUQ,EAAS,CAAC,EACpBP,EAAQQ,EAAO,CAAC,EAGhBP,EAASH,EAAW,OACxB,mBAAiBC,CAAO,EACxBC,EACA,CACF,EAGA,OAAOC,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,EAED,GAAG,aAAc,IAAM,CAErB,MAAMF,EAAUQ,EAAS,CAAC,EACpBP,EAAQQ,EAAO,CAAC,EAGhBP,EAASH,EAAW,OACxB,mBAAiBC,CAAO,EACxBC,EACA,CACF,EAGA,OAAOC,CAAM,EAAE,QAAQ,CAAC,4CAA4C,CAAC,CACvE,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_uniswap", "import_weth", "import_DefaultCommandDecoderDataSource", "import_EthersAbiDecoderDataSource", "apiDecoderMock", "dataSource", "command", "input", "result", "path", "acc", "address", "chainId", "abiDecoder", "commands", "inputs"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var m=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var g=(t,r)=>{for(var e in r)m(t,e,{get:r[e],enumerable:!0})},s=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of a(r))!b.call(t,o)&&o!==e&&m(t,o,{get:()=>r[o],enumerable:!(n=c(r,o))||n.enumerable});return t};var y=t=>s(m({},"__esModule",{value:!0}),t),f=(t,r,e,n)=>{for(var o=n>1?void 0:n?c(r,e):r,d=t.length-1,p;d>=0;d--)(p=t[d])&&(o=(n?p(r,e,o):p(o))||o);return n&&o&&m(r,e,o),o};var C={};g(C,{EthersAbiDecoderDataSource:()=>i});module.exports=y(C);var l=require("ethers"),u=require("inversify");let i=class{decode(r,e){try{return l.AbiCoder.defaultAbiCoder().decode(r,e)}catch{return[]}}};i=f([(0,u.injectable)()],i);0&&(module.exports={EthersAbiDecoderDataSource});
2
+ //# sourceMappingURL=EthersAbiDecoderDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/uniswap/data/EthersAbiDecoderDataSource.ts"],
4
+ "sourcesContent": ["import { AbiCoder } from \"ethers\";\nimport { injectable } from \"inversify\";\n\nimport { type AbiDecoderDataSource } from \"./AbiDecoderDataSource\";\n\n@injectable()\nexport class EthersAbiDecoderDataSource implements AbiDecoderDataSource {\n decode(types: string[], data: string): unknown[] {\n try {\n return AbiCoder.defaultAbiCoder().decode(types, data);\n } catch (_) {\n return [];\n }\n }\n}\n"],
5
+ "mappings": "2iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAyB,kBACzBC,EAA2B,qBAKpB,IAAMC,EAAN,KAAiE,CACtE,OAAOC,EAAiBC,EAAyB,CAC/C,GAAI,CACF,OAAO,WAAS,gBAAgB,EAAE,OAAOD,EAAOC,CAAI,CACtD,MAAY,CACV,MAAO,CAAC,CACV,CACF,CACF,EARaF,EAANG,EAAA,IADN,cAAW,GACCH",
6
+ "names": ["EthersAbiDecoderDataSource_exports", "__export", "EthersAbiDecoderDataSource", "__toCommonJS", "import_ethers", "import_inversify", "EthersAbiDecoderDataSource", "types", "data", "__decorateClass"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var a=require("./EthersAbiDecoderDataSource");describe("EthersAbiDecoderDataSource",()=>{let t;beforeEach(()=>{t=new a.EthersAbiDecoderDataSource}),it("should correctly decode valid ABI data",()=>{const c=["uint256","address"],e=t.decode(c,"0x000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000027213e28d7fda5c57fe9e5dd923818dbccf71c47");expect(e[0]).toEqual(10n),expect(e[1]).toEqual("0x27213E28D7fDA5c57Fe9e5dD923818DBCcf71c47")}),it("should return an empty array on decode failure",()=>{const c=["uint256"],e=t.decode(c,"0x1234");expect(e).toEqual([])})});
2
+ //# sourceMappingURL=EthersAbiDecoderDataSource.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/uniswap/data/EthersAbiDecoderDataSource.test.ts"],
4
+ "sourcesContent": ["import { EthersAbiDecoderDataSource } from \"./EthersAbiDecoderDataSource\";\n\ndescribe(\"EthersAbiDecoderDataSource\", () => {\n let decoder: EthersAbiDecoderDataSource;\n\n beforeEach(() => {\n decoder = new EthersAbiDecoderDataSource();\n });\n\n it(\"should correctly decode valid ABI data\", () => {\n const types = [\"uint256\", \"address\"];\n const data =\n \"0x\" +\n \"000000000000000000000000000000000000000000000000000000000000000a\" + // 10 as uint256\n \"00000000000000000000000027213e28d7fda5c57fe9e5dd923818dbccf71c47\"; // Address\n\n const result = decoder.decode(types, data);\n expect(result[0]).toEqual(10n);\n expect(result[1]).toEqual(\"0x27213E28D7fDA5c57Fe9e5dD923818DBCcf71c47\");\n });\n\n it(\"should return an empty array on decode failure\", () => {\n const types = [\"uint256\"];\n const invalidData = \"0x1234\"; // Invalid encoded data\n\n const result = decoder.decode(types, invalidData);\n expect(result).toEqual([]);\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAA2C,wCAE3C,SAAS,6BAA8B,IAAM,CAC3C,IAAIC,EAEJ,WAAW,IAAM,CACfA,EAAU,IAAI,4BAChB,CAAC,EAED,GAAG,yCAA0C,IAAM,CACjD,MAAMC,EAAQ,CAAC,UAAW,SAAS,EAM7BC,EAASF,EAAQ,OAAOC,EAJ5B,oIAIuC,EACzC,OAAOC,EAAO,CAAC,CAAC,EAAE,QAAQ,GAAG,EAC7B,OAAOA,EAAO,CAAC,CAAC,EAAE,QAAQ,4CAA4C,CACxE,CAAC,EAED,GAAG,iDAAkD,IAAM,CACzD,MAAMD,EAAQ,CAAC,SAAS,EAGlBC,EAASF,EAAQ,OAAOC,EAFV,QAE4B,EAChD,OAAOC,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,CACH,CAAC",
6
+ "names": ["import_EthersAbiDecoderDataSource", "decoder", "types", "result"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var n=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var f=(o,e)=>{for(var r in e)n(o,r,{get:e[r],enumerable:!0})},w=(o,e,r,m)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of D(e))!s.call(o,t)&&t!==r&&n(o,t,{get:()=>e[t],enumerable:!(m=c(e,t))||m.enumerable});return o};var C=o=>w(n({},"__esModule",{value:!0}),o);var l={};f(l,{uniswapModuleFactory:()=>S});module.exports=C(l);var i=require("inversify"),d=require("../../uniswap/data/DefaultCommandDecoderDataSource"),p=require("../../uniswap/data/EthersAbiDecoderDataSource"),u=require("../../uniswap/domain/UniswapContextLoader"),a=require("./uniswapTypes");const S=()=>new i.ContainerModule((o,e,r,m)=>{o(a.uniswapTypes.AbiDecoderDataSource).to(p.EthersAbiDecoderDataSource),o(a.uniswapTypes.CommandDecoderDataSource).to(d.DefaultCommandDecoderDataSource),o(a.uniswapTypes.UniswapContextLoader).to(u.UniswapContextLoader)});0&&(module.exports={uniswapModuleFactory});
2
+ //# sourceMappingURL=uniswapModuleFactory.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,qBAEhCC,EAAgD,0DAChDC,EAA2C,qDAC3CC,EAAqC,iDAErCC,EAA6B,0BAEtB,MAAMN,EAAuB,IAClC,IAAI,kBAAgB,CAACO,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAAK,eAAa,oBAAoB,EAAE,GAAG,4BAA0B,EACrEA,EAAK,eAAa,wBAAwB,EAAE,GAC1C,iCACF,EACAA,EAAK,eAAa,oBAAoB,EAAE,GAAG,sBAAoB,CACjE,CAAC",
6
+ "names": ["uniswapModuleFactory_exports", "__export", "uniswapModuleFactory", "__toCommonJS", "import_inversify", "import_DefaultCommandDecoderDataSource", "import_EthersAbiDecoderDataSource", "import_UniswapContextLoader", "import_uniswapTypes", "bind", "_unbind", "_isBound", "_rebind"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var t=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var m=(e,o)=>{for(var r in o)t(e,r,{get:o[r],enumerable:!0})},S=(e,o,r,c)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of n(o))!D.call(e,a)&&a!==r&&t(e,a,{get:()=>o[a],enumerable:!(c=d(o,a))||c.enumerable});return e};var b=e=>S(t({},"__esModule",{value:!0}),e);var p={};m(p,{uniswapTypes:()=>i});module.exports=b(p);const i={AbiDecoderDataSource:Symbol.for("AbiDecoderDataSource"),CommandDecoderDataSource:Symbol.for("CommandDecoderDataSource"),UniswapContextLoader:Symbol.for("UniswapContextLoader")};0&&(module.exports={uniswapTypes});
2
+ //# sourceMappingURL=uniswapTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/uniswap/di/uniswapTypes.ts"],
4
+ "sourcesContent": ["export const uniswapTypes = {\n AbiDecoderDataSource: Symbol.for(\"AbiDecoderDataSource\"),\n CommandDecoderDataSource: Symbol.for(\"CommandDecoderDataSource\"),\n UniswapContextLoader: Symbol.for(\"UniswapContextLoader\"),\n};\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAe,CAC1B,qBAAsB,OAAO,IAAI,sBAAsB,EACvD,yBAA0B,OAAO,IAAI,0BAA0B,EAC/D,qBAAsB,OAAO,IAAI,sBAAsB,CACzD",
6
+ "names": ["uniswapTypes_exports", "__export", "uniswapTypes", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var l=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var k=(n,e)=>{for(var t in e)l(n,t,{get:e[t],enumerable:!0})},H=(n,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of I(e))!w.call(n,r)&&r!==t&&l(n,r,{get:()=>e[r],enumerable:!(a=D(e,r))||a.enumerable});return n};var b=n=>H(l({},"__esModule",{value:!0}),n),_=(n,e,t,a)=>{for(var r=a>1?void 0:a?D(e,t):e,i=n.length-1,d;i>=0;i--)(d=n[i])&&(r=(a?d(e,t,r):d(r))||r);return a&&r&&l(e,t,r),r},C=(n,e)=>(t,a)=>e(t,a,n);var R={};k(R,{UniswapContextLoader:()=>p});module.exports=b(R);var o=require("@ledgerhq/device-management-kit"),A=require("ethers"),c=require("inversify"),S=require("purify-ts"),g=require("../../shared/model/ClearSignContext"),T=require("../../token/di/tokenTypes"),f=require("../../uniswap/constants/plugin"),s=require("../../uniswap/constants/uniswap"),h=require("../../uniswap/di/uniswapTypes");let p=class{constructor(e,t){this.commandDecoderDataSource=e;this.tokenDataSource=t}async load(e){if(!e.data||!(0,o.isHexaString)(e.data))return[];if(e.data.slice(0,10)!==s.UNISWAP_EXECUTE_SELECTOR)return[];const a=this._buildUniswapPluginCommandData(),r=await this._extractClearSignContexts(e.data,e.chainId);return r.length>0?[a,...r]:[]}_buildUniswapPluginCommandData(){const e=new o.ByteArrayBuilder().add8BitUIntToData(f.UNISWAP_PLUGIN_NAME.length).addAsciiStringToData(f.UNISWAP_PLUGIN_NAME).addBufferToData((0,o.hexaStringToBuffer)(s.UNISWAP_UNIVERSAL_ROUTER_ADDRESS)).addBufferToData((0,o.hexaStringToBuffer)(s.UNISWAP_EXECUTE_SELECTOR)).addBufferToData((0,o.hexaStringToBuffer)(f.UNISWAP_PLUGIN_SIGNATURE)).build();return{type:g.ClearSignContextType.EXTERNAL_PLUGIN,payload:(0,o.bufferToHexaString)(e).slice(2)}}async _extractClearSignContexts(e,t){try{const r=new A.Interface(s.UNISWAP_EXECUTE_ABI).parseTransaction({data:e}),i=r?.args[0],d=r?.args[1];if(!(0,o.isHexaString)(i)||!this._isHexaStringArray(d))return[];const x=this._extractCommands(i).orDefault([]);if(i.length===0||d.length!==x.length)return[];const y=x.reduce((m,u,U)=>{const N=d[U],E=this.commandDecoderDataSource.decode(u,N,t);return m.push([u,E]),m},[]);if(!this._isChainingSwapSupported(y))return[];const P=[...new Set(y.flatMap(([,m])=>m))];return(await Promise.all(P.map(m=>this.tokenDataSource.getTokenInfosPayload({address:m,chainId:t})))).map(m=>m.caseOf({Left:u=>({type:g.ClearSignContextType.ERROR,error:u}),Right:u=>({type:g.ClearSignContextType.TOKEN,payload:u})}))}catch{return[]}}_extractCommands(e){return S.Maybe.fromNullable(e.slice(2).match(/../g)).map(t=>t.map(a=>`0x${a}`)).map(t=>t.map(a=>s.UNISWAP_COMMANDS[a])).chain(t=>t.every(a=>a!==void 0)?S.Maybe.of(t):S.Nothing)}_isChainingSwapSupported(e){let t,a;for(const[r,i]of e){if(!s.UNISWAP_SWAP_COMMANDS.includes(r))continue;const d=r.slice(0,2);if(t&&(t!==i[0]||a!==d))return!1;t=i[i.length-1],a=d}return!0}_isHexaStringArray(e){return Array.isArray(e)&&e.every(t=>typeof t=="string"&&(0,o.isHexaString)(t))}};p=_([(0,c.injectable)(),C(0,(0,c.inject)(h.uniswapTypes.CommandDecoderDataSource)),C(1,(0,c.inject)(T.tokenTypes.TokenDataSource))],p);0&&(module.exports={UniswapContextLoader});
2
+ //# sourceMappingURL=UniswapContextLoader.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/uniswap/domain/UniswapContextLoader.ts"],
4
+ "sourcesContent": ["import {\n bufferToHexaString,\n ByteArrayBuilder,\n HexaString,\n hexaStringToBuffer,\n isHexaString,\n} from \"@ledgerhq/device-management-kit\";\nimport { Interface } from \"ethers\";\nimport { inject, injectable } from \"inversify\";\nimport { Maybe, Nothing } from \"purify-ts\";\n\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { TransactionContext } from \"@/shared/model/TransactionContext\";\nimport { type TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\nimport {\n UNISWAP_PLUGIN_NAME,\n UNISWAP_PLUGIN_SIGNATURE,\n} from \"@/uniswap/constants/plugin\";\nimport {\n UNISWAP_COMMANDS,\n UNISWAP_EXECUTE_ABI,\n UNISWAP_EXECUTE_SELECTOR,\n UNISWAP_SWAP_COMMANDS,\n UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n UniswapSupportedCommand,\n} from \"@/uniswap/constants/uniswap\";\nimport { type CommandDecoderDataSource } from \"@/uniswap/data/CommandDecoderDataSource\";\nimport { uniswapTypes } from \"@/uniswap/di/uniswapTypes\";\n\n@injectable()\nexport class UniswapContextLoader implements ContextLoader {\n constructor(\n @inject(uniswapTypes.CommandDecoderDataSource)\n private commandDecoderDataSource: CommandDecoderDataSource,\n @inject(tokenTypes.TokenDataSource)\n private tokenDataSource: TokenDataSource,\n ) {}\n\n async load(transaction: TransactionContext): Promise<ClearSignContext[]> {\n if (!transaction.data || !isHexaString(transaction.data)) {\n return [];\n }\n\n const selector = transaction.data.slice(0, 10);\n if (selector !== UNISWAP_EXECUTE_SELECTOR) {\n return [];\n }\n\n const externalPluginContext = this._buildUniswapPluginCommandData();\n const tokenContexts = await this._extractClearSignContexts(\n transaction.data,\n transaction.chainId,\n );\n\n if (tokenContexts.length > 0)\n return [externalPluginContext, ...tokenContexts];\n\n return [];\n }\n\n /**\n * Constructs the external plugin context for Uniswap external plugin command.\n *\n * @private\n * @returns {ClearSignContext} - The generated external plugin context.\n */\n private _buildUniswapPluginCommandData(): ClearSignContext {\n const buffer = new ByteArrayBuilder()\n .add8BitUIntToData(UNISWAP_PLUGIN_NAME.length)\n .addAsciiStringToData(UNISWAP_PLUGIN_NAME)\n .addBufferToData(hexaStringToBuffer(UNISWAP_UNIVERSAL_ROUTER_ADDRESS)!)\n .addBufferToData(hexaStringToBuffer(UNISWAP_EXECUTE_SELECTOR)!)\n .addBufferToData(hexaStringToBuffer(UNISWAP_PLUGIN_SIGNATURE)!)\n .build();\n\n return {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: bufferToHexaString(buffer).slice(2),\n };\n }\n\n /**\n * Extracts and decodes the clear sign contexts from a Uniswap calldata transaction.\n *\n * This function:\n * - Parses the calldata using the Uniswap `execute` function signature.\n * - Extracts and validates the `commands` and `inputs`.\n * - Decodes the commands and ensures they match the number of inputs.\n * - Extracts addresses used in the transaction and verifies if chaining swaps are supported.\n * - Fetches token information for unique addresses.\n * - Returns an array of `ClearSignContext` objects representing either token data or errors.\n *\n * @private\n * @param {HexaString} calldata - The raw calldata of the Uniswap transaction.\n * @param {number} chainId - The blockchain chain ID where the transaction is being executed.\n * @returns {Promise<ClearSignContext[]>} - A promise resolving to an array of clear sign contexts.\n */\n private async _extractClearSignContexts(\n calldata: HexaString,\n chainId: number,\n ): Promise<ClearSignContext[]> {\n try {\n const iface = new Interface(UNISWAP_EXECUTE_ABI);\n\n const tx = iface.parseTransaction({ data: calldata });\n const commands: unknown = tx?.args[0];\n const inputs: unknown = tx?.args[1];\n\n if (!isHexaString(commands) || !this._isHexaStringArray(inputs)) {\n return [];\n }\n\n const decodedCommands = this._extractCommands(commands).orDefault([]);\n if (commands.length === 0 || inputs.length !== decodedCommands.length) {\n // Invalid commands or inputs\n return [];\n }\n\n const addressesByCommand = decodedCommands.reduce(\n (acc, command, index) => {\n const input = inputs[index]!;\n const decoded: HexaString[] = this.commandDecoderDataSource.decode(\n command,\n input,\n chainId,\n );\n\n acc.push([command, decoded]);\n\n return acc;\n },\n [] as [UniswapSupportedCommand, HexaString[]][],\n );\n\n if (!this._isChainingSwapSupported(addressesByCommand)) {\n return [];\n }\n\n const uniqueAddresses = [\n ...new Set(addressesByCommand.flatMap(([, addresses]) => addresses)),\n ];\n\n const tokensPayload = await Promise.all(\n uniqueAddresses.map((address) =>\n this.tokenDataSource.getTokenInfosPayload({ address, chainId }),\n ),\n );\n\n return tokensPayload.map((either) =>\n either.caseOf<ClearSignContext>({\n Left: (error) => ({ type: ClearSignContextType.ERROR, error }),\n Right: (payload) => ({ type: ClearSignContextType.TOKEN, payload }),\n }),\n );\n } catch (_) {\n return [];\n }\n }\n\n /**\n * Extracts Uniswap-supported commands from a hexadecimal string.\n * Each command is represented by one byte (2 hex characters), and this function:\n * - Maps each command to a known Uniswap command.\n * - Returns `Nothing` if any extracted command is unsupported.\n *\n * @private\n * @param {HexaString} hex - A hexadecimal string representing commands.\n * @returns {Maybe<UniswapSupportedCommand[]>} - A `Maybe` containing an array of recognized commands, or `Nothing` if any command is unsupported.\n *\n * @example\n * // Valid command extraction\n * _extractCommands('0x0008');\n * // Returns: Just(['0x00', '0x08'])\n *\n * @example\n * // Contains an unsupported command (0x05 is not supported)\n * _extractCommands('0x0005');\n * // Returns: Nothing\n *\n * @example\n * // Empty or invalid input\n * _extractCommands('0x');\n * // Returns: Nothing\n */\n private _extractCommands(hex: HexaString): Maybe<UniswapSupportedCommand[]> {\n return Maybe.fromNullable(hex.slice(2).match(/../g))\n .map((bytes) => bytes.map((b) => `0x${b}` as HexaString))\n .map((hexBytes) => hexBytes.map((b) => UNISWAP_COMMANDS[b]))\n .chain((commands) =>\n commands.every((command) => command !== undefined)\n ? Maybe.of(commands as UniswapSupportedCommand[])\n : Nothing,\n );\n }\n\n /**\n * Checks if the provided swap commands can be chained together.\n * A valid chain requires that:\n * - The output asset of the previous swap matches the input asset of the next swap.\n * - The pool version remains consistent across swaps.\n *\n * @private\n * @param {Array<[UniswapSupportedCommand, HexaString[]]>} data - An array of tuples containing a swap command and associated addresses.\n * @returns {boolean} - Returns `true` if the swap commands form a valid chain, otherwise `false`.\n *\n * @example\n * // Valid chaining: same output/input asset and pool version\n * _isChainingSwapSupported([\n * ['0x08', ['0xABC', '0xDEF']],\n * ['0x08', ['0xDEF', '0x123']]\n * ]);\n * // Returns: true\n *\n * @example\n * // Invalid chaining: different pool versions\n * _isChainingSwapSupported([\n * ['0x08', ['0xABC', '0xDEF']],\n * ['0x01', ['0xDEF', '0x123']]\n * ]);\n * // Returns: false\n *\n * @example\n * // Invalid chaining: output does not match next input\n * _isChainingSwapSupported([\n * ['0x01A1', ['0xABC', '0xDEF']],\n * ['0x01B2', ['0xXYZ', '0x123']]\n * ]);\n * // Returns: false\n */\n private _isChainingSwapSupported(\n data: [UniswapSupportedCommand, HexaString[]][],\n ): boolean {\n let lastAsset: HexaString | undefined = undefined;\n let lastPoolVersion: string | undefined = undefined;\n\n for (const [command, addresses] of data) {\n if (!UNISWAP_SWAP_COMMANDS.includes(command)) continue; // Ignore non-swap commands\n\n const poolVersion = command.slice(0, 2);\n\n if (\n lastAsset &&\n (lastAsset !== addresses[0] || lastPoolVersion !== poolVersion)\n ) {\n // Invalid chaining, return empty array\n return false;\n }\n\n // update last asset and pool version\n lastAsset = addresses[addresses.length - 1];\n lastPoolVersion = poolVersion;\n }\n\n return true;\n }\n\n /**\n * Checks if a given value is an array of hexadecimal strings.\n *\n * @private\n * @param {unknown} array - The value to check.\n * @returns {array is HexaString[]} - `true` if the value is an array of hexadecimal strings, otherwise `false`.\n */\n private _isHexaStringArray(array: unknown): array is HexaString[] {\n return (\n Array.isArray(array) &&\n array.every((item) => typeof item === \"string\" && isHexaString(item))\n );\n }\n}\n"],
5
+ "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAMO,2CACPC,EAA0B,kBAC1BC,EAAmC,qBACnCC,EAA+B,qBAG/BC,EAGO,2CAGPC,EAA2B,iCAC3BC,EAGO,sCACPC,EAOO,uCAEPC,EAA6B,qCAGtB,IAAMC,EAAN,KAAoD,CACzD,YAEUC,EAEAC,EACR,CAHQ,8BAAAD,EAEA,qBAAAC,CACP,CAEH,MAAM,KAAKC,EAA8D,CACvE,GAAI,CAACA,EAAY,MAAQ,IAAC,gBAAaA,EAAY,IAAI,EACrD,MAAO,CAAC,EAIV,GADiBA,EAAY,KAAK,MAAM,EAAG,EAAE,IAC5B,2BACf,MAAO,CAAC,EAGV,MAAMC,EAAwB,KAAK,+BAA+B,EAC5DC,EAAgB,MAAM,KAAK,0BAC/BF,EAAY,KACZA,EAAY,OACd,EAEA,OAAIE,EAAc,OAAS,EAClB,CAACD,EAAuB,GAAGC,CAAa,EAE1C,CAAC,CACV,CAQQ,gCAAmD,CACzD,MAAMC,EAAS,IAAI,mBAAiB,EACjC,kBAAkB,sBAAoB,MAAM,EAC5C,qBAAqB,qBAAmB,EACxC,mBAAgB,sBAAmB,kCAAgC,CAAE,EACrE,mBAAgB,sBAAmB,0BAAwB,CAAE,EAC7D,mBAAgB,sBAAmB,0BAAwB,CAAE,EA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,CACV,MAAO,CAAC,CACV,CACF,CA2BQ,iBAAiBC,EAAmD,CAC1E,OAAO,QAAM,aAAaA,EAAI,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,EAChD,IAAKC,GAAUA,EAAM,IAAKC,GAAM,KAAKA,CAAC,EAAgB,CAAC,EACvD,IAAKC,GAAaA,EAAS,IAAKD,GAAM,mBAAiBA,CAAC,CAAC,CAAC,EAC1D,MAAOjB,GACNA,EAAS,MAAOK,GAAYA,IAAY,MAAS,EAC7C,QAAM,GAAGL,CAAqC,EAC9C,SACN,CACJ,CAoCQ,yBACNmB,EACS,CACT,IAAIC,EACAC,EAEJ,SAAW,CAAChB,EAASK,CAAS,IAAKS,EAAM,CACvC,GAAI,CAAC,wBAAsB,SAASd,CAAO,EAAG,SAE9C,MAAMiB,EAAcjB,EAAQ,MAAM,EAAG,CAAC,EAEtC,GACEe,IACCA,IAAcV,EAAU,CAAC,GAAKW,IAAoBC,GAGnD,MAAO,GAITF,EAAYV,EAAUA,EAAU,OAAS,CAAC,EAC1CW,EAAkBC,CACpB,CAEA,MAAO,EACT,CASQ,mBAAmBC,EAAuC,CAChE,OACE,MAAM,QAAQA,CAAK,GACnBA,EAAM,MAAOC,GAAS,OAAOA,GAAS,aAAY,gBAAaA,CAAI,CAAC,CAExE,CACF,EA/OalC,EAANmC,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,eAAa,wBAAwB,GAE5CA,EAAA,eAAO,aAAW,eAAe,IAJzBpC",
6
+ "names": ["UniswapContextLoader_exports", "__export", "UniswapContextLoader", "__toCommonJS", "import_device_management_kit", "import_ethers", "import_inversify", "import_purify_ts", "import_ClearSignContext", "import_tokenTypes", "import_plugin", "import_uniswap", "import_uniswapTypes", "UniswapContextLoader", "commandDecoderDataSource", "tokenDataSource", "transaction", "externalPluginContext", "tokenContexts", "buffer", "calldata", "chainId", "tx", "commands", "inputs", "decodedCommands", "addressesByCommand", "acc", "command", "index", "input", "decoded", "uniqueAddresses", "addresses", "address", "either", "error", "payload", "hex", "bytes", "b", "hexBytes", "data", "lastAsset", "lastPoolVersion", "poolVersion", "array", "item", "__decorateClass", "__decorateParam"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var s=require("ethers"),r=require("purify-ts"),f=require("../../shared/model/ClearSignContext"),e=require("../../uniswap/constants/uniswap"),l=require("../../uniswap/data/DefaultCommandDecoderDataSource"),x=require("../../uniswap/data/EthersAbiDecoderDataSource"),p=require("./UniswapContextLoader");describe("UniswapContextLoader",()=>{const t={decode:vi.fn()},o={getTokenInfosPayload:vi.fn()};let c;describe("load",()=>{describe("with tokenDataSourceMock",()=>{beforeEach(()=>{vi.spyOn(o,"getTokenInfosPayload").mockImplementation(({address:a})=>Promise.resolve((0,r.Right)(`payload-${a}`))),c=new p.UniswapContextLoader(new l.DefaultCommandDecoderDataSource(new x.EthersAbiDecoderDataSource),o)}),it("should return the external plugin context and the decoded contexts",async()=>{const a={chainId:1,data:"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000067a4855b000000000000000000000000000000000000000000000000000000000000000300060c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000a18f07d736b90be5500000000000000000000000000000000000000000000000000000000b0b8122abd8412900000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bb9f599ce614feb2e1bbe58f180f370d05b39344e002710c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000017cc6042605381c158d2adab487434bde79aa61c000000000000000000000000000000000000000000000000000000000000005b000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000b0b8122abd84129c001a053efc49d03b694742500f49aa09df2360bd7e297fa730c745e0d4320b42fc33fa01ca1c85a46c561f624830fffbae2441ba0f2d54eb5b0f17e0e3561d10db0b7ee"},n=await c.load(a);expect(n).toEqual([{type:f.ClearSignContextType.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 a={chainId:1,data:"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000669b9ec100000000000000000000000000000000000000000000000000000000000000030a010c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000016000000000000000000000000055747be9f9f5beb232ad59fe7af013b81d95fd5e000000000000000000000000ffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000066c32b0d0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000ef1c6e67703c7bd7107eed8303fbe6ec2554bf6b00000000000000000000000000000000000000000000000000000000669b9ec100000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000410d756f55acf289e9754faf91bba0a704b5c7c0aa4b1dfd551115ccbe4c7f290234e1a14265e1da0bc872a23627d997fe37a689c290d519f7b8c9bdde1b79108e1b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000030ba49cbff5a00000000000000000000000000000000000000000000000089677c957272141800000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc200271055747be9f9f5beb232ad59fe7af013b81d95fd5e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000030ba49cbff5a000c001a0e406d9c91c8b46d959fcd31a28518a77bb248ebb316c5fab7b98335cce922f2aa0462cb970c32a8dbfe71c57b888c43b9ed04fce41d169dbfcc745445587adb771"},n=await c.load(a);expect(n).toEqual([{type:f.ClearSignContextType.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 a={};vi.spyOn(t,"decode").mockReturnValue([]);const n=await c.load(a);expect(n).toEqual([])}),it("should return an empty array if a command is not supported",async()=>{const a={chainId:1,data:"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000067a4bef600000000000000000000000000000000000000000000000000000000000000050b0105040c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000078e6708e70aed0f000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000059a16770000000000000000000000000000000000000000000000000078e6708e70aed0f00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f4c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000027213e28d7fda5c57fe9e5dd923818dbccf71c4700000000000000000000000000000000000000000000000000000000003938700000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006f939b43d65be049b7533907db08e80ba6969f450000000000000000000000000000000000000000000000000000000059682f0000000000000000000000000000000000000000000000000000000000000000400000000000000000000000006f939b43d65be049b7533907db08e80ba6969f4500000000000000000000000000000000000000000000000000000000000000000cc080a07c86dd5813ec1f3725c402f8bea6105546d1093c59676023b971f1d83f61bd4ea02a353bf3028cabcbe68c5dc8906752bafe55afc86b6344edb3ffd8a3650332e8"},n=await c.load(a);expect(n).toEqual([])})}),describe("with mocked ethers parseTransaction",()=>{beforeEach(()=>{vi.resetAllMocks(),c=new p.UniswapContextLoader(t,o)}),it("should return an array with contexts if 2 chain swaps are supported",async()=>{const a={to:e.UNISWAP_UNIVERSAL_ROUTER_ADDRESS,data:e.UNISWAP_EXECUTE_SELECTOR,chainId:66};vi.spyOn(s.Interface.prototype,"parseTransaction").mockReturnValue({args:["0x0809",["0x0001","0x0002"]]}),vi.spyOn(t,"decode").mockReturnValueOnce(["0x01","0x04","0x02"]),vi.spyOn(t,"decode").mockReturnValueOnce(["0x02","0x03"]),vi.spyOn(o,"getTokenInfosPayload").mockImplementation(({address:i})=>Promise.resolve((0,r.Right)(`payload-${i}`)));const d=await c.load(a);expect(t.decode).toHaveBeenNthCalledWith(1,e.UniswapSupportedCommand.V2_SWAP_EXACT_IN,"0x0001",66),expect(t.decode).toHaveBeenNthCalledWith(2,e.UniswapSupportedCommand.V2_SWAP_EXACT_OUT,"0x0002",66),expect(o.getTokenInfosPayload).toHaveBeenNthCalledWith(1,{address:"0x01",chainId:66}),expect(o.getTokenInfosPayload).toHaveBeenNthCalledWith(2,{address:"0x04",chainId:66}),expect(o.getTokenInfosPayload).toHaveBeenNthCalledWith(3,{address:"0x02",chainId:66}),expect(o.getTokenInfosPayload).toHaveBeenNthCalledWith(4,{address:"0x03",chainId:66}),expect(d).toEqual([{type:f.ClearSignContextType.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 a={to:e.UNISWAP_UNIVERSAL_ROUTER_ADDRESS,data:e.UNISWAP_EXECUTE_SELECTOR,chainId:66};vi.spyOn(s.Interface.prototype,"parseTransaction").mockReturnValue({args:["0x0b0004",["0x0001","0x0002","0x0003"]]}),vi.spyOn(t,"decode").mockReturnValueOnce(["0x01"]),vi.spyOn(t,"decode").mockReturnValueOnce(["0x02","0x03"]),vi.spyOn(t,"decode").mockReturnValueOnce(["0x04"]),vi.spyOn(o,"getTokenInfosPayload").mockImplementation(({address:i})=>Promise.resolve((0,r.Right)(`payload-${i}`)));const d=await c.load(a);expect(t.decode).toHaveBeenNthCalledWith(1,e.UniswapSupportedCommand.WRAP_ETH,"0x0001",66),expect(o.getTokenInfosPayload).toHaveBeenNthCalledWith(1,{address:"0x01",chainId:66}),expect(o.getTokenInfosPayload).toHaveBeenNthCalledWith(2,{address:"0x02",chainId:66}),expect(o.getTokenInfosPayload).toHaveBeenNthCalledWith(3,{address:"0x03",chainId:66}),expect(o.getTokenInfosPayload).toHaveBeenNthCalledWith(4,{address:"0x04",chainId:66}),expect(d).toEqual([{type:f.ClearSignContextType.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 a={to:e.UNISWAP_UNIVERSAL_ROUTER_ADDRESS,data:e.UNISWAP_EXECUTE_SELECTOR,chainId:66};vi.spyOn(s.Interface.prototype,"parseTransaction").mockReturnValue({args:["0x0809",["0x0001","0x0002"]]}),vi.spyOn(t,"decode").mockReturnValueOnce(["0x01","0x02"]),vi.spyOn(t,"decode").mockReturnValueOnce(["0x02","0x03"]),vi.spyOn(o,"getTokenInfosPayload").mockResolvedValueOnce((0,r.Left)("error")),vi.spyOn(o,"getTokenInfosPayload").mockImplementation(({address:i})=>Promise.resolve((0,r.Right)(`payload-${i}`)));const d=await c.load(a);expect(t.decode).toHaveBeenNthCalledWith(1,e.UniswapSupportedCommand.V2_SWAP_EXACT_IN,"0x0001",66),expect(t.decode).toHaveBeenNthCalledWith(2,e.UniswapSupportedCommand.V2_SWAP_EXACT_OUT,"0x0002",66),expect(o.getTokenInfosPayload).toHaveBeenNthCalledWith(1,{address:"0x01",chainId:66}),expect(o.getTokenInfosPayload).toHaveBeenNthCalledWith(2,{address:"0x02",chainId:66}),expect(o.getTokenInfosPayload).toHaveBeenNthCalledWith(3,{address:"0x03",chainId:66}),expect(d).toEqual([{type:f.ClearSignContextType.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 a={to:e.UNISWAP_UNIVERSAL_ROUTER_ADDRESS,data:e.UNISWAP_EXECUTE_SELECTOR,chainId:66};vi.spyOn(s.Interface.prototype,"parseTransaction").mockReturnValue({args:["0x0809",["0x0001","0x0002"]]}),vi.spyOn(t,"decode").mockReturnValueOnce(["0x01","0x02"]),vi.spyOn(t,"decode").mockReturnValueOnce(["0x03","0x04"]);const d=await c.load(a);expect(t.decode).toHaveBeenNthCalledWith(1,e.UniswapSupportedCommand.V2_SWAP_EXACT_IN,"0x0001",66),expect(t.decode).toHaveBeenNthCalledWith(2,e.UniswapSupportedCommand.V2_SWAP_EXACT_OUT,"0x0002",66),expect(o.getTokenInfosPayload).not.toHaveBeenCalled(),expect(d).toEqual([])}),it("should return an empty array if no command are returned from parseTransaction",async()=>{const a={to:e.UNISWAP_UNIVERSAL_ROUTER_ADDRESS,data:e.UNISWAP_EXECUTE_SELECTOR};vi.spyOn(s.Interface.prototype,"parseTransaction").mockReturnValue({args:[""]});const n=await c.load(a);expect(t.decode).not.toHaveBeenCalled(),expect(o.getTokenInfosPayload).not.toHaveBeenCalled(),expect(n).toEqual([])}),it("should return an empty array if no inputs are returned from parseTransaction",async()=>{const a={to:e.UNISWAP_UNIVERSAL_ROUTER_ADDRESS,data:e.UNISWAP_EXECUTE_SELECTOR};vi.spyOn(s.Interface.prototype,"parseTransaction").mockReturnValue({args:["0x08",[]]});const n=await c.load(a);expect(o.getTokenInfosPayload).not.toHaveBeenCalled(),expect(n).toEqual([])}),it("should return an empty array if parseTransaction throws an error",async()=>{const a={to:e.UNISWAP_UNIVERSAL_ROUTER_ADDRESS,data:e.UNISWAP_EXECUTE_SELECTOR};vi.spyOn(s.Interface.prototype,"parseTransaction").mockImplementation(()=>{throw new Error});const n=await c.load(a);expect(t.decode).not.toHaveBeenCalled(),expect(o.getTokenInfosPayload).not.toHaveBeenCalled(),expect(n).toEqual([])}),it("should return an empty array if the swap is with multiple pool versions",async()=>{const a={to:e.UNISWAP_UNIVERSAL_ROUTER_ADDRESS,data:e.UNISWAP_EXECUTE_SELECTOR,chainId:66};vi.spyOn(s.Interface.prototype,"parseTransaction").mockReturnValue({args:["0x080900",["0x00","0x01","0x02"]]}),vi.spyOn(t,"decode").mockReturnValue(["0x01","0x02"]);const d=await c.load(a);expect(t.decode).toHaveBeenNthCalledWith(1,e.UniswapSupportedCommand.V2_SWAP_EXACT_IN,"0x00",66),expect(t.decode).toHaveBeenNthCalledWith(2,e.UniswapSupportedCommand.V2_SWAP_EXACT_OUT,"0x01",66),expect(t.decode).toHaveBeenNthCalledWith(3,e.UniswapSupportedCommand.V3_SWAP_EXACT_IN,"0x02",66),expect(o.getTokenInfosPayload).not.toHaveBeenCalled(),expect(d).toEqual([])}),it("should return an empty array if the selector is not supported",async()=>{const a={to:e.UNISWAP_UNIVERSAL_ROUTER_ADDRESS,data:"0x00000000",chainId:66},n=await c.load(a);expect(t.decode).not.toHaveBeenCalled(),expect(o.getTokenInfosPayload).not.toHaveBeenCalled(),expect(n).toEqual([])}),it("should return an empty array if the length of the commands and inputs are different",async()=>{const a={to:e.UNISWAP_UNIVERSAL_ROUTER_ADDRESS,data:e.UNISWAP_EXECUTE_SELECTOR,chainId:66};vi.spyOn(s.Interface.prototype,"parseTransaction").mockReturnValue({args:["0x0809",["0x0001"]]});const d=await c.load(a);expect(t.decode).not.toHaveBeenCalled(),expect(o.getTokenInfosPayload).not.toHaveBeenCalled(),expect(d).toEqual([])})})})});
2
+ //# sourceMappingURL=UniswapContextLoader.test.js.map