@ledgerhq/device-signer-kit-ethereum 0.0.0-rn-hid-improvements-20250523090318 → 0.0.0-rn-ble-pairing-removed-while-reconnecting-20250731133348

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 (288) hide show
  1. package/README.md +53 -0
  2. package/lib/cjs/api/SignerEth.js +1 -1
  3. package/lib/cjs/api/SignerEth.js.map +1 -1
  4. package/lib/cjs/api/app-binder/SignDelegationAuthorizationTypes.js +2 -0
  5. package/lib/cjs/api/app-binder/SignDelegationAuthorizationTypes.js.map +7 -0
  6. package/lib/cjs/api/app-binder/SignTransactionDeviceActionTypes.js +1 -1
  7. package/lib/cjs/api/app-binder/SignTransactionDeviceActionTypes.js.map +2 -2
  8. package/lib/cjs/api/index.js +1 -1
  9. package/lib/cjs/api/index.js.map +2 -2
  10. package/lib/cjs/api/model/ClearSigningType.js +2 -0
  11. package/lib/cjs/api/model/ClearSigningType.js.map +7 -0
  12. package/lib/cjs/internal/DefaultSignerEth.js +1 -1
  13. package/lib/cjs/internal/DefaultSignerEth.js.map +3 -3
  14. package/lib/cjs/internal/DefaultSignerEth.test.js +1 -1
  15. package/lib/cjs/internal/DefaultSignerEth.test.js.map +3 -3
  16. package/lib/cjs/internal/app-binder/EthAppBinder.js +1 -1
  17. package/lib/cjs/internal/app-binder/EthAppBinder.js.map +3 -3
  18. package/lib/cjs/internal/app-binder/EthAppBinder.test.js +1 -1
  19. package/lib/cjs/internal/app-binder/EthAppBinder.test.js.map +3 -3
  20. package/lib/cjs/internal/app-binder/command/ProvideProxyInfoCommand.js +2 -0
  21. package/lib/cjs/internal/app-binder/command/ProvideProxyInfoCommand.js.map +7 -0
  22. package/lib/cjs/internal/app-binder/command/ProvideProxyInfoCommand.test.js +2 -0
  23. package/lib/cjs/internal/app-binder/command/ProvideProxyInfoCommand.test.js.map +7 -0
  24. package/lib/cjs/internal/app-binder/command/SignAuthorizationDelegationCommand.js +2 -0
  25. package/lib/cjs/internal/app-binder/command/SignAuthorizationDelegationCommand.js.map +7 -0
  26. package/lib/cjs/internal/app-binder/command/SignAuthorizationDelegationCommand.test.js +2 -0
  27. package/lib/cjs/internal/app-binder/command/SignAuthorizationDelegationCommand.test.js.map +7 -0
  28. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js +1 -1
  29. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js.map +3 -3
  30. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js +1 -1
  31. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js.map +3 -3
  32. package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js +1 -1
  33. package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js.map +3 -3
  34. package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js +1 -1
  35. package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js.map +2 -2
  36. package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.test.js +1 -1
  37. package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.test.js.map +2 -2
  38. package/lib/cjs/internal/app-binder/task/BuildSubContextTask.js +2 -0
  39. package/lib/cjs/internal/app-binder/task/BuildSubContextTask.js.map +7 -0
  40. package/lib/cjs/internal/app-binder/task/BuildSubContextTask.test.js +2 -0
  41. package/lib/cjs/internal/app-binder/task/BuildSubContextTask.test.js.map +7 -0
  42. package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.js +1 -1
  43. package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.js.map +3 -3
  44. package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.test.js +1 -1
  45. package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.test.js.map +3 -3
  46. package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.test.js +1 -1
  47. package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.test.js.map +2 -2
  48. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.js +1 -1
  49. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.js.map +3 -3
  50. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.test.js +1 -1
  51. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.test.js.map +3 -3
  52. package/lib/cjs/internal/app-binder/task/SendPayloadInChunksTask.js +1 -1
  53. package/lib/cjs/internal/app-binder/task/SendPayloadInChunksTask.js.map +1 -1
  54. package/lib/cjs/internal/app-binder/task/SendSignAuthorizationDelegationTask.js +2 -0
  55. package/lib/cjs/internal/app-binder/task/SendSignAuthorizationDelegationTask.js.map +7 -0
  56. package/lib/cjs/internal/app-binder/task/SendSignAuthorizationDelegationTask.test.js +2 -0
  57. package/lib/cjs/internal/app-binder/task/SendSignAuthorizationDelegationTask.test.js.map +7 -0
  58. package/lib/cjs/internal/app-binder/task/SendSignTransactionTask.js +1 -1
  59. package/lib/cjs/internal/app-binder/task/SendSignTransactionTask.js.map +3 -3
  60. package/lib/cjs/internal/app-binder/task/SendSignTransactionTask.test.js +1 -1
  61. package/lib/cjs/internal/app-binder/task/SendSignTransactionTask.test.js.map +3 -3
  62. package/lib/cjs/internal/di.js +1 -1
  63. package/lib/cjs/internal/di.js.map +3 -3
  64. package/lib/cjs/internal/eip7702/di/eip7702Module.js +2 -0
  65. package/lib/cjs/internal/eip7702/di/eip7702Module.js.map +7 -0
  66. package/lib/cjs/internal/eip7702/di/eip7702Module.test.js +2 -0
  67. package/lib/cjs/internal/eip7702/di/eip7702Module.test.js.map +7 -0
  68. package/lib/cjs/internal/eip7702/di/eip7702Types.js +2 -0
  69. package/lib/cjs/internal/eip7702/di/eip7702Types.js.map +7 -0
  70. package/lib/cjs/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.js +2 -0
  71. package/lib/cjs/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.js.map +7 -0
  72. package/lib/cjs/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.test.js +2 -0
  73. package/lib/cjs/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.test.js.map +7 -0
  74. package/lib/cjs/internal/shared/utils/ApplicationChecker.js +1 -1
  75. package/lib/cjs/internal/shared/utils/ApplicationChecker.js.map +3 -3
  76. package/lib/cjs/internal/shared/utils/ApplicationChecker.test.js +1 -1
  77. package/lib/cjs/internal/shared/utils/ApplicationChecker.test.js.map +2 -2
  78. package/lib/cjs/internal/transaction/di/transactionModule.js +1 -1
  79. package/lib/cjs/internal/transaction/di/transactionModule.js.map +3 -3
  80. package/lib/cjs/internal/transaction/di/transactionModule.test.js +1 -1
  81. package/lib/cjs/internal/transaction/di/transactionModule.test.js.map +2 -2
  82. package/lib/cjs/internal/transaction/service/mapper/EthersTransactionMapperService.js +2 -0
  83. package/lib/cjs/internal/transaction/service/mapper/EthersTransactionMapperService.js.map +7 -0
  84. package/lib/cjs/internal/transaction/service/mapper/EthersTransactionMapperService.test.js +2 -0
  85. package/lib/cjs/internal/transaction/service/mapper/EthersTransactionMapperService.test.js.map +7 -0
  86. package/lib/cjs/internal/transaction/service/mapper/TransactionMapperService.js +1 -1
  87. package/lib/cjs/internal/transaction/service/mapper/TransactionMapperService.js.map +3 -3
  88. package/lib/cjs/package.json +1 -1
  89. package/lib/esm/api/app-binder/SignDelegationAuthorizationTypes.js +1 -0
  90. package/lib/esm/api/app-binder/SignTransactionDeviceActionTypes.js +1 -1
  91. package/lib/esm/api/app-binder/SignTransactionDeviceActionTypes.js.map +2 -2
  92. package/lib/esm/api/index.js +1 -1
  93. package/lib/esm/api/index.js.map +2 -2
  94. package/lib/esm/api/model/ClearSigningType.js +2 -0
  95. package/lib/esm/api/model/ClearSigningType.js.map +7 -0
  96. package/lib/esm/internal/DefaultSignerEth.js +1 -1
  97. package/lib/esm/internal/DefaultSignerEth.js.map +3 -3
  98. package/lib/esm/internal/DefaultSignerEth.test.js +1 -1
  99. package/lib/esm/internal/DefaultSignerEth.test.js.map +3 -3
  100. package/lib/esm/internal/app-binder/EthAppBinder.js +1 -1
  101. package/lib/esm/internal/app-binder/EthAppBinder.js.map +3 -3
  102. package/lib/esm/internal/app-binder/EthAppBinder.test.js +1 -1
  103. package/lib/esm/internal/app-binder/EthAppBinder.test.js.map +3 -3
  104. package/lib/esm/internal/app-binder/command/ProvideProxyInfoCommand.js +2 -0
  105. package/lib/esm/internal/app-binder/command/ProvideProxyInfoCommand.js.map +7 -0
  106. package/lib/esm/internal/app-binder/command/ProvideProxyInfoCommand.test.js +2 -0
  107. package/lib/esm/internal/app-binder/command/ProvideProxyInfoCommand.test.js.map +7 -0
  108. package/lib/esm/internal/app-binder/command/SignAuthorizationDelegationCommand.js +2 -0
  109. package/lib/esm/internal/app-binder/command/SignAuthorizationDelegationCommand.js.map +7 -0
  110. package/lib/esm/internal/app-binder/command/SignAuthorizationDelegationCommand.test.js +2 -0
  111. package/lib/esm/internal/app-binder/command/SignAuthorizationDelegationCommand.test.js.map +7 -0
  112. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js +1 -1
  113. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js.map +3 -3
  114. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js +1 -1
  115. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js.map +3 -3
  116. package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js +1 -1
  117. package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js.map +3 -3
  118. package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js +1 -1
  119. package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js.map +2 -2
  120. package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.test.js +1 -1
  121. package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.test.js.map +2 -2
  122. package/lib/esm/internal/app-binder/task/BuildSubContextTask.js +2 -0
  123. package/lib/esm/internal/app-binder/task/BuildSubContextTask.js.map +7 -0
  124. package/lib/esm/internal/app-binder/task/BuildSubContextTask.test.js +2 -0
  125. package/lib/esm/internal/app-binder/task/BuildSubContextTask.test.js.map +7 -0
  126. package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.js +1 -1
  127. package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.js.map +3 -3
  128. package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.test.js +1 -1
  129. package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.test.js.map +3 -3
  130. package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.test.js +1 -1
  131. package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.test.js.map +2 -2
  132. package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.js +1 -1
  133. package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.js.map +3 -3
  134. package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.test.js +1 -1
  135. package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.test.js.map +3 -3
  136. package/lib/esm/internal/app-binder/task/SendPayloadInChunksTask.js +1 -1
  137. package/lib/esm/internal/app-binder/task/SendPayloadInChunksTask.js.map +1 -1
  138. package/lib/esm/internal/app-binder/task/SendSignAuthorizationDelegationTask.js +2 -0
  139. package/lib/esm/internal/app-binder/task/SendSignAuthorizationDelegationTask.js.map +7 -0
  140. package/lib/esm/internal/app-binder/task/SendSignAuthorizationDelegationTask.test.js +2 -0
  141. package/lib/esm/internal/app-binder/task/SendSignAuthorizationDelegationTask.test.js.map +7 -0
  142. package/lib/esm/internal/app-binder/task/SendSignTransactionTask.js +1 -1
  143. package/lib/esm/internal/app-binder/task/SendSignTransactionTask.js.map +3 -3
  144. package/lib/esm/internal/app-binder/task/SendSignTransactionTask.test.js +1 -1
  145. package/lib/esm/internal/app-binder/task/SendSignTransactionTask.test.js.map +3 -3
  146. package/lib/esm/internal/di.js +1 -1
  147. package/lib/esm/internal/di.js.map +3 -3
  148. package/lib/esm/internal/eip7702/di/eip7702Module.js +2 -0
  149. package/lib/esm/internal/eip7702/di/eip7702Module.js.map +7 -0
  150. package/lib/esm/internal/eip7702/di/eip7702Module.test.js +2 -0
  151. package/lib/esm/internal/eip7702/di/eip7702Module.test.js.map +7 -0
  152. package/lib/esm/internal/eip7702/di/eip7702Types.js +2 -0
  153. package/lib/esm/internal/eip7702/di/eip7702Types.js.map +7 -0
  154. package/lib/esm/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.js +2 -0
  155. package/lib/esm/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.js.map +7 -0
  156. package/lib/esm/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.test.js +2 -0
  157. package/lib/esm/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.test.js.map +7 -0
  158. package/lib/esm/internal/shared/utils/ApplicationChecker.js +1 -1
  159. package/lib/esm/internal/shared/utils/ApplicationChecker.js.map +3 -3
  160. package/lib/esm/internal/shared/utils/ApplicationChecker.test.js +1 -1
  161. package/lib/esm/internal/shared/utils/ApplicationChecker.test.js.map +2 -2
  162. package/lib/esm/internal/transaction/di/transactionModule.js +1 -1
  163. package/lib/esm/internal/transaction/di/transactionModule.js.map +3 -3
  164. package/lib/esm/internal/transaction/di/transactionModule.test.js +1 -1
  165. package/lib/esm/internal/transaction/di/transactionModule.test.js.map +2 -2
  166. package/lib/esm/internal/transaction/service/mapper/EthersTransactionMapperService.js +2 -0
  167. package/lib/esm/internal/transaction/service/mapper/EthersTransactionMapperService.js.map +7 -0
  168. package/lib/esm/internal/transaction/service/mapper/EthersTransactionMapperService.test.js +2 -0
  169. package/lib/esm/internal/transaction/service/mapper/EthersTransactionMapperService.test.js.map +7 -0
  170. package/lib/esm/internal/transaction/service/mapper/TransactionMapperService.js +0 -1
  171. package/lib/esm/internal/transaction/service/mapper/TransactionMapperService.js.map +4 -4
  172. package/lib/esm/package.json +1 -1
  173. package/lib/types/api/SignerEth.d.ts +4 -2
  174. package/lib/types/api/SignerEth.d.ts.map +1 -1
  175. package/lib/types/api/app-binder/SignDelegationAuthorizationTypes.d.ts +19 -0
  176. package/lib/types/api/app-binder/SignDelegationAuthorizationTypes.d.ts.map +1 -0
  177. package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts +6 -7
  178. package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts.map +1 -1
  179. package/lib/types/api/index.d.ts +5 -0
  180. package/lib/types/api/index.d.ts.map +1 -1
  181. package/lib/types/api/model/ClearSigningType.d.ts +5 -0
  182. package/lib/types/api/model/ClearSigningType.d.ts.map +1 -0
  183. package/lib/types/internal/DefaultSignerEth.d.ts +2 -0
  184. package/lib/types/internal/DefaultSignerEth.d.ts.map +1 -1
  185. package/lib/types/internal/app-binder/EthAppBinder.d.ts +8 -1
  186. package/lib/types/internal/app-binder/EthAppBinder.d.ts.map +1 -1
  187. package/lib/types/internal/app-binder/command/ProvideProxyInfoCommand.d.ts +20 -0
  188. package/lib/types/internal/app-binder/command/ProvideProxyInfoCommand.d.ts.map +1 -0
  189. package/lib/types/internal/app-binder/command/ProvideProxyInfoCommand.test.d.ts +2 -0
  190. package/lib/types/internal/app-binder/command/ProvideProxyInfoCommand.test.d.ts.map +1 -0
  191. package/lib/types/internal/app-binder/command/SignAuthorizationDelegationCommand.d.ts +29 -0
  192. package/lib/types/internal/app-binder/command/SignAuthorizationDelegationCommand.d.ts.map +1 -0
  193. package/lib/types/internal/app-binder/command/SignAuthorizationDelegationCommand.test.d.ts +2 -0
  194. package/lib/types/internal/app-binder/command/SignAuthorizationDelegationCommand.test.d.ts.map +1 -0
  195. package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts +10 -16
  196. package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts.map +1 -1
  197. package/lib/types/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.d.ts.map +1 -1
  198. package/lib/types/internal/app-binder/task/BuildSubContextTask.d.ts +21 -0
  199. package/lib/types/internal/app-binder/task/BuildSubContextTask.d.ts.map +1 -0
  200. package/lib/types/internal/app-binder/task/BuildSubContextTask.test.d.ts +2 -0
  201. package/lib/types/internal/app-binder/task/BuildSubContextTask.test.d.ts.map +1 -0
  202. package/lib/types/internal/app-binder/task/BuildTransactionContextTask.d.ts +8 -7
  203. package/lib/types/internal/app-binder/task/BuildTransactionContextTask.d.ts.map +1 -1
  204. package/lib/types/internal/app-binder/task/ProvideTransactionContextTask.d.ts +28 -22
  205. package/lib/types/internal/app-binder/task/ProvideTransactionContextTask.d.ts.map +1 -1
  206. package/lib/types/internal/app-binder/task/SendPayloadInChunksTask.d.ts +1 -2
  207. package/lib/types/internal/app-binder/task/SendPayloadInChunksTask.d.ts.map +1 -1
  208. package/lib/types/internal/app-binder/task/SendSignAuthorizationDelegationTask.d.ts +18 -0
  209. package/lib/types/internal/app-binder/task/SendSignAuthorizationDelegationTask.d.ts.map +1 -0
  210. package/lib/types/internal/app-binder/task/SendSignAuthorizationDelegationTask.test.d.ts +2 -0
  211. package/lib/types/internal/app-binder/task/SendSignAuthorizationDelegationTask.test.d.ts.map +1 -0
  212. package/lib/types/internal/app-binder/task/SendSignTransactionTask.d.ts +2 -1
  213. package/lib/types/internal/app-binder/task/SendSignTransactionTask.d.ts.map +1 -1
  214. package/lib/types/internal/di.d.ts.map +1 -1
  215. package/lib/types/internal/eip7702/di/eip7702Module.d.ts +3 -0
  216. package/lib/types/internal/eip7702/di/eip7702Module.d.ts.map +1 -0
  217. package/lib/types/internal/eip7702/di/eip7702Module.test.d.ts +2 -0
  218. package/lib/types/internal/eip7702/di/eip7702Module.test.d.ts.map +1 -0
  219. package/lib/types/internal/eip7702/di/eip7702Types.d.ts +4 -0
  220. package/lib/types/internal/eip7702/di/eip7702Types.d.ts.map +1 -0
  221. package/lib/types/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.d.ts +8 -0
  222. package/lib/types/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.d.ts.map +1 -0
  223. package/lib/types/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.test.d.ts +2 -0
  224. package/lib/types/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.test.d.ts.map +1 -0
  225. package/lib/types/internal/shared/utils/ApplicationChecker.d.ts.map +1 -1
  226. package/lib/types/internal/transaction/di/transactionModule.d.ts.map +1 -1
  227. package/lib/types/internal/transaction/service/mapper/EthersTransactionMapperService.d.ts +8 -0
  228. package/lib/types/internal/transaction/service/mapper/EthersTransactionMapperService.d.ts.map +1 -0
  229. package/lib/types/internal/transaction/service/mapper/EthersTransactionMapperService.test.d.ts +2 -0
  230. package/lib/types/internal/transaction/service/mapper/EthersTransactionMapperService.test.d.ts.map +1 -0
  231. package/lib/types/internal/transaction/service/mapper/TransactionMapperService.d.ts +4 -7
  232. package/lib/types/internal/transaction/service/mapper/TransactionMapperService.d.ts.map +1 -1
  233. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  234. package/package.json +9 -9
  235. package/lib/cjs/internal/app-binder/constant/plugins.js +0 -2
  236. package/lib/cjs/internal/app-binder/constant/plugins.js.map +0 -7
  237. package/lib/cjs/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.js +0 -2
  238. package/lib/cjs/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.js.map +0 -7
  239. package/lib/cjs/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.test.js +0 -2
  240. package/lib/cjs/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.test.js.map +0 -7
  241. package/lib/cjs/internal/app-binder/task/ProvideTransactionGenericContextTask.js +0 -2
  242. package/lib/cjs/internal/app-binder/task/ProvideTransactionGenericContextTask.js.map +0 -7
  243. package/lib/cjs/internal/app-binder/task/ProvideTransactionGenericContextTask.test.js +0 -2
  244. package/lib/cjs/internal/app-binder/task/ProvideTransactionGenericContextTask.test.js.map +0 -7
  245. package/lib/cjs/internal/transaction/service/mapper/EthersRawTransactionMapper.js +0 -2
  246. package/lib/cjs/internal/transaction/service/mapper/EthersRawTransactionMapper.js.map +0 -7
  247. package/lib/cjs/internal/transaction/service/mapper/EthersRawTransactionMapper.test.js +0 -2
  248. package/lib/cjs/internal/transaction/service/mapper/EthersRawTransactionMapper.test.js.map +0 -7
  249. package/lib/cjs/internal/transaction/service/mapper/TransactionMapper.js +0 -2
  250. package/lib/cjs/internal/transaction/service/mapper/TransactionMapper.js.map +0 -7
  251. package/lib/cjs/internal/transaction/service/mapper/TransactionMapperService.test.js +0 -2
  252. package/lib/cjs/internal/transaction/service/mapper/TransactionMapperService.test.js.map +0 -7
  253. package/lib/esm/internal/app-binder/constant/plugins.js +0 -2
  254. package/lib/esm/internal/app-binder/constant/plugins.js.map +0 -7
  255. package/lib/esm/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.js +0 -2
  256. package/lib/esm/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.js.map +0 -7
  257. package/lib/esm/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.test.js +0 -2
  258. package/lib/esm/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.test.js.map +0 -7
  259. package/lib/esm/internal/app-binder/task/ProvideTransactionGenericContextTask.js +0 -2
  260. package/lib/esm/internal/app-binder/task/ProvideTransactionGenericContextTask.js.map +0 -7
  261. package/lib/esm/internal/app-binder/task/ProvideTransactionGenericContextTask.test.js +0 -2
  262. package/lib/esm/internal/app-binder/task/ProvideTransactionGenericContextTask.test.js.map +0 -7
  263. package/lib/esm/internal/transaction/service/mapper/EthersRawTransactionMapper.js +0 -2
  264. package/lib/esm/internal/transaction/service/mapper/EthersRawTransactionMapper.js.map +0 -7
  265. package/lib/esm/internal/transaction/service/mapper/EthersRawTransactionMapper.test.js +0 -2
  266. package/lib/esm/internal/transaction/service/mapper/EthersRawTransactionMapper.test.js.map +0 -7
  267. package/lib/esm/internal/transaction/service/mapper/TransactionMapper.js +0 -1
  268. package/lib/esm/internal/transaction/service/mapper/TransactionMapperService.test.js +0 -2
  269. package/lib/esm/internal/transaction/service/mapper/TransactionMapperService.test.js.map +0 -7
  270. package/lib/types/internal/app-binder/constant/plugins.d.ts +0 -2
  271. package/lib/types/internal/app-binder/constant/plugins.d.ts.map +0 -1
  272. package/lib/types/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.d.ts +0 -80
  273. package/lib/types/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.d.ts.map +0 -1
  274. package/lib/types/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.test.d.ts +0 -2
  275. package/lib/types/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.test.d.ts.map +0 -1
  276. package/lib/types/internal/app-binder/task/ProvideTransactionGenericContextTask.d.ts +0 -28
  277. package/lib/types/internal/app-binder/task/ProvideTransactionGenericContextTask.d.ts.map +0 -1
  278. package/lib/types/internal/app-binder/task/ProvideTransactionGenericContextTask.test.d.ts +0 -2
  279. package/lib/types/internal/app-binder/task/ProvideTransactionGenericContextTask.test.d.ts.map +0 -1
  280. package/lib/types/internal/transaction/service/mapper/EthersRawTransactionMapper.d.ts +0 -7
  281. package/lib/types/internal/transaction/service/mapper/EthersRawTransactionMapper.d.ts.map +0 -1
  282. package/lib/types/internal/transaction/service/mapper/EthersRawTransactionMapper.test.d.ts +0 -2
  283. package/lib/types/internal/transaction/service/mapper/EthersRawTransactionMapper.test.d.ts.map +0 -1
  284. package/lib/types/internal/transaction/service/mapper/TransactionMapper.d.ts +0 -6
  285. package/lib/types/internal/transaction/service/mapper/TransactionMapper.d.ts.map +0 -1
  286. package/lib/types/internal/transaction/service/mapper/TransactionMapperService.test.d.ts +0 -2
  287. package/lib/types/internal/transaction/service/mapper/TransactionMapperService.test.d.ts.map +0 -1
  288. /package/lib/esm/{internal/transaction/service/mapper/TransactionMapper.js.map → api/app-binder/SignDelegationAuthorizationTypes.js.map} +0 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/app-binder/task/BuildSubContextTask.ts"],
4
+ "sourcesContent": ["import {\n type ClearSignContext,\n type ClearSignContextReference,\n type ClearSignContextSuccess,\n ClearSignContextType,\n type ContextModule,\n type TransactionFieldContext,\n} from \"@ledgerhq/context-module\";\nimport {\n bufferToHexaString,\n type InternalApi,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { GetChallengeCommand } from \"@internal/app-binder/command/GetChallengeCommand\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nexport type BuildSubContextTaskArgs = {\n readonly context: ClearSignContextSuccess;\n readonly contextOptional: ClearSignContextSuccess[];\n readonly transactionParser: TransactionParserService;\n readonly serializedTransaction: Uint8Array;\n readonly contextModule: ContextModule;\n readonly chainId: number;\n};\n\nexport type BuildSubContextTaskResult = {\n subcontextCallbacks: (() => Promise<ClearSignContext>)[];\n};\n\nexport class BuildSubContextTask {\n constructor(\n private readonly api: InternalApi,\n private readonly args: BuildSubContextTaskArgs,\n ) {}\n\n run(): BuildSubContextTaskResult {\n const context = this.args.context;\n\n if (\n context.type === ClearSignContextType.TRANSACTION_INFO ||\n context.type === ClearSignContextType.ENUM ||\n context.type === ClearSignContextType.WEB3_CHECK ||\n context.type === ClearSignContextType.PLUGIN ||\n context.type === ClearSignContextType.EXTERNAL_PLUGIN\n ) {\n return {\n subcontextCallbacks: [],\n };\n }\n\n // if the reference is a string, it means it is a direct address\n // and we don't need to extract the value from the transaction\n // as it is already provided in the reference\n if (\n context.reference !== undefined &&\n \"value\" in context.reference &&\n context.reference.value !== undefined\n ) {\n const transactionFieldContext: TransactionFieldContext = {\n type: context.reference.type,\n chainId: this.args.chainId,\n address: context.reference.value,\n };\n\n return {\n subcontextCallbacks: [\n () => this.args.contextModule.getContext(transactionFieldContext),\n ],\n };\n }\n\n // if the reference is a path, it means we need to extract the value\n // from the transaction and provide it to the device\n if (\n context.reference !== undefined &&\n context.reference.valuePath !== undefined\n ) {\n // iterate on each reference and provide the context\n const referenceValues = this.args.transactionParser.extractValue(\n this.args.serializedTransaction,\n context.reference.valuePath,\n );\n\n if (referenceValues.isRight()) {\n const subcontextCallbacks: (() => Promise<ClearSignContext>)[] = [];\n\n for (const value of referenceValues.extract()) {\n if (context.reference.type === ClearSignContextType.ENUM) {\n const reference: ClearSignContextReference<ClearSignContextType.ENUM> =\n context.reference;\n const enumValue = value[value.length - 1];\n if (!enumValue) continue;\n\n const enumsContext = this.args.contextOptional.filter(\n (c) => c.type === ClearSignContextType.ENUM,\n );\n\n const subcontext = enumsContext.find(\n (enumContext) =>\n enumContext.value === enumValue &&\n enumContext.id === reference.id,\n );\n\n if (subcontext) {\n subcontextCallbacks.push(() => Promise.resolve(subcontext));\n }\n }\n\n if (\n context.reference.type === ClearSignContextType.TOKEN ||\n context.reference.type === ClearSignContextType.NFT\n ) {\n const reference: ClearSignContextReference<\n ClearSignContextType.TOKEN | ClearSignContextType.NFT\n > = context.reference;\n const address = bufferToHexaString(\n value.slice(Math.max(0, value.length - 20)),\n );\n\n subcontextCallbacks.push(() =>\n this.args.contextModule.getContext({\n type: reference.type,\n chainId: this.args.chainId,\n address,\n }),\n );\n }\n\n if (context.reference.type === ClearSignContextType.TRUSTED_NAME) {\n const reference: ClearSignContextReference<ClearSignContextType.TRUSTED_NAME> =\n context.reference;\n subcontextCallbacks.push(async () => {\n const address = bufferToHexaString(\n value.slice(Math.max(0, value.length - 20)),\n );\n\n const getChallengeResult = await this.api.sendCommand(\n new GetChallengeCommand(),\n );\n if (!isSuccessCommandResult(getChallengeResult)) {\n // TODO: we need to return an error here\n return {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Failed to get challenge\"),\n };\n }\n\n const subcontext = await this.args.contextModule.getContext({\n type: reference.type,\n chainId: this.args.chainId,\n address,\n challenge: getChallengeResult.data.challenge,\n types: reference.types,\n sources: reference.sources,\n });\n\n return subcontext;\n });\n }\n }\n\n return {\n subcontextCallbacks,\n };\n }\n }\n\n return {\n subcontextCallbacks: [],\n };\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAOO,oCACPC,EAIO,2CAEPC,EAAoC,4DAgB7B,MAAMJ,CAAoB,CAC/B,YACmBK,EACAC,EACjB,CAFiB,SAAAD,EACA,UAAAC,CAChB,CAEH,KAAiC,CAC/B,MAAMC,EAAU,KAAK,KAAK,QAE1B,GACEA,EAAQ,OAAS,uBAAqB,kBACtCA,EAAQ,OAAS,uBAAqB,MACtCA,EAAQ,OAAS,uBAAqB,YACtCA,EAAQ,OAAS,uBAAqB,QACtCA,EAAQ,OAAS,uBAAqB,gBAEtC,MAAO,CACL,oBAAqB,CAAC,CACxB,EAMF,GACEA,EAAQ,YAAc,QACtB,UAAWA,EAAQ,WACnBA,EAAQ,UAAU,QAAU,OAC5B,CACA,MAAMC,EAAmD,CACvD,KAAMD,EAAQ,UAAU,KACxB,QAAS,KAAK,KAAK,QACnB,QAASA,EAAQ,UAAU,KAC7B,EAEA,MAAO,CACL,oBAAqB,CACnB,IAAM,KAAK,KAAK,cAAc,WAAWC,CAAuB,CAClE,CACF,CACF,CAIA,GACED,EAAQ,YAAc,QACtBA,EAAQ,UAAU,YAAc,OAChC,CAEA,MAAME,EAAkB,KAAK,KAAK,kBAAkB,aAClD,KAAK,KAAK,sBACVF,EAAQ,UAAU,SACpB,EAEA,GAAIE,EAAgB,QAAQ,EAAG,CAC7B,MAAMC,EAA2D,CAAC,EAElE,UAAWC,KAASF,EAAgB,QAAQ,EAAG,CAC7C,GAAIF,EAAQ,UAAU,OAAS,uBAAqB,KAAM,CACxD,MAAMK,EACJL,EAAQ,UACJM,EAAYF,EAAMA,EAAM,OAAS,CAAC,EACxC,GAAI,CAACE,EAAW,SAMhB,MAAMC,EAJe,KAAK,KAAK,gBAAgB,OAC5CC,GAAMA,EAAE,OAAS,uBAAqB,IACzC,EAEgC,KAC7BC,GACCA,EAAY,QAAUH,GACtBG,EAAY,KAAOJ,EAAU,EACjC,EAEIE,GACFJ,EAAoB,KAAK,IAAM,QAAQ,QAAQI,CAAU,CAAC,CAE9D,CAEA,GACEP,EAAQ,UAAU,OAAS,uBAAqB,OAChDA,EAAQ,UAAU,OAAS,uBAAqB,IAChD,CACA,MAAMK,EAEFL,EAAQ,UACNU,KAAU,sBACdN,EAAM,MAAM,KAAK,IAAI,EAAGA,EAAM,OAAS,EAAE,CAAC,CAC5C,EAEAD,EAAoB,KAAK,IACvB,KAAK,KAAK,cAAc,WAAW,CACjC,KAAME,EAAU,KAChB,QAAS,KAAK,KAAK,QACnB,QAAAK,CACF,CAAC,CACH,CACF,CAEA,GAAIV,EAAQ,UAAU,OAAS,uBAAqB,aAAc,CAChE,MAAMK,EACJL,EAAQ,UACVG,EAAoB,KAAK,SAAY,CACnC,MAAMO,KAAU,sBACdN,EAAM,MAAM,KAAK,IAAI,EAAGA,EAAM,OAAS,EAAE,CAAC,CAC5C,EAEMO,EAAqB,MAAM,KAAK,IAAI,YACxC,IAAI,qBACN,EACA,SAAK,0BAAuBA,CAAkB,EAQ3B,MAAM,KAAK,KAAK,cAAc,WAAW,CAC1D,KAAMN,EAAU,KAChB,QAAS,KAAK,KAAK,QACnB,QAAAK,EACA,UAAWC,EAAmB,KAAK,UACnC,MAAON,EAAU,MACjB,QAASA,EAAU,OACrB,CAAC,EAbQ,CACL,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,yBAAyB,CAC5C,CAaJ,CAAC,CACH,CACF,CAEA,MAAO,CACL,oBAAAF,CACF,CACF,CACF,CAEA,MAAO,CACL,oBAAqB,CAAC,CACxB,CACF,CACF",
6
+ "names": ["BuildSubContextTask_exports", "__export", "BuildSubContextTask", "__toCommonJS", "import_context_module", "import_device_management_kit", "import_GetChallengeCommand", "api", "args", "context", "transactionFieldContext", "referenceValues", "subcontextCallbacks", "value", "reference", "enumValue", "subcontext", "c", "enumContext", "address", "getChallengeResult"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var e=require("@ledgerhq/context-module"),C=require("@ledgerhq/device-management-kit"),d=require("purify-ts"),h=require("../../app-binder/command/GetChallengeCommand"),k=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),x=require("./BuildSubContextTask");describe("BuildSubContextTask",()=>{const r={getContext:vi.fn()},p={extractValue:vi.fn()},s=(0,k.makeDeviceActionInternalApiMock)();let l;beforeEach(()=>{vi.resetAllMocks(),l={context:{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"test payload"},contextOptional:[],transactionParser:p,serializedTransaction:new Uint8Array([1,2,3]),contextModule:r,chainId:1}}),describe("when context type is a simple type",()=>{const n=[e.ClearSignContextType.TRANSACTION_INFO,e.ClearSignContextType.WEB3_CHECK,e.ClearSignContextType.PLUGIN,e.ClearSignContextType.EXTERNAL_PLUGIN,e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION];it.each(n)("should return context with empty subcontextCallbacks for %s",t=>{const c={...l,context:{type:t,payload:"test payload"}},o=new x.BuildSubContextTask(s,c).run();expect(o.subcontextCallbacks).toHaveLength(0)})}),describe("when context has a direct value reference",()=>{it("should create a callback to get context with the direct value",async()=>{const n={type:e.ClearSignContextType.TOKEN,payload:"test payload",reference:{type:e.ClearSignContextType.TOKEN,value:"0x1234567890123456789012345678901234567890"}},t={...l,context:n},a={type:e.ClearSignContextType.TOKEN,chainId:1,address:"0x1234567890123456789012345678901234567890"},c=new x.BuildSubContextTask(s,t).run();expect(c.subcontextCallbacks).toHaveLength(1);const o=c.subcontextCallbacks[0];await o(),expect(r.getContext).toHaveBeenCalledWith(a)}),it("should handle undefined value in reference",()=>{const n={type:e.ClearSignContextType.TOKEN,payload:"test payload",reference:void 0},t={...l,context:n},a=new x.BuildSubContextTask(s,t).run();expect(a.subcontextCallbacks).toHaveLength(0)})}),describe("when context has a valuePath reference",()=>{beforeEach(()=>{s.sendCommand.mockResolvedValue((0,C.CommandResultFactory)({data:{challenge:"test-challenge"}}))}),describe("when extractValue returns Left (error)",()=>{it("should return context with empty subcontextCallbacks",()=>{const n={type:e.ClearSignContextType.TOKEN,payload:"test payload",reference:{type:e.ClearSignContextType.TOKEN,valuePath:[{type:"SLICE",start:0,end:20}]}},t={...l,context:n};p.extractValue.mockReturnValue((0,d.Left)(new Error("Extraction failed")));const a=new x.BuildSubContextTask(s,t).run();expect(a.subcontextCallbacks).toHaveLength(0)})}),describe("when extractValue returns Right with values",()=>{describe("for ENUM type",()=>{it("should create callbacks for matching enum contexts",async()=>{const n={type:e.ClearSignContextType.TOKEN,payload:"test payload",reference:{type:e.ClearSignContextType.ENUM,id:1,valuePath:[{type:"TUPLE",offset:0}]}},t={type:e.ClearSignContextType.ENUM,id:1,value:1,payload:"enum context 1"},a={type:e.ClearSignContextType.ENUM,id:1,value:2,payload:"enum context 2"},c={type:e.ClearSignContextType.ENUM,id:2,value:2,payload:"enum context 3"},o={...l,context:n,contextOptional:[t,a,c]},u=[new Uint8Array([1,2])];p.extractValue.mockReturnValue((0,d.Right)(u));const i=new x.BuildSubContextTask(s,o).run();expect(i.subcontextCallbacks).toHaveLength(1);const y=i.subcontextCallbacks[0],b=await y();expect(b).toEqual(a)}),it("should create callbacks for matching enum contexts with two values",async()=>{const n={type:e.ClearSignContextType.TOKEN,payload:"test payload",reference:{type:e.ClearSignContextType.ENUM,id:1,valuePath:[{type:"TUPLE",offset:0}]}},t={type:e.ClearSignContextType.ENUM,id:1,value:1,payload:"enum context 1"},a={type:e.ClearSignContextType.ENUM,id:1,value:2,payload:"enum context 2"},c={type:e.ClearSignContextType.ENUM,id:2,value:2,payload:"enum context 3"},o={...l,context:n,contextOptional:[t,a,c]},u=[new Uint8Array([1,2]),new Uint8Array([3,2,1])];p.extractValue.mockReturnValue((0,d.Right)(u));const i=new x.BuildSubContextTask(s,o).run();expect(i.subcontextCallbacks).toHaveLength(2);const y=i.subcontextCallbacks[0],b=i.subcontextCallbacks[1],g=await y(),E=await b();expect(g).toEqual(a),expect(E).toEqual(t)}),it("should skip when enum value is undefined",()=>{const n={type:e.ClearSignContextType.TOKEN,payload:"test payload",reference:{type:e.ClearSignContextType.ENUM,id:1,valuePath:[{type:"TUPLE",offset:0}]}},t={...l,context:n},a=[new Uint8Array([])];p.extractValue.mockReturnValue((0,d.Right)(a));const c=new x.BuildSubContextTask(s,t).run();expect(c.subcontextCallbacks).toHaveLength(0)}),it("should skip when no matching enum context found",()=>{const n={type:e.ClearSignContextType.NFT,payload:"test payload",reference:{type:e.ClearSignContextType.ENUM,id:1,valuePath:[{type:"TUPLE",offset:0}]}},t={type:e.ClearSignContextType.ENUM,id:2,value:2,payload:"enum context"},a={...l,context:n,contextOptional:[t]},c=[new Uint8Array([1,2])];p.extractValue.mockReturnValue((0,d.Right)(c));const o=new x.BuildSubContextTask(s,a).run();expect(o.subcontextCallbacks).toHaveLength(0)})}),describe("for TOKEN type",()=>{it("should create callbacks to get token context",async()=>{const n={type:e.ClearSignContextType.TOKEN,payload:"test payload",reference:{type:e.ClearSignContextType.TOKEN,valuePath:[{type:"TUPLE",offset:0}]}},t={...l,context:n},a=[new Uint8Array([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])];p.extractValue.mockReturnValue((0,d.Right)(a)),r.getContext.mockResolvedValue({type:e.ClearSignContextType.TOKEN,payload:"token result"});const c=new x.BuildSubContextTask(s,t).run();expect(c.subcontextCallbacks).toHaveLength(1);const o=c.subcontextCallbacks[0],u=await o();expect(u).toEqual({type:e.ClearSignContextType.TOKEN,payload:"token result"}),expect(r.getContext).toHaveBeenCalledWith({type:e.ClearSignContextType.TOKEN,chainId:1,address:"0x030405060708090a0b0c0d0e0f10111213141516"})})}),describe("for NFT type",()=>{it("should create callbacks to get NFT context",async()=>{const n={type:e.ClearSignContextType.NFT,payload:"test payload",reference:{type:e.ClearSignContextType.NFT,valuePath:[{type:"TUPLE",offset:0}]}},t={...l,context:n},a=[new Uint8Array([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])];p.extractValue.mockReturnValue((0,d.Right)(a)),r.getContext.mockResolvedValue({type:e.ClearSignContextType.NFT,payload:"nft result"});const c=new x.BuildSubContextTask(s,t).run();expect(c.subcontextCallbacks).toHaveLength(1);const o=c.subcontextCallbacks[0],u=await o();expect(u).toEqual({type:e.ClearSignContextType.NFT,payload:"nft result"}),expect(r.getContext).toHaveBeenCalledWith({type:e.ClearSignContextType.NFT,chainId:1,address:"0x030405060708090a0b0c0d0e0f10111213141516"})})}),describe("for TRUSTED_NAME type",()=>{it("should create callbacks to get trusted name context with challenge",async()=>{const n={type:e.ClearSignContextType.TRUSTED_NAME,payload:"test payload",reference:{type:e.ClearSignContextType.TRUSTED_NAME,valuePath:[{type:"TUPLE",offset:0}],types:["type1","type2"],sources:["source1","source2"]}},t={...l,context:n},a=[new Uint8Array([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])];p.extractValue.mockReturnValue((0,d.Right)(a)),r.getContext.mockResolvedValue({type:e.ClearSignContextType.TRUSTED_NAME,payload:"trusted name result"});const c=new x.BuildSubContextTask(s,t).run();expect(c.subcontextCallbacks).toHaveLength(1);const o=c.subcontextCallbacks[0],u=await o();expect(u).toEqual({type:e.ClearSignContextType.TRUSTED_NAME,payload:"trusted name result"}),expect(s.sendCommand).toHaveBeenCalledWith(expect.any(h.GetChallengeCommand)),expect(r.getContext).toHaveBeenCalledWith({type:e.ClearSignContextType.TRUSTED_NAME,chainId:1,address:"0x030405060708090a0b0c0d0e0f10111213141516",challenge:"test-challenge",types:["type1","type2"],sources:["source1","source2"]})}),it("should handle challenge command failure",async()=>{const n={type:e.ClearSignContextType.TRUSTED_NAME,payload:"test payload",reference:{type:e.ClearSignContextType.TRUSTED_NAME,valuePath:[{type:"TUPLE",offset:0}],types:["type1"],sources:["source1"]}},t={...l,context:n},a=[new Uint8Array([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])];p.extractValue.mockReturnValue((0,d.Right)(a));const c=new C.UnknownDeviceExchangeError("Failed");s.sendCommand.mockResolvedValueOnce((0,C.CommandResultFactory)({error:c}));const o=new x.BuildSubContextTask(s,t).run();expect(o.subcontextCallbacks).toHaveLength(1);const u=o.subcontextCallbacks[0],i=await u();expect(i).toEqual({error:new Error("Failed to get challenge"),type:e.ClearSignContextType.ERROR})})}),describe("for multiple values",()=>{it("should create callbacks for each extracted value",async()=>{const n={type:e.ClearSignContextType.TOKEN,payload:"test payload",reference:{type:e.ClearSignContextType.TOKEN,valuePath:[{type:"TUPLE",offset:0}]}},t={...l,context:n},a=[new Uint8Array([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]),new Uint8Array([33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54])];p.extractValue.mockReturnValue((0,d.Right)(a)),r.getContext.mockResolvedValueOnce({type:e.ClearSignContextType.TOKEN,payload:"token result 1"}),r.getContext.mockResolvedValueOnce({type:e.ClearSignContextType.TOKEN,payload:"token result 2"});const c=new x.BuildSubContextTask(s,t).run();expect(c.subcontextCallbacks).toHaveLength(2);const o=c.subcontextCallbacks[0],u=c.subcontextCallbacks[1],i=await o(),y=await u();expect(i).toEqual({type:e.ClearSignContextType.TOKEN,payload:"token result 1"}),expect(y).toEqual({type:e.ClearSignContextType.TOKEN,payload:"token result 2"}),expect(r.getContext).toHaveBeenCalledTimes(2),expect(r.getContext).toHaveBeenNthCalledWith(1,{type:e.ClearSignContextType.TOKEN,chainId:1,address:"0x030405060708090a0b0c0d0e0f10111213141516"}),expect(r.getContext).toHaveBeenNthCalledWith(2,{type:e.ClearSignContextType.TOKEN,chainId:1,address:"0x232425262728292a2b2c2d2e2f30313233343536"})})})})}),describe("when context has no reference",()=>{it("should return context with empty subcontextCallbacks",()=>{const n={type:e.ClearSignContextType.TOKEN,payload:"test payload"},t={...l,context:n},a=new x.BuildSubContextTask(s,t).run();expect(a.subcontextCallbacks).toHaveLength(0)})}),describe("when context has reference but no valuePath",()=>{it("should return context with empty subcontextCallbacks",()=>{const n={type:e.ClearSignContextType.TOKEN,payload:"test payload",reference:{type:e.ClearSignContextType.TOKEN}},t={...l,context:n},a=new x.BuildSubContextTask(s,t).run();expect(a.subcontextCallbacks).toHaveLength(0)})}),describe("edge cases",()=>{it("should handle value array shorter than 20 bytes for address extraction",async()=>{const n={type:e.ClearSignContextType.TOKEN,payload:"test payload",reference:{type:e.ClearSignContextType.TOKEN,valuePath:[{type:"TUPLE",offset:0}]}},t={...l,context:n},a=[new Uint8Array([1,2,3])];p.extractValue.mockReturnValue((0,d.Right)(a)),r.getContext.mockResolvedValue({type:e.ClearSignContextType.ERROR,message:"Invalid address"});const c=new x.BuildSubContextTask(s,t).run();expect(c.subcontextCallbacks).toHaveLength(1);const o=c.subcontextCallbacks[0],u=await o();expect(u).toEqual({type:e.ClearSignContextType.ERROR,message:"Invalid address"}),expect(r.getContext).toHaveBeenCalledWith({type:e.ClearSignContextType.TOKEN,chainId:1,address:"0x010203"})}),it("should handle empty value array",async()=>{const n={type:e.ClearSignContextType.TOKEN,payload:"test payload",reference:{type:e.ClearSignContextType.TOKEN,valuePath:[{type:"TUPLE",offset:0}]}},t={...l,context:n},a=[new Uint8Array([])];p.extractValue.mockReturnValue((0,d.Right)(a)),r.getContext.mockResolvedValue({type:e.ClearSignContextType.TOKEN,payload:"token result"});const c=new x.BuildSubContextTask(s,t).run();expect(c.subcontextCallbacks).toHaveLength(1);const o=c.subcontextCallbacks[0],u=await o();expect(u).toEqual({type:e.ClearSignContextType.TOKEN,payload:"token result"}),expect(r.getContext).toHaveBeenCalledWith({type:e.ClearSignContextType.TOKEN,chainId:1,address:"0x"})})})});
2
+ //# sourceMappingURL=BuildSubContextTask.test.js.map
@@ -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 serializedTransaction: new Uint8Array([0x01, 0x02, 0x03]),\n contextModule: contextModuleMock as unknown as ContextModule,\n chainId: 1,\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,sBAAuB,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,EACxD,cAAeD,EACf,QAAS,CACX,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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,KAAM,uBAAqB,MAC3B,QAAS,iBACX,CAAC,EACD,OAAOf,EAAkB,UAAU,EAAE,qBAAqB,CACxD,KAAM,uBAAqB,MAC3B,QAAS,EACT,QAAS,UACX,CAAC,CACH,CAAC,EAED,GAAG,kCAAmC,SAAY,CAEhD,MAAMQ,EAAmC,CACvC,KAAM,uBAAqB,MAC3B,QAAS,eACT,UAAW,CACT,KAAM,uBAAqB,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 y=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var w=(i,t)=>{for(var n in t)y(i,n,{get:t[n],enumerable:!0})},D=(i,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of _(t))!b.call(i,a)&&a!==n&&y(i,a,{get:()=>t[a],enumerable:!(r=R(t,a))||r.enumerable});return i};var G=i=>D(y({},"__esModule",{value:!0}),i);var B={};w(B,{BuildTransactionContextTask:()=>P});module.exports=G(B);var o=require("@ledgerhq/context-module"),l=require("@ledgerhq/device-management-kit"),g=require("../../../api/model/ClearSigningType"),I=require("../../app-binder/command/GetChallengeCommand"),A=require("../../app-binder/task/GetWeb3CheckTask"),N=require("../../shared/utils/ApplicationChecker");class P{constructor(t,n,r=(a,p)=>new A.GetWeb3CheckTask(a,p)){this._api=t;this._args=n;this.getWeb3ChecksFactory=r}async run(){const{contextModule:t,mapper:n,transaction:r,options:a,appConfig:p,derivationPath:k}=this._args,C=this._api.getDeviceSessionState();let s=[],T=[],u=g.ClearSigningType.BASIC;const m=n.mapTransactionToSubset(r);m.ifLeft(e=>{throw e});const{subset:f,serializedTransaction:v,type:E}=m.unsafeCoerce();let c=null;p.web3ChecksEnabled&&(c=(await this.getWeb3ChecksFactory(this._api,{contextModule:t,derivationPath:k,mapper:n,transaction:r}).run()).web3Check);let x;if(C.deviceModelId!==l.DeviceModelId.NANO_S){const e=await this._api.sendCommand(new I.GetChallengeCommand);(0,l.isSuccessCommandResult)(e)&&(x=e.data.challenge)}const h=await t.getContexts({challenge:x,domain:a.domain,deviceModelId:C.deviceModelId,...f}),d=h.filter(e=>e.type!==o.ClearSignContextType.ERROR&&e.type!==o.ClearSignContextType.ENUM),M=h.filter(e=>e.type===o.ClearSignContextType.ENUM),S=d.find(e=>e.type===o.ClearSignContextType.TRANSACTION_INFO);if(!this.supportsGenericParser(C,p)||S===void 0)s=d.filter(e=>e.type!==o.ClearSignContextType.TRANSACTION_INFO&&e.type!==o.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION),c&&(s=[c,...s]);else if(S.certificate){const e=d.filter(O=>O.type===o.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION);s=[S,...e,...c?[c]:[]],T=[...M],u=g.ClearSigningType.EIP7730}return{clearSignContexts:s,clearSignContextsOptional:T,serializedTransaction:v,chainId:f.chainId,transactionType:E,clearSigningType:u}}supportsGenericParser(t,n){return new N.ApplicationChecker(t,n).withMinVersionExclusive("1.14.0").excludeDeviceModel(l.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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AGMC,EACJH,EAAkB,OACfE,GAAYA,EAAQ,OAAS,uBAAqB,IACrD,EAEF,IAAIE,EAA+D,CAAC,EACpE,MAAMC,EAAkBJ,EAAyB,KAC9CK,GAAQA,EAAI,OAAS,uBAAqB,gBAC7C,EAKA,GACE,CAAC,KAAK,sBAAsBf,EAAaF,CAAS,GAClDgB,IAAoB,OAEpBD,EAAmBH,EAAyB,OACzCK,GACCA,EAAI,OAAS,uBAAqB,kBAClCA,EAAI,OAAS,uBAAqB,6BACtC,UACSD,EAAgB,YAAa,CACtC,MAAME,EAAoBN,EAAyB,OAChDK,GACCA,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} 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 { 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\nexport type BuildTransactionTaskResult = {\n readonly clearSignContexts: ClearSignContextSuccess[];\n readonly clearSignContextsOptional: ClearSignContextSuccess[];\n readonly serializedTransaction: Uint8Array;\n readonly chainId: number;\n readonly transactionType: TransactionType;\n readonly clearSigningType: ClearSigningType;\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 let filteredContexts: ClearSignContextSuccess[] = [];\n let filteredContextOptional: ClearSignContextSuccess[] = [];\n let clearSigningType: ClearSigningType = ClearSigningType.BASIC;\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 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 serializedTransaction,\n chainId: subset.chainId,\n transactionType: type,\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,EAKO,oCACPC,EAKO,2CAGPC,EAAiC,uCAGjCC,EAAoC,4DACpCC,EAGO,sDACPC,EAAmC,qDAqB5B,MAAMP,CAA4B,CACvC,YACmBQ,EACAC,EACAC,EAAuB,CACtCC,EACAC,IACG,IAAI,mBAAiBD,EAAKC,CAAI,EACnC,CANiB,UAAAJ,EACA,WAAAC,EACA,0BAAAC,CAIhB,CAEH,MAAM,KAA2C,CAC/C,KAAM,CACJ,cAAAG,EACA,OAAAC,EACA,YAAAC,EACA,QAAAC,EACA,UAAAC,EACA,eAAAC,CACF,EAAI,KAAK,MACHC,EAAc,KAAK,KAAK,sBAAsB,EACpD,IAAIC,EAA8C,CAAC,EAC/CC,EAAqD,CAAC,EACtDC,EAAqC,mBAAiB,MAG1D,MAAMC,EAAST,EAAO,uBAAuBC,CAAW,EACxDQ,EAAO,OAAQC,GAAQ,CACrB,MAAMA,CACR,CAAC,EACD,KAAM,CAAE,OAAAC,EAAQ,sBAAAC,EAAuB,KAAAC,CAAK,EAAIJ,E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Q,sBACNH,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_ClearSigningType", "import_GetChallengeCommand", "import_GetWeb3CheckTask", "import_ApplicationChecker", "_api", "_args", "getWeb3ChecksFactory", "api", "args", "contextModule", "mapper", "transaction", "options", "appConfig", "derivationPath", "deviceState", "filteredContexts", "filteredContextOptional", "clearSigningType", "parsed", "err", "subset", "serializedTransaction", "type", "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 a=require("@ledgerhq/context-module"),e=require("@ledgerhq/device-management-kit"),m=require("ethers"),u=require("purify-ts"),S=require("../../../api/model/ClearSigningType"),g=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),d=require("./BuildTransactionContextTask"),h=require("./GetWeb3CheckTask");describe("BuildTransactionContextTask",()=>{const l={getContext:vi.fn(),getContexts:vi.fn(),getTypedDataFilters:vi.fn(),getWeb3Checks:vi.fn(),getSolanaContext:vi.fn()},p={mapTransactionToSubset:vi.fn()},R={domain:"domain-name.eth"},T=(0,e.hexaStringToBuffer)(m.Transaction.from({chainId:1n,nonce:0,data:"0x"}).unsignedSerialized),C={keyUsageNumber:1,payload:new Uint8Array([1,2,3])};let i;const o=(0,g.makeDeviceActionInternalApiMock)(),r=vi.fn();function x(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()=>Promise.resolve({web3Check:null})}),i={contextModule:l,mapper:p,transaction:T,options:R,appConfig:x(!1),derivationPath:"44'/60'/0'/0/0"}}),it("should init with a default GetWeb3CheckTaskFactory",()=>{const n=new d.BuildTransactionContextTask(o,i);expect(n.getWeb3ChecksFactory).toBeDefined(),expect(n.getWeb3ChecksFactory(o,{contextModule:i.contextModule,derivationPath:i.derivationPath,mapper:i.mapper,transaction:i.transaction})).toBeInstanceOf(h.GetWeb3CheckTask)}),it("should build the transaction context without clear sign contexts",async()=>{const n=new Uint8Array([1,2,3]),t=[],s=[],c={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:n,type:0};p.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(c)),l.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 y=await new d.BuildTransactionContextTask(o,{...i,appConfig:x(!0)},r).run();expect(y).toEqual({clearSignContexts:t,clearSignContextsOptional:s,serializedTransaction:n,chainId:1,transactionType:0,clearSigningType:S.ClearSigningType.BASIC})}),it("should build the transaction context with web3checks",async()=>{const n=new Uint8Array([1,2,3]),t=[],s=[],c={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:n,type:0},y="web3Check";r.mockReturnValueOnce({run:async()=>Promise.resolve({web3Check:y})}),p.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(c)),l.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 E=await new d.BuildTransactionContextTask(o,{...i,appConfig:x(!0)},r).run();expect(E).toEqual({clearSignContexts:[y,...t],clearSignContextsOptional:s,serializedTransaction:n,chainId:1,transactionType:0,clearSigningType:S.ClearSigningType.BASIC})}),it("should build the transaction context with web3checks and generic-parser clear sign contexts",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},c="web3Check";r.mockReturnValueOnce({run:async()=>Promise.resolve({web3Check:c})}),p.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),l.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 y=await new d.BuildTransactionContextTask(o,{...i,appConfig:x(!0)},r).run();expect(y).toEqual({clearSignContexts:[t[0],t[1],t[3],c],clearSignContextsOptional:[t[2]],serializedTransaction:n,chainId:1,transactionType:2,clearSigningType:S.ClearSigningType.EIP7730})}),it("should build the transaction context with web3checks and generic-parser clear sign contexts in the correct order",async()=>{const n=new Uint8Array([1,2,3]),t=[{type:a.ClearSignContextType.ENUM,payload:"payload-3",id:1,value:2,certificate:C},{type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"},{type:a.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:a.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1",certificate:C}],s={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:n,type:2},c="web3Check";r.mockReturnValueOnce({run:async()=>Promise.resolve({web3Check:c})}),p.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),l.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 y=await new d.BuildTransactionContextTask(o,{...i,appConfig:x(!0)},r).run();expect(y).toEqual({clearSignContexts:[t[3],t[1],t[2],c],clearSignContextsOptional:[t[0]],serializedTransaction:n,chainId:1,transactionType:2,clearSigningType:S.ClearSigningType.EIP7730})}),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()=>Promise.resolve({web3Check:c})}),p.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),l.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 y=await new d.BuildTransactionContextTask(o,i,r).run();expect(y).toEqual({clearSignContexts:t,clearSignContextsOptional:[],serializedTransaction:n,chainId:1,transactionType:2,clearSigningType:S.ClearSigningType.BASIC})}),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};p.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),l.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 d.BuildTransactionContextTask(o,i,r).run();expect(c).toEqual({clearSignContexts:[t[0],t[1],t[3]],clearSignContextsOptional:[t[2]],serializedTransaction:n,chainId:1,transactionType:2,clearSigningType:S.ClearSigningType.EIP7730})}),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};p.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),l.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 d.BuildTransactionContextTask(o,i,r).run(),expect(p.mapTransactionToSubset).toHaveBeenCalledWith(T)}),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};p.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),l.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 d.BuildTransactionContextTask(o,{...i,appConfig:x(!0)},r).run(),expect(r).toHaveBeenCalledWith(o,{contextModule:l,derivationPath:"44'/60'/0'/0/0",mapper:p,transaction:T})}),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};p.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),l.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 d.BuildTransactionContextTask(o,i,r).run(),expect(l.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};p.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),l.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 d.BuildTransactionContextTask(o,i,r).run(),expect(l.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};p.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),l.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 d.BuildTransactionContextTask(o,i,r).run(),expect(l.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");p.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 d.BuildTransactionContextTask(o,i,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};p.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),l.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 d.BuildTransactionContextTask(o,i,r).run();expect(c).toEqual({clearSignContexts:[t[1],t[3]],clearSignContextsOptional:[],serializedTransaction:n,chainId:1,transactionType:0,clearSigningType:S.ClearSigningType.BASIC})}),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};p.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),l.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 d.BuildTransactionContextTask(o,i,r).run();expect(c).toEqual({clearSignContexts:[t[1],t[3]],clearSignContextsOptional:[],serializedTransaction:n,chainId:1,transactionType:0,clearSigningType:S.ClearSigningType.BASIC})}),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};p.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),l.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 d.BuildTransactionContextTask(o,i,r).run();expect(c).toEqual({clearSignContexts:[t[1],t[3]],clearSignContextsOptional:[],serializedTransaction:n,chainId:1,transactionType:0,clearSigningType:S.ClearSigningType.BASIC})}),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};p.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),l.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 d.BuildTransactionContextTask(o,i,r).run();expect(c).toEqual({clearSignContexts:[t[1],t[3]],clearSignContextsOptional:[t[4]],serializedTransaction:n,chainId:1,transactionType:2,clearSigningType:S.ClearSigningType.EIP7730})}),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};p.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),l.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 d.BuildTransactionContextTask(o,i,r).run();expect(c).toEqual({clearSignContexts:[t[0]],clearSignContextsOptional:[],serializedTransaction:n,chainId:1,transactionType:2,clearSigningType:S.ClearSigningType.BASIC})}),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};p.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),l.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 d.BuildTransactionContextTask(o,i,r).run();expect(c).toEqual({clearSignContexts:[t[0]],clearSignContextsOptional:[],serializedTransaction:n,chainId:1,transactionType:2,clearSigningType:S.ClearSigningType.BASIC})}),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};p.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),l.getContexts.mockResolvedValueOnce(t),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:e.DeviceSessionStateType.Connected,deviceStatus:e.DeviceStatus.NOT_CONNECTED,deviceModelId:e.DeviceModelId.FLEX});const c=await new d.BuildTransactionContextTask(o,i,r).run();expect(c).toEqual({clearSignContexts:[t[0]],clearSignContextsOptional:[],serializedTransaction:n,chainId:1,transactionType:2,clearSigningType:S.ClearSigningType.BASIC})}),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};p.mapTransactionToSubset.mockReturnValueOnce((0,u.Right)(s)),l.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 d.BuildTransactionContextTask(o,i,r).run();expect(c).toEqual({clearSignContexts:[],clearSignContextsOptional:[],serializedTransaction:n,chainId:1,transactionType:2,clearSigningType:S.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,2CAC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CACE,KAAM,uBAAqB,KAC3B,QAAS,YACT,GAAI,EACJ,MAAO,CACT,CACF,EACMC,EAAwC,CAC5C,OAAQ,CAAE,QAAS,EAAG,GAAI,OAAW,KAAM,IAAK,EAChD,sBAAAF,EACA,KAAM,CACR,EACAT,EAAW,uBAAuB,uBAAoB,SAAMW,CAAY,CAAC,EACzEZ,EAAkB,YAAY,sBAAsBW,CAAiB,EACrEL,EAAQ,sBAAsB,oBAAoB,CAChD,iBAAkB,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,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\";\nimport { Left, Right } from \"purify-ts\";\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\";\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\";\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 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 () => Promise.resolve({ 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 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 mapper: defaultArgs.mapper,\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 serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [];\n const clearSignContextsOptional: 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 clearSignContextsOptional,\n serializedTransaction,\n chainId: 1,\n transactionType: 0,\n clearSigningType: ClearSigningType.BASIC,\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 clearSignContextsOptional: 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 () => Promise.resolve({ 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: [expectedWeb3Check, ...clearSignContexts],\n clearSignContextsOptional,\n serializedTransaction,\n chainId: 1,\n transactionType: 0,\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 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 const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ 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.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 serializedTransaction,\n chainId: 1,\n transactionType: 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 serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\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 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 () => Promise.resolve({ 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.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 serializedTransaction,\n chainId: 1,\n transactionType: 2,\n clearSigningType: ClearSigningType.EIP7730,\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 () => Promise.resolve({ 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 clearSignContextsOptional: [],\n serializedTransaction,\n chainId: 1,\n transactionType: 2,\n clearSigningType: ClearSigningType.BASIC,\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 clearSignContexts[0],\n clearSignContexts[1],\n clearSignContexts[3],\n ],\n clearSignContextsOptional: [clearSignContexts[2]],\n serializedTransaction,\n chainId: 1,\n transactionType: 2,\n clearSigningType: ClearSigningType.EIP7730,\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 clearSignContextsOptional: [],\n serializedTransaction,\n chainId: 1,\n transactionType: 0,\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 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 clearSignContextsOptional: [],\n serializedTransaction,\n chainId: 1,\n transactionType: 0,\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 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 clearSignContextsOptional: [],\n serializedTransaction,\n chainId: 1,\n transactionType: 0,\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 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: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [clearSignContexts[4]],\n serializedTransaction,\n chainId: 1,\n transactionType: 2,\n clearSigningType: ClearSigningType.EIP7730,\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 clearSignContextsOptional: [],\n serializedTransaction,\n chainId: 1,\n transactionType: 2,\n clearSigningType: ClearSigningType.BASIC,\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 clearSignContextsOptional: [],\n serializedTransaction,\n chainId: 1,\n transactionType: 2,\n clearSigningType: ClearSigningType.BASIC,\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 clearSignContextsOptional: [],\n serializedTransaction,\n chainId: 1,\n transactionType: 2,\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 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 clearSignContextsOptional: [],\n serializedTransaction,\n chainId: 1,\n transactionType: 2,\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAKO,oCACPC,EAOO,2CACPC,EAA4B,kBAC5BC,EAA4B,qBAG5BC,EAAiC,uCACjCC,EAAgD,6EAIhDC,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,EAAa,CACjB,uBAAwB,GAAG,GAAG,CAChC,EACMC,EAAiB,CACrB,OAAQ,iBACV,EACMC,KAAiC,sBACrC,cAAY,KAAK,CACf,QAAS,GACT,MAAO,EACP,KAAM,IACR,CAA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IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,EACzDC,EAAwC,CAC5C,CACE,KAAM,uBAAqB,iBAC3B,QAAS,WACX,EACA,CACE,KAAM,uBAAqB,8BAC3B,QAAS,WACX,EACA,CACE,KAAM,uBAAqB,KAC3B,QAAS,YACT,GAAI,EACJ,MAAO,CACT,CACF,EACME,EAAwC,CAC5C,OAAQ,CAAE,QAAS,EAAG,GAAI,OAAW,KAAM,IAAK,EAChD,sBAAAH,EACA,KAAM,CACR,EACAV,EAAW,uBAAuB,uBAAoB,SAAMa,CAAY,CAAC,EACzEd,EAAkB,YAAY,sBAAsBY,CAAiB,EACrEN,EAAQ,sBAAsB,oBAAoB,CAChD,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,WAAY,QAAS,QAAS,EAClD,cAAe,gBAAc,KAC7B,0BAA2B,EAC7B,CAAC,EAGD,MAAMS,EAAS,MAAM,IAAI,8BACvBT,EACAD,EACAE,CACF,EAAE,IAAI,EAGN,OAAOQ,CAAM,EAAE,QAAQ,CACrB,kBAAmB,CAAC,EACpB,0BAA2B,CAAC,EAC5B,sBAAAJ,EACA,QAAS,EACT,gBAAiB,EACjB,iBAAkB,mBAAiB,KACrC,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_context_module", "import_device_management_kit", "import_ethers", "import_purify_ts", "import_ClearSigningType", "import_makeInternalApi", "import_BuildTransactionContextTask", "import_GetWeb3CheckTask", "contextModuleMock", "mapperMock", "defaultOptions", "defaultTransaction", "defaultCertificate", "defaultArgs", "apiMock", "getWeb3ChecksFactoryMock", "createAppConfig", "web3ChecksEnabled", "task", "serializedTransaction", "clearSignContexts", "clearSignContextsOptional", "mapperResult", "result", "expectedWeb3Check", "error"]
7
7
  }