@ledgerhq/live-common 34.53.0-nightly.20251119023741 → 34.53.0-nightly.20251120023735

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 (237) hide show
  1. package/lib/e2e/deviceInteraction/DeviceController.d.ts +41 -0
  2. package/lib/e2e/deviceInteraction/DeviceController.d.ts.map +1 -0
  3. package/lib/e2e/deviceInteraction/DeviceController.js +68 -0
  4. package/lib/e2e/deviceInteraction/DeviceController.js.map +1 -0
  5. package/lib/e2e/families/algorand.d.ts +1 -1
  6. package/lib/e2e/families/algorand.d.ts.map +1 -1
  7. package/lib/e2e/families/algorand.js +5 -5
  8. package/lib/e2e/families/algorand.js.map +1 -1
  9. package/lib/e2e/families/aptos.d.ts +2 -2
  10. package/lib/e2e/families/aptos.d.ts.map +1 -1
  11. package/lib/e2e/families/aptos.js +9 -9
  12. package/lib/e2e/families/aptos.js.map +1 -1
  13. package/lib/e2e/families/bitcoin.d.ts +2 -2
  14. package/lib/e2e/families/bitcoin.d.ts.map +1 -1
  15. package/lib/e2e/families/bitcoin.js +11 -11
  16. package/lib/e2e/families/bitcoin.js.map +1 -1
  17. package/lib/e2e/families/cardano.d.ts +6 -0
  18. package/lib/e2e/families/cardano.d.ts.map +1 -1
  19. package/lib/e2e/families/cardano.js +28 -26
  20. package/lib/e2e/families/cardano.js.map +1 -1
  21. package/lib/e2e/families/celo.d.ts +1 -1
  22. package/lib/e2e/families/celo.d.ts.map +1 -1
  23. package/lib/e2e/families/celo.js +5 -5
  24. package/lib/e2e/families/celo.js.map +1 -1
  25. package/lib/e2e/families/cosmos.d.ts +2 -2
  26. package/lib/e2e/families/cosmos.d.ts.map +1 -1
  27. package/lib/e2e/families/cosmos.js +9 -9
  28. package/lib/e2e/families/cosmos.js.map +1 -1
  29. package/lib/e2e/families/evm.d.ts +2 -0
  30. package/lib/e2e/families/evm.d.ts.map +1 -1
  31. package/lib/e2e/families/evm.js +13 -12
  32. package/lib/e2e/families/evm.js.map +1 -1
  33. package/lib/e2e/families/hedera.d.ts +1 -1
  34. package/lib/e2e/families/hedera.d.ts.map +1 -1
  35. package/lib/e2e/families/hedera.js +5 -5
  36. package/lib/e2e/families/hedera.js.map +1 -1
  37. package/lib/e2e/families/kaspa.d.ts +2 -2
  38. package/lib/e2e/families/kaspa.d.ts.map +1 -1
  39. package/lib/e2e/families/kaspa.js +9 -9
  40. package/lib/e2e/families/kaspa.js.map +1 -1
  41. package/lib/e2e/families/multiversX.d.ts +1 -1
  42. package/lib/e2e/families/multiversX.d.ts.map +1 -1
  43. package/lib/e2e/families/multiversX.js +5 -5
  44. package/lib/e2e/families/multiversX.js.map +1 -1
  45. package/lib/e2e/families/near.d.ts +1 -1
  46. package/lib/e2e/families/near.d.ts.map +1 -1
  47. package/lib/e2e/families/near.js +6 -6
  48. package/lib/e2e/families/near.js.map +1 -1
  49. package/lib/e2e/families/osmosis.d.ts +1 -1
  50. package/lib/e2e/families/osmosis.d.ts.map +1 -1
  51. package/lib/e2e/families/osmosis.js +5 -5
  52. package/lib/e2e/families/osmosis.js.map +1 -1
  53. package/lib/e2e/families/polkadot.d.ts +1 -1
  54. package/lib/e2e/families/polkadot.d.ts.map +1 -1
  55. package/lib/e2e/families/polkadot.js +5 -5
  56. package/lib/e2e/families/polkadot.js.map +1 -1
  57. package/lib/e2e/families/solana.d.ts +2 -2
  58. package/lib/e2e/families/solana.d.ts.map +1 -1
  59. package/lib/e2e/families/solana.js +9 -9
  60. package/lib/e2e/families/solana.js.map +1 -1
  61. package/lib/e2e/families/stellar.d.ts +1 -1
  62. package/lib/e2e/families/stellar.d.ts.map +1 -1
  63. package/lib/e2e/families/stellar.js +5 -5
  64. package/lib/e2e/families/stellar.js.map +1 -1
  65. package/lib/e2e/families/sui.d.ts +1 -1
  66. package/lib/e2e/families/sui.d.ts.map +1 -1
  67. package/lib/e2e/families/sui.js +5 -5
  68. package/lib/e2e/families/sui.js.map +1 -1
  69. package/lib/e2e/families/tezos.d.ts +1 -1
  70. package/lib/e2e/families/tezos.d.ts.map +1 -1
  71. package/lib/e2e/families/tezos.js +7 -8
  72. package/lib/e2e/families/tezos.js.map +1 -1
  73. package/lib/e2e/families/tron.d.ts +1 -1
  74. package/lib/e2e/families/tron.d.ts.map +1 -1
  75. package/lib/e2e/families/tron.js +5 -5
  76. package/lib/e2e/families/tron.js.map +1 -1
  77. package/lib/e2e/families/xrp.d.ts +1 -1
  78. package/lib/e2e/families/xrp.d.ts.map +1 -1
  79. package/lib/e2e/families/xrp.js +5 -5
  80. package/lib/e2e/families/xrp.js.map +1 -1
  81. package/lib/e2e/index.d.ts +6 -0
  82. package/lib/e2e/index.d.ts.map +1 -1
  83. package/lib/e2e/speculos.d.ts +11 -11
  84. package/lib/e2e/speculos.d.ts.map +1 -1
  85. package/lib/e2e/speculos.js +78 -78
  86. package/lib/e2e/speculos.js.map +1 -1
  87. package/lib/families/canton/bridge/mock.d.ts.map +1 -1
  88. package/lib/families/canton/bridge/mock.js +1 -0
  89. package/lib/families/canton/bridge/mock.js.map +1 -1
  90. package/lib/families/canton/react.d.ts +15 -0
  91. package/lib/families/canton/react.d.ts.map +1 -0
  92. package/lib/families/canton/react.js +14 -0
  93. package/lib/families/canton/react.js.map +1 -0
  94. package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
  95. package/lib/featureFlags/defaultFeatures.js +2 -0
  96. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  97. package/lib/featureFlags/useFeature.d.ts +1 -1
  98. package/lib/featureFlags/useFeature.d.ts.map +1 -1
  99. package/lib/wallet-api/react.d.ts.map +1 -1
  100. package/lib/wallet-api/react.js +2 -0
  101. package/lib/wallet-api/react.js.map +1 -1
  102. package/lib-es/e2e/deviceInteraction/DeviceController.d.ts +41 -0
  103. package/lib-es/e2e/deviceInteraction/DeviceController.d.ts.map +1 -0
  104. package/lib-es/e2e/deviceInteraction/DeviceController.js +63 -0
  105. package/lib-es/e2e/deviceInteraction/DeviceController.js.map +1 -0
  106. package/lib-es/e2e/families/algorand.d.ts +1 -1
  107. package/lib-es/e2e/families/algorand.d.ts.map +1 -1
  108. package/lib-es/e2e/families/algorand.js +5 -4
  109. package/lib-es/e2e/families/algorand.js.map +1 -1
  110. package/lib-es/e2e/families/aptos.d.ts +2 -2
  111. package/lib-es/e2e/families/aptos.d.ts.map +1 -1
  112. package/lib-es/e2e/families/aptos.js +9 -7
  113. package/lib-es/e2e/families/aptos.js.map +1 -1
  114. package/lib-es/e2e/families/bitcoin.d.ts +2 -2
  115. package/lib-es/e2e/families/bitcoin.d.ts.map +1 -1
  116. package/lib-es/e2e/families/bitcoin.js +11 -9
  117. package/lib-es/e2e/families/bitcoin.js.map +1 -1
  118. package/lib-es/e2e/families/cardano.d.ts +6 -0
  119. package/lib-es/e2e/families/cardano.d.ts.map +1 -1
  120. package/lib-es/e2e/families/cardano.js +23 -21
  121. package/lib-es/e2e/families/cardano.js.map +1 -1
  122. package/lib-es/e2e/families/celo.d.ts +1 -1
  123. package/lib-es/e2e/families/celo.d.ts.map +1 -1
  124. package/lib-es/e2e/families/celo.js +5 -4
  125. package/lib-es/e2e/families/celo.js.map +1 -1
  126. package/lib-es/e2e/families/cosmos.d.ts +2 -2
  127. package/lib-es/e2e/families/cosmos.d.ts.map +1 -1
  128. package/lib-es/e2e/families/cosmos.js +9 -7
  129. package/lib-es/e2e/families/cosmos.js.map +1 -1
  130. package/lib-es/e2e/families/evm.d.ts +2 -0
  131. package/lib-es/e2e/families/evm.d.ts.map +1 -1
  132. package/lib-es/e2e/families/evm.js +10 -9
  133. package/lib-es/e2e/families/evm.js.map +1 -1
  134. package/lib-es/e2e/families/hedera.d.ts +1 -1
  135. package/lib-es/e2e/families/hedera.d.ts.map +1 -1
  136. package/lib-es/e2e/families/hedera.js +5 -4
  137. package/lib-es/e2e/families/hedera.js.map +1 -1
  138. package/lib-es/e2e/families/kaspa.d.ts +2 -2
  139. package/lib-es/e2e/families/kaspa.d.ts.map +1 -1
  140. package/lib-es/e2e/families/kaspa.js +9 -7
  141. package/lib-es/e2e/families/kaspa.js.map +1 -1
  142. package/lib-es/e2e/families/multiversX.d.ts +1 -1
  143. package/lib-es/e2e/families/multiversX.d.ts.map +1 -1
  144. package/lib-es/e2e/families/multiversX.js +5 -4
  145. package/lib-es/e2e/families/multiversX.js.map +1 -1
  146. package/lib-es/e2e/families/near.d.ts +1 -1
  147. package/lib-es/e2e/families/near.d.ts.map +1 -1
  148. package/lib-es/e2e/families/near.js +6 -5
  149. package/lib-es/e2e/families/near.js.map +1 -1
  150. package/lib-es/e2e/families/osmosis.d.ts +1 -1
  151. package/lib-es/e2e/families/osmosis.d.ts.map +1 -1
  152. package/lib-es/e2e/families/osmosis.js +5 -4
  153. package/lib-es/e2e/families/osmosis.js.map +1 -1
  154. package/lib-es/e2e/families/polkadot.d.ts +1 -1
  155. package/lib-es/e2e/families/polkadot.d.ts.map +1 -1
  156. package/lib-es/e2e/families/polkadot.js +5 -4
  157. package/lib-es/e2e/families/polkadot.js.map +1 -1
  158. package/lib-es/e2e/families/solana.d.ts +2 -2
  159. package/lib-es/e2e/families/solana.d.ts.map +1 -1
  160. package/lib-es/e2e/families/solana.js +9 -7
  161. package/lib-es/e2e/families/solana.js.map +1 -1
  162. package/lib-es/e2e/families/stellar.d.ts +1 -1
  163. package/lib-es/e2e/families/stellar.d.ts.map +1 -1
  164. package/lib-es/e2e/families/stellar.js +5 -4
  165. package/lib-es/e2e/families/stellar.js.map +1 -1
  166. package/lib-es/e2e/families/sui.d.ts +1 -1
  167. package/lib-es/e2e/families/sui.d.ts.map +1 -1
  168. package/lib-es/e2e/families/sui.js +5 -4
  169. package/lib-es/e2e/families/sui.js.map +1 -1
  170. package/lib-es/e2e/families/tezos.d.ts +1 -1
  171. package/lib-es/e2e/families/tezos.d.ts.map +1 -1
  172. package/lib-es/e2e/families/tezos.js +8 -8
  173. package/lib-es/e2e/families/tezos.js.map +1 -1
  174. package/lib-es/e2e/families/tron.d.ts +1 -1
  175. package/lib-es/e2e/families/tron.d.ts.map +1 -1
  176. package/lib-es/e2e/families/tron.js +5 -4
  177. package/lib-es/e2e/families/tron.js.map +1 -1
  178. package/lib-es/e2e/families/xrp.d.ts +1 -1
  179. package/lib-es/e2e/families/xrp.d.ts.map +1 -1
  180. package/lib-es/e2e/families/xrp.js +5 -4
  181. package/lib-es/e2e/families/xrp.js.map +1 -1
  182. package/lib-es/e2e/index.d.ts +6 -0
  183. package/lib-es/e2e/index.d.ts.map +1 -1
  184. package/lib-es/e2e/speculos.d.ts +11 -11
  185. package/lib-es/e2e/speculos.d.ts.map +1 -1
  186. package/lib-es/e2e/speculos.js +54 -43
  187. package/lib-es/e2e/speculos.js.map +1 -1
  188. package/lib-es/families/canton/bridge/mock.d.ts.map +1 -1
  189. package/lib-es/families/canton/bridge/mock.js +1 -0
  190. package/lib-es/families/canton/bridge/mock.js.map +1 -1
  191. package/lib-es/families/canton/react.d.ts +15 -0
  192. package/lib-es/families/canton/react.d.ts.map +1 -0
  193. package/lib-es/families/canton/react.js +10 -0
  194. package/lib-es/families/canton/react.js.map +1 -0
  195. package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
  196. package/lib-es/featureFlags/defaultFeatures.js +2 -0
  197. package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
  198. package/lib-es/featureFlags/useFeature.d.ts +1 -1
  199. package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
  200. package/lib-es/wallet-api/react.d.ts.map +1 -1
  201. package/lib-es/wallet-api/react.js +2 -0
  202. package/lib-es/wallet-api/react.js.map +1 -1
  203. package/package.json +52 -51
  204. package/src/e2e/deviceInteraction/DeviceController.ts +85 -0
  205. package/src/e2e/families/algorand.ts +20 -13
  206. package/src/e2e/families/aptos.ts +28 -16
  207. package/src/e2e/families/bitcoin.ts +53 -39
  208. package/src/e2e/families/cardano.ts +47 -36
  209. package/src/e2e/families/celo.ts +18 -12
  210. package/src/e2e/families/cosmos.ts +35 -23
  211. package/src/e2e/families/evm.ts +24 -13
  212. package/src/e2e/families/hedera.ts +6 -4
  213. package/src/e2e/families/kaspa.ts +28 -16
  214. package/src/e2e/families/multiversX.ts +16 -10
  215. package/src/e2e/families/near.ts +23 -17
  216. package/src/e2e/families/osmosis.ts +19 -13
  217. package/src/e2e/families/polkadot.ts +19 -13
  218. package/src/e2e/families/solana.ts +35 -23
  219. package/src/e2e/families/stellar.ts +18 -13
  220. package/src/e2e/families/sui.ts +15 -9
  221. package/src/e2e/families/tezos.ts +25 -18
  222. package/src/e2e/families/tron.ts +19 -13
  223. package/src/e2e/families/xrp.ts +19 -13
  224. package/src/e2e/speculos.ts +168 -140
  225. package/src/families/canton/bridge/mock.ts +1 -0
  226. package/src/families/canton/react.ts +50 -0
  227. package/src/featureFlags/defaultFeatures.ts +2 -0
  228. package/src/wallet-api/react.ts +2 -0
  229. package/lib/e2e/deviceInteraction/ButtonDeviceSimulator.d.ts +0 -3
  230. package/lib/e2e/deviceInteraction/ButtonDeviceSimulator.d.ts.map +0 -1
  231. package/lib/e2e/deviceInteraction/ButtonDeviceSimulator.js +0 -26
  232. package/lib/e2e/deviceInteraction/ButtonDeviceSimulator.js.map +0 -1
  233. package/lib-es/e2e/deviceInteraction/ButtonDeviceSimulator.d.ts +0 -3
  234. package/lib-es/e2e/deviceInteraction/ButtonDeviceSimulator.d.ts.map +0 -1
  235. package/lib-es/e2e/deviceInteraction/ButtonDeviceSimulator.js +0 -18
  236. package/lib-es/e2e/deviceInteraction/ButtonDeviceSimulator.js.map +0 -1
  237. package/src/e2e/deviceInteraction/ButtonDeviceSimulator.ts +0 -23
@@ -1,8 +1,7 @@
1
1
  import expect from "expect";
2
2
  import { Transaction } from "../models/Transaction";
3
3
  import { pressUntilTextFound, containsSubstringInEvent, waitFor } from "../speculos";
4
- import { getSpeculosModel } from "../speculosAppVersion";
5
- import { pressBoth, pressRightButton } from "../deviceInteraction/ButtonDeviceSimulator";
4
+ import { getSpeculosModel, isTouchDevice } from "../speculosAppVersion";
6
5
  import {
7
6
  pressAndRelease,
8
7
  longPressAndRelease,
@@ -10,7 +9,7 @@ import {
10
9
  } from "../deviceInteraction/TouchDeviceSimulator";
11
10
  import { DeviceLabels } from "../enum/DeviceLabels";
12
11
  import { DeviceModelId } from "@ledgerhq/types-devices";
13
- import { isTouchDevice } from "../speculosAppVersion";
12
+ import { withDeviceController } from "../deviceInteraction/DeviceController";
14
13
 
15
14
  type ActionType = "both" | "right" | "tap" | "swipe" | "confirm" | "hold";
16
15
 
@@ -32,32 +31,40 @@ async function sendCardanoTouchDevices(tx: Transaction) {
32
31
  await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
33
32
  }
34
33
 
35
- async function sendCardanoNanoS(_tx: Transaction) {
36
- await waitFor(DeviceLabels.NEW_ORDINARY);
37
- await pressRightButton();
38
- await waitFor(DeviceLabels.SEND_TO_ADDRESS);
39
- await pressBoth();
40
- await pressUntilTextFound(DeviceLabels.SEND);
41
- await pressBoth();
42
- await waitFor(DeviceLabels.TRANSACTION_FEE);
43
- await pressBoth();
44
- await waitFor(DeviceLabels.CONFIRM);
45
- await pressRightButton();
46
- }
34
+ export const sendCardanoNanoS = withDeviceController(
35
+ ({ getButtonsController }) =>
36
+ async (_tx: Transaction) => {
37
+ const buttons = getButtonsController();
38
+ await waitFor(DeviceLabels.NEW_ORDINARY);
39
+ await buttons.right();
40
+ await waitFor(DeviceLabels.SEND_TO_ADDRESS);
41
+ await buttons.both();
42
+ await pressUntilTextFound(DeviceLabels.SEND);
43
+ await buttons.both();
44
+ await waitFor(DeviceLabels.TRANSACTION_FEE);
45
+ await buttons.both();
46
+ await waitFor(DeviceLabels.CONFIRM);
47
+ await buttons.right();
48
+ },
49
+ );
47
50
 
48
- async function sendCardanoButtonDevice(tx: Transaction) {
49
- await waitFor(DeviceLabels.NEW_ORDINARY);
50
- await pressBoth();
51
- await pressUntilTextFound(DeviceLabels.SEND_TO_ADDRESS_2);
52
- await pressBoth();
53
- const events = await pressUntilTextFound(DeviceLabels.SEND);
54
- validateTransactionData(tx, events);
55
- await pressBoth();
56
- await waitFor(DeviceLabels.TRANSACTION_FEE);
57
- await pressBoth();
58
- await waitFor(DeviceLabels.CONFIRM);
59
- await pressBoth();
60
- }
51
+ export const sendCardanoButtonDevice = withDeviceController(
52
+ ({ getButtonsController }) =>
53
+ async (tx: Transaction) => {
54
+ const buttons = getButtonsController();
55
+ await waitFor(DeviceLabels.NEW_ORDINARY);
56
+ await buttons.both();
57
+ await pressUntilTextFound(DeviceLabels.SEND_TO_ADDRESS_2);
58
+ await buttons.both();
59
+ const events = await pressUntilTextFound(DeviceLabels.SEND);
60
+ validateTransactionData(tx, events);
61
+ await buttons.both();
62
+ await waitFor(DeviceLabels.TRANSACTION_FEE);
63
+ await buttons.both();
64
+ await waitFor(DeviceLabels.CONFIRM);
65
+ await buttons.both();
66
+ },
67
+ );
61
68
 
62
69
  export async function sendCardano(tx: Transaction) {
63
70
  const speculosModel = getSpeculosModel();
@@ -127,14 +134,18 @@ async function delegateTouchDevicesAction(label: DeviceLabels) {
127
134
  }
128
135
  }
129
136
 
130
- async function delegateNanoAction(label: DeviceLabels, action: ActionType) {
131
- await waitFor(label);
132
- if (action === "both") {
133
- await pressBoth();
134
- } else {
135
- await pressRightButton();
136
- }
137
- }
137
+ export const delegateNanoAction = withDeviceController(
138
+ ({ getButtonsController }) =>
139
+ async (label: DeviceLabels, action: ActionType) => {
140
+ const buttons = getButtonsController();
141
+ await waitFor(label);
142
+ if (action === "both") {
143
+ await buttons.both();
144
+ } else {
145
+ await buttons.right();
146
+ }
147
+ },
148
+ );
138
149
 
139
150
  async function executeDelegateStep(label: DeviceLabels, action: ActionType) {
140
151
  try {
@@ -2,18 +2,24 @@ import { containsSubstringInEvent, getDelegateEvents, pressUntilTextFound } from
2
2
  import { isTouchDevice } from "../speculosAppVersion";
3
3
  import { Delegate } from "../models/Delegate";
4
4
  import expect from "expect";
5
- import { pressBoth } from "../deviceInteraction/ButtonDeviceSimulator";
6
5
  import { longPressAndRelease } from "../deviceInteraction/TouchDeviceSimulator";
7
6
  import { DeviceLabels } from "../enum/DeviceLabels";
7
+ import { withDeviceController } from "../deviceInteraction/DeviceController";
8
8
 
9
- export async function delegateCelo(delegatingAccount: Delegate) {
10
- const events = await getDelegateEvents(delegatingAccount);
11
- const isAmountCorrect = containsSubstringInEvent(delegatingAccount.amount, events);
12
- expect(isAmountCorrect).toBeTruthy();
13
- if (isTouchDevice()) {
14
- await pressUntilTextFound(DeviceLabels.HOLD_TO_SIGN);
15
- await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
16
- } else {
17
- await pressBoth();
18
- }
19
- }
9
+ export const delegateCelo = withDeviceController(
10
+ ({ getButtonsController }) =>
11
+ async (delegatingAccount: Delegate) => {
12
+ const buttons = getButtonsController();
13
+
14
+ const events = await getDelegateEvents(delegatingAccount);
15
+ const isAmountCorrect = containsSubstringInEvent(delegatingAccount.amount, events);
16
+ expect(isAmountCorrect).toBeTruthy();
17
+
18
+ if (isTouchDevice()) {
19
+ await pressUntilTextFound(DeviceLabels.HOLD_TO_SIGN);
20
+ await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
21
+ } else {
22
+ await buttons.both();
23
+ }
24
+ },
25
+ );
@@ -2,32 +2,44 @@ import expect from "expect";
2
2
  import { Delegate } from "../models/Delegate";
3
3
  import { Transaction } from "../models/Transaction";
4
4
  import { containsSubstringInEvent, getDelegateEvents, getSendEvents } from "../speculos";
5
- import { pressBoth } from "../deviceInteraction/ButtonDeviceSimulator";
6
5
  import { DeviceLabels } from "../enum/DeviceLabels";
7
6
  import { isTouchDevice } from "../speculosAppVersion";
8
7
  import { longPressAndRelease } from "../deviceInteraction/TouchDeviceSimulator";
8
+ import { withDeviceController } from "../deviceInteraction/DeviceController";
9
9
 
10
- export async function delegateCosmos(delegatingAccount: Delegate) {
11
- const events = await getDelegateEvents(delegatingAccount);
12
- const isAmountCorrect = containsSubstringInEvent(delegatingAccount.amount, events);
13
- expect(isAmountCorrect).toBeTruthy();
14
- if (isTouchDevice()) {
15
- await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
16
- } else {
17
- await pressBoth();
18
- }
19
- }
10
+ export const delegateCosmos = withDeviceController(
11
+ ({ getButtonsController }) =>
12
+ async (delegatingAccount: Delegate) => {
13
+ const buttons = getButtonsController();
20
14
 
21
- export async function sendCosmos(tx: Transaction) {
22
- const events = await getSendEvents(tx);
23
- const isAmountCorrect = containsSubstringInEvent(tx.amount, events);
24
- expect(isAmountCorrect).toBeTruthy();
25
- const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events);
26
- expect(isAddressCorrect).toBeTruthy();
15
+ const events = await getDelegateEvents(delegatingAccount);
16
+ const isAmountCorrect = containsSubstringInEvent(delegatingAccount.amount, events);
17
+ expect(isAmountCorrect).toBeTruthy();
27
18
 
28
- if (isTouchDevice()) {
29
- await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
30
- } else {
31
- await pressBoth();
32
- }
33
- }
19
+ if (isTouchDevice()) {
20
+ await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
21
+ } else {
22
+ await buttons.both();
23
+ }
24
+ },
25
+ );
26
+
27
+ export const sendCosmos = withDeviceController(
28
+ ({ getButtonsController }) =>
29
+ async (tx: Transaction) => {
30
+ const buttons = getButtonsController();
31
+
32
+ const events = await getSendEvents(tx);
33
+ const isAmountCorrect = containsSubstringInEvent(tx.amount, events);
34
+ expect(isAmountCorrect).toBeTruthy();
35
+
36
+ const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events);
37
+ expect(isAddressCorrect).toBeTruthy();
38
+
39
+ if (isTouchDevice()) {
40
+ await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
41
+ } else {
42
+ await buttons.both();
43
+ }
44
+ },
45
+ );
@@ -1,17 +1,17 @@
1
1
  import expect from "expect";
2
2
  import { Transaction } from "../models/Transaction";
3
3
  import { containsSubstringInEvent, pressUntilTextFound } from "../speculos";
4
- import { getSpeculosModel } from "../speculosAppVersion";
5
- import { pressBoth } from "../deviceInteraction/ButtonDeviceSimulator";
4
+ import { getSpeculosModel, isTouchDevice } from "../speculosAppVersion";
6
5
  import { longPressAndRelease } from "../deviceInteraction/TouchDeviceSimulator";
7
6
  import { DeviceLabels } from "../enum/DeviceLabels";
8
7
  import { Device } from "../enum/Device";
9
8
  import { DeviceModelId } from "@ledgerhq/types-devices";
10
- import { isTouchDevice } from "../speculosAppVersion";
9
+ import { withDeviceController } from "../deviceInteraction/DeviceController";
11
10
 
12
11
  function validateTransactionData(tx: Transaction, events: string[]) {
13
12
  const isAmountCorrect = containsSubstringInEvent(tx.amount, events);
14
13
  expect(isAmountCorrect).toBeTruthy();
14
+
15
15
  if (tx.accountToCredit.ensName && process.env.SPECULOS_DEVICE !== Device.LNS.name) {
16
16
  const isENSNameCorrect = containsSubstringInEvent(tx.accountToCredit.ensName, events);
17
17
  expect(isENSNameCorrect).toBeTruthy();
@@ -27,20 +27,31 @@ async function sendEvmTouchDevices(tx: Transaction) {
27
27
  await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
28
28
  }
29
29
 
30
- async function sendEvmButtonDevice(tx: Transaction) {
31
- const events = await pressUntilTextFound(DeviceLabels.SIGN_TRANSACTION);
32
- validateTransactionData(tx, events);
33
- await pressBoth();
34
- }
30
+ export const sendEvmButtonDevice = withDeviceController(
31
+ ({ getButtonsController }) =>
32
+ async (tx: Transaction) => {
33
+ const buttons = getButtonsController();
35
34
 
36
- async function sendEvmNanoS(tx: Transaction) {
37
- const events = await pressUntilTextFound(DeviceLabels.ACCEPT);
38
- validateTransactionData(tx, events);
39
- await pressBoth();
40
- }
35
+ const events = await pressUntilTextFound(DeviceLabels.SIGN_TRANSACTION);
36
+ validateTransactionData(tx, events);
37
+ await buttons.both();
38
+ },
39
+ );
40
+
41
+ export const sendEvmNanoS = withDeviceController(
42
+ ({ getButtonsController }) =>
43
+ async (tx: Transaction) => {
44
+ const buttons = getButtonsController();
45
+
46
+ const events = await pressUntilTextFound(DeviceLabels.ACCEPT);
47
+ validateTransactionData(tx, events);
48
+ await buttons.both();
49
+ },
50
+ );
41
51
 
42
52
  export async function sendEVM(tx: Transaction) {
43
53
  const speculosModel = getSpeculosModel();
54
+
44
55
  if (isTouchDevice()) {
45
56
  return sendEvmTouchDevices(tx);
46
57
  }
@@ -1,8 +1,10 @@
1
- import { pressBoth } from "../deviceInteraction/ButtonDeviceSimulator";
2
1
  import { DeviceLabels } from "../enum/DeviceLabels";
3
2
  import { pressUntilTextFound } from "../speculos";
3
+ import { withDeviceController } from "../deviceInteraction/DeviceController";
4
+
5
+ export const sendHedera = withDeviceController(({ getButtonsController }) => async () => {
6
+ const buttons = getButtonsController();
4
7
 
5
- export async function sendHedera() {
6
8
  await pressUntilTextFound(DeviceLabels.APPROVE);
7
- await pressBoth();
8
- }
9
+ await buttons.both();
10
+ });
@@ -1,25 +1,37 @@
1
1
  import expect from "expect";
2
2
  import { waitFor, containsSubstringInEvent, pressUntilTextFound, getSendEvents } from "../speculos";
3
3
  import { isTouchDevice } from "../speculosAppVersion";
4
- import { pressBoth } from "../deviceInteraction/ButtonDeviceSimulator";
5
4
  import { DeviceLabels } from "../enum/DeviceLabels";
6
5
  import { Delegate } from "../models/Delegate";
7
6
  import { longPressAndRelease } from "../deviceInteraction/TouchDeviceSimulator";
8
7
  import { Transaction } from "../models/Transaction";
8
+ import { withDeviceController } from "../deviceInteraction/DeviceController";
9
9
 
10
- export async function sendKaspa(tx: Transaction) {
11
- await getSendEvents(tx);
12
- if (isTouchDevice()) {
13
- await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
14
- } else {
15
- await pressBoth();
16
- }
17
- }
10
+ export const sendKaspa = withDeviceController(
11
+ ({ getButtonsController }) =>
12
+ async (tx: Transaction) => {
13
+ const buttons = getButtonsController();
18
14
 
19
- export async function delegateKaspa(delegatingAccount: Delegate) {
20
- await waitFor(DeviceLabels.REVIEW_OPERATION);
21
- const events = await pressUntilTextFound(DeviceLabels.APPROVE);
22
- const isAmountCorrect = containsSubstringInEvent(delegatingAccount.amount, events);
23
- expect(isAmountCorrect).toBeTruthy();
24
- await pressBoth();
25
- }
15
+ await getSendEvents(tx);
16
+
17
+ if (isTouchDevice()) {
18
+ await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
19
+ } else {
20
+ await buttons.both();
21
+ }
22
+ },
23
+ );
24
+
25
+ export const delegateKaspa = withDeviceController(
26
+ ({ getButtonsController }) =>
27
+ async (delegatingAccount: Delegate) => {
28
+ const buttons = getButtonsController();
29
+
30
+ await waitFor(DeviceLabels.REVIEW_OPERATION);
31
+ const events = await pressUntilTextFound(DeviceLabels.APPROVE);
32
+ const isAmountCorrect = containsSubstringInEvent(delegatingAccount.amount, events);
33
+ expect(isAmountCorrect).toBeTruthy();
34
+
35
+ await buttons.both();
36
+ },
37
+ );
@@ -1,16 +1,22 @@
1
1
  import { getDelegateEvents, pressUntilTextFound } from "../speculos";
2
2
  import { Delegate } from "../models/Delegate";
3
- import { pressBoth } from "../deviceInteraction/ButtonDeviceSimulator";
4
3
  import { DeviceLabels } from "../enum/DeviceLabels";
5
4
  import { isTouchDevice } from "../speculosAppVersion";
6
5
  import { longPressAndRelease } from "../deviceInteraction/TouchDeviceSimulator";
6
+ import { withDeviceController } from "../deviceInteraction/DeviceController";
7
7
 
8
- export async function delegateMultiversX(delegatingAccount: Delegate) {
9
- await getDelegateEvents(delegatingAccount);
10
- if (isTouchDevice()) {
11
- await pressUntilTextFound(DeviceLabels.HOLD_TO_SIGN);
12
- await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
13
- } else {
14
- await pressBoth();
15
- }
16
- }
8
+ export const delegateMultiversX = withDeviceController(
9
+ ({ getButtonsController }) =>
10
+ async (delegatingAccount: Delegate) => {
11
+ const buttons = getButtonsController();
12
+
13
+ await getDelegateEvents(delegatingAccount);
14
+
15
+ if (isTouchDevice()) {
16
+ await pressUntilTextFound(DeviceLabels.HOLD_TO_SIGN);
17
+ await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
18
+ } else {
19
+ await buttons.both();
20
+ }
21
+ },
22
+ );
@@ -7,23 +7,29 @@ import {
7
7
  pressUntilTextFound,
8
8
  } from "../speculos";
9
9
  import { isTouchDevice } from "../speculosAppVersion";
10
- import { pressBoth } from "../deviceInteraction/ButtonDeviceSimulator";
11
10
  import { DeviceLabels } from "../enum/DeviceLabels";
12
11
  import { longPressAndRelease, pressAndRelease } from "../deviceInteraction/TouchDeviceSimulator";
12
+ import { withDeviceController } from "../deviceInteraction/DeviceController";
13
13
 
14
- export async function delegateNear(delegatingAccount: Delegate) {
15
- const events = await getDelegateEvents(delegatingAccount);
16
- const isProviderCorrect = containsSubstringInEvent(delegatingAccount.provider, events);
17
- expect(isProviderCorrect).toBeTruthy();
18
- if (isTouchDevice()) {
19
- await pressAndRelease(DeviceLabels.CONFIRM_HEADER);
20
- await waitFor(DeviceLabels.VIEW_ACTION);
21
- await pressUntilTextFound(DeviceLabels.HOLD_TO_SIGN);
22
- await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
23
- } else {
24
- await pressBoth();
25
- await waitFor(DeviceLabels.VIEW_ACTION);
26
- await pressUntilTextFound(DeviceLabels.SIGN);
27
- await pressBoth();
28
- }
29
- }
14
+ export const delegateNear = withDeviceController(
15
+ ({ getButtonsController }) =>
16
+ async (delegatingAccount: Delegate) => {
17
+ const buttons = getButtonsController();
18
+
19
+ const events = await getDelegateEvents(delegatingAccount);
20
+ const isProviderCorrect = containsSubstringInEvent(delegatingAccount.provider, events);
21
+ expect(isProviderCorrect).toBeTruthy();
22
+
23
+ if (isTouchDevice()) {
24
+ await pressAndRelease(DeviceLabels.CONFIRM_HEADER);
25
+ await waitFor(DeviceLabels.VIEW_ACTION);
26
+ await pressUntilTextFound(DeviceLabels.HOLD_TO_SIGN);
27
+ await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
28
+ } else {
29
+ await buttons.both();
30
+ await waitFor(DeviceLabels.VIEW_ACTION);
31
+ await pressUntilTextFound(DeviceLabels.SIGN);
32
+ await buttons.both();
33
+ }
34
+ },
35
+ );
@@ -2,19 +2,25 @@ import { Delegate } from "../models/Delegate";
2
2
  import { pressUntilTextFound, containsSubstringInEvent, getDelegateEvents } from "../speculos";
3
3
  import { isTouchDevice } from "../speculosAppVersion";
4
4
  import expect from "expect";
5
- import { pressBoth } from "../deviceInteraction/ButtonDeviceSimulator";
6
5
  import { DeviceLabels } from "../enum/DeviceLabels";
7
6
  import { longPressAndRelease } from "../deviceInteraction/TouchDeviceSimulator";
7
+ import { withDeviceController } from "../deviceInteraction/DeviceController";
8
8
 
9
- export async function delegateOsmosis(delegatingAccount: Delegate) {
10
- const events = await getDelegateEvents(delegatingAccount);
11
- const amountInUosmo = (Number(delegatingAccount.amount) * 1_000_000).toString();
12
- const isAmountCorrect = containsSubstringInEvent(amountInUosmo, events);
13
- expect(isAmountCorrect).toBeTruthy();
14
- if (isTouchDevice()) {
15
- await pressUntilTextFound(DeviceLabels.HOLD_TO_SIGN);
16
- await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
17
- } else {
18
- await pressBoth();
19
- }
20
- }
9
+ export const delegateOsmosis = withDeviceController(
10
+ ({ getButtonsController }) =>
11
+ async (delegatingAccount: Delegate) => {
12
+ const buttons = getButtonsController();
13
+
14
+ const events = await getDelegateEvents(delegatingAccount);
15
+ const amountInUosmo = (Number(delegatingAccount.amount) * 1_000_000).toString();
16
+ const isAmountCorrect = containsSubstringInEvent(amountInUosmo, events);
17
+ expect(isAmountCorrect).toBeTruthy();
18
+
19
+ if (isTouchDevice()) {
20
+ await pressUntilTextFound(DeviceLabels.HOLD_TO_SIGN);
21
+ await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
22
+ } else {
23
+ await buttons.both();
24
+ }
25
+ },
26
+ );
@@ -2,20 +2,26 @@ import expect from "expect";
2
2
  import { Transaction } from "../models/Transaction";
3
3
  import { containsSubstringInEvent, getSendEvents } from "../speculos";
4
4
  import { isTouchDevice } from "../speculosAppVersion";
5
- import { pressBoth } from "../deviceInteraction/ButtonDeviceSimulator";
6
5
  import { DeviceLabels } from "../enum/DeviceLabels";
7
6
  import { longPressAndRelease } from "../deviceInteraction/TouchDeviceSimulator";
7
+ import { withDeviceController } from "../deviceInteraction/DeviceController";
8
8
 
9
- export async function sendPolkadot(tx: Transaction) {
10
- const events = await getSendEvents(tx);
11
- const isAmountCorrect = containsSubstringInEvent(tx.amount, events);
12
- expect(isAmountCorrect).toBeTruthy();
13
- const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events);
14
- expect(isAddressCorrect).toBeTruthy();
9
+ export const sendPolkadot = withDeviceController(
10
+ ({ getButtonsController }) =>
11
+ async (tx: Transaction) => {
12
+ const buttons = getButtonsController();
15
13
 
16
- if (isTouchDevice()) {
17
- await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
18
- } else {
19
- await pressBoth();
20
- }
21
- }
14
+ const events = await getSendEvents(tx);
15
+ const isAmountCorrect = containsSubstringInEvent(tx.amount, events);
16
+ expect(isAmountCorrect).toBeTruthy();
17
+
18
+ const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events);
19
+ expect(isAddressCorrect).toBeTruthy();
20
+
21
+ if (isTouchDevice()) {
22
+ await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
23
+ } else {
24
+ await buttons.both();
25
+ }
26
+ },
27
+ );
@@ -2,33 +2,45 @@ import expect from "expect";
2
2
  import { containsSubstringInEvent, getDelegateEvents, getSendEvents } from "../speculos";
3
3
  import { isTouchDevice } from "../speculosAppVersion";
4
4
  import { longPressAndRelease } from "../deviceInteraction/TouchDeviceSimulator";
5
- import { pressBoth } from "../deviceInteraction/ButtonDeviceSimulator";
6
5
  import { DeviceLabels } from "../enum/DeviceLabels";
7
6
  import { Device } from "../enum/Device";
8
7
  import { Transaction } from "../models/Transaction";
9
8
  import { Delegate } from "../models/Delegate";
9
+ import { withDeviceController } from "../deviceInteraction/DeviceController";
10
10
 
11
- export async function delegateSolana(delegatingAccount: Delegate) {
12
- await getDelegateEvents(delegatingAccount);
13
- if (isTouchDevice()) {
14
- await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
15
- } else {
16
- await pressBoth();
17
- }
18
- }
11
+ export const delegateSolana = withDeviceController(
12
+ ({ getButtonsController }) =>
13
+ async (delegatingAccount: Delegate) => {
14
+ const buttons = getButtonsController();
19
15
 
20
- export async function sendSolana(tx: Transaction) {
21
- const events = await getSendEvents(tx);
22
- const isAmountCorrect = containsSubstringInEvent(tx.amount, events);
23
- expect(isAmountCorrect).toBeTruthy();
24
- if (process.env.SPECULOS_DEVICE !== Device.LNS.name) {
25
- const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events);
26
- expect(isAddressCorrect).toBeTruthy();
27
- }
16
+ await getDelegateEvents(delegatingAccount);
28
17
 
29
- if (isTouchDevice()) {
30
- await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
31
- } else {
32
- await pressBoth();
33
- }
34
- }
18
+ if (isTouchDevice()) {
19
+ await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
20
+ } else {
21
+ await buttons.both();
22
+ }
23
+ },
24
+ );
25
+
26
+ export const sendSolana = withDeviceController(
27
+ ({ getButtonsController }) =>
28
+ async (tx: Transaction) => {
29
+ const buttons = getButtonsController();
30
+
31
+ const events = await getSendEvents(tx);
32
+ const isAmountCorrect = containsSubstringInEvent(tx.amount, events);
33
+ expect(isAmountCorrect).toBeTruthy();
34
+
35
+ if (process.env.SPECULOS_DEVICE !== Device.LNS.name) {
36
+ const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events);
37
+ expect(isAddressCorrect).toBeTruthy();
38
+ }
39
+
40
+ if (isTouchDevice()) {
41
+ await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
42
+ } else {
43
+ await buttons.both();
44
+ }
45
+ },
46
+ );
@@ -2,21 +2,26 @@ import expect from "expect";
2
2
  import { Transaction } from "../models/Transaction";
3
3
  import { containsSubstringInEvent, getSendEvents } from "../speculos";
4
4
  import { isTouchDevice } from "../speculosAppVersion";
5
- import { pressBoth } from "../deviceInteraction/ButtonDeviceSimulator";
6
5
  import { DeviceLabels } from "../enum/DeviceLabels";
7
6
  import { longPressAndRelease } from "../deviceInteraction/TouchDeviceSimulator";
7
+ import { withDeviceController } from "../deviceInteraction/DeviceController";
8
8
 
9
- export async function sendStellar(tx: Transaction) {
10
- const events = await getSendEvents(tx);
11
- const isAmountCorrect = containsSubstringInEvent(tx.amount, events);
12
- expect(isAmountCorrect).toBeTruthy();
9
+ export const sendStellar = withDeviceController(
10
+ ({ getButtonsController }) =>
11
+ async (tx: Transaction) => {
12
+ const buttons = getButtonsController();
13
13
 
14
- const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events);
15
- expect(isAddressCorrect).toBeTruthy();
14
+ const events = await getSendEvents(tx);
15
+ const isAmountCorrect = containsSubstringInEvent(tx.amount, events);
16
+ expect(isAmountCorrect).toBeTruthy();
16
17
 
17
- if (isTouchDevice()) {
18
- await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
19
- } else {
20
- await pressBoth();
21
- }
22
- }
18
+ const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events);
19
+ expect(isAddressCorrect).toBeTruthy();
20
+
21
+ if (isTouchDevice()) {
22
+ await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
23
+ } else {
24
+ await buttons.both();
25
+ }
26
+ },
27
+ );