@ledgerhq/context-module 0.0.0-develop-20260428002525 → 0.0.0-develop-20260430002707

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 (233) hide show
  1. package/lib/cjs/package.json +1 -2
  2. package/lib/cjs/src/account-ownership/data/HttpAccountOwnershipDataSource.js +1 -1
  3. package/lib/cjs/src/account-ownership/data/HttpAccountOwnershipDataSource.js.map +3 -3
  4. package/lib/cjs/src/account-ownership/data/HttpAccountOwnershipDataSource.test.js +1 -1
  5. package/lib/cjs/src/account-ownership/data/HttpAccountOwnershipDataSource.test.js.map +3 -3
  6. package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.js +1 -1
  7. package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.js.map +3 -3
  8. package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.test.js +1 -1
  9. package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.test.js.map +3 -3
  10. package/lib/cjs/src/calldata/di/calldataModuleFactory.js +1 -1
  11. package/lib/cjs/src/calldata/di/calldataModuleFactory.js.map +3 -3
  12. package/lib/cjs/src/di.js +1 -1
  13. package/lib/cjs/src/di.js.map +3 -3
  14. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.js +1 -1
  15. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.js.map +3 -3
  16. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js +1 -1
  17. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js.map +3 -3
  18. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js +1 -1
  19. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js.map +3 -3
  20. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
  21. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +3 -3
  22. package/lib/cjs/src/gated-signing/data/HttpGatedDescriptorDataSource.js +1 -1
  23. package/lib/cjs/src/gated-signing/data/HttpGatedDescriptorDataSource.js.map +3 -3
  24. package/lib/cjs/src/gated-signing/data/HttpGatedDescriptorDataSource.test.js +1 -1
  25. package/lib/cjs/src/gated-signing/data/HttpGatedDescriptorDataSource.test.js.map +3 -3
  26. package/lib/cjs/src/network/di/networkModuleFactory.js +2 -0
  27. package/lib/cjs/src/network/di/networkModuleFactory.js.map +7 -0
  28. package/lib/cjs/src/network/di/networkTypes.js +2 -0
  29. package/lib/cjs/src/network/di/networkTypes.js.map +7 -0
  30. package/lib/cjs/src/network/networkClientFactory.js +2 -0
  31. package/lib/cjs/src/network/networkClientFactory.js.map +7 -0
  32. package/lib/cjs/src/network/networkClientFactory.test.js +2 -0
  33. package/lib/cjs/src/network/networkClientFactory.test.js.map +7 -0
  34. package/lib/cjs/src/nft/data/HttpNftDataSource.js +1 -1
  35. package/lib/cjs/src/nft/data/HttpNftDataSource.js.map +3 -3
  36. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js +1 -1
  37. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js.map +3 -3
  38. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.js +1 -1
  39. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.js.map +3 -3
  40. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.test.js +1 -1
  41. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.test.js.map +3 -3
  42. package/lib/cjs/src/proxy/data/HttpProxyDataSource.js +1 -1
  43. package/lib/cjs/src/proxy/data/HttpProxyDataSource.js.map +3 -3
  44. package/lib/cjs/src/proxy/data/HttpProxyDataSource.test.js +1 -1
  45. package/lib/cjs/src/proxy/data/HttpProxyDataSource.test.js.map +3 -3
  46. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.js +1 -1
  47. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.js.map +3 -3
  48. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.test.js +1 -1
  49. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.test.js.map +3 -3
  50. package/lib/cjs/src/proxy/di/proxyModuleFactory.test.js +1 -1
  51. package/lib/cjs/src/proxy/di/proxyModuleFactory.test.js.map +3 -3
  52. package/lib/cjs/src/reporter/data/HttpBlindSigningReporterDatasource.js +1 -1
  53. package/lib/cjs/src/reporter/data/HttpBlindSigningReporterDatasource.js.map +3 -3
  54. package/lib/cjs/src/reporter/data/HttpBlindSigningReporterDatasource.test.js +1 -1
  55. package/lib/cjs/src/reporter/data/HttpBlindSigningReporterDatasource.test.js.map +3 -3
  56. package/lib/cjs/src/safe/data/HttpSafeAccountDataSource.js +1 -1
  57. package/lib/cjs/src/safe/data/HttpSafeAccountDataSource.js.map +3 -3
  58. package/lib/cjs/src/safe/data/HttpSafeAccountDataSource.test.js +1 -1
  59. package/lib/cjs/src/safe/data/HttpSafeAccountDataSource.test.js.map +3 -3
  60. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js +1 -1
  61. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +3 -3
  62. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +1 -1
  63. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +3 -3
  64. package/lib/cjs/src/solanaLifi/data/HttpSolanaLifiDataSource.js +1 -1
  65. package/lib/cjs/src/solanaLifi/data/HttpSolanaLifiDataSource.js.map +3 -3
  66. package/lib/cjs/src/solanaLifi/data/HttpSolanaLifiDataSource.test.js +1 -1
  67. package/lib/cjs/src/solanaLifi/data/HttpSolanaLifiDataSource.test.js.map +3 -3
  68. package/lib/cjs/src/solanaToken/data/HttpSolanaTokenDataSource.js +1 -1
  69. package/lib/cjs/src/solanaToken/data/HttpSolanaTokenDataSource.js.map +3 -3
  70. package/lib/cjs/src/solanaToken/data/HttpSolanaTokenDataSource.test.js +6 -6
  71. package/lib/cjs/src/solanaToken/data/HttpSolanaTokenDataSource.test.js.map +3 -3
  72. package/lib/cjs/src/token/data/HttpTokenDataSource.js +1 -1
  73. package/lib/cjs/src/token/data/HttpTokenDataSource.js.map +3 -3
  74. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js +1 -1
  75. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js.map +3 -3
  76. package/lib/cjs/src/transaction-check/data/HttpTransactionCheckDataSource.js +1 -1
  77. package/lib/cjs/src/transaction-check/data/HttpTransactionCheckDataSource.js.map +3 -3
  78. package/lib/cjs/src/transaction-check/data/HttpTransactionCheckDataSource.test.js +1 -1
  79. package/lib/cjs/src/transaction-check/data/HttpTransactionCheckDataSource.test.js.map +3 -3
  80. package/lib/cjs/src/transaction-check/data/HttpTypedDataCheckDataSource.js +1 -1
  81. package/lib/cjs/src/transaction-check/data/HttpTypedDataCheckDataSource.js.map +3 -3
  82. package/lib/cjs/src/transaction-check/data/HttpTypedDataCheckDataSource.test.js +1 -1
  83. package/lib/cjs/src/transaction-check/data/HttpTypedDataCheckDataSource.test.js.map +3 -3
  84. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  85. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
  86. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  87. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +3 -3
  88. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  89. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js.map +3 -3
  90. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  91. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
  92. package/lib/esm/package.json +1 -2
  93. package/lib/esm/src/account-ownership/data/HttpAccountOwnershipDataSource.js +1 -1
  94. package/lib/esm/src/account-ownership/data/HttpAccountOwnershipDataSource.js.map +3 -3
  95. package/lib/esm/src/account-ownership/data/HttpAccountOwnershipDataSource.test.js +1 -1
  96. package/lib/esm/src/account-ownership/data/HttpAccountOwnershipDataSource.test.js.map +3 -3
  97. package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.js +1 -1
  98. package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.js.map +3 -3
  99. package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.test.js +1 -1
  100. package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.test.js.map +3 -3
  101. package/lib/esm/src/calldata/di/calldataModuleFactory.js +1 -1
  102. package/lib/esm/src/calldata/di/calldataModuleFactory.js.map +3 -3
  103. package/lib/esm/src/di.js +1 -1
  104. package/lib/esm/src/di.js.map +3 -3
  105. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.js +1 -1
  106. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.js.map +3 -3
  107. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js +1 -1
  108. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js.map +3 -3
  109. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js +1 -1
  110. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js.map +3 -3
  111. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
  112. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +3 -3
  113. package/lib/esm/src/gated-signing/data/HttpGatedDescriptorDataSource.js +1 -1
  114. package/lib/esm/src/gated-signing/data/HttpGatedDescriptorDataSource.js.map +3 -3
  115. package/lib/esm/src/gated-signing/data/HttpGatedDescriptorDataSource.test.js +1 -1
  116. package/lib/esm/src/gated-signing/data/HttpGatedDescriptorDataSource.test.js.map +3 -3
  117. package/lib/esm/src/network/di/networkModuleFactory.js +2 -0
  118. package/lib/esm/src/network/di/networkModuleFactory.js.map +7 -0
  119. package/lib/esm/src/network/di/networkTypes.js +2 -0
  120. package/lib/esm/src/network/di/networkTypes.js.map +7 -0
  121. package/lib/esm/src/network/networkClientFactory.js +2 -0
  122. package/lib/esm/src/network/networkClientFactory.js.map +7 -0
  123. package/lib/esm/src/network/networkClientFactory.test.js +2 -0
  124. package/lib/esm/src/network/networkClientFactory.test.js.map +7 -0
  125. package/lib/esm/src/nft/data/HttpNftDataSource.js +1 -1
  126. package/lib/esm/src/nft/data/HttpNftDataSource.js.map +3 -3
  127. package/lib/esm/src/nft/data/HttpNftDataSource.test.js +1 -1
  128. package/lib/esm/src/nft/data/HttpNftDataSource.test.js.map +3 -3
  129. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.js +1 -1
  130. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.js.map +3 -3
  131. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.test.js +1 -1
  132. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.test.js.map +3 -3
  133. package/lib/esm/src/proxy/data/HttpProxyDataSource.js +1 -1
  134. package/lib/esm/src/proxy/data/HttpProxyDataSource.js.map +3 -3
  135. package/lib/esm/src/proxy/data/HttpProxyDataSource.test.js +1 -1
  136. package/lib/esm/src/proxy/data/HttpProxyDataSource.test.js.map +3 -3
  137. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.js +1 -1
  138. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.js.map +3 -3
  139. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.test.js +1 -1
  140. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.test.js.map +3 -3
  141. package/lib/esm/src/proxy/di/proxyModuleFactory.test.js +1 -1
  142. package/lib/esm/src/proxy/di/proxyModuleFactory.test.js.map +3 -3
  143. package/lib/esm/src/reporter/data/HttpBlindSigningReporterDatasource.js +1 -1
  144. package/lib/esm/src/reporter/data/HttpBlindSigningReporterDatasource.js.map +3 -3
  145. package/lib/esm/src/reporter/data/HttpBlindSigningReporterDatasource.test.js +1 -1
  146. package/lib/esm/src/reporter/data/HttpBlindSigningReporterDatasource.test.js.map +3 -3
  147. package/lib/esm/src/safe/data/HttpSafeAccountDataSource.js +1 -1
  148. package/lib/esm/src/safe/data/HttpSafeAccountDataSource.js.map +3 -3
  149. package/lib/esm/src/safe/data/HttpSafeAccountDataSource.test.js +1 -1
  150. package/lib/esm/src/safe/data/HttpSafeAccountDataSource.test.js.map +3 -3
  151. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js +1 -1
  152. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +3 -3
  153. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +1 -1
  154. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +3 -3
  155. package/lib/esm/src/solanaLifi/data/HttpSolanaLifiDataSource.js +1 -1
  156. package/lib/esm/src/solanaLifi/data/HttpSolanaLifiDataSource.js.map +3 -3
  157. package/lib/esm/src/solanaLifi/data/HttpSolanaLifiDataSource.test.js +1 -1
  158. package/lib/esm/src/solanaLifi/data/HttpSolanaLifiDataSource.test.js.map +3 -3
  159. package/lib/esm/src/solanaToken/data/HttpSolanaTokenDataSource.js +1 -1
  160. package/lib/esm/src/solanaToken/data/HttpSolanaTokenDataSource.js.map +3 -3
  161. package/lib/esm/src/solanaToken/data/HttpSolanaTokenDataSource.test.js +6 -6
  162. package/lib/esm/src/solanaToken/data/HttpSolanaTokenDataSource.test.js.map +3 -3
  163. package/lib/esm/src/token/data/HttpTokenDataSource.js +1 -1
  164. package/lib/esm/src/token/data/HttpTokenDataSource.js.map +3 -3
  165. package/lib/esm/src/token/data/HttpTokenDataSource.test.js +1 -1
  166. package/lib/esm/src/token/data/HttpTokenDataSource.test.js.map +3 -3
  167. package/lib/esm/src/transaction-check/data/HttpTransactionCheckDataSource.js +1 -1
  168. package/lib/esm/src/transaction-check/data/HttpTransactionCheckDataSource.js.map +3 -3
  169. package/lib/esm/src/transaction-check/data/HttpTransactionCheckDataSource.test.js +1 -1
  170. package/lib/esm/src/transaction-check/data/HttpTransactionCheckDataSource.test.js.map +3 -3
  171. package/lib/esm/src/transaction-check/data/HttpTypedDataCheckDataSource.js +1 -1
  172. package/lib/esm/src/transaction-check/data/HttpTypedDataCheckDataSource.js.map +3 -3
  173. package/lib/esm/src/transaction-check/data/HttpTypedDataCheckDataSource.test.js +1 -1
  174. package/lib/esm/src/transaction-check/data/HttpTypedDataCheckDataSource.test.js.map +3 -3
  175. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  176. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
  177. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  178. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +3 -3
  179. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  180. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js.map +3 -3
  181. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  182. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
  183. package/lib/types/src/account-ownership/data/HttpAccountOwnershipDataSource.d.ts +10 -10
  184. package/lib/types/src/account-ownership/data/HttpAccountOwnershipDataSource.d.ts.map +1 -1
  185. package/lib/types/src/calldata/data/HttpCalldataDescriptorDataSource.d.ts +3 -1
  186. package/lib/types/src/calldata/data/HttpCalldataDescriptorDataSource.d.ts.map +1 -1
  187. package/lib/types/src/calldata/di/calldataModuleFactory.d.ts.map +1 -1
  188. package/lib/types/src/di.d.ts.map +1 -1
  189. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.d.ts +3 -1
  190. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.d.ts.map +1 -1
  191. package/lib/types/src/external-plugin/data/HttpExternalPluginDataSource.d.ts +3 -1
  192. package/lib/types/src/external-plugin/data/HttpExternalPluginDataSource.d.ts.map +1 -1
  193. package/lib/types/src/gated-signing/data/HttpGatedDescriptorDataSource.d.ts +3 -1
  194. package/lib/types/src/gated-signing/data/HttpGatedDescriptorDataSource.d.ts.map +1 -1
  195. package/lib/types/src/network/di/networkModuleFactory.d.ts +4 -0
  196. package/lib/types/src/network/di/networkModuleFactory.d.ts.map +1 -0
  197. package/lib/types/src/network/di/networkTypes.d.ts +4 -0
  198. package/lib/types/src/network/di/networkTypes.d.ts.map +1 -0
  199. package/lib/types/src/network/networkClientFactory.d.ts +4 -0
  200. package/lib/types/src/network/networkClientFactory.d.ts.map +1 -0
  201. package/lib/types/src/network/networkClientFactory.test.d.ts +2 -0
  202. package/lib/types/src/network/networkClientFactory.test.d.ts.map +1 -0
  203. package/lib/types/src/nft/data/HttpNftDataSource.d.ts +3 -1
  204. package/lib/types/src/nft/data/HttpNftDataSource.d.ts.map +1 -1
  205. package/lib/types/src/pki/data/HttpPkiCertificateDataSource.d.ts +4 -1
  206. package/lib/types/src/pki/data/HttpPkiCertificateDataSource.d.ts.map +1 -1
  207. package/lib/types/src/proxy/data/HttpProxyDataSource.d.ts +3 -1
  208. package/lib/types/src/proxy/data/HttpProxyDataSource.d.ts.map +1 -1
  209. package/lib/types/src/proxy/data/HttpSafeProxyDataSource.d.ts +3 -1
  210. package/lib/types/src/proxy/data/HttpSafeProxyDataSource.d.ts.map +1 -1
  211. package/lib/types/src/reporter/data/HttpBlindSigningReporterDatasource.d.ts +3 -1
  212. package/lib/types/src/reporter/data/HttpBlindSigningReporterDatasource.d.ts.map +1 -1
  213. package/lib/types/src/safe/data/HttpSafeAccountDataSource.d.ts +3 -1
  214. package/lib/types/src/safe/data/HttpSafeAccountDataSource.d.ts.map +1 -1
  215. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.d.ts +3 -1
  216. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.d.ts.map +1 -1
  217. package/lib/types/src/solanaLifi/data/HttpSolanaLifiDataSource.d.ts +3 -2
  218. package/lib/types/src/solanaLifi/data/HttpSolanaLifiDataSource.d.ts.map +1 -1
  219. package/lib/types/src/solanaToken/data/HttpSolanaTokenDataSource.d.ts +3 -1
  220. package/lib/types/src/solanaToken/data/HttpSolanaTokenDataSource.d.ts.map +1 -1
  221. package/lib/types/src/token/data/HttpTokenDataSource.d.ts +3 -1
  222. package/lib/types/src/token/data/HttpTokenDataSource.d.ts.map +1 -1
  223. package/lib/types/src/transaction-check/data/HttpTransactionCheckDataSource.d.ts +3 -1
  224. package/lib/types/src/transaction-check/data/HttpTransactionCheckDataSource.d.ts.map +1 -1
  225. package/lib/types/src/transaction-check/data/HttpTypedDataCheckDataSource.d.ts +3 -1
  226. package/lib/types/src/transaction-check/data/HttpTypedDataCheckDataSource.d.ts.map +1 -1
  227. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts +3 -1
  228. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts.map +1 -1
  229. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts +3 -1
  230. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts.map +1 -1
  231. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts.map +1 -1
  232. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  233. package/package.json +5 -6
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/calldata/data/HttpCalldataDescriptorDataSource.ts"],
4
- "sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport {\n type ContextModuleCalMode,\n type ContextModuleServiceConfig,\n} from \"@/config/model/ContextModuleConfig\";\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport { PkiCertificateInfo } from \"@/pki/model/PkiCertificateInfo\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport {\n ClearSignContextReference,\n ClearSignContextReferenceType,\n ClearSignContextSuccess,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { GenericPath } from \"@/shared/model/GenericPath\";\nimport { INFO_SIGNATURE_TAG } from \"@/shared/model/SignatureTags\";\nimport { HexStringUtils } from \"@/shared/utils/HexStringUtils\";\nimport PACKAGE from \"@root/package.json\";\n\nimport {\n CalldataDescriptor,\n CalldataDescriptorContainerPathV1,\n CalldataDescriptorParam,\n CalldataDescriptorPathElementsV1,\n CalldataDescriptorPathElementV1,\n CalldataDescriptorV1,\n CalldataDescriptorValueBinaryPathV1,\n CalldataDescriptorValueConstantV1,\n CalldataDescriptorValueV1,\n CalldataDto,\n CalldataEnumV1,\n CalldataFieldV1,\n CalldataSignatures,\n CalldataTransactionDescriptor,\n CalldataTransactionInfoV1,\n} from \"./dto/CalldataDto\";\nimport {\n CalldataDescriptorDataSource,\n GetCalldataDescriptorsParams,\n} from \"./CalldataDescriptorDataSource\";\n\n@injectable()\nexport class HttpCalldataDescriptorDataSource\n implements CalldataDescriptorDataSource\n{\n constructor(\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly _certificateLoader: PkiCertificateLoader,\n private readonly endpoint: string,\n ) {}\n\n public async getCalldataDescriptors({\n chainId,\n address,\n selector,\n deviceModelId,\n }: GetCalldataDescriptorsParams): Promise<\n Either<Error, ClearSignContextSuccess[]>\n > {\n let dto: CalldataDto[] | undefined;\n try {\n const response = await axios.request<CalldataDto[]>({\n method: \"GET\",\n url: `${this.config.cal.url}/${this.endpoint}`,\n params: {\n output: \"descriptors_calldata\",\n chain_id: chainId,\n contracts: address, // used for dapps\n contract_address: address, // used for tokens\n ref: `branch:${this.config.cal.branch}`,\n },\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n });\n dto = response.data;\n } catch (error) {\n return Left(\n new Error(\n `[ContextModule] HttpCalldataDescriptorDataSource: Failed to fetch calldata descriptors: ${error}`,\n ),\n );\n }\n\n if (!Array.isArray(dto)) {\n return Left(\n new Error(\n `[ContextModule] HttpCalldataDescriptorDataSource: Response is not an array`,\n ),\n );\n }\n\n if (dto.length === 0) {\n return Left(\n new Error(\n `[ContextModule] HttpCalldataDescriptorDataSource: No data for contract ${address} and selector ${selector}`,\n ),\n );\n }\n\n for (const calldata of dto) {\n // Normalize the address and selector\n address = address.toLowerCase();\n selector = `0x${selector.slice(2).toLowerCase()}`;\n const calldataDescriptor =\n calldata.descriptors_calldata?.[address]?.[selector];\n\n if (\n !calldataDescriptor ||\n !this.isCalldataDescriptorV1(calldataDescriptor, this.config.cal.mode)\n ) {\n continue;\n }\n\n const infoData = calldataDescriptor.transaction_info.descriptor.data;\n const infoSignature =\n calldataDescriptor.transaction_info.descriptor.signatures[\n this.config.cal.mode\n ];\n\n const certificateInfos: PkiCertificateInfo = {\n targetDevice: deviceModelId,\n keyUsage: KeyUsage.Calldata,\n keyId: KeyId.CalCalldataKey,\n };\n const certificate: PkiCertificate | undefined =\n await this._certificateLoader.loadCertificate(certificateInfos);\n\n const info: ClearSignContextSuccess = {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: HexStringUtils.appendSignatureToPayload(\n infoData,\n infoSignature,\n INFO_SIGNATURE_TAG,\n ),\n certificate,\n };\n\n const enums: ClearSignContextSuccess[] = [];\n for (const [id, values] of Object.entries(calldataDescriptor.enums)) {\n for (const [\n value,\n { data, signatures },\n ] of Object.entries<CalldataTransactionDescriptor>(values)) {\n enums.push({\n type: ClearSignContextType.ENUM,\n id: Number(id),\n value: Number(value),\n payload: HexStringUtils.appendSignatureToPayload(\n data,\n signatures[this.config.cal.mode]!,\n INFO_SIGNATURE_TAG,\n ),\n certificate,\n });\n }\n }\n\n const fields: ClearSignContextSuccess[] = calldataDescriptor.fields.map(\n (field) => ({\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: field.descriptor,\n reference: this.getReference(field.param),\n }),\n );\n return Right([info, ...enums, ...fields]);\n }\n\n return Left(\n new Error(\n `[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract ${address} and selector ${selector}`,\n ),\n );\n }\n\n private getReference(\n param: CalldataDescriptorParam,\n ): ClearSignContextReference | undefined {\n if (\n param.type === \"TOKEN_AMOUNT\" &&\n param.token !== undefined &&\n param.token.type === \"path\"\n ) {\n return {\n type: ClearSignContextReferenceType.TOKEN,\n valuePath: this.toGenericPath(param.token.binary_path),\n };\n } else if (\n param.type === \"TOKEN_AMOUNT\" &&\n param.token !== undefined &&\n param.token.type === \"constant\"\n ) {\n return {\n type: ClearSignContextReferenceType.TOKEN,\n value: param.token.value,\n };\n } else if (param.type === \"NFT\" && param.collection.type === \"path\") {\n return {\n type: ClearSignContextReferenceType.NFT,\n valuePath: this.toGenericPath(param.collection.binary_path),\n };\n } else if (param.type === \"NFT\" && param.collection.type === \"constant\") {\n return {\n type: ClearSignContextReferenceType.NFT,\n value: param.collection.value,\n };\n } else if (param.type === \"TRUSTED_NAME\" && param.value.type === \"path\") {\n return {\n type: ClearSignContextReferenceType.TRUSTED_NAME,\n valuePath: this.toGenericPath(param.value.binary_path),\n types: param.types,\n sources: param.sources,\n };\n } else if (param.type === \"ENUM\" && param.value.type === \"path\") {\n return {\n type: ClearSignContextReferenceType.ENUM,\n valuePath: this.toGenericPath(param.value.binary_path),\n id: param.id,\n };\n } else if (\n param.type === \"CALLDATA\" &&\n param.value.type === \"path\" &&\n param.callee.type === \"path\"\n ) {\n return {\n type: ClearSignContextReferenceType.CALLDATA,\n valuePath: this.toGenericPath(param.value.binary_path),\n callee: this.toGenericPath(param.callee.binary_path),\n selector:\n param.selector?.type === \"path\"\n ? this.toGenericPath(param.selector.binary_path)\n : undefined,\n amount:\n param.amount?.type === \"path\"\n ? this.toGenericPath(param.amount.binary_path)\n : undefined,\n spender:\n param.spender?.type === \"path\"\n ? this.toGenericPath(param.spender.binary_path)\n : undefined,\n chainId:\n param.chainId?.type === \"path\"\n ? this.toGenericPath(param.chainId.binary_path)\n : undefined,\n };\n }\n return undefined;\n }\n\n private toGenericPath(\n path: CalldataDescriptorContainerPathV1 | CalldataDescriptorPathElementsV1,\n ): GenericPath {\n if (path.type === \"CONTAINER\") {\n return path.value;\n }\n return path.elements.map((element) => {\n if (element.type === \"ARRAY\") {\n const { weight: itemSize, ...rest } = element;\n return {\n itemSize,\n ...rest,\n };\n } else if (element.type === \"LEAF\") {\n const { leaf_type: leafType, ...rest } = element;\n return {\n leafType,\n ...rest,\n };\n }\n return element;\n });\n }\n\n private isCalldataDescriptorV1(\n data: CalldataDescriptor,\n mode: ContextModuleCalMode,\n ): data is CalldataDescriptorV1 & {\n transaction_info: {\n descriptor: {\n signatures: { [_key in ContextModuleCalMode]: string };\n };\n };\n } {\n return (\n typeof data === \"object\" &&\n data.type === \"calldata\" &&\n data.version === \"v1\" &&\n this.isTransactionInfoV1(data.transaction_info, mode) &&\n this.isEnumV1(data.enums, mode) &&\n Array.isArray(data.fields) &&\n data.fields.every((f) => this.isFieldV1(f))\n );\n }\n\n private isTransactionInfoV1(\n data: CalldataTransactionInfoV1,\n mode: ContextModuleCalMode,\n ): data is CalldataTransactionInfoV1 & {\n descriptor: {\n signatures: { [_key in ContextModuleCalMode]: string };\n };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.descriptor === \"object\" &&\n typeof data.descriptor.data === \"string\" &&\n typeof data.descriptor.signatures === \"object\" &&\n typeof data.descriptor.signatures[mode] === \"string\"\n );\n }\n\n private isEnumV1(\n calldata: CalldataEnumV1,\n mode: ContextModuleCalMode,\n ): calldata is CalldataEnumV1 {\n return (\n typeof calldata === \"object\" &&\n Object.entries(calldata).every(\n ([id, values]) =>\n typeof id === \"string\" &&\n typeof values === \"object\" &&\n Object.entries<CalldataTransactionDescriptor>(values).every(\n ([value, obj]) =>\n typeof value === \"string\" &&\n typeof obj === \"object\" &&\n typeof obj.data === \"string\" &&\n obj.signatures !== undefined &&\n this.isCalldataSignatures(obj.signatures, mode),\n ),\n )\n );\n }\n\n private isCalldataSignatures(\n data: CalldataSignatures,\n mode: ContextModuleCalMode,\n ): data is CalldataSignatures & { [_key in ContextModuleCalMode]: string } {\n return typeof data === \"object\" && typeof data[mode] === \"string\";\n }\n\n private isFieldV1(data: CalldataFieldV1): boolean {\n return (\n typeof data === \"object\" &&\n typeof data.descriptor === \"string\" &&\n typeof data.param === \"object\" &&\n typeof data.param.value === \"object\" &&\n this.isDescriptorValueV1(data.param.value) &&\n (data.param.type === \"RAW\" ||\n data.param.type === \"AMOUNT\" ||\n data.param.type === \"DATETIME\" ||\n data.param.type === \"DURATION\" ||\n data.param.type === \"UNIT\" ||\n data.param.type === \"ENUM\" ||\n (data.param.type === \"NFT\" &&\n this.isDescriptorValueV1(data.param.collection)) ||\n (data.param.type === \"TOKEN_AMOUNT\" &&\n (data.param.token === undefined ||\n this.isDescriptorValueV1(data.param.token))) ||\n (data.param.type === \"TRUSTED_NAME\" &&\n Array.isArray(data.param.types) &&\n Array.isArray(data.param.sources) &&\n data.param.types.every((t) => typeof t === \"string\") &&\n data.param.sources.every((t) => typeof t === \"string\")) ||\n (data.param.type === \"CALLDATA\" &&\n this.isDescriptorValueV1(data.param.value) &&\n this.isDescriptorValueV1(data.param.callee) &&\n (data.param.selector === undefined ||\n this.isDescriptorValueV1(data.param.selector)) &&\n (data.param.amount === undefined ||\n this.isDescriptorValueV1(data.param.amount)) &&\n (data.param.spender === undefined ||\n this.isDescriptorValueV1(data.param.spender)) &&\n (data.param.chainId === undefined ||\n this.isDescriptorValueV1(data.param.chainId))))\n );\n }\n\n private isDescriptorValueV1(data: CalldataDescriptorValueV1): boolean {\n return (\n typeof data === \"object\" &&\n typeof data.type_family === \"string\" &&\n [\n \"UINT\",\n \"INT\",\n \"UFIXED\",\n \"FIXED\",\n \"ADDRESS\",\n \"BOOL\",\n \"BYTES\",\n \"STRING\",\n ].includes(data.type_family) &&\n (typeof data.type_size === \"undefined\" ||\n typeof data.type_size === \"number\") &&\n ((data.type === \"path\" &&\n this.isCalldataDescriptorValueBinaryPathV1(data)) ||\n (data.type === \"constant\" &&\n this.isCalldataDescriptorValueConstantV1(data)))\n );\n }\n\n private isCalldataDescriptorValueConstantV1(\n data: CalldataDescriptorValueConstantV1,\n ): boolean {\n return (\n typeof data === \"object\" &&\n data.type === \"constant\" &&\n typeof data.value === \"string\"\n );\n }\n\n private isCalldataDescriptorValueBinaryPathV1(\n data: CalldataDescriptorValueBinaryPathV1,\n ): boolean {\n return (\n typeof data === \"object\" &&\n ((data.type === \"path\" &&\n data.binary_path.type === \"CONTAINER\" &&\n [\"FROM\", \"TO\", \"VALUE\"].includes(data.binary_path.value)) ||\n (data.binary_path.type === \"DATA\" &&\n Array.isArray(data.binary_path.elements) &&\n data.binary_path.elements.every((e) => this.isPathElementV1(e))))\n );\n }\n\n private isPathElementV1(data: CalldataDescriptorPathElementV1): boolean {\n return (\n typeof data === \"object\" &&\n (data.type === \"REF\" ||\n (data.type === \"TUPLE\" && typeof data.offset === \"number\") ||\n (data.type === \"ARRAY\" &&\n typeof data.weight === \"number\" &&\n (typeof data.start === \"undefined\" ||\n typeof data.start === \"number\") &&\n (typeof data.end === \"undefined\" || typeof data.end === \"number\")) ||\n (data.type === \"LEAF\" &&\n typeof data.leaf_type === \"string\" &&\n [\"ARRAY_LEAF\", \"TUPLE_LEAF\", \"STATIC_LEAF\", \"DYNAMIC_LEAF\"].includes(\n data.leaf_type,\n )) ||\n (data.type === \"SLICE\" &&\n (typeof data.start === \"undefined\" ||\n typeof data.start === \"number\") &&\n (typeof data.end === \"undef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AKPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,GAEzBF,EAAA,EAAAC,EAAOE,EAAS,oBAAoB,IAN5BpD",
6
- "names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "pkiTypes", "KeyId", "KeyUsage", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "ClearSignContextReferenceType", "ClearSignContextType", "INFO_SIGNATURE_TAG", "HexStringUtils", "PACKAGE", "HttpCalldataDescriptorDataSource", "config", "_certificateLoader", "endpoint", "chainId", "address", "selector", "deviceModelId", "dto", "axios", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "LEDGER_ORIGIN_TOKEN_HEADER", "error", "Left", "calldata", "calldataDescriptor", "infoData", "infoSignature", "certificateInfos", "KeyUsage", "KeyId", "certificate", "info", "ClearSignContextType", "HexStringUtils", "INFO_SIGNATURE_TAG", "enums", "id", "values", "value", "data", "signatures", "fields", "field", "Right", "param", "ClearSignContextReferenceType", "path", "element", "itemSize", "rest", "leafType", "mode", "f", "obj", "e", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes", "pkiTypes"]
4
+ "sourcesContent": ["import { DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport {\n type ContextModuleCalMode,\n type ContextModuleServiceConfig,\n} from \"@/config/model/ContextModuleConfig\";\nimport { networkTypes } from \"@/network/di/networkTypes\";\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport { PkiCertificateInfo } from \"@/pki/model/PkiCertificateInfo\";\nimport {\n ClearSignContextReference,\n ClearSignContextReferenceType,\n ClearSignContextSuccess,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { GenericPath } from \"@/shared/model/GenericPath\";\nimport { INFO_SIGNATURE_TAG } from \"@/shared/model/SignatureTags\";\nimport { HexStringUtils } from \"@/shared/utils/HexStringUtils\";\n\nimport {\n CalldataDescriptor,\n CalldataDescriptorContainerPathV1,\n CalldataDescriptorParam,\n CalldataDescriptorPathElementsV1,\n CalldataDescriptorPathElementV1,\n CalldataDescriptorV1,\n CalldataDescriptorValueBinaryPathV1,\n CalldataDescriptorValueConstantV1,\n CalldataDescriptorValueV1,\n CalldataDto,\n CalldataEnumV1,\n CalldataFieldV1,\n CalldataSignatures,\n CalldataTransactionDescriptor,\n CalldataTransactionInfoV1,\n} from \"./dto/CalldataDto\";\nimport {\n CalldataDescriptorDataSource,\n GetCalldataDescriptorsParams,\n} from \"./CalldataDescriptorDataSource\";\n\n@injectable()\nexport class HttpCalldataDescriptorDataSource\n implements CalldataDescriptorDataSource\n{\n constructor(\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly _certificateLoader: PkiCertificateLoader,\n private readonly endpoint: string,\n @inject(networkTypes.NetworkClient)\n private readonly http: DmkNetworkClient,\n ) {}\n\n public async getCalldataDescriptors({\n chainId,\n address,\n selector,\n deviceModelId,\n }: GetCalldataDescriptorsParams): Promise<\n Either<Error, ClearSignContextSuccess[]>\n > {\n let dto: CalldataDto[] | undefined;\n try {\n dto = (await this.http.get(`${this.config.cal.url}/${this.endpoint}`, {\n params: {\n output: \"descriptors_calldata\",\n chain_id: chainId,\n contracts: address,\n contract_address: address,\n ref: `branch:${this.config.cal.branch}`,\n },\n })) as CalldataDto[];\n } catch (error) {\n return Left(\n new Error(\n `[ContextModule] HttpCalldataDescriptorDataSource: Failed to fetch calldata descriptors: ${error}`,\n ),\n );\n }\n\n if (!Array.isArray(dto)) {\n return Left(\n new Error(\n `[ContextModule] HttpCalldataDescriptorDataSource: Response is not an array`,\n ),\n );\n }\n\n if (dto.length === 0) {\n return Left(\n new Error(\n `[ContextModule] HttpCalldataDescriptorDataSource: No data for contract ${address} and selector ${selector}`,\n ),\n );\n }\n\n for (const calldata of dto) {\n // Normalize the address and selector\n address = address.toLowerCase();\n selector = `0x${selector.slice(2).toLowerCase()}`;\n const calldataDescriptor =\n calldata.descriptors_calldata?.[address]?.[selector];\n\n if (\n !calldataDescriptor ||\n !this.isCalldataDescriptorV1(calldataDescriptor, this.config.cal.mode)\n ) {\n continue;\n }\n\n const infoData = calldataDescriptor.transaction_info.descriptor.data;\n const infoSignature =\n calldataDescriptor.transaction_info.descriptor.signatures[\n this.config.cal.mode\n ];\n\n const certificateInfos: PkiCertificateInfo = {\n targetDevice: deviceModelId,\n keyUsage: KeyUsage.Calldata,\n keyId: KeyId.CalCalldataKey,\n };\n const certificate: PkiCertificate | undefined =\n await this._certificateLoader.loadCertificate(certificateInfos);\n\n const info: ClearSignContextSuccess = {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: HexStringUtils.appendSignatureToPayload(\n infoData,\n infoSignature,\n INFO_SIGNATURE_TAG,\n ),\n certificate,\n };\n\n const enums: ClearSignContextSuccess[] = [];\n for (const [id, values] of Object.entries(calldataDescriptor.enums)) {\n for (const [\n value,\n { data, signatures },\n ] of Object.entries<CalldataTransactionDescriptor>(values)) {\n enums.push({\n type: ClearSignContextType.ENUM,\n id: Number(id),\n value: Number(value),\n payload: HexStringUtils.appendSignatureToPayload(\n data,\n signatures[this.config.cal.mode]!,\n INFO_SIGNATURE_TAG,\n ),\n certificate,\n });\n }\n }\n\n const fields: ClearSignContextSuccess[] = calldataDescriptor.fields.map(\n (field) => ({\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: field.descriptor,\n reference: this.getReference(field.param),\n }),\n );\n return Right([info, ...enums, ...fields]);\n }\n\n return Left(\n new Error(\n `[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract ${address} and selector ${selector}`,\n ),\n );\n }\n\n private getReference(\n param: CalldataDescriptorParam,\n ): ClearSignContextReference | undefined {\n if (\n param.type === \"TOKEN_AMOUNT\" &&\n param.token !== undefined &&\n param.token.type === \"path\"\n ) {\n return {\n type: ClearSignContextReferenceType.TOKEN,\n valuePath: this.toGenericPath(param.token.binary_path),\n };\n } else if (\n param.type === \"TOKEN_AMOUNT\" &&\n param.token !== undefined &&\n param.token.type === \"constant\"\n ) {\n return {\n type: ClearSignContextReferenceType.TOKEN,\n value: param.token.value,\n };\n } else if (param.type === \"NFT\" && param.collection.type === \"path\") {\n return {\n type: ClearSignContextReferenceType.NFT,\n valuePath: this.toGenericPath(param.collection.binary_path),\n };\n } else if (param.type === \"NFT\" && param.collection.type === \"constant\") {\n return {\n type: ClearSignContextReferenceType.NFT,\n value: param.collection.value,\n };\n } else if (param.type === \"TRUSTED_NAME\" && param.value.type === \"path\") {\n return {\n type: ClearSignContextReferenceType.TRUSTED_NAME,\n valuePath: this.toGenericPath(param.value.binary_path),\n types: param.types,\n sources: param.sources,\n };\n } else if (param.type === \"ENUM\" && param.value.type === \"path\") {\n return {\n type: ClearSignContextReferenceType.ENUM,\n valuePath: this.toGenericPath(param.value.binary_path),\n id: param.id,\n };\n } else if (\n param.type === \"CALLDATA\" &&\n param.value.type === \"path\" &&\n param.callee.type === \"path\"\n ) {\n return {\n type: ClearSignContextReferenceType.CALLDATA,\n valuePath: this.toGenericPath(param.value.binary_path),\n callee: this.toGenericPath(param.callee.binary_path),\n selector:\n param.selector?.type === \"path\"\n ? this.toGenericPath(param.selector.binary_path)\n : undefined,\n amount:\n param.amount?.type === \"path\"\n ? this.toGenericPath(param.amount.binary_path)\n : undefined,\n spender:\n param.spender?.type === \"path\"\n ? this.toGenericPath(param.spender.binary_path)\n : undefined,\n chainId:\n param.chainId?.type === \"path\"\n ? this.toGenericPath(param.chainId.binary_path)\n : undefined,\n };\n }\n return undefined;\n }\n\n private toGenericPath(\n path: CalldataDescriptorContainerPathV1 | CalldataDescriptorPathElementsV1,\n ): GenericPath {\n if (path.type === \"CONTAINER\") {\n return path.value;\n }\n return path.elements.map((element) => {\n if (element.type === \"ARRAY\") {\n const { weight: itemSize, ...rest } = element;\n return {\n itemSize,\n ...rest,\n };\n } else if (element.type === \"LEAF\") {\n const { leaf_type: leafType, ...rest } = element;\n return {\n leafType,\n ...rest,\n };\n }\n return element;\n });\n }\n\n private isCalldataDescriptorV1(\n data: CalldataDescriptor,\n mode: ContextModuleCalMode,\n ): data is CalldataDescriptorV1 & {\n transaction_info: {\n descriptor: {\n signatures: { [_key in ContextModuleCalMode]: string };\n };\n };\n } {\n return (\n typeof data === \"object\" &&\n data.type === \"calldata\" &&\n data.version === \"v1\" &&\n this.isTransactionInfoV1(data.transaction_info, mode) &&\n this.isEnumV1(data.enums, mode) &&\n Array.isArray(data.fields) &&\n data.fields.every((f) => this.isFieldV1(f))\n );\n }\n\n private isTransactionInfoV1(\n data: CalldataTransactionInfoV1,\n mode: ContextModuleCalMode,\n ): data is CalldataTransactionInfoV1 & {\n descriptor: {\n signatures: { [_key in ContextModuleCalMode]: string };\n };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.descriptor === \"object\" &&\n typeof data.descriptor.data === \"string\" &&\n typeof data.descriptor.signatures === \"object\" &&\n typeof data.descriptor.signatures[mode] === \"string\"\n );\n }\n\n private isEnumV1(\n calldata: CalldataEnumV1,\n mode: ContextModuleCalMode,\n ): calldata is CalldataEnumV1 {\n return (\n typeof calldata === \"object\" &&\n Object.entries(calldata).every(\n ([id, values]) =>\n typeof id === \"string\" &&\n typeof values === \"object\" &&\n Object.entries<CalldataTransactionDescriptor>(values).every(\n ([value, obj]) =>\n typeof value === \"string\" &&\n typeof obj === \"object\" &&\n typeof obj.data === \"string\" &&\n obj.signatures !== undefined &&\n this.isCalldataSignatures(obj.signatures, mode),\n ),\n )\n );\n }\n\n private isCalldataSignatures(\n data: CalldataSignatures,\n mode: ContextModuleCalMode,\n ): data is CalldataSignatures & { [_key in ContextModuleCalMode]: string } {\n return typeof data === \"object\" && typeof data[mode] === \"string\";\n }\n\n private isFieldV1(data: CalldataFieldV1): boolean {\n return (\n typeof data === \"object\" &&\n typeof data.descriptor === \"string\" &&\n typeof data.param === \"object\" &&\n typeof data.param.value === \"object\" &&\n this.isDescriptorValueV1(data.param.value) &&\n (data.param.type === \"RAW\" ||\n data.param.type === \"AMOUNT\" ||\n data.param.type === \"DATETIME\" ||\n data.param.type === \"DURATION\" ||\n data.param.type === \"UNIT\" ||\n data.param.type === \"ENUM\" ||\n (data.param.type === \"NFT\" &&\n this.isDescriptorValueV1(data.param.collection)) ||\n (data.param.type === \"TOKEN_AMOUNT\" &&\n (data.param.token === undefined ||\n this.isDescriptorValueV1(data.param.token))) ||\n (data.param.type === \"TRUSTED_NAME\" &&\n Array.isArray(data.param.types) &&\n Array.isArray(data.param.sources) &&\n data.param.types.every((t) => typeof t === \"string\") &&\n data.param.sources.every((t) => typeof t === \"string\")) ||\n (data.param.type === \"CALLDATA\" &&\n this.isDescriptorValueV1(data.param.value) &&\n this.isDescriptorValueV1(data.param.callee) &&\n (data.param.selector === undefined ||\n this.isDescriptorValueV1(data.param.selector)) &&\n (data.param.amount === undefined ||\n this.isDescriptorValueV1(data.param.amount)) &&\n (data.param.spender === undefined ||\n this.isDescriptorValueV1(data.param.spender)) &&\n (data.param.chainId === undefined ||\n this.isDescriptorValueV1(data.param.chainId))))\n );\n }\n\n private isDescriptorValueV1(data: CalldataDescriptorValueV1): boolean {\n return (\n typeof data === \"object\" &&\n typeof data.type_family === \"string\" &&\n [\n \"UINT\",\n \"INT\",\n \"UFIXED\",\n \"FIXED\",\n \"ADDRESS\",\n \"BOOL\",\n \"BYTES\",\n \"STRING\",\n ].includes(data.type_family) &&\n (typeof data.type_size === \"undefined\" ||\n typeof data.type_size === \"number\") &&\n ((data.type === \"path\" &&\n this.isCalldataDescriptorValueBinaryPathV1(data)) ||\n (data.type === \"constant\" &&\n this.isCalldataDescriptorValueConstantV1(data)))\n );\n }\n\n private isCalldataDescriptorValueConstantV1(\n data: CalldataDescriptorValueConstantV1,\n ): boolean {\n return (\n typeof data === \"object\" &&\n data.type === \"constant\" &&\n typeof data.value === \"string\"\n );\n }\n\n private isCalldataDescriptorValueBinaryPathV1(\n data: CalldataDescriptorValueBinaryPathV1,\n ): boolean {\n return (\n typeof data === \"object\" &&\n ((data.type === \"path\" &&\n data.binary_path.type === \"CONTAINER\" &&\n [\"FROM\", \"TO\", \"VALUE\"].includes(data.binary_path.value)) ||\n (data.binary_path.type === \"DATA\" &&\n Array.isArray(data.binary_path.elements) &&\n data.binary_path.elements.every((e) => this.isPathElementV1(e))))\n );\n }\n\n private isPathElementV1(data: CalldataDescriptorPathElementV1): boolean {\n return (\n typeof data === \"object\" &&\n (data.type === \"REF\" ||\n (data.type === \"TUPLE\" && typeof data.offset === \"number\") ||\n (data.type === \"ARRAY\" &&\n typeof data.weight === \"number\" &&\n (typeof data.start === \"undefined\" ||\n typeof data.start === \"number\") &&\n (typeof data.end === \"undefined\" || typeof data.end === \"number\")) ||\n (data.type === \"LEAF\" &&\n typeof data.leaf_type === \"string\" &&\n [\"ARRAY_LEAF\", \"TUPLE_LEAF\", \"STATIC_LEAF\", \"DYNAMIC_LEAF\"].includes(\n data.leaf_type,\n )) ||\n (data.type === \"SLICE\" &&\n (typeof data.start === \"undefined\" ||\n typeof data.start === \"number\") &&\n (typeof data.end === \"undefined\" || typeof data.end === \"number\")))\n );\n }\n}\n"],
5
+ "mappings": "iOACA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAK5B,OAAS,gBAAAC,MAAoB,4BAC7B,OAAS,YAAAC,MAAgB,oBAEzB,OAAS,SAAAC,MAAa,oBACtB,OAAS,YAAAC,MAAgB,uBAGzB,OAEE,iCAAAC,EAEA,wBAAAC,MACK,kCAEP,OAAS,sBAAAC,MAA0B,+BACnC,OAAS,kBAAAC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,KAAM,OAAO,EAAE,SAASA,EAAK,YAAY,KAAK,GACtDA,EAAK,YAAY,OAAS,QACzB,MAAM,QAAQA,EAAK,YAAY,QAAQ,GACvCA,EAAK,YAAY,SAAS,MAAOe,GAAM,KAAK,gBAAgBA,CAAC,CAAC,EAEtE,CAEQ,gBAAgBf,EAAgD,CACtE,OACE,OAAOA,GAAS,WACfA,EAAK,OAAS,OACZA,EAAK,OAAS,SAAW,OAAOA,EAAK,QAAW,UAChDA,EAAK,OAAS,SACb,OAAOA,EAAK,QAAW,WACtB,OAAOA,EAAK,MAAU,KACrB,OAAOA,EAAK,OAAU,YACvB,OAAOA,EAAK,IAAQ,KAAe,OAAOA,EAAK,KAAQ,WACzDA,EAAK,OAAS,QACb,OAAOA,EAAK,WAAc,UAC1B,CAAC,aAAc,aAAc,cAAe,cAAc,EAAE,SAC1DA,EAAK,SACP,GACDA,EAAK,OAAS,UACZ,OAAOA,EAAK,MAAU,KACrB,OAAOA,EAAK,OAAU,YACvB,OAAOA,EAAK,IAAQ,KAAe,OAAOA,EAAK,KAAQ,UAEhE,CACF,EAjZa5B,EAAN4C,EAAA,CADNC,EAAW,EAKPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,GAEzBF,EAAA,EAAAC,EAAOE,EAAS,oBAAoB,GAGpCH,EAAA,EAAAC,EAAOG,EAAa,aAAa,IATzBlD",
6
+ "names": ["inject", "injectable", "Left", "Right", "configTypes", "networkTypes", "pkiTypes", "KeyId", "KeyUsage", "ClearSignContextReferenceType", "ClearSignContextType", "INFO_SIGNATURE_TAG", "HexStringUtils", "HttpCalldataDescriptorDataSource", "config", "_certificateLoader", "endpoint", "http", "chainId", "address", "selector", "deviceModelId", "dto", "error", "Left", "calldata", "calldataDescriptor", "infoData", "infoSignature", "certificateInfos", "KeyUsage", "KeyId", "certificate", "info", "ClearSignContextType", "HexStringUtils", "INFO_SIGNATURE_TAG", "enums", "id", "values", "value", "data", "signatures", "fields", "field", "Right", "param", "ClearSignContextReferenceType", "path", "element", "itemSize", "rest", "leafType", "mode", "f", "obj", "e", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes", "pkiTypes", "networkTypes"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{DeviceModelId as o}from"@ledgerhq/device-management-kit";import t from"axios";import{Left as i}from"purify-ts";import{LEDGER_CLIENT_VERSION_HEADER as A,LEDGER_ORIGIN_TOKEN_HEADER as h}from"../../shared/constant/HttpHeaders";import T from"../../../package.json";import{HttpCalldataDescriptorDataSource as I}from"./HttpCalldataDescriptorDataSource";vi.mock("axios");const C={cal:{url:"https://crypto-assets-service.api.ledger.com/v1",mode:"test",branch:"main"},originToken:"originToken"};describe("HttpCalldataDescriptorDataSource",()=>{let d,l,u,n,v,E,p,f,b,y,m,x;const c={loadCertificate:vi.fn()};beforeAll(()=>{vi.clearAllMocks(),d=new I(C,c,"dapps"),l={descriptor:{data:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c",signatures:{test:"3045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f"}}},u={0:{1:{data:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec0401000501010606737461626c65",signatures:{test:"3045022100862e724db664f5d94484928a6a5963268a22cd8178ad36e8c4ff13769ac5c27e0220079da2b6e86810156f6b5955b8190bc016c2fe813d27fcb878a9b99658546582"}},2:{data:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04010005010206087661726961626c65",signatures:{test:"3045022100b838ee3d597d6bad2533606cef7335f6c8a45b46d5717803e646777f6c8a6897022074f04b82c3dad8445bb6230ab762010c5fc6ee06198fd3e54752287cbf95c523"}}}},p=D("FROM","UFIXED","AMOUNT","06"),f=D("TO","FIXED","DATETIME","07"),b=D("TO","BOOL","UNIT","08"),y=D("VALUE","INT","DURATION","09"),n={param:{value:{type:"path",binary_path:{type:"DATA",elements:[{type:"ARRAY",start:0,end:5,weight:1},{type:"LEAF",leaf_type:"DYNAMIC_LEAF"}]},type_family:"ADDRESS",type_size:20},type:"TOKEN_AMOUNT",token:{type:"path",binary_path:{type:"DATA",elements:[{type:"ARRAY",start:0,end:5,weight:1},{type:"LEAF",leaf_type:"DYNAMIC_LEAF"}]},type_family:"ADDRESS",type_size:20}},descriptor:"0001000112416d6f756e7420746f20776974686472617702010203580001000115000100010101020120030a000100010200010401030215000100010105020114030a000100010200000401030420ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff05034d6178"},v={param:{value:{type:"path",binary_path:{type:"CONTAINER",value:"TO"},type_family:"STRING",type_size:20},type:"TRUSTED_NAME",types:["eoa"],sources:["ens","unstoppable_domain"]},descriptor:"000100010c546f20726563697069656e7402010803230001000115000100010105020114030a00010001020002040103020101030402030402"},E={param:{value:{type:"path",binary_path:{type:"DATA",elements:[{type:"ARRAY",weight:2},{type:"LEAF",leaf_type:"TUPLE_LEAF"},{type:"SLICE",end:2}]},type_family:"BYTES",type_size:20},collection:{type:"path",binary_path:{type:"DATA",elements:[{type:"REF"},{type:"LEAF",leaf_type:"ARRAY_LEAF"},{type:"SLICE",start:1}]},type_family:"INT",type_size:20},type:"NFT"},descriptor:"000100010c546f20726563697069656e7402010803230001000115000100010105020114"},m={param:{id:0,value:{type:"path",binary_path:{type:"DATA",elements:[]},type_family:"BYTES",type_size:20},type:"ENUM"},descriptor:"000100010c546f20726563697069656e7402010803230001000115000100010105020112"},x={param:{value:{type:"path",binary_path:{type:"DATA",elements:[{type:"TUPLE",offset:0},{type:"LEAF",leaf_type:"STATIC_LEAF"}]},type_family:"BYTES",type_size:32},callee:{type:"path",binary_path:{type:"DATA",elements:[{type:"ARRAY",weight:1},{type:"LEAF",leaf_type:"DYNAMIC_LEAF"}]},type_family:"ADDRESS",type_size:20},selector:{type:"path",binary_path:{type:"CONTAINER",value:"FROM"},type_family:"BYTES",type_size:4},amount:{type:"path",binary_path:{type:"DATA",elements:[{type:"REF"},{type:"LEAF",leaf_type:"TUPLE_LEAF"}]},type_family:"UINT",type_size:32},spender:{type:"path",binary_path:{type:"DATA",elements:[{type:"SLICE",start:0,end:20},{type:"LEAF",leaf_type:"ARRAY_LEAF"}]},type_family:"ADDRESS",type_size:20},type:"CALLDATA"},descriptor:"000100010c43616c6c64617461207465737402010803230001000115000100010105020114"}});function D(a,e,r,F){return{param:{value:{type:"path",binary_path:{type:"CONTAINER",value:a},type_family:e,type_size:32},type:r},descriptor:F}}function s(a,e,r){return{descriptors_calldata:{"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9":{"0x69328dec":{type:"calldata",version:"v1",transaction_info:a,enums:e,fields:r}}}}}it("should call axios with the ledger client version header",async()=>{const a=`context-module/${T.version}`,e=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(t,"request").mockImplementation(e),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0),await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x0abc",selector:"0x01ff"}),expect(e).toHaveBeenCalledWith(expect.objectContaining({headers:{[A]:a,[h]:C.originToken}}))}),it.each([["dapps"],["tokens"]])("should call axios with the correct url for endpoint '%s'",async a=>{const e=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(t,"request").mockImplementation(e),await new I(C,c,a).getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x0abc",selector:"0x01ff"}),expect(e).toHaveBeenCalledWith(expect.objectContaining({url:`https://crypto-assets-service.api.ledger.com/v1/${a}`}))}),it("should return an error when axios throws an error",async()=>{vi.spyOn(t,"request").mockRejectedValue(new Error),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const a=await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x0abc",selector:"0x01ff"});expect(a).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Failed to fetch calldata descriptors: Error")))}),it("should return an error when no payload is returned",async()=>{const a={data:{test:""}};vi.spyOn(t,"request").mockResolvedValue(a),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const e=await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Response is not an array")))}),it("should return an error when an empty array is returned",async()=>{vi.spyOn(t,"request").mockResolvedValue({data:[]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const a=await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x0abc",selector:"0x01ff"});expect(a).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: No data for contract 0x0abc and selector 0x01ff")))}),it("should return an error when selector is not found",async()=>{const a=s(l,u,[n]);vi.spyOn(t,"request").mockResolvedValue({data:[a]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const e=await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x01fe"});expect(e).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x01fe")))}),it("Calldata with fields references and enums",async()=>{const a=s(l,u,[n,v,E,m]);vi.spyOn(t,"request").mockResolvedValue({data:[a]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const e=await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80B7a3454c06bdac94a69ddc7a9",selector:"0x69328dEc"});expect(e.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{payload:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec0401000501010606737461626c6581ff473045022100862e724db664f5d94484928a6a5963268a22cd8178ad36e8c4ff13769ac5c27e0220079da2b6e86810156f6b5955b8190bc016c2fe813d27fcb878a9b99658546582",type:"enum",id:0,value:1},{payload:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04010005010206087661726961626c6581ff473045022100b838ee3d597d6bad2533606cef7335f6c8a45b46d5717803e646777f6c8a6897022074f04b82c3dad8445bb6230ab762010c5fc6ee06198fd3e54752287cbf95c523",type:"enum",id:0,value:2},{payload:n.descriptor,type:"transactionFieldDescription",reference:{type:"token",valuePath:[{type:"ARRAY",start:0,end:5,itemSize:1},{type:"LEAF",leafType:"DYNAMIC_LEAF"}]}},{payload:v.descriptor,type:"transactionFieldDescription",reference:{type:"trustedName",valuePath:"TO",types:["eoa"],sources:["ens","unstoppable_domain"]}},{payload:E.descriptor,type:"transactionFieldDescription",reference:{type:"nft",valuePath:[{type:"REF"},{type:"LEAF",leafType:"ARRAY_LEAF"},{type:"SLICE",start:1}]}},{payload:m.descriptor,type:"transactionFieldDescription",reference:{type:"enum",valuePath:[],id:0}}])}),it("Calldata with fields references and enums with certificates",async()=>{const a=s(l,u,[n,v,E,m]),e={keyUsageNumber:11,payload:new Uint8Array([1,2,3,4,21,4,5,6,7,8])};vi.spyOn(t,"request").mockResolvedValue({data:[a]}),vi.spyOn(c,"loadCertificate").mockResolvedValueOnce(e);const r=await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80B7a3454c06bdac94a69ddc7a9",selector:"0x69328dEc"});expect(r.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo",certificate:e},{payload:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec0401000501010606737461626c6581ff473045022100862e724db664f5d94484928a6a5963268a22cd8178ad36e8c4ff13769ac5c27e0220079da2b6e86810156f6b5955b8190bc016c2fe813d27fcb878a9b99658546582",type:"enum",id:0,value:1,certificate:e},{payload:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04010005010206087661726961626c6581ff473045022100b838ee3d597d6bad2533606cef7335f6c8a45b46d5717803e646777f6c8a6897022074f04b82c3dad8445bb6230ab762010c5fc6ee06198fd3e54752287cbf95c523",type:"enum",id:0,value:2,certificate:e},{payload:n.descriptor,type:"transactionFieldDescription",reference:{type:"token",valuePath:[{type:"ARRAY",start:0,end:5,itemSize:1},{type:"LEAF",leafType:"DYNAMIC_LEAF"}]}},{payload:v.descriptor,type:"transactionFieldDescription",reference:{type:"trustedName",valuePath:"TO",types:["eoa"],sources:["ens","unstoppable_domain"]}},{payload:E.descriptor,type:"transactionFieldDescription",reference:{type:"nft",valuePath:[{type:"REF"},{type:"LEAF",leafType:"ARRAY_LEAF"},{type:"SLICE",start:1}]}},{payload:m.descriptor,type:"transactionFieldDescription",reference:{type:"enum",valuePath:[],id:0}}])}),it("Calldata without fields references",async()=>{const a=s(l,[],[p,f,b,y]);vi.spyOn(t,"request").mockResolvedValue({data:[a]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const e=await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{type:"transactionFieldDescription",payload:p.descriptor},{type:"transactionFieldDescription",payload:f.descriptor},{type:"transactionFieldDescription",payload:b.descriptor},{type:"transactionFieldDescription",payload:y.descriptor}])}),it("Calldata on third array element",async()=>{const a=s(l,[],[p,f,b,y]);vi.spyOn(t,"request").mockResolvedValue({data:[{},{},a]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const e=await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{type:"transactionFieldDescription",payload:p.descriptor},{type:"transactionFieldDescription",payload:f.descriptor},{type:"transactionFieldDescription",payload:b.descriptor},{type:"transactionFieldDescription",payload:y.descriptor}])}),it("Calldata without fields references and transaction info signature length % 2 different from 0",async()=>{const a={descriptor:{data:l.descriptor.data,signatures:{test:l.descriptor.signatures.test+"0"}}},e=s(a,[],[p,f,b,y]);vi.spyOn(t,"request").mockResolvedValue({data:[e]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const r=await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(r.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff4803045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f0",type:"transactionInfo"},{type:"transactionFieldDescription",payload:p.descriptor},{type:"transactionFieldDescription",payload:f.descriptor},{type:"transactionFieldDescription",payload:b.descriptor},{type:"transactionFieldDescription",payload:y.descriptor}])}),it("Calldata with token fields references as constants",async()=>{const a={name:"Amount to exchange",param:{type:"TOKEN_AMOUNT",token:{raw:"0xae7ab96520de3a18e5e111b5eaab095312d7fe84",type:"constant",value:"0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84",version:1,type_size:20,type_family:"ADDRESS"},value:{type:"path",version:1,abi_path:{type:"data",absolute:!0,elements:[{type:"field",identifier:"_stETHAmount"}]},type_size:32,binary_path:{type:"DATA",version:1,elements:[{type:"TUPLE",offset:0},{type:"LEAF",leaf_type:"STATIC_LEAF"}]},type_family:"UINT"},version:1},version:1,descriptor:"0001010112416d6f756e7420746f2065786368616e6765020102033b0001010115000101010101020120030a00010101020000040103021f0001010101050201140514ae7ab96520de3a18e5e111b5eaab095312d7fe84"},e=s(l,[],[a]);vi.spyOn(t,"request").mockResolvedValue({data:[e]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const r=await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(r.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{payload:a.descriptor,type:"transactionFieldDescription",reference:{type:"token",value:"0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84"}}])}),it("Calldata with collection fields references as constants",async()=>{const a={name:"Collection ID",param:{type:"NFT",collection:{raw:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",type:"constant",value:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",version:1,type_size:20,type_family:"ADDRESS"},value:{type:"path",version:1,abi_path:{type:"data",absolute:!0,elements:[{type:"field",identifier:"_collectionId"}]},type_size:20,binary_path:{type:"DATA",version:1,elements:[{type:"ARRAY",weight:2},{type:"LEAF",leaf_type:"TUPLE_LEAF"},{type:"SLICE",end:2}]},type_family:"BYTES"},version:1},version:1,descriptor:"0001010112416d6f756e7420746f2065786368616e6765020102033b0001010115000101010101020120030a00010101020000040103021f00010101010502011405147d2768de32b0b80b7a3454c06bdac94a69ddc7a9"},e=s(l,[],[a]);vi.spyOn(t,"request").mockResolvedValue({data:[e]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const r=await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(r.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{payload:a.descriptor,type:"transactionFieldDescription",reference:{type:"nft",value:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9"}}])}),it("Calldata with CALLDATA fields references",async()=>{const a=s(l,[],[x]);vi.spyOn(t,"request").mockResolvedValue({data:[a]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const e=await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{payload:x.descriptor,type:"transactionFieldDescription",reference:{type:"calldata",valuePath:[{type:"TUPLE",offset:0},{type:"LEAF",leafType:"STATIC_LEAF"}],callee:[{type:"ARRAY",itemSize:1},{type:"LEAF",leafType:"DYNAMIC_LEAF"}],selector:"FROM",amount:[{type:"REF"},{type:"LEAF",leafType:"TUPLE_LEAF"}],spender:[{type:"SLICE",start:0,end:20},{type:"LEAF",leafType:"ARRAY_LEAF"}]}}])}),it("Calldata with CALLDATA fields references without optional properties",async()=>{const a={param:{value:{type:"path",binary_path:{type:"DATA",elements:[{type:"TUPLE",offset:0},{type:"LEAF",leaf_type:"STATIC_LEAF"}]},type_family:"BYTES",type_size:32},callee:{type:"path",binary_path:{type:"DATA",elements:[{type:"TUPLE",offset:0},{type:"LEAF",leaf_type:"STATIC_LEAF"}]},type_family:"BYTES",type_size:32},type:"CALLDATA"},descriptor:"000100010c43616c6c64617461207465737402010803230001000115000100010105020114"},e=s(l,[],[a]);vi.spyOn(t,"request").mockResolvedValue({data:[e]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const r=await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(r.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{payload:a.descriptor,type:"transactionFieldDescription",reference:{type:"calldata",valuePath:[{type:"TUPLE",offset:0},{type:"LEAF",leafType:"STATIC_LEAF"}],callee:[{type:"TUPLE",offset:0},{type:"LEAF",leafType:"STATIC_LEAF"}],selector:void 0,amount:void 0,spender:void 0,chainId:void 0}}])}),it("should return an error when calldata is not correctly formatted",async()=>{const a={descriptors_calldata:{"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9":{"0x69328dec":{type:"calldat",version:"v1",transaction_info:l,enums:u,fields:[n]}}}};vi.spyOn(t,"request").mockResolvedValue({data:[a]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const e=await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when transactionInfo is not correctly formatted",async()=>{const a=s({descriptor:{data:"1234",signatures:{prod:"1234"}}},u,[n]);vi.spyOn(t,"request").mockResolvedValue({data:[a]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const e=await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when enum is not correctly formatted",async()=>{const a=s(l,["badEnum"],[n]);vi.spyOn(t,"request").mockResolvedValue({data:[a]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const e=await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when enum does not contain a signature",async()=>{const a=s(l,{0:{1:{data:"1234"}}},[n]);vi.spyOn(t,"request").mockResolvedValue({data:[a]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const e=await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when enum contain the wrong signature",async()=>{const a=s(l,{0:{1:{data:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04010005010106067374626c65",signatures:{prod:"wrongSignature"}}}},[n]);vi.spyOn(t,"request").mockResolvedValue({data:[a]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const e=await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field is not correctly formatted",async()=>{const a=s(l,[],[{descriptor:3}]);vi.spyOn(t,"request").mockResolvedValue({data:[a]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const e=await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field value is not correctly formatted",async()=>{const e=s(l,[],[{param:{value:{binary_path:"TO",type_family:"UNKNOWN",type_size:20},type:"DATETIME"},descriptor:"000100010c546f20726563697069667"}]);vi.spyOn(t,"request").mockResolvedValue({data:[e]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const r=await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(r).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field container path is not correctly formatted",async()=>{const e=s(l,[],[{param:{value:{binary_path:"UNKNOWN",type_family:"ADDRESS",type_size:20},type:"DATETIME"},descriptor:"000100010c546f20726563697069667"}]);vi.spyOn(t,"request").mockResolvedValue({data:[e]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const r=await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(r).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field calldata path is not correctly formatted",async()=>{const e=s(l,[],[{param:{value:{binary_path:{elements:[{type:"UNKNOWN"}]},type_family:"ADDRESS",type_size:20},type:"DATETIME"},descriptor:"000100010c546f20726563697069667"}]);vi.spyOn(t,"request").mockResolvedValue({data:[e]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const r=await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(r).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field type is not correctly formatted",async()=>{const e=s(l,[],[{param:{value:{binary_path:"TO",type_family:"ADDRESS",type_size:20},type:"UNKNOWN"},descriptor:"000100010c546f20726563697069667"}]);vi.spyOn(t,"request").mockResolvedValue({data:[e]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const r=await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(r).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should call axios with the correct headers",async()=>{vi.spyOn(t,"request").mockResolvedValueOnce({data:{}}),await d.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"}),expect(t.request).toHaveBeenCalledWith(expect.objectContaining({headers:{[A]:`context-module/${T.version}`,[h]:C.originToken}}))})});
1
+ import{DeviceModelId as o}from"@ledgerhq/device-management-kit";import{Left as i}from"purify-ts";import{HttpCalldataDescriptorDataSource as x}from"./HttpCalldataDescriptorDataSource";const C={cal:{url:"https://crypto-assets-service.api.ledger.com/v1",mode:"test",branch:"main"},originToken:"originToken"};describe("HttpCalldataDescriptorDataSource",()=>{let c,t,r,u,s,E,m,f,p,b,y,D,A;const d={loadCertificate:vi.fn()};beforeEach(()=>{t={get:vi.fn()},c=new x(C,d,"dapps",t)}),beforeAll(()=>{vi.clearAllMocks(),r={descriptor:{data:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c",signatures:{test:"3045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f"}}},u={0:{1:{data:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec0401000501010606737461626c65",signatures:{test:"3045022100862e724db664f5d94484928a6a5963268a22cd8178ad36e8c4ff13769ac5c27e0220079da2b6e86810156f6b5955b8190bc016c2fe813d27fcb878a9b99658546582"}},2:{data:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04010005010206087661726961626c65",signatures:{test:"3045022100b838ee3d597d6bad2533606cef7335f6c8a45b46d5717803e646777f6c8a6897022074f04b82c3dad8445bb6230ab762010c5fc6ee06198fd3e54752287cbf95c523"}}}},f=v("FROM","UFIXED","AMOUNT","06"),p=v("TO","FIXED","DATETIME","07"),b=v("TO","BOOL","UNIT","08"),y=v("VALUE","INT","DURATION","09"),s={param:{value:{type:"path",binary_path:{type:"DATA",elements:[{type:"ARRAY",start:0,end:5,weight:1},{type:"LEAF",leaf_type:"DYNAMIC_LEAF"}]},type_family:"ADDRESS",type_size:20},type:"TOKEN_AMOUNT",token:{type:"path",binary_path:{type:"DATA",elements:[{type:"ARRAY",start:0,end:5,weight:1},{type:"LEAF",leaf_type:"DYNAMIC_LEAF"}]},type_family:"ADDRESS",type_size:20}},descriptor:"0001000112416d6f756e7420746f20776974686472617702010203580001000115000100010101020120030a000100010200010401030215000100010105020114030a000100010200000401030420ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff05034d6178"},E={param:{value:{type:"path",binary_path:{type:"CONTAINER",value:"TO"},type_family:"STRING",type_size:20},type:"TRUSTED_NAME",types:["eoa"],sources:["ens","unstoppable_domain"]},descriptor:"000100010c546f20726563697069656e7402010803230001000115000100010105020114030a00010001020002040103020101030402030402"},m={param:{value:{type:"path",binary_path:{type:"DATA",elements:[{type:"ARRAY",weight:2},{type:"LEAF",leaf_type:"TUPLE_LEAF"},{type:"SLICE",end:2}]},type_family:"BYTES",type_size:20},collection:{type:"path",binary_path:{type:"DATA",elements:[{type:"REF"},{type:"LEAF",leaf_type:"ARRAY_LEAF"},{type:"SLICE",start:1}]},type_family:"INT",type_size:20},type:"NFT"},descriptor:"000100010c546f20726563697069656e7402010803230001000115000100010105020114"},D={param:{id:0,value:{type:"path",binary_path:{type:"DATA",elements:[]},type_family:"BYTES",type_size:20},type:"ENUM"},descriptor:"000100010c546f20726563697069656e7402010803230001000115000100010105020112"},A={param:{value:{type:"path",binary_path:{type:"DATA",elements:[{type:"TUPLE",offset:0},{type:"LEAF",leaf_type:"STATIC_LEAF"}]},type_family:"BYTES",type_size:32},callee:{type:"path",binary_path:{type:"DATA",elements:[{type:"ARRAY",weight:1},{type:"LEAF",leaf_type:"DYNAMIC_LEAF"}]},type_family:"ADDRESS",type_size:20},selector:{type:"path",binary_path:{type:"CONTAINER",value:"FROM"},type_family:"BYTES",type_size:4},amount:{type:"path",binary_path:{type:"DATA",elements:[{type:"REF"},{type:"LEAF",leaf_type:"TUPLE_LEAF"}]},type_family:"UINT",type_size:32},spender:{type:"path",binary_path:{type:"DATA",elements:[{type:"SLICE",start:0,end:20},{type:"LEAF",leaf_type:"ARRAY_LEAF"}]},type_family:"ADDRESS",type_size:20},type:"CALLDATA"},descriptor:"000100010c43616c6c64617461207465737402010803230001000115000100010105020114"}});function v(e,a,l,h){return{param:{value:{type:"path",binary_path:{type:"CONTAINER",value:e},type_family:a,type_size:32},type:l},descriptor:h}}function n(e,a,l){return{descriptors_calldata:{"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9":{"0x69328dec":{type:"calldata",version:"v1",transaction_info:e,enums:a,fields:l}}}}}it.each([["dapps"],["tokens"]])("should call http.get with the correct url for endpoint '%s'",async e=>{t.get.mockResolvedValue([]),await new x(C,d,e,t).getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x0abc",selector:"0x01ff"}),expect(t.get).toHaveBeenCalledWith(`${C.cal.url}/${e}`,{params:{output:"descriptors_calldata",chain_id:1,contracts:"0x0abc",contract_address:"0x0abc",ref:`branch:${C.cal.branch}`}})}),it("should return an error when http.get throws an error",async()=>{t.get.mockRejectedValue(new Error("boom")),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const e=await c.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Failed to fetch calldata descriptors: Error: boom")))}),it("should return an error when no payload is returned",async()=>{t.get.mockResolvedValue({test:""}),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const e=await c.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Response is not an array")))}),it("should return an error when an empty array is returned",async()=>{t.get.mockResolvedValue([]),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const e=await c.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: No data for contract 0x0abc and selector 0x01ff")))}),it("should return an error when selector is not found",async()=>{const e=n(r,u,[s]);t.get.mockResolvedValue([e]),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const a=await c.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x01fe"});expect(a).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x01fe")))}),it("Calldata with fields references and enums",async()=>{const e=n(r,u,[s,E,m,D]);t.get.mockResolvedValue([e]),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const a=await c.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80B7a3454c06bdac94a69ddc7a9",selector:"0x69328dEc"});expect(a.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{payload:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec0401000501010606737461626c6581ff473045022100862e724db664f5d94484928a6a5963268a22cd8178ad36e8c4ff13769ac5c27e0220079da2b6e86810156f6b5955b8190bc016c2fe813d27fcb878a9b99658546582",type:"enum",id:0,value:1},{payload:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04010005010206087661726961626c6581ff473045022100b838ee3d597d6bad2533606cef7335f6c8a45b46d5717803e646777f6c8a6897022074f04b82c3dad8445bb6230ab762010c5fc6ee06198fd3e54752287cbf95c523",type:"enum",id:0,value:2},{payload:s.descriptor,type:"transactionFieldDescription",reference:{type:"token",valuePath:[{type:"ARRAY",start:0,end:5,itemSize:1},{type:"LEAF",leafType:"DYNAMIC_LEAF"}]}},{payload:E.descriptor,type:"transactionFieldDescription",reference:{type:"trustedName",valuePath:"TO",types:["eoa"],sources:["ens","unstoppable_domain"]}},{payload:m.descriptor,type:"transactionFieldDescription",reference:{type:"nft",valuePath:[{type:"REF"},{type:"LEAF",leafType:"ARRAY_LEAF"},{type:"SLICE",start:1}]}},{payload:D.descriptor,type:"transactionFieldDescription",reference:{type:"enum",valuePath:[],id:0}}])}),it("Calldata with fields references and enums with certificates",async()=>{const e=n(r,u,[s,E,m,D]),a={keyUsageNumber:11,payload:new Uint8Array([1,2,3,4,21,4,5,6,7,8])};t.get.mockResolvedValue([e]),vi.spyOn(d,"loadCertificate").mockResolvedValueOnce(a);const l=await c.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80B7a3454c06bdac94a69ddc7a9",selector:"0x69328dEc"});expect(l.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo",certificate:a},{payload:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec0401000501010606737461626c6581ff473045022100862e724db664f5d94484928a6a5963268a22cd8178ad36e8c4ff13769ac5c27e0220079da2b6e86810156f6b5955b8190bc016c2fe813d27fcb878a9b99658546582",type:"enum",id:0,value:1,certificate:a},{payload:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04010005010206087661726961626c6581ff473045022100b838ee3d597d6bad2533606cef7335f6c8a45b46d5717803e646777f6c8a6897022074f04b82c3dad8445bb6230ab762010c5fc6ee06198fd3e54752287cbf95c523",type:"enum",id:0,value:2,certificate:a},{payload:s.descriptor,type:"transactionFieldDescription",reference:{type:"token",valuePath:[{type:"ARRAY",start:0,end:5,itemSize:1},{type:"LEAF",leafType:"DYNAMIC_LEAF"}]}},{payload:E.descriptor,type:"transactionFieldDescription",reference:{type:"trustedName",valuePath:"TO",types:["eoa"],sources:["ens","unstoppable_domain"]}},{payload:m.descriptor,type:"transactionFieldDescription",reference:{type:"nft",valuePath:[{type:"REF"},{type:"LEAF",leafType:"ARRAY_LEAF"},{type:"SLICE",start:1}]}},{payload:D.descriptor,type:"transactionFieldDescription",reference:{type:"enum",valuePath:[],id:0}}])}),it("Calldata without fields references",async()=>{const e=n(r,[],[f,p,b,y]);t.get.mockResolvedValue([e]),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const a=await c.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{type:"transactionFieldDescription",payload:f.descriptor},{type:"transactionFieldDescription",payload:p.descriptor},{type:"transactionFieldDescription",payload:b.descriptor},{type:"transactionFieldDescription",payload:y.descriptor}])}),it("Calldata on third array element",async()=>{const e=n(r,[],[f,p,b,y]);t.get.mockResolvedValue([{},{},e]),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const a=await c.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{type:"transactionFieldDescription",payload:f.descriptor},{type:"transactionFieldDescription",payload:p.descriptor},{type:"transactionFieldDescription",payload:b.descriptor},{type:"transactionFieldDescription",payload:y.descriptor}])}),it("Calldata without fields references and transaction info signature length % 2 different from 0",async()=>{const e={descriptor:{data:r.descriptor.data,signatures:{test:r.descriptor.signatures.test+"0"}}},a=n(e,[],[f,p,b,y]);t.get.mockResolvedValue([a]),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const l=await c.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(l.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff4803045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f0",type:"transactionInfo"},{type:"transactionFieldDescription",payload:f.descriptor},{type:"transactionFieldDescription",payload:p.descriptor},{type:"transactionFieldDescription",payload:b.descriptor},{type:"transactionFieldDescription",payload:y.descriptor}])}),it("Calldata with token fields references as constants",async()=>{const e={name:"Amount to exchange",param:{type:"TOKEN_AMOUNT",token:{raw:"0xae7ab96520de3a18e5e111b5eaab095312d7fe84",type:"constant",value:"0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84",version:1,type_size:20,type_family:"ADDRESS"},value:{type:"path",version:1,abi_path:{type:"data",absolute:!0,elements:[{type:"field",identifier:"_stETHAmount"}]},type_size:32,binary_path:{type:"DATA",version:1,elements:[{type:"TUPLE",offset:0},{type:"LEAF",leaf_type:"STATIC_LEAF"}]},type_family:"UINT"},version:1},version:1,descriptor:"0001010112416d6f756e7420746f2065786368616e6765020102033b0001010115000101010101020120030a00010101020000040103021f0001010101050201140514ae7ab96520de3a18e5e111b5eaab095312d7fe84"},a=n(r,[],[e]);t.get.mockResolvedValue([a]),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const l=await c.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(l.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{payload:e.descriptor,type:"transactionFieldDescription",reference:{type:"token",value:"0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84"}}])}),it("Calldata with collection fields references as constants",async()=>{const e={name:"Collection ID",param:{type:"NFT",collection:{raw:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",type:"constant",value:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",version:1,type_size:20,type_family:"ADDRESS"},value:{type:"path",version:1,abi_path:{type:"data",absolute:!0,elements:[{type:"field",identifier:"_collectionId"}]},type_size:20,binary_path:{type:"DATA",version:1,elements:[{type:"ARRAY",weight:2},{type:"LEAF",leaf_type:"TUPLE_LEAF"},{type:"SLICE",end:2}]},type_family:"BYTES"},version:1},version:1,descriptor:"0001010112416d6f756e7420746f2065786368616e6765020102033b0001010115000101010101020120030a00010101020000040103021f00010101010502011405147d2768de32b0b80b7a3454c06bdac94a69ddc7a9"},a=n(r,[],[e]);t.get.mockResolvedValue([a]),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const l=await c.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(l.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{payload:e.descriptor,type:"transactionFieldDescription",reference:{type:"nft",value:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9"}}])}),it("Calldata with CALLDATA fields references",async()=>{const e=n(r,[],[A]);t.get.mockResolvedValue([e]),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const a=await c.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{payload:A.descriptor,type:"transactionFieldDescription",reference:{type:"calldata",valuePath:[{type:"TUPLE",offset:0},{type:"LEAF",leafType:"STATIC_LEAF"}],callee:[{type:"ARRAY",itemSize:1},{type:"LEAF",leafType:"DYNAMIC_LEAF"}],selector:"FROM",amount:[{type:"REF"},{type:"LEAF",leafType:"TUPLE_LEAF"}],spender:[{type:"SLICE",start:0,end:20},{type:"LEAF",leafType:"ARRAY_LEAF"}]}}])}),it("Calldata with CALLDATA fields references without optional properties",async()=>{const e={param:{value:{type:"path",binary_path:{type:"DATA",elements:[{type:"TUPLE",offset:0},{type:"LEAF",leaf_type:"STATIC_LEAF"}]},type_family:"BYTES",type_size:32},callee:{type:"path",binary_path:{type:"DATA",elements:[{type:"TUPLE",offset:0},{type:"LEAF",leaf_type:"STATIC_LEAF"}]},type_family:"BYTES",type_size:32},type:"CALLDATA"},descriptor:"000100010c43616c6c64617461207465737402010803230001000115000100010105020114"},a=n(r,[],[e]);t.get.mockResolvedValue([a]),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const l=await c.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(l.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{payload:e.descriptor,type:"transactionFieldDescription",reference:{type:"calldata",valuePath:[{type:"TUPLE",offset:0},{type:"LEAF",leafType:"STATIC_LEAF"}],callee:[{type:"TUPLE",offset:0},{type:"LEAF",leafType:"STATIC_LEAF"}],selector:void 0,amount:void 0,spender:void 0,chainId:void 0}}])}),it("should return an error when calldata is not correctly formatted",async()=>{const e={descriptors_calldata:{"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9":{"0x69328dec":{type:"calldat",version:"v1",transaction_info:r,enums:u,fields:[s]}}}};t.get.mockResolvedValue([e]),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const a=await c.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when transactionInfo is not correctly formatted",async()=>{const e=n({descriptor:{data:"1234",signatures:{prod:"1234"}}},u,[s]);t.get.mockResolvedValue([e]),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const a=await c.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when enum is not correctly formatted",async()=>{const e=n(r,["badEnum"],[s]);t.get.mockResolvedValue([e]),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const a=await c.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when enum does not contain a signature",async()=>{const e=n(r,{0:{1:{data:"1234"}}},[s]);t.get.mockResolvedValue([e]),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const a=await c.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when enum contain the wrong signature",async()=>{const e=n(r,{0:{1:{data:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04010005010106067374626c65",signatures:{prod:"wrongSignature"}}}},[s]);t.get.mockResolvedValue([e]),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const a=await c.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field is not correctly formatted",async()=>{const e=n(r,[],[{descriptor:3}]);t.get.mockResolvedValue([e]),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const a=await c.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field value is not correctly formatted",async()=>{const a=n(r,[],[{param:{value:{binary_path:"TO",type_family:"UNKNOWN",type_size:20},type:"DATETIME"},descriptor:"000100010c546f20726563697069667"}]);t.get.mockResolvedValue([a]),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const l=await c.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(l).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field container path is not correctly formatted",async()=>{const a=n(r,[],[{param:{value:{binary_path:"UNKNOWN",type_family:"ADDRESS",type_size:20},type:"DATETIME"},descriptor:"000100010c546f20726563697069667"}]);t.get.mockResolvedValue([a]),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const l=await c.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(l).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field calldata path is not correctly formatted",async()=>{const a=n(r,[],[{param:{value:{binary_path:{elements:[{type:"UNKNOWN"}]},type_family:"ADDRESS",type_size:20},type:"DATETIME"},descriptor:"000100010c546f20726563697069667"}]);t.get.mockResolvedValue([a]),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const l=await c.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(l).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field type is not correctly formatted",async()=>{const a=n(r,[],[{param:{value:{binary_path:"TO",type_family:"ADDRESS",type_size:20},type:"UNKNOWN"},descriptor:"000100010c546f20726563697069667"}]);t.get.mockResolvedValue([a]),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const l=await c.getCalldataDescriptors({deviceModelId:o.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(l).toEqual(i(new Error("[ContextModule] HttpCalldataDescriptorDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))})});
2
2
  //# sourceMappingURL=HttpCalldataDescriptorDataSource.test.js.map