@ledgerhq/device-signer-kit-ethereum 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/lib/cjs/api/app-binder/SignTransactionDeviceActionTypes.js +1 -1
  2. package/lib/cjs/api/app-binder/SignTransactionDeviceActionTypes.js.map +2 -2
  3. package/lib/cjs/api/model/ClearSigningType.js +2 -0
  4. package/lib/cjs/api/model/ClearSigningType.js.map +7 -0
  5. package/lib/cjs/internal/app-binder/EthAppBinder.js +1 -1
  6. package/lib/cjs/internal/app-binder/EthAppBinder.js.map +3 -3
  7. package/lib/cjs/internal/app-binder/EthAppBinder.test.js +1 -1
  8. package/lib/cjs/internal/app-binder/EthAppBinder.test.js.map +3 -3
  9. package/lib/cjs/internal/app-binder/command/ProvideProxyInfoCommand.js +2 -0
  10. package/lib/cjs/internal/app-binder/command/ProvideProxyInfoCommand.js.map +7 -0
  11. package/lib/cjs/internal/app-binder/command/ProvideProxyInfoCommand.test.js +2 -0
  12. package/lib/cjs/internal/app-binder/command/ProvideProxyInfoCommand.test.js.map +7 -0
  13. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js +1 -1
  14. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js.map +3 -3
  15. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js +1 -1
  16. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js.map +3 -3
  17. package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js +1 -1
  18. package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js.map +3 -3
  19. package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js +1 -1
  20. package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js.map +2 -2
  21. package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.test.js +1 -1
  22. package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.test.js.map +2 -2
  23. package/lib/cjs/internal/app-binder/task/BuildSubContextTask.js +2 -0
  24. package/lib/cjs/internal/app-binder/task/BuildSubContextTask.js.map +7 -0
  25. package/lib/cjs/internal/app-binder/task/BuildSubContextTask.test.js +2 -0
  26. package/lib/cjs/internal/app-binder/task/BuildSubContextTask.test.js.map +7 -0
  27. package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.js +1 -1
  28. package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.js.map +3 -3
  29. package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.test.js +1 -1
  30. package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.test.js.map +3 -3
  31. package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.js +1 -1
  32. package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.js.map +3 -3
  33. package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.test.js +1 -1
  34. package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.test.js.map +3 -3
  35. package/lib/cjs/internal/app-binder/task/PreBuildContextTask.js +2 -0
  36. package/lib/cjs/internal/app-binder/task/PreBuildContextTask.js.map +7 -0
  37. package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.test.js +1 -1
  38. package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.test.js.map +2 -2
  39. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.js +1 -1
  40. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.js.map +3 -3
  41. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.test.js +1 -1
  42. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.test.js.map +3 -3
  43. package/lib/cjs/internal/app-binder/task/SendPayloadInChunksTask.js +1 -1
  44. package/lib/cjs/internal/app-binder/task/SendPayloadInChunksTask.js.map +1 -1
  45. package/lib/cjs/internal/app-binder/task/SendSignTransactionTask.js +1 -1
  46. package/lib/cjs/internal/app-binder/task/SendSignTransactionTask.js.map +3 -3
  47. package/lib/cjs/internal/app-binder/task/SendSignTransactionTask.test.js +1 -1
  48. package/lib/cjs/internal/app-binder/task/SendSignTransactionTask.test.js.map +3 -3
  49. package/lib/cjs/internal/shared/utils/ApplicationChecker.js +1 -1
  50. package/lib/cjs/internal/shared/utils/ApplicationChecker.js.map +3 -3
  51. package/lib/cjs/internal/shared/utils/ApplicationChecker.test.js +1 -1
  52. package/lib/cjs/internal/shared/utils/ApplicationChecker.test.js.map +2 -2
  53. package/lib/cjs/internal/transaction/di/transactionModule.js +1 -1
  54. package/lib/cjs/internal/transaction/di/transactionModule.js.map +3 -3
  55. package/lib/cjs/internal/transaction/di/transactionModule.test.js +1 -1
  56. package/lib/cjs/internal/transaction/di/transactionModule.test.js.map +2 -2
  57. package/lib/cjs/internal/transaction/service/mapper/EthersTransactionMapperService.js +2 -0
  58. package/lib/cjs/internal/transaction/service/mapper/EthersTransactionMapperService.js.map +7 -0
  59. package/lib/cjs/internal/transaction/service/mapper/EthersTransactionMapperService.test.js +2 -0
  60. package/lib/cjs/internal/transaction/service/mapper/EthersTransactionMapperService.test.js.map +7 -0
  61. package/lib/cjs/internal/transaction/service/mapper/TransactionMapperService.js +1 -1
  62. package/lib/cjs/internal/transaction/service/mapper/TransactionMapperService.js.map +3 -3
  63. package/lib/cjs/internal/transaction/service/parser/TransactionParserService.js +1 -1
  64. package/lib/cjs/internal/transaction/service/parser/TransactionParserService.js.map +3 -3
  65. package/lib/cjs/internal/transaction/service/parser/TransactionParserService.test.js +1 -1
  66. package/lib/cjs/internal/transaction/service/parser/TransactionParserService.test.js.map +3 -3
  67. package/lib/cjs/package.json +3 -3
  68. package/lib/esm/api/app-binder/SignTransactionDeviceActionTypes.js +1 -1
  69. package/lib/esm/api/app-binder/SignTransactionDeviceActionTypes.js.map +2 -2
  70. package/lib/esm/api/model/ClearSigningType.js +2 -0
  71. package/lib/esm/api/model/ClearSigningType.js.map +7 -0
  72. package/lib/esm/internal/app-binder/EthAppBinder.js +1 -1
  73. package/lib/esm/internal/app-binder/EthAppBinder.js.map +3 -3
  74. package/lib/esm/internal/app-binder/EthAppBinder.test.js +1 -1
  75. package/lib/esm/internal/app-binder/EthAppBinder.test.js.map +3 -3
  76. package/lib/esm/internal/app-binder/command/ProvideProxyInfoCommand.js +2 -0
  77. package/lib/esm/internal/app-binder/command/ProvideProxyInfoCommand.js.map +7 -0
  78. package/lib/esm/internal/app-binder/command/ProvideProxyInfoCommand.test.js +2 -0
  79. package/lib/esm/internal/app-binder/command/ProvideProxyInfoCommand.test.js.map +7 -0
  80. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js +1 -1
  81. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js.map +3 -3
  82. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js +1 -1
  83. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js.map +3 -3
  84. package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js +1 -1
  85. package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js.map +3 -3
  86. package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js +1 -1
  87. package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js.map +2 -2
  88. package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.test.js +1 -1
  89. package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.test.js.map +2 -2
  90. package/lib/esm/internal/app-binder/task/BuildSubContextTask.js +2 -0
  91. package/lib/esm/internal/app-binder/task/BuildSubContextTask.js.map +7 -0
  92. package/lib/esm/internal/app-binder/task/BuildSubContextTask.test.js +2 -0
  93. package/lib/esm/internal/app-binder/task/BuildSubContextTask.test.js.map +7 -0
  94. package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.js +1 -1
  95. package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.js.map +3 -3
  96. package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.test.js +1 -1
  97. package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.test.js.map +3 -3
  98. package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.js +1 -1
  99. package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.js.map +3 -3
  100. package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.test.js +1 -1
  101. package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.test.js.map +3 -3
  102. package/lib/esm/internal/app-binder/task/PreBuildContextTask.js +2 -0
  103. package/lib/esm/internal/app-binder/task/PreBuildContextTask.js.map +7 -0
  104. package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.test.js +1 -1
  105. package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.test.js.map +2 -2
  106. package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.js +1 -1
  107. package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.js.map +3 -3
  108. package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.test.js +1 -1
  109. package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.test.js.map +3 -3
  110. package/lib/esm/internal/app-binder/task/SendPayloadInChunksTask.js +1 -1
  111. package/lib/esm/internal/app-binder/task/SendPayloadInChunksTask.js.map +1 -1
  112. package/lib/esm/internal/app-binder/task/SendSignTransactionTask.js +1 -1
  113. package/lib/esm/internal/app-binder/task/SendSignTransactionTask.js.map +3 -3
  114. package/lib/esm/internal/app-binder/task/SendSignTransactionTask.test.js +1 -1
  115. package/lib/esm/internal/app-binder/task/SendSignTransactionTask.test.js.map +3 -3
  116. package/lib/esm/internal/shared/utils/ApplicationChecker.js +1 -1
  117. package/lib/esm/internal/shared/utils/ApplicationChecker.js.map +3 -3
  118. package/lib/esm/internal/shared/utils/ApplicationChecker.test.js +1 -1
  119. package/lib/esm/internal/shared/utils/ApplicationChecker.test.js.map +2 -2
  120. package/lib/esm/internal/transaction/di/transactionModule.js +1 -1
  121. package/lib/esm/internal/transaction/di/transactionModule.js.map +3 -3
  122. package/lib/esm/internal/transaction/di/transactionModule.test.js +1 -1
  123. package/lib/esm/internal/transaction/di/transactionModule.test.js.map +2 -2
  124. package/lib/esm/internal/transaction/service/mapper/EthersTransactionMapperService.js +2 -0
  125. package/lib/esm/internal/transaction/service/mapper/EthersTransactionMapperService.js.map +7 -0
  126. package/lib/esm/internal/transaction/service/mapper/EthersTransactionMapperService.test.js +2 -0
  127. package/lib/esm/internal/transaction/service/mapper/EthersTransactionMapperService.test.js.map +7 -0
  128. package/lib/esm/internal/transaction/service/mapper/TransactionMapperService.js +0 -1
  129. package/lib/esm/internal/transaction/service/mapper/TransactionMapperService.js.map +4 -4
  130. package/lib/esm/internal/transaction/service/parser/TransactionParserService.js +1 -1
  131. package/lib/esm/internal/transaction/service/parser/TransactionParserService.js.map +3 -3
  132. package/lib/esm/internal/transaction/service/parser/TransactionParserService.test.js +1 -1
  133. package/lib/esm/internal/transaction/service/parser/TransactionParserService.test.js.map +3 -3
  134. package/lib/esm/package.json +3 -3
  135. package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts +8 -9
  136. package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts.map +1 -1
  137. package/lib/types/api/model/ClearSigningType.d.ts +5 -0
  138. package/lib/types/api/model/ClearSigningType.d.ts.map +1 -0
  139. package/lib/types/internal/app-binder/EthAppBinder.d.ts +1 -1
  140. package/lib/types/internal/app-binder/EthAppBinder.d.ts.map +1 -1
  141. package/lib/types/internal/app-binder/command/ProvideProxyInfoCommand.d.ts +20 -0
  142. package/lib/types/internal/app-binder/command/ProvideProxyInfoCommand.d.ts.map +1 -0
  143. package/lib/types/internal/app-binder/command/ProvideProxyInfoCommand.test.d.ts +2 -0
  144. package/lib/types/internal/app-binder/command/ProvideProxyInfoCommand.test.d.ts.map +1 -0
  145. package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts +14 -31
  146. package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts.map +1 -1
  147. package/lib/types/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.d.ts.map +1 -1
  148. package/lib/types/internal/app-binder/task/BuildSubContextTask.d.ts +20 -0
  149. package/lib/types/internal/app-binder/task/BuildSubContextTask.d.ts.map +1 -0
  150. package/lib/types/internal/app-binder/task/BuildSubContextTask.test.d.ts +2 -0
  151. package/lib/types/internal/app-binder/task/BuildSubContextTask.test.d.ts.map +1 -0
  152. package/lib/types/internal/app-binder/task/BuildTransactionContextTask.d.ts +10 -14
  153. package/lib/types/internal/app-binder/task/BuildTransactionContextTask.d.ts.map +1 -1
  154. package/lib/types/internal/app-binder/task/GetWeb3CheckTask.d.ts +2 -3
  155. package/lib/types/internal/app-binder/task/GetWeb3CheckTask.d.ts.map +1 -1
  156. package/lib/types/internal/app-binder/task/PreBuildContextTask.d.ts +17 -0
  157. package/lib/types/internal/app-binder/task/PreBuildContextTask.d.ts.map +1 -0
  158. package/lib/types/internal/app-binder/task/ProvideTransactionContextTask.d.ts +28 -22
  159. package/lib/types/internal/app-binder/task/ProvideTransactionContextTask.d.ts.map +1 -1
  160. package/lib/types/internal/app-binder/task/SendPayloadInChunksTask.d.ts +1 -2
  161. package/lib/types/internal/app-binder/task/SendPayloadInChunksTask.d.ts.map +1 -1
  162. package/lib/types/internal/app-binder/task/SendSignTransactionTask.d.ts +2 -1
  163. package/lib/types/internal/app-binder/task/SendSignTransactionTask.d.ts.map +1 -1
  164. package/lib/types/internal/shared/utils/ApplicationChecker.d.ts.map +1 -1
  165. package/lib/types/internal/transaction/di/transactionModule.d.ts.map +1 -1
  166. package/lib/types/internal/transaction/service/mapper/EthersTransactionMapperService.d.ts +8 -0
  167. package/lib/types/internal/transaction/service/mapper/EthersTransactionMapperService.d.ts.map +1 -0
  168. package/lib/types/internal/transaction/service/mapper/EthersTransactionMapperService.test.d.ts +2 -0
  169. package/lib/types/internal/transaction/service/mapper/EthersTransactionMapperService.test.d.ts.map +1 -0
  170. package/lib/types/internal/transaction/service/mapper/TransactionMapperService.d.ts +4 -7
  171. package/lib/types/internal/transaction/service/mapper/TransactionMapperService.d.ts.map +1 -1
  172. package/lib/types/internal/transaction/service/parser/TransactionParserService.d.ts +2 -2
  173. package/lib/types/internal/transaction/service/parser/TransactionParserService.d.ts.map +1 -1
  174. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  175. package/package.json +8 -8
  176. package/lib/cjs/internal/app-binder/constant/plugins.js +0 -2
  177. package/lib/cjs/internal/app-binder/constant/plugins.js.map +0 -7
  178. package/lib/cjs/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.js +0 -2
  179. package/lib/cjs/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.js.map +0 -7
  180. package/lib/cjs/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.test.js +0 -2
  181. package/lib/cjs/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.test.js.map +0 -7
  182. package/lib/cjs/internal/app-binder/task/ProvideTransactionGenericContextTask.js +0 -2
  183. package/lib/cjs/internal/app-binder/task/ProvideTransactionGenericContextTask.js.map +0 -7
  184. package/lib/cjs/internal/app-binder/task/ProvideTransactionGenericContextTask.test.js +0 -2
  185. package/lib/cjs/internal/app-binder/task/ProvideTransactionGenericContextTask.test.js.map +0 -7
  186. package/lib/cjs/internal/transaction/service/mapper/EthersRawTransactionMapper.js +0 -2
  187. package/lib/cjs/internal/transaction/service/mapper/EthersRawTransactionMapper.js.map +0 -7
  188. package/lib/cjs/internal/transaction/service/mapper/EthersRawTransactionMapper.test.js +0 -2
  189. package/lib/cjs/internal/transaction/service/mapper/EthersRawTransactionMapper.test.js.map +0 -7
  190. package/lib/cjs/internal/transaction/service/mapper/TransactionMapper.js +0 -2
  191. package/lib/cjs/internal/transaction/service/mapper/TransactionMapper.js.map +0 -7
  192. package/lib/cjs/internal/transaction/service/mapper/TransactionMapperService.test.js +0 -2
  193. package/lib/cjs/internal/transaction/service/mapper/TransactionMapperService.test.js.map +0 -7
  194. package/lib/esm/internal/app-binder/constant/plugins.js +0 -2
  195. package/lib/esm/internal/app-binder/constant/plugins.js.map +0 -7
  196. package/lib/esm/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.js +0 -2
  197. package/lib/esm/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.js.map +0 -7
  198. package/lib/esm/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.test.js +0 -2
  199. package/lib/esm/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.test.js.map +0 -7
  200. package/lib/esm/internal/app-binder/task/ProvideTransactionGenericContextTask.js +0 -2
  201. package/lib/esm/internal/app-binder/task/ProvideTransactionGenericContextTask.js.map +0 -7
  202. package/lib/esm/internal/app-binder/task/ProvideTransactionGenericContextTask.test.js +0 -2
  203. package/lib/esm/internal/app-binder/task/ProvideTransactionGenericContextTask.test.js.map +0 -7
  204. package/lib/esm/internal/transaction/service/mapper/EthersRawTransactionMapper.js +0 -2
  205. package/lib/esm/internal/transaction/service/mapper/EthersRawTransactionMapper.js.map +0 -7
  206. package/lib/esm/internal/transaction/service/mapper/EthersRawTransactionMapper.test.js +0 -2
  207. package/lib/esm/internal/transaction/service/mapper/EthersRawTransactionMapper.test.js.map +0 -7
  208. package/lib/esm/internal/transaction/service/mapper/TransactionMapper.js +0 -1
  209. package/lib/esm/internal/transaction/service/mapper/TransactionMapper.js.map +0 -7
  210. package/lib/esm/internal/transaction/service/mapper/TransactionMapperService.test.js +0 -2
  211. package/lib/esm/internal/transaction/service/mapper/TransactionMapperService.test.js.map +0 -7
  212. package/lib/types/internal/app-binder/constant/plugins.d.ts +0 -2
  213. package/lib/types/internal/app-binder/constant/plugins.d.ts.map +0 -1
  214. package/lib/types/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.d.ts +0 -80
  215. package/lib/types/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.d.ts.map +0 -1
  216. package/lib/types/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.test.d.ts +0 -2
  217. package/lib/types/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.test.d.ts.map +0 -1
  218. package/lib/types/internal/app-binder/task/ProvideTransactionGenericContextTask.d.ts +0 -28
  219. package/lib/types/internal/app-binder/task/ProvideTransactionGenericContextTask.d.ts.map +0 -1
  220. package/lib/types/internal/app-binder/task/ProvideTransactionGenericContextTask.test.d.ts +0 -2
  221. package/lib/types/internal/app-binder/task/ProvideTransactionGenericContextTask.test.d.ts.map +0 -1
  222. package/lib/types/internal/transaction/service/mapper/EthersRawTransactionMapper.d.ts +0 -7
  223. package/lib/types/internal/transaction/service/mapper/EthersRawTransactionMapper.d.ts.map +0 -1
  224. package/lib/types/internal/transaction/service/mapper/EthersRawTransactionMapper.test.d.ts +0 -2
  225. package/lib/types/internal/transaction/service/mapper/EthersRawTransactionMapper.test.d.ts.map +0 -1
  226. package/lib/types/internal/transaction/service/mapper/TransactionMapper.d.ts +0 -6
  227. package/lib/types/internal/transaction/service/mapper/TransactionMapper.d.ts.map +0 -1
  228. package/lib/types/internal/transaction/service/mapper/TransactionMapperService.test.d.ts +0 -2
  229. package/lib/types/internal/transaction/service/mapper/TransactionMapperService.test.d.ts.map +0 -1
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/app-binder/task/BuildSubContextTask.test.ts"],
4
+ "sourcesContent": ["import {\n type ClearSignContextReference,\n type ClearSignContextSuccess,\n ClearSignContextType,\n type ContextModule,\n type TransactionFieldContext,\n} from \"@ledgerhq/context-module\";\nimport {\n CommandResultFactory,\n UnknownDeviceExchangeError,\n} from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { GetChallengeCommand } from \"@internal/app-binder/command/GetChallengeCommand\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nimport {\n BuildSubContextTask,\n type BuildSubContextTaskArgs,\n} from \"./BuildSubContextTask\";\n\ndescribe(\"BuildSubContextTask\", () => {\n const contextModuleMock = {\n getContext: vi.fn(),\n };\n const transactionParserMock = {\n extractValue: vi.fn(),\n };\n const apiMock = makeDeviceActionInternalApiMock();\n\n let defaultArgs: BuildSubContextTaskArgs;\n\n beforeEach(() => {\n vi.resetAllMocks();\n defaultArgs = {\n context: {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"test payload\",\n },\n contextOptional: [],\n transactionParser:\n transactionParserMock as unknown as TransactionParserService,\n subset: {\n chainId: 1,\n data: \"0x\",\n selector: \"0x\",\n to: \"0x\",\n value: BigInt(0),\n },\n contextModule: contextModuleMock as unknown as ContextModule,\n };\n });\n\n describe(\"when context type is a simple type\", () => {\n const simpleTypes: ClearSignContextSuccess[\"type\"][] = [\n ClearSignContextType.TRANSACTION_INFO,\n ClearSignContextType.WEB3_CHECK,\n ClearSignContextType.PLUGIN,\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n ];\n\n it.each(simpleTypes)(\n \"should return context with empty subcontextCallbacks for %s\",\n (type) => {\n // GIVEN\n const context: ClearSignContextSuccess = {\n type,\n payload: \"test payload\",\n } as ClearSignContextSuccess;\n const args = { ...defaultArgs, context };\n\n // WHEN\n const result = new BuildSubContextTask(apiMock, args).run();\n\n // THEN\n expect(result.subcontextCallbacks).toHaveLength(0);\n },\n );\n });\n\n describe(\"when context has a direct value reference\", () => {\n it(\"should create a callback to get context with the direct value\", async () => {\n // GIVEN\n const context: ClearSignContextSuccess = {\n type: ClearSignContextType.TOKEN,\n payload: \"test payload\",\n reference: {\n type: ClearSignContextType.TOKEN,\n value: \"0x1234567890123456789012345678901234567890\",\n },\n };\n const args = { ...defaultArgs, context };\n const expectedContext: TransactionFieldContext = {\n type: ClearSignContextType.TOKEN,\n chainId: 1,\n address: \"0x1234567890123456789012345678901234567890\",\n };\n\n // WHEN\n const result = new BuildSubContextTask(apiMock, args).run();\n\n // THEN\n expect(result.subcontextCallbacks).toHaveLength(1);\n\n // Verify the callback calls getContext with correct parameters\n const callback = result.subcontextCallbacks[0]!;\n await callback();\n expect(contextModuleMock.getContext).toHaveBeenCalledWith(\n expectedContext,\n );\n });\n\n it(\"should handle undefined value in reference\", () => {\n // GIVEN\n const context: ClearSignContextSuccess = {\n type: ClearSignContextType.TOKEN,\n payload: \"test payload\",\n reference: undefined as unknown as ClearSignContextReference,\n };\n const args = { ...defaultArgs, context };\n\n // WHEN\n const result = new BuildSubContextTask(apiMock, args).run();\n\n // THEN\n expect(result.subcontextCallbacks).toHaveLength(0);\n });\n });\n\n describe(\"when context has a valuePath reference\", () => {\n beforeEach(() => {\n apiMock.sendCommand.mockResolvedValue(\n CommandResultFactory({ data: { challenge: \"test-challenge\" } }),\n );\n });\n\n describe(\"when extractValue returns Left (error)\", () => {\n it(\"should return context with empty subcontextCallbacks\", () => {\n // GIVEN\n const context: ClearSignContextSuccess = {\n type: ClearSignContextType.TOKEN,\n payload: \"test payload\",\n reference: {\n type: ClearSignContextType.TOKEN,\n valuePath: [{ type: \"SLICE\", start: 0, end: 20 }],\n },\n };\n const args = { ...defaultArgs, context };\n transactionParserMock.extractValue.mockReturnValue(\n Left(new Error(\"Extraction failed\")),\n );\n\n // WHEN\n const result = new BuildSubContextTask(apiMock, args).run();\n\n // THEN\n expect(result.subcontextCallbacks).toHaveLength(0);\n });\n });\n\n describe(\"when extractValue returns Right with values\", () => {\n describe(\"for ENUM type\", () => {\n it(\"should create callbacks for matching enum contexts\", async () => {\n // GIVEN\n const context: ClearSignContextSuccess = {\n type: ClearSignContextType.TOKEN,\n payload: \"test payload\",\n reference: {\n type: ClearSignContextType.ENUM,\n id: 1,\n valuePath: [{ type: \"TUPLE\", offset: 0 }],\n },\n };\n // enum with the same id but different value\n const enumContext1: ClearSignContextSuccess = {\n type: ClearSignContextType.ENUM,\n id: 1,\n value: 1,\n payload: \"enum context 1\",\n };\n // enum to select, id and value match\n const enumContext2: ClearSignContextSuccess = {\n type: ClearSignContextType.ENUM,\n id: 1,\n value: 2,\n payload: \"enum context 2\",\n };\n // other enum context with different id\n const enumContext3: ClearSignContextSuccess = {\n type: ClearSignContextType.ENUM,\n id: 2,\n value: 2,\n payload: \"enum context 3\",\n };\n const args = {\n ...defaultArgs,\n context,\n contextOptional: [enumContext1, enumContext2, enumContext3],\n };\n const extractedValues = [new Uint8Array([0x01, 0x02])]; // Last byte is 2\n transactionParserMock.extractValue.mockReturnValue(\n Right(extractedValues),\n );\n\n // WHEN\n const result = new BuildSubContextTask(apiMock, args).run();\n\n // THEN\n expect(result.subcontextCallbacks).toHaveLength(1);\n const callback = result.subcontextCallbacks[0]!;\n const callbackResult = await callback();\n expect(callbackResult).toEqual(enumContext2);\n });\n\n it(\"should create callbacks for matching enum contexts with two values\", async () => {\n // GIVEN\n const context: ClearSignContextSuccess = {\n type: ClearSignContextType.TOKEN,\n payload: \"test payload\",\n reference: {\n type: ClearSignContextType.ENUM,\n id: 1,\n valuePath: [{ type: \"TUPLE\", offset: 0 }],\n },\n };\n // enum to select, id and value match\n const enumContext1: ClearSignContextSuccess = {\n type: ClearSignContextType.ENUM,\n id: 1,\n value: 1,\n payload: \"enum context 1\",\n };\n // enum to select, id and value match\n const enumContext2: ClearSignContextSuccess = {\n type: ClearSignContextType.ENUM,\n id: 1,\n value: 2,\n payload: \"enum context 2\",\n };\n // other enum context with different id\n const enumContext3: ClearSignContextSuccess = {\n type: ClearSignContextType.ENUM,\n id: 2,\n value: 2,\n payload: \"enum context 3\",\n };\n const args = {\n ...defaultArgs,\n context,\n contextOptional: [enumContext1, enumContext2, enumContext3],\n };\n const extractedValues = [\n new Uint8Array([0x01, 0x02]),\n new Uint8Array([0x03, 0x02, 0x01]),\n ]; // Last byte is 2\n transactionParserMock.extractValue.mockReturnValue(\n Right(extractedValues),\n );\n\n // WHEN\n const result = new BuildSubContextTask(apiMock, args).run();\n\n // THEN\n expect(result.subcontextCallbacks).toHaveLength(2);\n const callback1 = result.subcontextCallbacks[0]!;\n const callback2 = result.subcontextCallbacks[1]!;\n const callbackResult1 = await callback1();\n const callbackResult2 = await callback2();\n expect(callbackResult1).toEqual(enumContext2);\n expect(callbackResult2).toEqual(enumContext1);\n });\n\n it(\"should skip when enum value is undefined\", () => {\n // GIVEN\n const context: ClearSignContextSuccess = {\n type: ClearSignContextType.TOKEN,\n payload: \"test payload\",\n reference: {\n type: ClearSignContextType.ENUM,\n id: 1,\n valuePath: [{ type: \"TUPLE\", offset: 0 }],\n },\n };\n const args = { ...defaultArgs, context };\n const extractedValues = [new Uint8Array([])]; // Empty array\n transactionParserMock.extractValue.mockReturnValue(\n Right(extractedValues),\n );\n\n // WHEN\n const result = new BuildSubContextTask(apiMock, args).run();\n\n // THEN\n expect(result.subcontextCallbacks).toHaveLength(0);\n });\n\n it(\"should skip when no matching enum context found\", () => {\n // GIVEN\n const context: ClearSignContextSuccess = {\n type: ClearSignContextType.NFT,\n payload: \"test payload\",\n reference: {\n type: ClearSignContextType.ENUM,\n id: 1,\n valuePath: [{ type: \"TUPLE\", offset: 0 }],\n },\n };\n const enumContext: ClearSignContextSuccess = {\n type: ClearSignContextType.ENUM,\n id: 2, // Different ID\n value: 2,\n payload: \"enum context\",\n };\n const args = {\n ...defaultArgs,\n context,\n contextOptional: [enumContext],\n };\n const extractedValues = [new Uint8Array([0x01, 0x02])];\n transactionParserMock.extractValue.mockReturnValue(\n Right(extractedValues),\n );\n\n // WHEN\n const result = new BuildSubContextTask(apiMock, args).run();\n\n // THEN\n expect(result.subcontextCallbacks).toHaveLength(0);\n });\n });\n\n describe(\"for TOKEN type\", () => {\n it(\"should create callbacks to get token context\", async () => {\n // GIVEN\n const context: ClearSignContextSuccess = {\n type: ClearSignContextType.TOKEN,\n payload: \"test payload\",\n reference: {\n type: ClearSignContextType.TOKEN,\n valuePath: [{ type: \"TUPLE\", offset: 0 }],\n },\n };\n const args = { ...defaultArgs, context };\n const extractedValues = [\n new Uint8Array([\n 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,\n 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,\n ]),\n ];\n transactionParserMock.extractValue.mockReturnValue(\n Right(extractedValues),\n );\n contextModuleMock.getContext.mockResolvedValue({\n type: ClearSignContextType.TOKEN,\n payload: \"token result\",\n });\n\n // WHEN\n const result = new BuildSubContextTask(apiMock, args).run();\n\n // THEN\n expect(result.subcontextCallbacks).toHaveLength(1);\n const callback = result.subcontextCallbacks[0]!;\n const callbackResult = await callback();\n expect(callbackResult).toEqual({\n type: ClearSignContextType.TOKEN,\n payload: \"token result\",\n });\n expect(contextModuleMock.getContext).toHaveBeenCalledWith({\n type: ClearSignContextType.TOKEN,\n chainId: 1,\n address: \"0x030405060708090a0b0c0d0e0f10111213141516\",\n });\n });\n });\n\n describe(\"for NFT type\", () => {\n it(\"should create callbacks to get NFT context\", async () => {\n // GIVEN\n const context: ClearSignContextSuccess = {\n type: ClearSignContextType.NFT,\n payload: \"test payload\",\n reference: {\n type: ClearSignContextType.NFT,\n valuePath: [{ type: \"TUPLE\", offset: 0 }],\n },\n };\n const args = { ...defaultArgs, context };\n const extractedValues = [\n new Uint8Array([\n 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,\n 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,\n ]),\n ];\n transactionParserMock.extractValue.mockReturnValue(\n Right(extractedValues),\n );\n contextModuleMock.getContext.mockResolvedValue({\n type: ClearSignContextType.NFT,\n payload: \"nft result\",\n });\n\n // WHEN\n const result = new BuildSubContextTask(apiMock, args).run();\n\n // THEN\n expect(result.subcontextCallbacks).toHaveLength(1);\n const callback = result.subcontextCallbacks[0]!;\n const callbackResult = await callback();\n expect(callbackResult).toEqual({\n type: ClearSignContextType.NFT,\n payload: \"nft result\",\n });\n expect(contextModuleMock.getContext).toHaveBeenCalledWith({\n type: ClearSignContextType.NFT,\n chainId: 1,\n address: \"0x030405060708090a0b0c0d0e0f10111213141516\",\n });\n });\n });\n\n describe(\"for TRUSTED_NAME type\", () => {\n it(\"should create callbacks to get trusted name context with challenge\", async () => {\n // GIVEN\n const context: ClearSignContextSuccess = {\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"test payload\",\n reference: {\n type: ClearSignContextType.TRUSTED_NAME,\n valuePath: [{ type: \"TUPLE\", offset: 0 }],\n types: [\"type1\", \"type2\"],\n sources: [\"source1\", \"source2\"],\n },\n };\n const args = { ...defaultArgs, context };\n const extractedValues = [\n new Uint8Array([\n 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,\n 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,\n ]),\n ];\n transactionParserMock.extractValue.mockReturnValue(\n Right(extractedValues),\n );\n contextModuleMock.getContext.mockResolvedValue({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"trusted name result\",\n });\n\n // WHEN\n const result = new BuildSubContextTask(apiMock, args).run();\n\n // THEN\n expect(result.subcontextCallbacks).toHaveLength(1);\n const callback = result.subcontextCallbacks[0]!;\n const callbackResult = await callback();\n expect(callbackResult).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"trusted name result\",\n });\n expect(apiMock.sendCommand).toHaveBeenCalledWith(\n expect.any(GetChallengeCommand),\n );\n expect(contextModuleMock.getContext).toHaveBeenCalledWith({\n type: ClearSignContextType.TRUSTED_NAME,\n chainId: 1,\n address: \"0x030405060708090a0b0c0d0e0f10111213141516\",\n challenge: \"test-challenge\",\n types: [\"type1\", \"type2\"],\n sources: [\"source1\", \"source2\"],\n });\n });\n\n it(\"should handle challenge command failure\", async () => {\n // GIVEN\n const context: ClearSignContextSuccess = {\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"test payload\",\n reference: {\n type: ClearSignContextType.TRUSTED_NAME,\n valuePath: [{ type: \"TUPLE\", offset: 0 }],\n types: [\"type1\"],\n sources: [\"source1\"],\n },\n };\n const args = { ...defaultArgs, context };\n const extractedValues = [\n new Uint8Array([\n 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,\n 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,\n ]),\n ];\n transactionParserMock.extractValue.mockReturnValue(\n Right(extractedValues),\n );\n const error = new UnknownDeviceExchangeError(\"Failed\");\n apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({\n error,\n }),\n );\n\n // WHEN\n const result = new BuildSubContextTask(apiMock, args).run();\n\n // THEN\n expect(result.subcontextCallbacks).toHaveLength(1);\n const callback = result.subcontextCallbacks[0]!;\n const callbackResult = await callback();\n expect(callbackResult).toEqual({\n error: new Error(\"Failed to get challenge\"),\n type: ClearSignContextType.ERROR,\n });\n });\n });\n\n describe(\"for multiple values\", () => {\n it(\"should create callbacks for each extracted value\", async () => {\n // GIVEN\n const context: ClearSignContextSuccess = {\n type: ClearSignContextType.TOKEN,\n payload: \"test payload\",\n reference: {\n type: ClearSignContextType.TOKEN,\n valuePath: [{ type: \"TUPLE\", offset: 0 }],\n },\n };\n const args = { ...defaultArgs, context };\n const extractedValues = [\n new Uint8Array([\n 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,\n 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,\n ]),\n new Uint8Array([\n 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,\n 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,\n ]),\n ];\n transactionParserMock.extractValue.mockReturnValue(\n Right(extractedValues),\n );\n contextModuleMock.getContext.mockResolvedValueOnce({\n type: ClearSignContextType.TOKEN,\n payload: \"token result 1\",\n });\n contextModuleMock.getContext.mockResolvedValueOnce({\n type: ClearSignContextType.TOKEN,\n payload: \"token result 2\",\n });\n\n // WHEN\n const result = new BuildSubContextTask(apiMock, args).run();\n\n // THEN\n expect(result.subcontextCallbacks).toHaveLength(2);\n const callback1 = result.subcontextCallbacks[0]!;\n const callback2 = result.subcontextCallbacks[1]!;\n const callbackResult1 = await callback1();\n const callbackResult2 = await callback2();\n expect(callbackResult1).toEqual({\n type: ClearSignContextType.TOKEN,\n payload: \"token result 1\",\n });\n expect(callbackResult2).toEqual({\n type: ClearSignContextType.TOKEN,\n payload: \"token result 2\",\n });\n expect(contextModuleMock.getContext).toHaveBeenCalledTimes(2);\n expect(contextModuleMock.getContext).toHaveBeenNthCalledWith(1, {\n type: ClearSignContextType.TOKEN,\n chainId: 1,\n address: \"0x030405060708090a0b0c0d0e0f10111213141516\",\n });\n expect(contextModuleMock.getContext).toHaveBeenNthCalledWith(2, {\n type: ClearSignContextType.TOKEN,\n chainId: 1,\n address: \"0x232425262728292a2b2c2d2e2f30313233343536\",\n });\n });\n });\n });\n });\n\n describe(\"when context has no reference\", () => {\n it(\"should return context with empty subcontextCallbacks\", () => {\n // GIVEN\n const context: ClearSignContextSuccess = {\n type: ClearSignContextType.TOKEN,\n payload: \"test payload\",\n };\n const args = { ...defaultArgs, context };\n\n // WHEN\n const result = new BuildSubContextTask(apiMock, args).run();\n\n // THEN\n expect(result.subcontextCallbacks).toHaveLength(0);\n });\n });\n\n describe(\"when context has reference but no valuePath\", () => {\n it(\"should return context with empty subcontextCallbacks\", () => {\n // GIVEN\n const context: ClearSignContextSuccess = {\n type: ClearSignContextType.TOKEN,\n payload: \"test payload\",\n reference: {\n type: ClearSignContextType.TOKEN,\n } as ClearSignContextReference<ClearSignContextType.TOKEN>,\n };\n const args = { ...defaultArgs, context };\n\n // WHEN\n const result = new BuildSubContextTask(apiMock, args).run();\n\n // THEN\n expect(result.subcontextCallbacks).toHaveLength(0);\n });\n });\n\n describe(\"edge cases\", () => {\n it(\"should handle value array shorter than 20 bytes for address extraction\", async () => {\n // GIVEN\n const context: ClearSignContextSuccess = {\n type: ClearSignContextType.TOKEN,\n payload: \"test payload\",\n reference: {\n type: ClearSignContextType.TOKEN,\n valuePath: [{ type: \"TUPLE\", offset: 0 }],\n },\n };\n const args = { ...defaultArgs, context };\n const extractedValues = [new Uint8Array([0x01, 0x02, 0x03])]; // Only 3 bytes\n transactionParserMock.extractValue.mockReturnValue(\n Right(extractedValues),\n );\n contextModuleMock.getContext.mockResolvedValue({\n type: ClearSignContextType.ERROR,\n message: \"Invalid address\",\n });\n\n // WHEN\n const result = new BuildSubContextTask(apiMock, args).run();\n\n // THEN\n expect(result.subcontextCallbacks).toHaveLength(1);\n const callback = result.subcontextCallbacks[0]!;\n const callbackResult = await callback();\n expect(callbackResult).toEqual({\n type: ClearSignContextType.ERROR,\n message: \"Invalid address\",\n });\n expect(contextModuleMock.getContext).toHaveBeenCalledWith({\n type: ClearSignContextType.TOKEN,\n chainId: 1,\n address: \"0x010203\",\n });\n });\n\n it(\"should handle empty value array\", async () => {\n // GIVEN\n const context: ClearSignContextSuccess = {\n type: ClearSignContextType.TOKEN,\n payload: \"test payload\",\n reference: {\n type: ClearSignContextType.TOKEN,\n valuePath: [{ type: \"TUPLE\", offset: 0 }],\n },\n };\n const args = { ...defaultArgs, context };\n const extractedValues = [new Uint8Array([])]; // Empty array\n transactionParserMock.extractValue.mockReturnValue(\n Right(extractedValues),\n );\n contextModuleMock.getContext.mockResolvedValue({\n type: ClearSignContextType.TOKEN,\n payload: \"token result\",\n });\n\n // WHEN\n const result = new BuildSubContextTask(apiMock, args).run();\n\n // THEN\n expect(result.subcontextCallbacks).toHaveLength(1);\n\n // Verify the callback calls getContext with empty address\n const callback = result.subcontextCallbacks[0]!;\n const callbackResult = await callback();\n expect(callbackResult).toEqual({\n type: ClearSignContextType.TOKEN,\n payload: \"token result\",\n });\n expect(contextModuleMock.getContext).toHaveBeenCalledWith({\n type: ClearSignContextType.TOKEN,\n chainId: 1,\n address: \"0x\",\n });\n });\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAMO,oCACPC,EAGO,2CACPC,EAA4B,qBAE5BC,EAAoC,4DACpCC,EAAgD,6EAGhDC,EAGO,iCAEP,SAAS,sBAAuB,IAAM,CACpC,MAAMC,EAAoB,CACxB,WAAY,GAAG,GAAG,CACpB,EACMC,EAAwB,CAC5B,aAAc,GAAG,GAAG,CACtB,EACMC,KAAU,mCAAgC,EAEhD,IAAIC,EAEJ,WAAW,IAAM,CACf,GAAG,cAAc,EACjBA,EAAc,CACZ,QAAS,CACP,KAAM,uBAAqB,iBAC3B,QAAS,cACX,EACA,gBAAiB,CAAC,EAClB,kBACEF,EACF,OAAQ,CACN,QAAS,EACT,KAAM,KACN,SAAU,KACV,GAAI,KACJ,MAAO,OAAO,CAAC,CACjB,EACA,cAAeD,CACjB,CACF,CAAC,EAED,SAAS,qCAAsC,IAAM,CACnD,MAAMI,EAAiD,CACrD,uBAAqB,iBACrB,uBAAqB,WACrB,uBAAqB,OACrB,uBAAqB,gBACrB,uBAAqB,6BACvB,EAEA,GAAG,KAAKA,CAAW,EACjB,8DACCC,GAAS,CAMR,MAAMC,EAAO,CAAE,GAAGH,EAAa,QAJU,CACvC,KAAAE,EACA,QAAS,cACX,CACuC,EAGjCE,EAAS,IAAI,sBAAoBL,EAASI,CAAI,EAAE,IAAI,EAG1D,OAAOC,EAAO,mBAAmB,EAAE,aAAa,CAAC,CACnD,CACF,CACF,CAAC,EAED,SAAS,4CAA6C,IAAM,CAC1D,GAAG,gEAAiE,SAAY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qB,MAC3B,UAAW,CAAC,CAAE,KAAM,QAAS,OAAQ,CAAE,CAAC,CAC1C,CACF,EACMF,EAAO,CAAE,GAAGH,EAAa,QAAAK,CAAQ,EACjCM,EAAkB,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,EAC3Cb,EAAsB,aAAa,mBACjC,SAAMa,CAAe,CACvB,EACAd,EAAkB,WAAW,kBAAkB,CAC7C,KAAM,uBAAqB,MAC3B,QAAS,cACX,CAAC,EAGD,MAAMO,EAAS,IAAI,sBAAoBL,EAASI,CAAI,EAAE,IAAI,EAG1D,OAAOC,EAAO,mBAAmB,EAAE,aAAa,CAAC,EAGjD,MAAMG,EAAWH,EAAO,oBAAoB,CAAC,EACvCQ,EAAiB,MAAML,EAAS,EACtC,OAAOK,CAAc,EAAE,QAAQ,CAC7B,KAAM,uBAAqB,MAC3B,QAAS,cACX,CAAC,EACD,OAAOf,EAAkB,UAAU,EAAE,qBAAqB,CACxD,KAAM,uBAAqB,MAC3B,QAAS,EACT,QAAS,IACX,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_context_module", "import_device_management_kit", "import_purify_ts", "import_GetChallengeCommand", "import_makeInternalApi", "import_BuildSubContextTask", "contextModuleMock", "transactionParserMock", "apiMock", "defaultArgs", "simpleTypes", "type", "args", "result", "context", "expectedContext", "callback", "enumContext1", "enumContext2", "enumContext3", "extractedValues", "callbackResult", "callback1", "callback2", "callbackResult1", "callbackResult2", "enumContext", "error"]
7
+ }
@@ -1,2 +1,2 @@
1
- "use strict";var y=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var b=(o,t)=>{for(var n in t)y(o,n,{get:t[n],enumerable:!0})},O=(o,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of M(t))!R.call(o,a)&&a!==n&&y(o,a,{get:()=>t[a],enumerable:!(r=E(t,a))||r.enumerable});return o};var w=o=>O(y({},"__esModule",{value:!0}),o);var _={};b(_,{BuildTransactionContextTask:()=>G});module.exports=w(_);var i=require("@ledgerhq/context-module"),s=require("@ledgerhq/device-management-kit"),f=require("../../app-binder/command/GetChallengeCommand"),x=require("../../app-binder/task/GetWeb3CheckTask"),h=require("../../shared/utils/ApplicationChecker");class G{constructor(t,n,r=(a,c)=>new x.GetWeb3CheckTask(a,c)){this.api=t;this.args=n;this.getWeb3ChecksFactory=r}async run(){const{contextModule:t,mapper:n,transaction:r,options:a,appConfig:c,derivationPath:I}=this.args,p=this.api.getDeviceSessionState(),S=n.mapTransactionToSubset(r);S.ifLeft(e=>{throw e});const{subset:u,serializedTransaction:A,type:N}=S.unsafeCoerce();let T=null;c.web3ChecksEnabled&&(T=(await this.getWeb3ChecksFactory(this.api,{contextModule:t,derivationPath:I,mapper:n,transaction:r}).run()).web3Check);let g;if(p.deviceModelId!==s.DeviceModelId.NANO_S){const e=await this.api.sendCommand(new f.GetChallengeCommand);(0,s.isSuccessCommandResult)(e)&&(g=e.data.challenge)}const m=await t.getContexts({challenge:g,domain:a.domain,deviceModelId:p.deviceModelId,...u}),C=m.filter(e=>e.type!==i.ClearSignContextType.ERROR&&e.type!==i.ClearSignContextType.ENUM),k=m.filter(e=>e.type===i.ClearSignContextType.ENUM);let d=[];const l=C.find(e=>e.type===i.ClearSignContextType.TRANSACTION_INFO);if(!this.supportsGenericParser(p,c)||l===void 0)d=C.filter(e=>e.type!==i.ClearSignContextType.TRANSACTION_INFO&&e.type!==i.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION);else if(l.certificate){const e=C.filter(v=>v.type===i.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION);d={transactionInfo:l.payload,transactionInfoCertificate:l.certificate,transactionFields:e,transactionEnums:k}}return{clearSignContexts:d,serializedTransaction:A,chainId:u.chainId,transactionType:N,web3Check:T}}supportsGenericParser(t,n){return new h.ApplicationChecker(t,n).withMinVersionExclusive("1.14.0").excludeDeviceModel(s.DeviceModelId.NANO_S).check()}}0&&(module.exports={BuildTransactionContextTask});
1
+ "use strict";var g=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var R=(o,e)=>{for(var n in e)g(o,n,{get:e[n],enumerable:!0})},_=(o,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of E(e))!O.call(o,i)&&i!==n&&g(o,i,{get:()=>e[i],enumerable:!(s=v(e,i))||s.enumerable});return o};var b=o=>_(g({},"__esModule",{value:!0}),o);var w={};R(w,{BuildTransactionContextTask:()=>M});module.exports=b(w);var a=require("@ledgerhq/context-module"),c=require("@ledgerhq/device-management-kit"),y=require("../../../api/model/ClearSigningType"),h=require("../../app-binder/command/GetChallengeCommand"),I=require("../../app-binder/task/GetWeb3CheckTask"),A=require("../../shared/utils/ApplicationChecker");class M{constructor(e,n,s=(i,C)=>new I.GetWeb3CheckTask(i,C)){this._api=e;this._args=n;this.getWeb3ChecksFactory=s}async run(){const{contextModule:e,options:n,appConfig:s,derivationPath:i,transaction:C,subset:u}=this._args,p=this._api.getDeviceSessionState();let r=[],T=[],x=y.ClearSigningType.BASIC,l=null;s.web3ChecksEnabled&&(l=(await this.getWeb3ChecksFactory(this._api,{contextModule:e,derivationPath:i,subset:u,transaction:C}).run()).web3Check);let m;if(p.deviceModelId!==c.DeviceModelId.NANO_S){const t=await this._api.sendCommand(new h.GetChallengeCommand);(0,c.isSuccessCommandResult)(t)&&(m=t.data.challenge)}const f=await e.getContexts({challenge:m,domain:n.domain,deviceModelId:p.deviceModelId,...u}),d=f.filter(t=>t.type!==a.ClearSignContextType.ERROR&&t.type!==a.ClearSignContextType.ENUM),N=f.filter(t=>t.type===a.ClearSignContextType.ENUM),S=d.find(t=>t.type===a.ClearSignContextType.TRANSACTION_INFO);if(!this.supportsGenericParser(p,s)||S===void 0)r=d.filter(t=>t.type!==a.ClearSignContextType.TRANSACTION_INFO&&t.type!==a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION),l&&(r=[l,...r]);else if(S.certificate){const t=d.filter(k=>k.type===a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION);r=[S,...t,...l?[l]:[]],T=[...N],x=y.ClearSigningType.EIP7730}return{clearSignContexts:r,clearSignContextsOptional:T,clearSigningType:x}}supportsGenericParser(e,n){return new A.ApplicationChecker(e,n).withMinVersionExclusive("1.14.0").excludeDeviceModel(c.DeviceModelId.NANO_S).check()}}0&&(module.exports={BuildTransactionContextTask});
2
2
  //# sourceMappingURL=BuildTransactionContextTask.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/task/BuildTransactionContextTask.ts"],
4
- "sourcesContent": ["import {\n type ClearSignContextSuccess,\n type ClearSignContextSuccessType,\n ClearSignContextType,\n type ContextModule,\n} from \"@ledgerhq/context-module\";\nimport {\n DeviceModelId,\n type DeviceSessionState,\n type InternalApi,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { type TransactionOptions } from \"@api/model/TransactionOptions\";\nimport { type TransactionType } from \"@api/model/TransactionType\";\nimport { GetChallengeCommand } from \"@internal/app-binder/command/GetChallengeCommand\";\nimport {\n GetWeb3CheckTask,\n type GetWeb3CheckTaskArgs,\n} from \"@internal/app-binder/task/GetWeb3CheckTask\";\nimport { ApplicationChecker } from \"@internal/shared/utils/ApplicationChecker\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\n\nimport { type GenericContext } from \"./ProvideTransactionGenericContextTask\";\n\nexport type BuildTransactionTaskResult = {\n readonly clearSignContexts: ClearSignContextSuccess[] | GenericContext;\n readonly serializedTransaction: Uint8Array;\n readonly chainId: number;\n readonly transactionType: TransactionType;\n readonly web3Check: ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null;\n};\n\nexport type BuildTransactionContextTaskArgs = {\n readonly contextModule: ContextModule;\n readonly mapper: TransactionMapperService;\n readonly transaction: Uint8Array;\n readonly options: TransactionOptions;\n readonly appConfig: GetConfigCommandResponse;\n readonly derivationPath: string;\n};\n\nexport class BuildTransactionContextTask {\n constructor(\n private readonly api: InternalApi,\n private readonly args: BuildTransactionContextTaskArgs,\n private readonly getWeb3ChecksFactory = (\n api: InternalApi,\n args: GetWeb3CheckTaskArgs,\n ) => new GetWeb3CheckTask(api, args),\n ) {}\n\n async run(): Promise<BuildTransactionTaskResult> {\n const {\n contextModule,\n mapper,\n transaction,\n options,\n appConfig,\n derivationPath,\n } = this.args;\n const deviceState = this.api.getDeviceSessionState();\n\n // Parse transaction\n const parsed = mapper.mapTransactionToSubset(transaction);\n parsed.ifLeft((err) => {\n throw err;\n });\n const { subset, serializedTransaction, type } = parsed.unsafeCoerce();\n\n // Run the web3checks if needed\n let web3Check: ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null =\n null;\n if (appConfig.web3ChecksEnabled) {\n web3Check = (\n await this.getWeb3ChecksFactory(this.api, {\n contextModule,\n derivationPath,\n mapper,\n transaction,\n }).run()\n ).web3Check;\n }\n\n // Get challenge (not supported on Nano S)\n let challenge: string | undefined = undefined;\n if (deviceState.deviceModelId !== DeviceModelId.NANO_S) {\n const challengeRes = await this.api.sendCommand(\n new GetChallengeCommand(),\n );\n if (isSuccessCommandResult(challengeRes)) {\n challenge = challengeRes.data.challenge;\n }\n }\n\n // Get the clear sign contexts\n const clearSignContexts = await contextModule.getContexts({\n challenge: challenge,\n domain: options.domain,\n deviceModelId: deviceState.deviceModelId,\n ...subset,\n });\n\n // NOTE: we need to filter out the ENUM and ERROR types\n // ENUM are handled differently\n // ERROR are not handled at all for now\n const clearSignContextsSuccess: ClearSignContextSuccess<\n Exclude<ClearSignContextSuccessType, ClearSignContextType.ENUM>\n >[] = clearSignContexts.filter(\n (context) =>\n context.type !== ClearSignContextType.ERROR &&\n context.type !== ClearSignContextType.ENUM,\n );\n\n // Retrieve all ENUM contexts\n const transactionEnums: ClearSignContextSuccess<ClearSignContextType.ENUM>[] =\n clearSignContexts.filter(\n (context) => context.type === ClearSignContextType.ENUM,\n );\n\n let filteredContexts: ClearSignContextSuccess[] | GenericContext = [];\n const transactionInfo = clearSignContextsSuccess.find(\n (ctx) => ctx.type === ClearSignContextType.TRANSACTION_INFO,\n );\n\n // If the device does not support the generic parser,\n // we need to filter out the transaction info and transaction field description\n // as they are not supported by the device\n if (\n !this.supportsGenericParser(deviceState, appConfig) ||\n transactionInfo === undefined\n ) {\n filteredContexts = clearSignContextsSuccess.filter(\n (ctx) =>\n ctx.type !== ClearSignContextType.TRANSACTION_INFO &&\n ctx.type !== ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n );\n } else if (transactionInfo.certificate) {\n const transactionFields = clearSignContextsSuccess.filter(\n (ctx) =>\n ctx.type === ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n );\n filteredContexts = {\n transactionInfo: transactionInfo.payload,\n transactionInfoCertificate: transactionInfo.certificate!,\n transactionFields,\n transactionEnums,\n };\n }\n\n return {\n clearSignContexts: filteredContexts,\n serializedTransaction,\n chainId: subset.chainId,\n transactionType: type,\n web3Check,\n };\n }\n\n private supportsGenericParser(\n deviceState: DeviceSessionState,\n appConfig: GetConfigCommandResponse,\n ): boolean {\n return new ApplicationChecker(deviceState, appConfig)\n .withMinVersionExclusive(\"1.14.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAKO,oCACPC,EAKO,2CAKPC,EAAoC,4DACpCC,EAGO,sDACPC,EAAmC,qDAsB5B,MAAMN,CAA4B,CACvC,YACmBO,EACAC,EACAC,EAAuB,CACtCF,EACAC,IACG,IAAI,mBAAiBD,EAAKC,CAAI,EACnC,CANiB,SAAAD,EACA,UAAAC,EACA,0BAAAC,CA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ACCA,EAAI,OAAS,uBAAqB,6BACtC,EACAF,EAAmB,CACjB,gBAAiBC,EAAgB,QACjC,2BAA4BA,EAAgB,YAC5C,kBAAAE,EACA,iBAAAJ,CACF,CACF,CAEA,MAAO,CACL,kBAAmBC,EACnB,sBAAAT,EACA,QAASD,EAAO,QAChB,gBAAiBE,EACjB,UAAAC,CACF,CACF,CAEQ,sBACNN,EACAF,EACS,CACT,OAAO,IAAI,qBAAmBE,EAAaF,CAAS,EACjD,wBAAwB,QAAQ,EAChC,mBAAmB,gBAAc,MAAM,EACvC,MAAM,CACX,CACF",
6
- "names": ["BuildTransactionContextTask_exports", "__export", "BuildTransactionContextTask", "__toCommonJS", "import_context_module", "import_device_management_kit", "import_GetChallengeCommand", "import_GetWeb3CheckTask", "import_ApplicationChecker", "api", "args", "getWeb3ChecksFactory", "contextModule", "mapper", "transaction", "options", "appConfig", "derivationPath", "deviceState", "parsed", "err", "subset", "serializedTransaction", "type", "web3Check", "challenge", "challengeRes", "clearSignContexts", "clearSignContextsSuccess", "context", "transactionEnums", "filteredContexts", "transactionInfo", "ctx", "transactionFields"]
4
+ "sourcesContent": ["import {\n type ClearSignContextSuccess,\n type ClearSignContextSuccessType,\n ClearSignContextType,\n type ContextModule,\n type TransactionSubset,\n} from \"@ledgerhq/context-module\";\nimport {\n DeviceModelId,\n type DeviceSessionState,\n type InternalApi,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { type TransactionOptions } from \"@api/model/TransactionOptions\";\nimport { GetChallengeCommand } from \"@internal/app-binder/command/GetChallengeCommand\";\nimport {\n GetWeb3CheckTask,\n type GetWeb3CheckTaskArgs,\n} from \"@internal/app-binder/task/GetWeb3CheckTask\";\nimport { ApplicationChecker } from \"@internal/shared/utils/ApplicationChecker\";\n\nexport type BuildTransactionTaskResult = {\n readonly clearSignContexts: ClearSignContextSuccess[];\n readonly clearSignContextsOptional: ClearSignContextSuccess[];\n readonly clearSigningType: ClearSigningType;\n};\n\nexport type BuildTransactionContextTaskArgs = {\n readonly contextModule: ContextModule;\n readonly options: TransactionOptions;\n readonly appConfig: GetConfigCommandResponse;\n readonly derivationPath: string;\n readonly transaction: Uint8Array;\n readonly subset: TransactionSubset;\n};\n\nexport class BuildTransactionContextTask {\n constructor(\n private readonly _api: InternalApi,\n private readonly _args: BuildTransactionContextTaskArgs,\n private readonly getWeb3ChecksFactory = (\n api: InternalApi,\n args: GetWeb3CheckTaskArgs,\n ) => new GetWeb3CheckTask(api, args),\n ) {}\n\n async run(): Promise<BuildTransactionTaskResult> {\n const {\n contextModule,\n options,\n appConfig,\n derivationPath,\n transaction,\n subset,\n } = this._args;\n const deviceState = this._api.getDeviceSessionState();\n let filteredContexts: ClearSignContextSuccess[] = [];\n let filteredContextOptional: ClearSignContextSuccess[] = [];\n let clearSigningType: ClearSigningType = ClearSigningType.BASIC;\n\n // Run the web3checks if needed\n let web3Check: ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null =\n null;\n if (appConfig.web3ChecksEnabled) {\n web3Check = (\n await this.getWeb3ChecksFactory(this._api, {\n contextModule,\n derivationPath,\n subset,\n transaction,\n }).run()\n ).web3Check;\n }\n\n // Get challenge (not supported on Nano S)\n let challenge: string | undefined = undefined;\n if (deviceState.deviceModelId !== DeviceModelId.NANO_S) {\n const challengeRes = await this._api.sendCommand(\n new GetChallengeCommand(),\n );\n if (isSuccessCommandResult(challengeRes)) {\n challenge = challengeRes.data.challenge;\n }\n }\n\n // Get the clear sign contexts\n const clearSignContexts = await contextModule.getContexts({\n challenge: challenge,\n domain: options.domain,\n deviceModelId: deviceState.deviceModelId,\n ...subset,\n });\n\n // NOTE: we need to filter out the ENUM and ERROR types\n // ENUM are handled differently\n // ERROR are not handled at all for now\n const clearSignContextsSuccess: ClearSignContextSuccess<\n Exclude<ClearSignContextSuccessType, ClearSignContextType.ENUM>\n >[] = clearSignContexts.filter(\n (context) =>\n context.type !== ClearSignContextType.ERROR &&\n context.type !== ClearSignContextType.ENUM,\n );\n\n // Retrieve all ENUM contexts\n const transactionEnums: ClearSignContextSuccess<ClearSignContextType.ENUM>[] =\n clearSignContexts.filter(\n (context) => context.type === ClearSignContextType.ENUM,\n );\n\n const transactionInfo = clearSignContextsSuccess.find(\n (ctx) => ctx.type === ClearSignContextType.TRANSACTION_INFO,\n );\n\n // If the device does not support the generic parser,\n // we need to filter out the transaction info and transaction field description\n // as they are not supported by the device\n if (\n !this.supportsGenericParser(deviceState, appConfig) ||\n transactionInfo === undefined\n ) {\n filteredContexts = clearSignContextsSuccess.filter(\n (ctx) =>\n ctx.type !== ClearSignContextType.TRANSACTION_INFO &&\n ctx.type !== ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n );\n\n // If the device supports the web3 check, we need to add it to the list of contexts\n if (web3Check) {\n filteredContexts = [web3Check, ...filteredContexts];\n }\n } else if (transactionInfo.certificate) {\n const transactionFields = clearSignContextsSuccess.filter(\n (ctx) =>\n ctx.type === ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n );\n\n filteredContexts = [\n transactionInfo,\n ...transactionFields,\n ...(web3Check ? [web3Check] : []),\n ];\n filteredContextOptional = [...transactionEnums];\n clearSigningType = ClearSigningType.EIP7730;\n }\n\n return {\n clearSignContexts: filteredContexts,\n clearSignContextsOptional: filteredContextOptional,\n clearSigningType,\n };\n }\n\n private supportsGenericParser(\n deviceState: DeviceSessionState,\n appConfig: GetConfigCommandResponse,\n ): boolean {\n return new ApplicationChecker(deviceState, appConfig)\n .withMinVersionExclusive(\"1.14.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAMO,oCACPC,EAKO,2CAGPC,EAAiC,uCAEjCC,EAAoC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,EAAmB,CAACG,EAAW,GAAGH,CAAgB,WAE3CU,EAAgB,YAAa,CACtC,MAAME,EAAoBL,EAAyB,OAChDI,GACCA,EAAI,OAAS,uBAAqB,6BACtC,EAEAX,EAAmB,CACjBU,EACA,GAAGE,EACH,GAAIT,EAAY,CAACA,CAAS,EAAI,CAAC,CACjC,EACAF,EAA0B,CAAC,GAAGQ,CAAgB,EAC9CP,EAAmB,mBAAiB,OACtC,CAEA,MAAO,CACL,kBAAmBF,EACnB,0BAA2BC,EAC3B,iBAAAC,CACF,CACF,CAEQ,sBACNH,EACAJ,EACS,CACT,OAAO,IAAI,qBAAmBI,EAAaJ,CAAS,EACjD,wBAAwB,QAAQ,EAChC,mBAAmB,gBAAc,MAAM,EACvC,MAAM,CACX,CACF",
6
+ "names": ["BuildTransactionContextTask_exports", "__export", "BuildTransactionContextTask", "__toCommonJS", "import_context_module", "import_device_management_kit", "import_ClearSigningType", "import_GetChallengeCommand", "import_GetWeb3CheckTask", "import_ApplicationChecker", "_api", "_args", "getWeb3ChecksFactory", "api", "args", "contextModule", "options", "appConfig", "derivationPath", "transaction", "subset", "deviceState", "filteredContexts", "filteredContextOptional", "clearSigningType", "web3Check", "challenge", "challengeRes", "clearSignContexts", "clearSignContextsSuccess", "context", "transactionEnums", "transactionInfo", "ctx", "transactionFields"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var a=require("@ledgerhq/context-module"),e=require("@ledgerhq/device-management-kit"),T=require("ethers"),u=require("purify-ts"),m=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),p=require("./BuildTransactionContextTask");describe("BuildTransactionContextTask",()=>{const i={getContext:vi.fn(),getContexts:vi.fn(),getTypedDataFilters:vi.fn(),getWeb3Checks:vi.fn()},l={mapTransactionToSubset:vi.fn()},h={domain:"domain-name.eth"},S=(0,e.hexaStringToBuffer)(T.Transaction.from({chainId:1n,nonce:0,data:"0x"}).unsignedSerialized),C={keyUsageNumber:1,payload:new Uint8Array([1,2,3])};let d;const o=(0,m.makeDeviceActionInternalApiMock)(),r=vi.fn();function y(n){return{blindSigningEnabled:!1,web3ChecksEnabled:n,web3ChecksOptIn:!1,version:"1.13.0"}}beforeEach(()=>{vi.resetAllMocks(),o.sendCommand.mockResolvedValue((0,e.CommandResultFactory)({data:{challenge:"challenge"}})),r.mockReturnValue({run:async()=>({web3Check:null})}),d={contextModule:i,mapper:l,transaction:S,options:h,appConfig:y(!1),derivationPath:"44'/60'/0'/0/0"}}),it("should build the transaction context without clear sign contexts",async()=>{const n=new Uint8Array([1,2,3]),t=[],s={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:n,type:0};l.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),i.getContexts.mockResolvedValueOnce(t),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const c=await new p.BuildTransactionContextTask(o,{...d,appConfig:y(!0)},r).run();expect(c).toEqual({clearSignContexts:t,serializedTransaction:n,chainId:1,transactionType:0,web3Check:null})}),it("should build the transaction context with web3checks",async()=>{const n=new Uint8Array([1,2,3]),t=[],s={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:n,type:0},c="web3Check";r.mockReturnValueOnce({run:async()=>({web3Check:c})}),l.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),i.getContexts.mockResolvedValueOnce(t),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const x=await new p.BuildTransactionContextTask(o,{...d,appConfig:y(!0)},r).run();expect(x).toEqual({clearSignContexts:t,serializedTransaction:n,chainId:1,transactionType:0,web3Check:c})}),it("should build the transaction context with clear sign contexts",async()=>{const n=new Uint8Array([1,2,3]),t=[{type:a.ClearSignContextType.TOKEN,payload:"payload-1"},{type:a.ClearSignContextType.NFT,payload:"payload-2"}],s={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:n,type:2},c="web3Check";r.mockReturnValueOnce({run:async()=>({web3Check:c})}),l.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),i.getContexts.mockResolvedValueOnce(t),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const x=await new p.BuildTransactionContextTask(o,d,r).run();expect(x).toEqual({clearSignContexts:t,serializedTransaction:n,chainId:1,transactionType:2,web3Check:null})}),it("should build the transaction context with generic-parser context",async()=>{const n=new Uint8Array([1,2,3]),t=[{type:a.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1",certificate:C},{type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:a.ClearSignContextType.ENUM,payload:"payload-3",id:1,value:2,certificate:C},{type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"}],s={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:n,type:2};l.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),i.getContexts.mockResolvedValueOnce(t),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const c=await new p.BuildTransactionContextTask(o,d,r).run();expect(c).toEqual({clearSignContexts:{transactionInfo:"payload-1",transactionInfoCertificate:C,transactionFields:[t[1],t[3]],transactionEnums:[t[2]]},serializedTransaction:n,chainId:1,transactionType:2,web3Check:null})}),it("should call the mapper with the transaction",async()=>{const n=new Uint8Array([1,2,3]),t=[],s={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:n,type:0};l.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),i.getContexts.mockResolvedValueOnce(t),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),await new p.BuildTransactionContextTask(o,d,r).run(),expect(l.mapTransactionToSubset).toHaveBeenCalledWith(S)}),it("should call the web3checks factory with correct parameters",async()=>{const n=new Uint8Array([1,2,3]),t=[],s={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:n,type:0};l.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),i.getContexts.mockResolvedValueOnce(t),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),await new p.BuildTransactionContextTask(o,{...d,appConfig:y(!0)},r).run(),expect(r).toHaveBeenCalledWith(o,{contextModule:i,derivationPath:"44'/60'/0'/0/0",mapper:l,transaction:S})}),it("should call the context module with the correct parameters",async()=>{const n=new Uint8Array([1,2,3]),t=[],s={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:n,type:0};l.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),i.getContexts.mockResolvedValueOnce(t),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),await new p.BuildTransactionContextTask(o,d,r).run(),expect(i.getContexts).toHaveBeenCalledWith({deviceModelId:e.DeviceModelId.FLEX,challenge:"challenge",domain:"domain-name.eth",...s.subset})}),it("should call the context module without challenge for Nano S",async()=>{const n=new Uint8Array([1,2,3]),t=[],s={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:n,type:0};l.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),i.getContexts.mockResolvedValueOnce(t),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.NANO_S,isSecureConnectionAllowed:!1}),await new p.BuildTransactionContextTask(o,d,r).run(),expect(i.getContexts).toHaveBeenCalledWith({deviceModelId:e.DeviceModelId.NANO_S,domain:"domain-name.eth",...s.subset})}),it("should call the context module without context on error",async()=>{const n=new Uint8Array([1,2,3]),t=[],s={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:n,type:0};l.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),i.getContexts.mockResolvedValueOnce(t),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),o.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({error:new e.UnknownDeviceExchangeError})),await new p.BuildTransactionContextTask(o,d,r).run(),expect(i.getContexts).toHaveBeenCalledWith({deviceModelId:e.DeviceModelId.FLEX,challenge:void 0,domain:"domain-name.eth",...s.subset})}),it("should throw an error if the mapper returns an error",async()=>{const n=new Error("error");l.mapTransactionToSubset.mockReturnValueOnce((0,u.Left)(n)),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const t=new p.BuildTransactionContextTask(o,d,r);await expect(t.run()).rejects.toThrow(n)}),it("should exclude error contexts from the result",async()=>{const n=new Uint8Array([1,2,3]),t=[{type:a.ClearSignContextType.ERROR,error:new Error("error")},{type:a.ClearSignContextType.TOKEN,payload:"payload-1"},{type:a.ClearSignContextType.ERROR,error:new Error("error")},{type:a.ClearSignContextType.NFT,payload:"payload-2"}],s={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:n,type:0};l.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),i.getContexts.mockResolvedValueOnce(t),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const c=await new p.BuildTransactionContextTask(o,d,r).run();expect(c).toEqual({clearSignContexts:[t[1],t[3]],serializedTransaction:n,chainId:1,transactionType:0,web3Check:null})}),it("should exclude generic-parser contexts from the result on old apps",async()=>{const n=new Uint8Array([1,2,3]),t=[{type:a.ClearSignContextType.TRANSACTION_INFO,payload:"transaction_info",certificate:C},{type:a.ClearSignContextType.TOKEN,payload:"payload-1"},{type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"transaction_field"},{type:a.ClearSignContextType.NFT,payload:"payload-2"},{type:a.ClearSignContextType.ENUM,payload:"enum",id:1,value:2,certificate:C}],s={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:n,type:0};l.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),i.getContexts.mockResolvedValueOnce(t),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const c=await new p.BuildTransactionContextTask(o,d,r).run();expect(c).toEqual({clearSignContexts:[t[1],t[3]],serializedTransaction:n,chainId:1,transactionType:0,web3Check:null})}),it("should exclude generic-parser contexts from the result if no transaction_info was found",async()=>{const n=new Uint8Array([1,2,3]),t=[{type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"transaction_field"},{type:a.ClearSignContextType.TOKEN,payload:"payload-1"},{type:a.ClearSignContextType.ENUM,payload:"enum",id:1,value:2},{type:a.ClearSignContextType.NFT,payload:"payload-2"}],s={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:n,type:0};l.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),i.getContexts.mockResolvedValueOnce(t),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.14.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const c=await new p.BuildTransactionContextTask(o,d,r).run();expect(c).toEqual({clearSignContexts:[t[1],t[3]],serializedTransaction:n,chainId:1,transactionType:0,web3Check:null})}),it("should exclude legacy contexts from the result for generic-parser transactions",async()=>{const n=new Uint8Array([1,2,3]),t=[{type:a.ClearSignContextType.TOKEN,payload:"payload-1"},{type:a.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:C},{type:a.ClearSignContextType.EXTERNAL_PLUGIN,payload:"payload-3"},{type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"},{type:a.ClearSignContextType.ENUM,payload:"payload-5",id:1,value:2,certificate:C}],s={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:n,type:2};l.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),i.getContexts.mockResolvedValueOnce(t),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const c=await new p.BuildTransactionContextTask(o,d,r).run();expect(c).toEqual({clearSignContexts:{transactionInfo:"payload-2",transactionInfoCertificate:C,transactionFields:[t[3]],transactionEnums:[t[4]]},serializedTransaction:n,chainId:1,transactionType:2,web3Check:null})}),it("should exclude generic-parser contexts with a nano s device",async()=>{const n=new Uint8Array([1,2,3]),t=[{type:a.ClearSignContextType.TOKEN,payload:"payload-1"},{type:a.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:C},{type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:a.ClearSignContextType.ENUM,payload:"payload-4",id:1,value:2,certificate:C}],s={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:n,type:2};l.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),i.getContexts.mockResolvedValueOnce(t),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.14.0"},deviceModelId:e.DeviceModelId.NANO_S,isSecureConnectionAllowed:!1});const c=await new p.BuildTransactionContextTask(o,d,r).run();expect(c).toEqual({clearSignContexts:[t[0]],serializedTransaction:n,chainId:1,transactionType:2,web3Check:null})}),it("should exclude generic-parser contexts with an old app version",async()=>{const n=new Uint8Array([1,2,3]),t=[{type:a.ClearSignContextType.TOKEN,payload:"payload-1"},{type:a.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:C},{type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:a.ClearSignContextType.ENUM,payload:"payload-4",id:1,value:2,certificate:C}],s={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:n,type:2};l.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),i.getContexts.mockResolvedValueOnce(t),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const c=await new p.BuildTransactionContextTask(o,d,r).run();expect(c).toEqual({clearSignContexts:[t[0]],serializedTransaction:n,chainId:1,transactionType:2,web3Check:null})}),it("should exclude generic-parser contexts with a non ready device",async()=>{const n=new Uint8Array([1,2,3]),t=[{type:a.ClearSignContextType.TOKEN,payload:"payload-1"},{type:a.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:C},{type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:a.ClearSignContextType.ENUM,payload:"payload-4",id:1,value:2,certificate:C}],s={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:n,type:2};l.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),i.getContexts.mockResolvedValueOnce(t),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.Connected,deviceStatus:e.DeviceStatus.NOT_CONNECTED,deviceModelId:e.DeviceModelId.FLEX});const c=await new p.BuildTransactionContextTask(o,d,r).run();expect(c).toEqual({clearSignContexts:[t[0]],serializedTransaction:n,chainId:1,transactionType:2,web3Check:null})}),it("should return no clear sign context if the transaction info certificate is missing",async()=>{const n=new Uint8Array([1,2,3]),t=[{type:a.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},{type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:a.ClearSignContextType.ENUM,payload:"payload-3",id:1,value:2}],s={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:n,type:2};l.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),i.getContexts.mockResolvedValueOnce(t),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.17.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const c=await new p.BuildTransactionContextTask(o,d,r).run();expect(c).toEqual({clearSignContexts:[],serializedTransaction:n,chainId:1,transactionType:2,web3Check:null})})});
1
+ "use strict";var n=require("@ledgerhq/context-module"),t=require("@ledgerhq/device-management-kit"),S=require("ethers"),d=require("../../../api/model/ClearSigningType"),y=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),l=require("./BuildTransactionContextTask"),g=require("./GetWeb3CheckTask");describe("BuildTransactionContextTask",()=>{const s={getContext:vi.fn(),getContexts:vi.fn(),getTypedDataFilters:vi.fn(),getWeb3Checks:vi.fn(),getSolanaContext:vi.fn()},x={domain:"domain-name.eth"},C=(0,t.hexaStringToBuffer)(S.Transaction.from({chainId:1n,nonce:0,data:"0x"}).unsignedSerialized),r={keyUsageNumber:1,payload:new Uint8Array([1,2,3])};let c;const a=(0,y.makeDeviceActionInternalApiMock)(),i=vi.fn();function u(e){return{blindSigningEnabled:!1,web3ChecksEnabled:e,web3ChecksOptIn:!1,version:"1.13.0"}}beforeEach(()=>{vi.resetAllMocks(),a.sendCommand.mockResolvedValue((0,t.CommandResultFactory)({data:{challenge:"challenge"}})),i.mockReturnValue({run:async()=>Promise.resolve({web3Check:null})}),c={contextModule:s,subset:{chainId:1,to:void 0,data:"0x",selector:"0x"},transaction:C,options:x,appConfig:u(!1),derivationPath:"44'/60'/0'/0/0"}}),it("should init with a default GetWeb3CheckTaskFactory",()=>{const e=new l.BuildTransactionContextTask(a,c);expect(e.getWeb3ChecksFactory).toBeDefined(),expect(e.getWeb3ChecksFactory(a,{contextModule:c.contextModule,derivationPath:c.derivationPath,subset:c.subset,transaction:c.transaction})).toBeInstanceOf(g.GetWeb3CheckTask)}),it("should build the transaction context without clear sign contexts",async()=>{const e=[],o=[];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const p=await new l.BuildTransactionContextTask(a,{...c,appConfig:u(!0)},i).run();expect(p).toEqual({clearSignContexts:e,clearSignContextsOptional:o,clearSigningType:d.ClearSigningType.BASIC})}),it("should build the transaction context with web3checks",async()=>{const e=[],o=[],p="web3Check";i.mockReturnValueOnce({run:async()=>Promise.resolve({web3Check:p})}),s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const E=await new l.BuildTransactionContextTask(a,{...c,appConfig:u(!0)},i).run();expect(E).toEqual({clearSignContexts:[p,...e],clearSignContextsOptional:o,clearSigningType:d.ClearSigningType.BASIC})}),it("should build the transaction context with web3checks and generic-parser clear sign contexts",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1",certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ClearSignContextType.ENUM,payload:"payload-3",id:1,value:2,certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"}],o="web3Check";i.mockReturnValueOnce({run:async()=>Promise.resolve({web3Check:o})}),s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const p=await new l.BuildTransactionContextTask(a,{...c,appConfig:u(!0)},i).run();expect(p).toEqual({clearSignContexts:[e[0],e[1],e[3],o],clearSignContextsOptional:[e[2]],clearSigningType:d.ClearSigningType.EIP7730})}),it("should build the transaction context with web3checks and generic-parser clear sign contexts in the correct order",async()=>{const e=[{type:n.ClearSignContextType.ENUM,payload:"payload-3",id:1,value:2,certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1",certificate:r}],o="web3Check";i.mockReturnValueOnce({run:async()=>Promise.resolve({web3Check:o})}),s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const p=await new l.BuildTransactionContextTask(a,{...c,appConfig:u(!0)},i).run();expect(p).toEqual({clearSignContexts:[e[3],e[1],e[2],o],clearSignContextsOptional:[e[0]],clearSigningType:d.ClearSigningType.EIP7730})}),it("should build the transaction context with clear sign contexts",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.NFT,payload:"payload-2"}],o="web3Check";i.mockReturnValueOnce({run:async()=>Promise.resolve({web3Check:o})}),s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const p=await new l.BuildTransactionContextTask(a,c,i).run();expect(p).toEqual({clearSignContexts:e,clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should build the transaction context with generic-parser context",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1",certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ClearSignContextType.ENUM,payload:"payload-3",id:1,value:2,certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"}];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new l.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[0],e[1],e[3]],clearSignContextsOptional:[e[2]],clearSigningType:d.ClearSigningType.EIP7730})}),it("should call the web3checks factory with correct parameters",async()=>{const e=[];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),await new l.BuildTransactionContextTask(a,{...c,appConfig:u(!0)},i).run(),expect(i).toHaveBeenCalledWith(a,{contextModule:s,derivationPath:"44'/60'/0'/0/0",subset:c.subset,transaction:C})}),it("should call the context module with the correct parameters",async()=>{const e=[];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),await new l.BuildTransactionContextTask(a,c,i).run(),expect(s.getContexts).toHaveBeenCalledWith({deviceModelId:t.DeviceModelId.FLEX,challenge:"challenge",domain:"domain-name.eth",...c.subset})}),it("should call the context module without challenge for Nano S",async()=>{const e=[];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.NANO_S,isSecureConnectionAllowed:!1}),await new l.BuildTransactionContextTask(a,c,i).run(),expect(s.getContexts).toHaveBeenCalledWith({deviceModelId:t.DeviceModelId.NANO_S,domain:"domain-name.eth",...c.subset})}),it("should call the context module without context on error",async()=>{const e=[];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),a.sendCommand.mockResolvedValueOnce((0,t.CommandResultFactory)({error:new t.UnknownDeviceExchangeError})),await new l.BuildTransactionContextTask(a,c,i).run(),expect(s.getContexts).toHaveBeenCalledWith({deviceModelId:t.DeviceModelId.FLEX,challenge:void 0,domain:"domain-name.eth",...c.subset})}),it("should exclude error contexts from the result",async()=>{const e=[{type:n.ClearSignContextType.ERROR,error:new Error("error")},{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.ERROR,error:new Error("error")},{type:n.ClearSignContextType.NFT,payload:"payload-2"}];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new l.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should exclude generic-parser contexts from the result on old apps",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"transaction_info",certificate:r},{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"transaction_field"},{type:n.ClearSignContextType.NFT,payload:"payload-2"},{type:n.ClearSignContextType.ENUM,payload:"enum",id:1,value:2,certificate:r}];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new l.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should exclude generic-parser contexts from the result if no transaction_info was found",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"transaction_field"},{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.ENUM,payload:"enum",id:1,value:2},{type:n.ClearSignContextType.NFT,payload:"payload-2"}];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.14.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new l.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should exclude legacy contexts from the result for generic-parser transactions",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:r},{type:n.ClearSignContextType.EXTERNAL_PLUGIN,payload:"payload-3"},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"},{type:n.ClearSignContextType.ENUM,payload:"payload-5",id:1,value:2,certificate:r}];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new l.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[e[4]],clearSigningType:d.ClearSigningType.EIP7730})}),it("should exclude generic-parser contexts with a nano s device",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:n.ClearSignContextType.ENUM,payload:"payload-4",id:1,value:2,certificate:r}];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.14.0"},deviceModelId:t.DeviceModelId.NANO_S,isSecureConnectionAllowed:!1});const o=await new l.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[0]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should exclude generic-parser contexts with an old app version",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:n.ClearSignContextType.ENUM,payload:"payload-4",id:1,value:2,certificate:r}];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new l.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[0]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should exclude generic-parser contexts with a non ready device",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:n.ClearSignContextType.ENUM,payload:"payload-4",id:1,value:2,certificate:r}];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.Connected,deviceStatus:t.DeviceStatus.NOT_CONNECTED,deviceModelId:t.DeviceModelId.FLEX});const o=await new l.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[0]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should return no clear sign context if the transaction info certificate is missing",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ClearSignContextType.ENUM,payload:"payload-3",id:1,value:2}];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.17.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new l.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})})});
2
2
  //# sourceMappingURL=BuildTransactionContextTask.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/task/BuildTransactionContextTask.test.ts"],
4
- "sourcesContent": ["import {\n type ClearSignContext,\n type ClearSignContextSuccess,\n ClearSignContextType,\n type PkiCertificate,\n} from \"@ledgerhq/context-module\";\nimport {\n CommandResultFactory,\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n hexaStringToBuffer,\n UnknownDeviceExchangeError,\n} from \"@ledgerhq/device-management-kit\";\nimport { Transaction } from \"ethers\";\nimport { Left, Right } from \"purify-ts\";\n\nimport type { GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\nimport { type TransactionMapperResult } from \"@internal/transaction/service/mapper/model/TransactionMapperResult\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\n\nimport {\n BuildTransactionContextTask,\n type BuildTransactionContextTaskArgs,\n} from \"./BuildTransactionContextTask\";\n\ndescribe(\"BuildTransactionContextTask\", () => {\n const contextModuleMock = {\n getContext: vi.fn(),\n getContexts: vi.fn(),\n getTypedDataFilters: vi.fn(),\n getWeb3Checks: vi.fn(),\n };\n const mapperMock = {\n mapTransactionToSubset: vi.fn(),\n };\n const defaultOptions = {\n domain: \"domain-name.eth\",\n };\n const defaultTransaction: Uint8Array = hexaStringToBuffer(\n Transaction.from({\n chainId: 1n,\n nonce: 0,\n data: \"0x\",\n }).unsignedSerialized,\n )!;\n const defaultCertificate: PkiCertificate = {\n keyUsageNumber: 1,\n payload: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n let defaultArgs: BuildTransactionContextTaskArgs;\n const apiMock = makeDeviceActionInternalApiMock();\n const getWeb3ChecksFactoryMock = vi.fn();\n\n function createAppConfig(\n web3ChecksEnabled: boolean,\n ): GetConfigCommandResponse {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled,\n web3ChecksOptIn: false,\n version: \"1.13.0\",\n };\n }\n\n beforeEach(() => {\n vi.resetAllMocks();\n apiMock.sendCommand.mockResolvedValue(\n CommandResultFactory({ data: { challenge: \"challenge\" } }),\n );\n getWeb3ChecksFactoryMock.mockReturnValue({\n run: async () => ({ web3Check: null }),\n });\n\n defaultArgs = {\n contextModule: contextModuleMock,\n mapper: mapperMock as unknown as TransactionMapperService,\n transaction: defaultTransaction,\n options: defaultOptions,\n appConfig: createAppConfig(false),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n });\n\n it(\"should build the transaction context without clear sign contexts\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n serializedTransaction,\n chainId: 1,\n transactionType: 0,\n web3Check: null,\n });\n });\n\n it(\"should build the transaction context with web3checks\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => ({ web3Check: expectedWeb3Check }),\n });\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n serializedTransaction,\n chainId: 1,\n transactionType: 0,\n web3Check: expectedWeb3Check,\n });\n });\n\n it(\"should build the transaction context with clear sign contexts\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 2,\n };\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => ({ web3Check: expectedWeb3Check }),\n });\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n serializedTransaction,\n chainId: 1,\n transactionType: 2,\n web3Check: null,\n });\n });\n\n it(\"should build the transaction context with generic-parser context\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n ];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 2,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: {\n transactionInfo: \"payload-1\",\n transactionInfoCertificate: defaultCertificate,\n transactionFields: [clearSignContexts[1], clearSignContexts[3]],\n transactionEnums: [clearSignContexts[2]],\n },\n serializedTransaction,\n chainId: 1,\n transactionType: 2,\n web3Check: null,\n });\n });\n\n it(\"should call the mapper with the transaction\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(mapperMock.mapTransactionToSubset).toHaveBeenCalledWith(\n defaultTransaction,\n );\n });\n\n it(\"should call the web3checks factory with correct parameters\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildTransactionContextTask(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(getWeb3ChecksFactoryMock).toHaveBeenCalledWith(apiMock, {\n contextModule: contextModuleMock,\n derivationPath: \"44'/60'/0'/0/0\",\n mapper: mapperMock,\n transaction: defaultTransaction,\n });\n });\n\n it(\"should call the context module with the correct parameters\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.FLEX,\n challenge: \"challenge\",\n domain: \"domain-name.eth\",\n ...mapperResult.subset,\n });\n });\n\n it(\"should call the context module without challenge for Nano S\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.NANO_S,\n domain: \"domain-name.eth\",\n ...mapperResult.subset,\n });\n });\n\n it(\"should call the context module without context on error\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ error: new UnknownDeviceExchangeError() }),\n );\n\n // WHEN\n await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.FLEX,\n challenge: undefined,\n domain: \"domain-name.eth\",\n ...mapperResult.subset,\n });\n });\n\n it(\"should throw an error if the mapper returns an error\", async () => {\n // GIVEN\n const error = new Error(\"error\");\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Left(error));\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const task = new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n );\n\n // THEN\n await expect(task.run()).rejects.toThrow(error);\n });\n\n it(\"should exclude error contexts from the result\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n serializedTransaction,\n chainId: 1,\n transactionType: 0,\n web3Check: null,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result on old apps\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"transaction_info\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n serializedTransaction,\n chainId: 1,\n transactionType: 0,\n web3Check: null,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result if no transaction_info was found\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n serializedTransaction,\n chainId: 1,\n transactionType: 0,\n web3Check: null,\n });\n });\n\n it(\"should exclude legacy contexts from the result for generic-parser transactions\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-5\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 2,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: {\n transactionInfo: \"payload-2\",\n transactionInfoCertificate: defaultCertificate,\n transactionFields: [clearSignContexts[3]],\n transactionEnums: [clearSignContexts[4]],\n },\n serializedTransaction,\n chainId: 1,\n transactionType: 2,\n web3Check: null,\n });\n });\n\n it(\"should exclude generic-parser contexts with a nano s device\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 2,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n serializedTransaction,\n chainId: 1,\n transactionType: 2,\n web3Check: null,\n });\n });\n\n it(\"should exclude generic-parser contexts with an old app version\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 2,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n serializedTransaction,\n chainId: 1,\n transactionType: 2,\n web3Check: null,\n });\n });\n\n it(\"should exclude generic-parser contexts with a non ready device\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 2,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.NOT_CONNECTED,\n deviceModelId: DeviceModelId.FLEX,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n serializedTransaction,\n chainId: 1,\n transactionType: 2,\n web3Check: null,\n });\n });\n\n it(\"should return no clear sign context if the transaction info certificate is missing\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n },\n ];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 2,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.17.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [],\n serializedTransaction,\n chainId: 1,\n transactionType: 2,\n web3Check: null,\n });\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAKO,oCACPC,EAOO,2CACPC,EAA4B,kBAC5BC,EAA4B,qBAG5BC,EAAgD,6EAIhDC,EAGO,yCAEP,SAAS,8BAA+B,IAAM,CAC5C,MAAMC,EAAoB,CACxB,WAAY,GAAG,GAAG,EAClB,YAAa,GAAG,GAAG,EACnB,oBAAqB,GAAG,GAAG,EAC3B,cAAe,GAAG,GAAG,CACvB,EACMC,EAAa,CACjB,uBAAwB,GAAG,GAAG,CAChC,EACMC,EAAiB,CACrB,OAAQ,iBACV,EACMC,KAAiC,sBACrC,cAAY,KAA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a,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,WAAY,QAAS,QAAS,EAClD,cAAe,gBAAc,KAC7B,0BAA2B,EAC7B,CAAC,EAGD,MAAMO,EAAS,MAAM,IAAI,8BACvBP,EACAD,EACAE,CACF,EAAE,IAAI,EAGN,OAAOM,CAAM,EAAE,QAAQ,CACrB,kBAAmB,CAAC,EACpB,sBAAAH,EACA,QAAS,EACT,gBAAiB,EACjB,UAAW,IACb,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["import_context_module", "import_device_management_kit", "import_ethers", "import_purify_ts", "import_makeInternalApi", "import_BuildTransactionContextTask", "contextModuleMock", "mapperMock", "defaultOptions", "defaultTransaction", "defaultCertificate", "defaultArgs", "apiMock", "getWeb3ChecksFactoryMock", "createAppConfig", "web3ChecksEnabled", "serializedTransaction", "clearSignContexts", "mapperResult", "result", "expectedWeb3Check", "error", "task"]
4
+ "sourcesContent": ["import {\n type ClearSignContext,\n type ClearSignContextSuccess,\n ClearSignContextType,\n type PkiCertificate,\n} from \"@ledgerhq/context-module\";\nimport {\n CommandResultFactory,\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n hexaStringToBuffer,\n UnknownDeviceExchangeError,\n} from \"@ledgerhq/device-management-kit\";\nimport { Transaction } from \"ethers\";\n\nimport type { GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\n\nimport {\n BuildTransactionContextTask,\n type BuildTransactionContextTaskArgs,\n} from \"./BuildTransactionContextTask\";\nimport { GetWeb3CheckTask } from \"./GetWeb3CheckTask\";\n\ndescribe(\"BuildTransactionContextTask\", () => {\n const contextModuleMock = {\n getContext: vi.fn(),\n getContexts: vi.fn(),\n getTypedDataFilters: vi.fn(),\n getWeb3Checks: vi.fn(),\n getSolanaContext: vi.fn(),\n };\n const defaultOptions = {\n domain: \"domain-name.eth\",\n };\n const defaultTransaction: Uint8Array = hexaStringToBuffer(\n Transaction.from({\n chainId: 1n,\n nonce: 0,\n data: \"0x\",\n }).unsignedSerialized,\n )!;\n const defaultCertificate: PkiCertificate = {\n keyUsageNumber: 1,\n payload: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n let defaultArgs: BuildTransactionContextTaskArgs;\n const apiMock = makeDeviceActionInternalApiMock();\n const getWeb3ChecksFactoryMock = vi.fn();\n\n function createAppConfig(\n web3ChecksEnabled: boolean,\n ): GetConfigCommandResponse {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled,\n web3ChecksOptIn: false,\n version: \"1.13.0\",\n };\n }\n\n beforeEach(() => {\n vi.resetAllMocks();\n apiMock.sendCommand.mockResolvedValue(\n CommandResultFactory({ data: { challenge: \"challenge\" } }),\n );\n getWeb3ChecksFactoryMock.mockReturnValue({\n run: async () => Promise.resolve({ web3Check: null }),\n });\n\n defaultArgs = {\n contextModule: contextModuleMock,\n subset: { chainId: 1, to: undefined, data: \"0x\", selector: \"0x\" },\n transaction: defaultTransaction,\n options: defaultOptions,\n appConfig: createAppConfig(false),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n });\n\n it(\"should init with a default GetWeb3CheckTaskFactory\", () => {\n // GIVEN\n const task = new BuildTransactionContextTask(apiMock, defaultArgs);\n\n // THEN\n expect(task[\"getWeb3ChecksFactory\"]).toBeDefined();\n expect(\n task[\"getWeb3ChecksFactory\"](apiMock, {\n contextModule: defaultArgs.contextModule,\n derivationPath: defaultArgs.derivationPath,\n subset: defaultArgs.subset,\n transaction: defaultArgs.transaction,\n }),\n ).toBeInstanceOf(GetWeb3CheckTask);\n });\n\n it(\"should build the transaction context without clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n const clearSignContextsOptional: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with web3checks\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n const clearSignContextsOptional: ClearSignContext[] = [];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [expectedWeb3Check, ...clearSignContexts],\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with web3checks and generic-parser clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n ];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n clearSignContexts[0],\n clearSignContexts[1],\n clearSignContexts[3],\n expectedWeb3Check,\n ],\n clearSignContextsOptional: [clearSignContexts[2]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with web3checks and generic-parser clear sign contexts in the correct order\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n ];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n clearSignContexts[3], // transaction info\n clearSignContexts[1], // transaction field description\n clearSignContexts[2], // transaction field description\n expectedWeb3Check, // web3 check\n ],\n clearSignContextsOptional: [clearSignContexts[0]], // enum\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with generic-parser context\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n clearSignContexts[0],\n clearSignContexts[1],\n clearSignContexts[3],\n ],\n clearSignContextsOptional: [clearSignContexts[2]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should call the web3checks factory with correct parameters\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildTransactionContextTask(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(getWeb3ChecksFactoryMock).toHaveBeenCalledWith(apiMock, {\n contextModule: contextModuleMock,\n derivationPath: \"44'/60'/0'/0/0\",\n subset: defaultArgs.subset,\n transaction: defaultTransaction,\n });\n });\n\n it(\"should call the context module with the correct parameters\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.FLEX,\n challenge: \"challenge\",\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n });\n });\n\n it(\"should call the context module without challenge for Nano S\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.NANO_S,\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n });\n });\n\n it(\"should call the context module without context on error\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ error: new UnknownDeviceExchangeError() }),\n );\n\n // WHEN\n await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.FLEX,\n challenge: undefined,\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n });\n });\n\n it(\"should exclude error contexts from the result\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result on old apps\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"transaction_info\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result if no transaction_info was found\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude legacy contexts from the result for generic-parser transactions\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-5\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [clearSignContexts[4]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should exclude generic-parser contexts with a nano s device\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts with an old app version\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts with a non ready device\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.NOT_CONNECTED,\n deviceModelId: DeviceModelId.FLEX,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should return no clear sign context if the transaction info certificate is missing\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.17.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAKO,oCACPC,EAOO,2CACPC,EAA4B,kBAG5BC,EAAiC,uCACjCC,EAAgD,6EAEhDC,EAGO,yCACPC,EAAiC,8BAEjC,SAAS,8BAA+B,IAAM,CAC5C,MAAMC,EAAoB,CACxB,WAAY,GAAG,GAAG,EAClB,YAAa,GAAG,GAAG,EACnB,oBAAqB,GAAG,GAAG,EAC3B,cAAe,GAAG,GAAG,EACrB,iBAAkB,GAAG,GAAG,CAC1B,EACMC,EAAiB,CACrB,OAAQ,iBACV,EACMC,KAAiC,sBACrC,cAAY,KAAK,CACf,QAAS,GACT,MAAO,EACP,KAAM,IACR,CAAC,EAAE,kBACL,EACMC,EAAqC,CACzC,eAAgB,EAChB,QAAS,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,CAC5C,EAEA,IAAIC,EACJ,MAAMC,KAAU,mCAAgC,EAC1CC,EAA2B,GAAG,GAAG,EAEvC,SAASC,EACPC,EAC0B,CAC1B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yBAAuB,0BACzC,aAAc,eAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,WAAY,QAAS,QAAS,EAClD,cAAe,gBAAc,KAC7B,0BAA2B,EAC7B,CAAC,EAGD,MAAMO,EAAS,MAAM,IAAI,8BACvBP,EACAD,EACAE,CACF,EAAE,IAAI,EAGN,OAAOM,CAAM,EAAE,QAAQ,CACrB,kBAAmB,CAAC,EACpB,0BAA2B,CAAC,EAC5B,iBAAkB,mBAAiB,KACrC,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_context_module", "import_device_management_kit", "import_ethers", "import_ClearSigningType", "import_makeInternalApi", "import_BuildTransactionContextTask", "import_GetWeb3CheckTask", "contextModuleMock", "defaultOptions", "defaultTransaction", "defaultCertificate", "defaultArgs", "apiMock", "getWeb3ChecksFactoryMock", "createAppConfig", "web3ChecksEnabled", "task", "clearSignContexts", "clearSignContextsOptional", "result", "expectedWeb3Check"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var c=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var x=(t,e)=>{for(var a in e)c(t,a,{get:e[a],enumerable:!0})},u=(t,e,a,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of y(e))!g.call(t,r)&&r!==a&&c(t,r,{get:()=>e[r],enumerable:!(s=k(e,r))||s.enumerable});return t};var T=t=>u(c({},"__esModule",{value:!0}),t);var m={};x(m,{GetWeb3CheckTask:()=>b});module.exports=T(m);var C=require("@ledgerhq/context-module"),i=require("@ledgerhq/device-management-kit"),d=require("../../app-binder/command/GetAddressCommand");class b{constructor(e,a){this.api=e;this.args=a}async run(){const e=await this.api.sendCommand(new d.GetAddressCommand({derivationPath:this.args.derivationPath,checkOnDevice:!1,returnChainCode:!1}));if(!(0,i.isSuccessCommandResult)(e))return{web3Check:null,error:e.error};const a=e.data.address,{deviceModelId:s}=this.api.getDeviceSessionState(),{contextModule:r}=this.args;let n;if(this.isRawTx(this.args)){const o=this.args.mapper.mapTransactionToSubset(this.args.transaction);if(o.isRight()){const{subset:l,serializedTransaction:p}=o.extract(),h={deviceModelId:s,from:a,rawTx:(0,i.bufferToHexaString)(p),chainId:l.chainId};n=await r.getWeb3Checks(h)}else throw o.extract()}else{const o={deviceModelId:s,from:a,data:this.args.data};n=await r.getWeb3Checks(o)}return n===null||n?.type!==C.ClearSignContextType.WEB3_CHECK?{web3Check:null}:{web3Check:n}}isRawTx(e){return"transaction"in e}}0&&(module.exports={GetWeb3CheckTask});
1
+ "use strict";var c=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var u=(t,e)=>{for(var a in e)c(t,a,{get:e[a],enumerable:!0})},b=(t,e,a,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of p(e))!y.call(t,r)&&r!==a&&c(t,r,{get:()=>e[r],enumerable:!(s=k(e,r))||s.enumerable});return t};var g=t=>b(c({},"__esModule",{value:!0}),t);var T={};u(T,{GetWeb3CheckTask:()=>x});module.exports=g(T);var C=require("@ledgerhq/context-module"),o=require("@ledgerhq/device-management-kit"),d=require("../../app-binder/command/GetAddressCommand");class x{constructor(e,a){this.api=e;this.args=a}async run(){const e=await this.api.sendCommand(new d.GetAddressCommand({derivationPath:this.args.derivationPath,checkOnDevice:!1,returnChainCode:!1}));if(!(0,o.isSuccessCommandResult)(e))return{web3Check:null,error:e.error};const a=e.data.address,{deviceModelId:s}=this.api.getDeviceSessionState(),{contextModule:r}=this.args;let n;if(this.isRawTx(this.args)){const{subset:i,transaction:l}=this.args,h={deviceModelId:s,from:a,rawTx:(0,o.bufferToHexaString)(l),chainId:i.chainId};n=await r.getWeb3Checks(h)}else{const i={deviceModelId:s,from:a,data:this.args.data};n=await r.getWeb3Checks(i)}return n===null||n?.type!==C.ClearSignContextType.WEB3_CHECK?{web3Check:null}:{web3Check:n}}isRawTx(e){return"transaction"in e}}0&&(module.exports={GetWeb3CheckTask});
2
2
  //# sourceMappingURL=GetWeb3CheckTask.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/task/GetWeb3CheckTask.ts"],
4
- "sourcesContent": ["import {\n type ClearSignContext,\n type ClearSignContextSuccess,\n ClearSignContextType,\n type ContextModule,\n type Web3CheckContext,\n} from \"@ledgerhq/context-module\";\nimport {\n bufferToHexaString,\n type DmkError,\n type InternalApi,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type TypedData } from \"@api/model/TypedData\";\nimport { GetAddressCommand } from \"@internal/app-binder/command/GetAddressCommand\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\n\nexport type GetWeb3CheckTaskResult =\n | {\n readonly web3Check: ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null;\n }\n | {\n readonly web3Check: null;\n error: DmkError;\n };\n\nexport type GetWeb3CheckTypedDataTaskArgs = {\n readonly contextModule: ContextModule;\n readonly derivationPath: string;\n readonly data: TypedData;\n};\nexport type GetWeb3CheckRawTxTaskArgs = {\n readonly contextModule: ContextModule;\n readonly derivationPath: string;\n readonly mapper: TransactionMapperService;\n readonly transaction: Uint8Array;\n};\nexport type GetWeb3CheckTaskArgs =\n | GetWeb3CheckTypedDataTaskArgs\n | GetWeb3CheckRawTxTaskArgs;\n\nexport class GetWeb3CheckTask {\n constructor(\n private readonly api: InternalApi,\n private readonly args: GetWeb3CheckTaskArgs,\n ) {}\n\n async run(): Promise<GetWeb3CheckTaskResult> {\n // Get sender address\n const getAddressResult = await this.api.sendCommand(\n new GetAddressCommand({\n derivationPath: this.args.derivationPath,\n checkOnDevice: false,\n returnChainCode: false,\n }),\n );\n if (!isSuccessCommandResult(getAddressResult)) {\n return {\n web3Check: null,\n error: getAddressResult.error,\n };\n }\n\n const address = getAddressResult.data.address;\n const { deviceModelId } = this.api.getDeviceSessionState();\n const { contextModule } = this.args;\n let web3CheckContext: ClearSignContext | null;\n\n if (this.isRawTx(this.args)) {\n // Transaction simulation\n const parsed = this.args.mapper.mapTransactionToSubset(\n this.args.transaction,\n );\n if (parsed.isRight()) {\n const { subset, serializedTransaction } = parsed.extract();\n const web3Params: Web3CheckContext = {\n deviceModelId,\n from: address,\n rawTx: bufferToHexaString(serializedTransaction),\n chainId: subset.chainId,\n };\n web3CheckContext = await contextModule.getWeb3Checks(web3Params);\n } else {\n throw parsed.extract();\n }\n } else {\n // Typed data simulation\n const web3Params: Web3CheckContext = {\n deviceModelId,\n from: address,\n data: this.args.data,\n };\n web3CheckContext = await contextModule.getWeb3Checks(web3Params);\n }\n\n if (\n web3CheckContext === null ||\n web3CheckContext?.type !== ClearSignContextType.WEB3_CHECK\n ) {\n return {\n web3Check: null,\n };\n }\n\n return {\n web3Check: web3CheckContext,\n };\n }\n\n private isRawTx(\n args: GetWeb3CheckTaskArgs,\n ): args is GetWeb3CheckRawTxTaskArgs {\n return \"transaction\" in args;\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAMO,oCACPC,EAKO,2CAGPC,EAAkC,0DA2B3B,MAAMJ,CAAiB,CAC5B,YACmBK,EACAC,EACjB,CAFiB,SAAAD,EACA,UAAAC,CAChB,CAEH,MAAM,KAAuC,CAE3C,MAAMC,EAAmB,MAAM,KAAK,IAAI,YACtC,IAAI,oBAAkB,CACpB,eAAgB,KAAK,KAAK,eAC1B,cAAe,GACf,gBAAiB,EACnB,CAAC,CACH,EACA,GAAI,IAAC,0BAAuBA,CAAgB,EAC1C,MAAO,CACL,UAAW,KACX,MAAOA,EAAiB,KAC1B,EAGF,MAAMC,EAAUD,EAAiB,KAAK,QAChC,CAAE,cAAAE,CAAc,EAAI,KAAK,IAAI,sBAAsB,EACnD,CAAE,cAAAC,CAAc,EAAI,KAAK,KAC/B,IAAIC,EAEJ,GAAI,KAAK,QAAQ,KAAK,IAAI,EAAG,CAE3B,MAAMC,EAAS,KAAK,KAAK,OAAO,uBAC9B,KAAK,KAAK,WACZ,EACA,GAAIA,EAAO,QAAQ,EAAG,CACpB,KAAM,CAAE,OAAAC,EAAQ,sBAAAC,CAAsB,EAAIF,EAAO,QAAQ,EACnDG,EAA+B,CACnC,cAAAN,EACA,KAAMD,EACN,SAAO,sBAAmBM,CAAqB,EAC/C,QAASD,EAAO,OAClB,EACAF,EAAmB,MAAMD,EAAc,cAAcK,CAAU,CACjE,KACE,OAAMH,EAAO,QAAQ,CAEzB,KAAO,CAEL,MAAMG,EAA+B,CACnC,cAAAN,EACA,KAAMD,EACN,KAAM,KAAK,KAAK,IAClB,EACAG,EAAmB,MAAMD,EAAc,cAAcK,CAAU,CACjE,CAEA,OACEJ,IAAqB,MACrBA,GAAkB,OAAS,uBAAqB,WAEzC,CACL,UAAW,IACb,EAGK,CACL,UAAWA,CACb,CACF,CAEQ,QACNL,EACmC,CACnC,MAAO,gBAAiBA,CAC1B,CACF",
6
- "names": ["GetWeb3CheckTask_exports", "__export", "GetWeb3CheckTask", "__toCommonJS", "import_context_module", "import_device_management_kit", "import_GetAddressCommand", "api", "args", "getAddressResult", "address", "deviceModelId", "contextModule", "web3CheckContext", "parsed", "subset", "serializedTransaction", "web3Params"]
4
+ "sourcesContent": ["import {\n type ClearSignContext,\n type ClearSignContextSuccess,\n ClearSignContextType,\n type ContextModule,\n type TransactionSubset,\n type Web3CheckContext,\n} from \"@ledgerhq/context-module\";\nimport {\n bufferToHexaString,\n type DmkError,\n type InternalApi,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type TypedData } from \"@api/model/TypedData\";\nimport { GetAddressCommand } from \"@internal/app-binder/command/GetAddressCommand\";\n\nexport type GetWeb3CheckTaskResult =\n | {\n readonly web3Check: ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null;\n }\n | {\n readonly web3Check: null;\n error: DmkError;\n };\n\nexport type GetWeb3CheckTypedDataTaskArgs = {\n readonly contextModule: ContextModule;\n readonly derivationPath: string;\n readonly data: TypedData;\n};\nexport type GetWeb3CheckRawTxTaskArgs = {\n readonly contextModule: ContextModule;\n readonly derivationPath: string;\n readonly subset: TransactionSubset;\n readonly transaction: Uint8Array;\n};\nexport type GetWeb3CheckTaskArgs =\n | GetWeb3CheckTypedDataTaskArgs\n | GetWeb3CheckRawTxTaskArgs;\n\nexport class GetWeb3CheckTask {\n constructor(\n private readonly api: InternalApi,\n private readonly args: GetWeb3CheckTaskArgs,\n ) {}\n\n async run(): Promise<GetWeb3CheckTaskResult> {\n // Get sender address\n const getAddressResult = await this.api.sendCommand(\n new GetAddressCommand({\n derivationPath: this.args.derivationPath,\n checkOnDevice: false,\n returnChainCode: false,\n }),\n );\n if (!isSuccessCommandResult(getAddressResult)) {\n return {\n web3Check: null,\n error: getAddressResult.error,\n };\n }\n\n const address = getAddressResult.data.address;\n const { deviceModelId } = this.api.getDeviceSessionState();\n const { contextModule } = this.args;\n let web3CheckContext: ClearSignContext | null;\n\n if (this.isRawTx(this.args)) {\n // Transaction simulation\n const { subset, transaction } = this.args;\n const web3Params: Web3CheckContext = {\n deviceModelId,\n from: address,\n rawTx: bufferToHexaString(transaction),\n chainId: subset.chainId,\n };\n web3CheckContext = await contextModule.getWeb3Checks(web3Params);\n } else {\n // Typed data simulation\n const web3Params: Web3CheckContext = {\n deviceModelId,\n from: address,\n data: this.args.data,\n };\n web3CheckContext = await contextModule.getWeb3Checks(web3Params);\n }\n\n if (\n web3CheckContext === null ||\n web3CheckContext?.type !== ClearSignContextType.WEB3_CHECK\n ) {\n return {\n web3Check: null,\n };\n }\n\n return {\n web3Check: web3CheckContext,\n };\n }\n\n private isRawTx(\n args: GetWeb3CheckTaskArgs,\n ): args is GetWeb3CheckRawTxTaskArgs {\n return \"transaction\" in args;\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAOO,oCACPC,EAKO,2CAGPC,EAAkC,0DA0B3B,MAAMJ,CAAiB,CAC5B,YACmBK,EACAC,EACjB,CAFiB,SAAAD,EACA,UAAAC,CAChB,CAEH,MAAM,KAAuC,CAE3C,MAAMC,EAAmB,MAAM,KAAK,IAAI,YACtC,IAAI,oBAAkB,CACpB,eAAgB,KAAK,KAAK,eAC1B,cAAe,GACf,gBAAiB,EACnB,CAAC,CACH,EACA,GAAI,IAAC,0BAAuBA,CAAgB,EAC1C,MAAO,CACL,UAAW,KACX,MAAOA,EAAiB,KAC1B,EAGF,MAAMC,EAAUD,EAAiB,KAAK,QAChC,CAAE,cAAAE,CAAc,EAAI,KAAK,IAAI,sBAAsB,EACnD,CAAE,cAAAC,CAAc,EAAI,KAAK,KAC/B,IAAIC,EAEJ,GAAI,KAAK,QAAQ,KAAK,IAAI,EAAG,CAE3B,KAAM,CAAE,OAAAC,EAAQ,YAAAC,CAAY,EAAI,KAAK,KAC/BC,EAA+B,CACnC,cAAAL,EACA,KAAMD,EACN,SAAO,sBAAmBK,CAAW,EACrC,QAASD,EAAO,OAClB,EACAD,EAAmB,MAAMD,EAAc,cAAcI,CAAU,CACjE,KAAO,CAEL,MAAMA,EAA+B,CACnC,cAAAL,EACA,KAAMD,EACN,KAAM,KAAK,KAAK,IAClB,EACAG,EAAmB,MAAMD,EAAc,cAAcI,CAAU,CACjE,CAEA,OACEH,IAAqB,MACrBA,GAAkB,OAAS,uBAAqB,WAEzC,CACL,UAAW,IACb,EAGK,CACL,UAAWA,CACb,CACF,CAEQ,QACNL,EACmC,CACnC,MAAO,gBAAiBA,CAC1B,CACF",
6
+ "names": ["GetWeb3CheckTask_exports", "__export", "GetWeb3CheckTask", "__toCommonJS", "import_context_module", "import_device_management_kit", "import_GetAddressCommand", "api", "args", "getAddressResult", "address", "deviceModelId", "contextModule", "web3CheckContext", "subset", "transaction", "web3Params"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("@ledgerhq/device-management-kit"),r=require("purify-ts"),i=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),s=require("../../app-binder/task/GetWeb3CheckTask");describe("GetWeb3CheckTask",()=>{const a=(0,i.makeDeviceActionInternalApiMock)(),t={getWeb3Checks:vi.fn()},o={mapTransactionToSubset:vi.fn()},d=new Uint8Array([1,2,3,4]),c="44'/60'/0'/0/0";describe("run",()=>{beforeEach(()=>{vi.clearAllMocks(),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.16.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!0})}),describe("errors",()=>{it("should throw an error if mapTransactionToSubset assert.fails",async()=>{const n=new Error("error");a.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({data:{address:"address"}})),o.mapTransactionToSubset.mockReturnValue((0,r.Left)(n));try{await new s.GetWeb3CheckTask(a,{contextModule:t,mapper:o,transaction:d,derivationPath:c}).run(),assert.fail("should throw an error")}catch(u){expect(u).toEqual(n)}}),it("should return a context error if GetAddressCommand assert.fails",async()=>{o.mapTransactionToSubset.mockReturnValue((0,r.Right)({subset:{},serializedTransaction:new Uint8Array})),a.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({error:new e.InvalidStatusWordError("error")}));const n=await new s.GetWeb3CheckTask(a,{contextModule:t,mapper:o,transaction:d,derivationPath:c}).run();expect(n).toEqual({web3Check:null,error:new e.InvalidStatusWordError("error")})}),it("should return null if the type is not a ClearSignContextSuccess web3check",async()=>{o.mapTransactionToSubset.mockReturnValue((0,r.Right)({subset:{},serializedTransaction:new Uint8Array})),a.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({data:{address:"address"}})),t.getWeb3Checks.mockResolvedValue({type:"invalid-type",id:1});const n=await new s.GetWeb3CheckTask(a,{contextModule:t,mapper:o,transaction:d,derivationPath:c}).run();expect(n).toEqual({web3Check:null})})}),describe("success",()=>{it("should return null if the context module does not have a web3 check",async()=>{o.mapTransactionToSubset.mockReturnValue((0,r.Right)({subset:{},serializedTransaction:new Uint8Array})),a.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({data:{address:"address"}})),t.getWeb3Checks.mockResolvedValue(null);const n=await new s.GetWeb3CheckTask(a,{contextModule:t,mapper:o,transaction:d,derivationPath:c}).run();expect(n).toEqual({web3Check:null})}),it("should return a web3 check",async()=>{const n={type:"web3Check",id:1};o.mapTransactionToSubset.mockReturnValue((0,r.Right)({subset:{},serializedTransaction:new Uint8Array})),a.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({data:{address:"address"}})),t.getWeb3Checks.mockResolvedValue(n);const u=await new s.GetWeb3CheckTask(a,{contextModule:t,mapper:o,transaction:d,derivationPath:c}).run();expect(u).toEqual({web3Check:n})}),it("should return a web3 check for typed data",async()=>{const n={type:"web3Check",id:1};a.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({data:{address:"address"}})),t.getWeb3Checks.mockResolvedValue(n);const u=await new s.GetWeb3CheckTask(a,{contextModule:t,data:"typed data",derivationPath:c}).run();expect(u).toEqual({web3Check:n})}),it("should call the context module with the right parameters",async()=>{o.mapTransactionToSubset.mockReturnValue((0,r.Right)({subset:{chainId:15,from:"from"},serializedTransaction:new Uint8Array([1,2,3])})),a.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({data:{address:"address"}})),t.getWeb3Checks.mockResolvedValue(null),await new s.GetWeb3CheckTask(a,{contextModule:t,mapper:o,transaction:d,derivationPath:c}).run(),expect(t.getWeb3Checks).toHaveBeenCalledWith({deviceModelId:e.DeviceModelId.FLEX,from:"address",rawTx:"0x010203",chainId:15})})})})});
1
+ "use strict";var e=require("@ledgerhq/device-management-kit"),l=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),n=require("../../app-binder/task/GetWeb3CheckTask");describe("GetWeb3CheckTask",()=>{const t=(0,l.makeDeviceActionInternalApiMock)(),o={getWeb3Checks:vi.fn()},d=new Uint8Array([1,2,3,4]),a="44'/60'/0'/0/0",c={chainId:15,to:"to",data:"0x060708090A",selector:"0x06070809",value:0n};describe("run",()=>{beforeEach(()=>{vi.clearAllMocks(),t.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.16.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!0})}),describe("errors",()=>{it("should return a context error if GetAddressCommand assert.fails",async()=>{t.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({error:new e.InvalidStatusWordError("error")}));const s=await new n.GetWeb3CheckTask(t,{contextModule:o,subset:c,transaction:d,derivationPath:a}).run();expect(s).toEqual({web3Check:null,error:new e.InvalidStatusWordError("error")})}),it("should return null if the type is not a ClearSignContextSuccess web3check",async()=>{t.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({data:{address:"address"}})),o.getWeb3Checks.mockResolvedValue({type:"invalid-type",id:1});const s=await new n.GetWeb3CheckTask(t,{contextModule:o,subset:c,transaction:d,derivationPath:a}).run();expect(s).toEqual({web3Check:null})})}),describe("success",()=>{it("should return null if the context module does not have a web3 check",async()=>{t.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({data:{address:"address"}})),o.getWeb3Checks.mockResolvedValue(null);const s=await new n.GetWeb3CheckTask(t,{contextModule:o,subset:c,transaction:d,derivationPath:a}).run();expect(s).toEqual({web3Check:null})}),it("should return a web3 check",async()=>{const s={type:"web3Check",id:1};t.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({data:{address:"address"}})),o.getWeb3Checks.mockResolvedValue(s);const r=await new n.GetWeb3CheckTask(t,{contextModule:o,subset:c,transaction:d,derivationPath:a}).run();expect(r).toEqual({web3Check:s})}),it("should return a web3 check for typed data",async()=>{const s={type:"web3Check",id:1};t.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({data:{address:"address"}})),o.getWeb3Checks.mockResolvedValue(s);const r=await new n.GetWeb3CheckTask(t,{contextModule:o,data:"typed data",derivationPath:a}).run();expect(r).toEqual({web3Check:s})}),it("should call the context module with the right parameters",async()=>{t.sendCommand.mockResolvedValueOnce((0,e.CommandResultFactory)({data:{address:"address"}})),o.getWeb3Checks.mockResolvedValue(null),await new n.GetWeb3CheckTask(t,{contextModule:o,subset:c,transaction:d,derivationPath:a}).run(),expect(o.getWeb3Checks).toHaveBeenCalledWith({deviceModelId:e.DeviceModelId.FLEX,from:"address",rawTx:"0x01020304",chainId:15})})})})});
2
2
  //# sourceMappingURL=GetWeb3CheckTask.test.js.map