@ledgerhq/coin-vechain 2.11.0-nightly.8 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +20 -68
  3. package/lib/bridge/broadcast.test.d.ts +2 -0
  4. package/lib/bridge/broadcast.test.d.ts.map +1 -0
  5. package/lib/bridge/broadcast.test.js +188 -0
  6. package/lib/bridge/broadcast.test.js.map +1 -0
  7. package/lib/bridge/buildOptimisticOperatioin.test.d.ts +2 -0
  8. package/lib/bridge/buildOptimisticOperatioin.test.d.ts.map +1 -0
  9. package/lib/bridge/buildOptimisticOperatioin.test.js +286 -0
  10. package/lib/bridge/buildOptimisticOperatioin.test.js.map +1 -0
  11. package/lib/bridge/createTransaction.test.d.ts +2 -0
  12. package/lib/bridge/createTransaction.test.d.ts.map +1 -0
  13. package/lib/bridge/createTransaction.test.js +167 -0
  14. package/lib/bridge/createTransaction.test.js.map +1 -0
  15. package/lib/bridge/estimateMaxSpendable.test.d.ts +2 -0
  16. package/lib/bridge/estimateMaxSpendable.test.d.ts.map +1 -0
  17. package/lib/bridge/estimateMaxSpendable.test.js +269 -0
  18. package/lib/bridge/estimateMaxSpendable.test.js.map +1 -0
  19. package/lib/bridge/getTransactionStatus.test.d.ts +2 -0
  20. package/lib/bridge/getTransactionStatus.test.d.ts.map +1 -0
  21. package/lib/bridge/getTransactionStatus.test.js +282 -0
  22. package/lib/bridge/getTransactionStatus.test.js.map +1 -0
  23. package/lib/bridge/helpers.test.d.ts +2 -0
  24. package/lib/bridge/helpers.test.d.ts.map +1 -0
  25. package/lib/bridge/helpers.test.js +298 -0
  26. package/lib/bridge/helpers.test.js.map +1 -0
  27. package/lib/bridge/prepareTransaction.test.d.ts +2 -0
  28. package/lib/bridge/prepareTransaction.test.d.ts.map +1 -0
  29. package/lib/bridge/prepareTransaction.test.js +277 -0
  30. package/lib/bridge/prepareTransaction.test.js.map +1 -0
  31. package/lib/bridge/signOperation.test.d.ts +2 -0
  32. package/lib/bridge/signOperation.test.d.ts.map +1 -0
  33. package/lib/bridge/signOperation.test.js +295 -0
  34. package/lib/bridge/signOperation.test.js.map +1 -0
  35. package/lib/bridge/synchronisation.test.d.ts +2 -0
  36. package/lib/bridge/synchronisation.test.d.ts.map +1 -0
  37. package/lib/bridge/synchronisation.test.js +201 -0
  38. package/lib/bridge/synchronisation.test.js.map +1 -0
  39. package/lib/bridge/transaction.test.d.ts +2 -0
  40. package/lib/bridge/transaction.test.d.ts.map +1 -0
  41. package/lib/bridge/transaction.test.js +353 -0
  42. package/lib/bridge/transaction.test.js.map +1 -0
  43. package/lib/common-logic/calculateClauses.test.d.ts +2 -0
  44. package/lib/common-logic/calculateClauses.test.d.ts.map +1 -0
  45. package/lib/common-logic/calculateClauses.test.js +156 -0
  46. package/lib/common-logic/calculateClauses.test.js.map +1 -0
  47. package/lib/common-logic/calculateGasFees.test.d.ts +2 -0
  48. package/lib/common-logic/calculateGasFees.test.d.ts.map +1 -0
  49. package/lib/common-logic/calculateGasFees.test.js +279 -0
  50. package/lib/common-logic/calculateGasFees.test.js.map +1 -0
  51. package/lib/common-logic/calculateTransactionInfo.test.d.ts +2 -0
  52. package/lib/common-logic/calculateTransactionInfo.test.d.ts.map +1 -0
  53. package/lib/common-logic/calculateTransactionInfo.test.js +314 -0
  54. package/lib/common-logic/calculateTransactionInfo.test.js.map +1 -0
  55. package/lib/common-logic/estimateGas.test.d.ts +2 -0
  56. package/lib/common-logic/estimateGas.test.d.ts.map +1 -0
  57. package/lib/common-logic/estimateGas.test.js +129 -0
  58. package/lib/common-logic/estimateGas.test.js.map +1 -0
  59. package/lib/common-logic/fixPrefixCase.test.d.ts +2 -0
  60. package/lib/common-logic/fixPrefixCase.test.d.ts.map +1 -0
  61. package/lib/common-logic/fixPrefixCase.test.js +46 -0
  62. package/lib/common-logic/fixPrefixCase.test.js.map +1 -0
  63. package/lib/common-logic/generateNonce.test.d.ts +2 -0
  64. package/lib/common-logic/generateNonce.test.d.ts.map +1 -0
  65. package/lib/common-logic/generateNonce.test.js +59 -0
  66. package/lib/common-logic/generateNonce.test.js.map +1 -0
  67. package/lib/common-logic/getThorClient.test.d.ts +2 -0
  68. package/lib/common-logic/getThorClient.test.d.ts.map +1 -0
  69. package/lib/common-logic/getThorClient.test.js +53 -0
  70. package/lib/common-logic/getThorClient.test.js.map +1 -0
  71. package/lib/common-logic/mapTransfersToOperations.test.d.ts +2 -0
  72. package/lib/common-logic/mapTransfersToOperations.test.d.ts.map +1 -0
  73. package/lib/common-logic/mapTransfersToOperations.test.js +274 -0
  74. package/lib/common-logic/mapTransfersToOperations.test.js.map +1 -0
  75. package/lib/common-logic/padAddress.test.d.ts +2 -0
  76. package/lib/common-logic/padAddress.test.d.ts.map +1 -0
  77. package/lib/common-logic/padAddress.test.js +59 -0
  78. package/lib/common-logic/padAddress.test.js.map +1 -0
  79. package/lib/common-logic/parseAddress.test.d.ts +2 -0
  80. package/lib/common-logic/parseAddress.test.d.ts.map +1 -0
  81. package/lib/common-logic/parseAddress.test.js +97 -0
  82. package/lib/common-logic/parseAddress.test.js.map +1 -0
  83. package/lib/signer/getAddress.test.d.ts +2 -0
  84. package/lib/signer/getAddress.test.d.ts.map +1 -0
  85. package/lib/signer/getAddress.test.js +357 -0
  86. package/lib/signer/getAddress.test.js.map +1 -0
  87. package/lib/signer/signMessage.test.d.ts +2 -0
  88. package/lib/signer/signMessage.test.d.ts.map +1 -0
  89. package/lib/signer/signMessage.test.js +242 -0
  90. package/lib/signer/signMessage.test.js.map +1 -0
  91. package/lib-es/bridge/broadcast.test.d.ts +2 -0
  92. package/lib-es/bridge/broadcast.test.d.ts.map +1 -0
  93. package/lib-es/bridge/broadcast.test.js +183 -0
  94. package/lib-es/bridge/broadcast.test.js.map +1 -0
  95. package/lib-es/bridge/buildOptimisticOperatioin.test.d.ts +2 -0
  96. package/lib-es/bridge/buildOptimisticOperatioin.test.d.ts.map +1 -0
  97. package/lib-es/bridge/buildOptimisticOperatioin.test.js +281 -0
  98. package/lib-es/bridge/buildOptimisticOperatioin.test.js.map +1 -0
  99. package/lib-es/bridge/createTransaction.test.d.ts +2 -0
  100. package/lib-es/bridge/createTransaction.test.d.ts.map +1 -0
  101. package/lib-es/bridge/createTransaction.test.js +162 -0
  102. package/lib-es/bridge/createTransaction.test.js.map +1 -0
  103. package/lib-es/bridge/estimateMaxSpendable.test.d.ts +2 -0
  104. package/lib-es/bridge/estimateMaxSpendable.test.d.ts.map +1 -0
  105. package/lib-es/bridge/estimateMaxSpendable.test.js +264 -0
  106. package/lib-es/bridge/estimateMaxSpendable.test.js.map +1 -0
  107. package/lib-es/bridge/getTransactionStatus.test.d.ts +2 -0
  108. package/lib-es/bridge/getTransactionStatus.test.d.ts.map +1 -0
  109. package/lib-es/bridge/getTransactionStatus.test.js +277 -0
  110. package/lib-es/bridge/getTransactionStatus.test.js.map +1 -0
  111. package/lib-es/bridge/helpers.test.d.ts +2 -0
  112. package/lib-es/bridge/helpers.test.d.ts.map +1 -0
  113. package/lib-es/bridge/helpers.test.js +293 -0
  114. package/lib-es/bridge/helpers.test.js.map +1 -0
  115. package/lib-es/bridge/prepareTransaction.test.d.ts +2 -0
  116. package/lib-es/bridge/prepareTransaction.test.d.ts.map +1 -0
  117. package/lib-es/bridge/prepareTransaction.test.js +272 -0
  118. package/lib-es/bridge/prepareTransaction.test.js.map +1 -0
  119. package/lib-es/bridge/signOperation.test.d.ts +2 -0
  120. package/lib-es/bridge/signOperation.test.d.ts.map +1 -0
  121. package/lib-es/bridge/signOperation.test.js +290 -0
  122. package/lib-es/bridge/signOperation.test.js.map +1 -0
  123. package/lib-es/bridge/synchronisation.test.d.ts +2 -0
  124. package/lib-es/bridge/synchronisation.test.d.ts.map +1 -0
  125. package/lib-es/bridge/synchronisation.test.js +196 -0
  126. package/lib-es/bridge/synchronisation.test.js.map +1 -0
  127. package/lib-es/bridge/transaction.test.d.ts +2 -0
  128. package/lib-es/bridge/transaction.test.d.ts.map +1 -0
  129. package/lib-es/bridge/transaction.test.js +347 -0
  130. package/lib-es/bridge/transaction.test.js.map +1 -0
  131. package/lib-es/common-logic/calculateClauses.test.d.ts +2 -0
  132. package/lib-es/common-logic/calculateClauses.test.d.ts.map +1 -0
  133. package/lib-es/common-logic/calculateClauses.test.js +151 -0
  134. package/lib-es/common-logic/calculateClauses.test.js.map +1 -0
  135. package/lib-es/common-logic/calculateGasFees.test.d.ts +2 -0
  136. package/lib-es/common-logic/calculateGasFees.test.d.ts.map +1 -0
  137. package/lib-es/common-logic/calculateGasFees.test.js +274 -0
  138. package/lib-es/common-logic/calculateGasFees.test.js.map +1 -0
  139. package/lib-es/common-logic/calculateTransactionInfo.test.d.ts +2 -0
  140. package/lib-es/common-logic/calculateTransactionInfo.test.d.ts.map +1 -0
  141. package/lib-es/common-logic/calculateTransactionInfo.test.js +309 -0
  142. package/lib-es/common-logic/calculateTransactionInfo.test.js.map +1 -0
  143. package/lib-es/common-logic/estimateGas.test.d.ts +2 -0
  144. package/lib-es/common-logic/estimateGas.test.d.ts.map +1 -0
  145. package/lib-es/common-logic/estimateGas.test.js +127 -0
  146. package/lib-es/common-logic/estimateGas.test.js.map +1 -0
  147. package/lib-es/common-logic/fixPrefixCase.test.d.ts +2 -0
  148. package/lib-es/common-logic/fixPrefixCase.test.d.ts.map +1 -0
  149. package/lib-es/common-logic/fixPrefixCase.test.js +44 -0
  150. package/lib-es/common-logic/fixPrefixCase.test.js.map +1 -0
  151. package/lib-es/common-logic/generateNonce.test.d.ts +2 -0
  152. package/lib-es/common-logic/generateNonce.test.d.ts.map +1 -0
  153. package/lib-es/common-logic/generateNonce.test.js +57 -0
  154. package/lib-es/common-logic/generateNonce.test.js.map +1 -0
  155. package/lib-es/common-logic/getThorClient.test.d.ts +2 -0
  156. package/lib-es/common-logic/getThorClient.test.d.ts.map +1 -0
  157. package/lib-es/common-logic/getThorClient.test.js +51 -0
  158. package/lib-es/common-logic/getThorClient.test.js.map +1 -0
  159. package/lib-es/common-logic/mapTransfersToOperations.test.d.ts +2 -0
  160. package/lib-es/common-logic/mapTransfersToOperations.test.d.ts.map +1 -0
  161. package/lib-es/common-logic/mapTransfersToOperations.test.js +269 -0
  162. package/lib-es/common-logic/mapTransfersToOperations.test.js.map +1 -0
  163. package/lib-es/common-logic/padAddress.test.d.ts +2 -0
  164. package/lib-es/common-logic/padAddress.test.d.ts.map +1 -0
  165. package/lib-es/common-logic/padAddress.test.js +57 -0
  166. package/lib-es/common-logic/padAddress.test.js.map +1 -0
  167. package/lib-es/common-logic/parseAddress.test.d.ts +2 -0
  168. package/lib-es/common-logic/parseAddress.test.d.ts.map +1 -0
  169. package/lib-es/common-logic/parseAddress.test.js +95 -0
  170. package/lib-es/common-logic/parseAddress.test.js.map +1 -0
  171. package/lib-es/signer/getAddress.test.d.ts +2 -0
  172. package/lib-es/signer/getAddress.test.d.ts.map +1 -0
  173. package/lib-es/signer/getAddress.test.js +352 -0
  174. package/lib-es/signer/getAddress.test.js.map +1 -0
  175. package/lib-es/signer/signMessage.test.d.ts +2 -0
  176. package/lib-es/signer/signMessage.test.d.ts.map +1 -0
  177. package/lib-es/signer/signMessage.test.js +240 -0
  178. package/lib-es/signer/signMessage.test.js.map +1 -0
  179. package/package.json +9 -9
@@ -1,4 +1,4 @@
1
1
 
2
- > @ledgerhq/coin-vechain@2.11.0-nightly.7 build /home/runner/work/ledger-live/ledger-live/libs/coin-modules/coin-vechain
2
+ > @ledgerhq/coin-vechain@2.11.0 build /home/runner/work/ledger-live/ledger-live/libs/coin-modules/coin-vechain
3
3
  > tsc && tsc -m esnext --moduleResolution bundler --outDir lib-es
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,92 +1,44 @@
1
1
  # @ledgerhq/coin-evm
2
2
 
3
- ## 2.11.0-nightly.8
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies [[`c96d73f`](https://github.com/LedgerHQ/ledger-live/commit/c96d73fed0a75a9c208f78d51c34b742703a7dda)]:
8
- - @ledgerhq/coin-framework@6.7.0-nightly.8
9
-
10
- ## 2.11.0-nightly.7
11
-
12
- ### Patch Changes
13
-
14
- - Updated dependencies [[`b4ceaff`](https://github.com/LedgerHQ/ledger-live/commit/b4ceaff2ecf68d8a14e09801c76ab0b014c45286), [`cbc0648`](https://github.com/LedgerHQ/ledger-live/commit/cbc064885d8e0459e40d327a2e5389204b3ec705)]:
15
- - @ledgerhq/cryptoassets@13.31.0-nightly.7
16
- - @ledgerhq/live-env@2.19.0-nightly.2
17
- - @ledgerhq/coin-framework@6.7.0-nightly.7
18
- - @ledgerhq/live-network@2.0.20-nightly.3
19
-
20
- ## 2.11.0-nightly.6
21
-
22
- ### Patch Changes
23
-
24
- - Updated dependencies []:
25
- - @ledgerhq/coin-framework@6.7.0-nightly.6
26
- - @ledgerhq/cryptoassets@13.31.0-nightly.6
27
-
28
- ## 2.11.0-nightly.5
29
-
30
- ### Patch Changes
31
-
32
- - Updated dependencies [[`cadf2e1`](https://github.com/LedgerHQ/ledger-live/commit/cadf2e1dfb09248d3f77d96f94ae774425dbca75)]:
33
- - @ledgerhq/live-env@2.19.0-nightly.1
34
- - @ledgerhq/coin-framework@6.7.0-nightly.5
35
- - @ledgerhq/cryptoassets@13.31.0-nightly.5
36
- - @ledgerhq/live-network@2.0.20-nightly.2
37
-
38
- ## 2.11.0-nightly.4
39
-
40
- ### Patch Changes
41
-
42
- - Updated dependencies [[`759064d`](https://github.com/LedgerHQ/ledger-live/commit/759064d4815c636af2d73ba548a85b4f53e7b491)]:
43
- - @ledgerhq/errors@6.27.0-nightly.0
44
- - @ledgerhq/coin-framework@6.7.0-nightly.4
45
- - @ledgerhq/cryptoassets@13.31.0-nightly.4
46
- - @ledgerhq/devices@8.6.2-nightly.0
47
- - @ledgerhq/live-network@2.0.20-nightly.1
48
-
49
- ## 2.11.0-nightly.3
50
-
51
- ### Patch Changes
52
-
53
- - Updated dependencies []:
54
- - @ledgerhq/coin-framework@6.7.0-nightly.3
55
- - @ledgerhq/cryptoassets@13.31.0-nightly.3
56
-
57
- ## 2.11.0-nightly.2
3
+ ## 2.11.0
58
4
 
59
5
  ### Minor Changes
60
6
 
7
+ - [#12015](https://github.com/LedgerHQ/ledger-live/pull/12015) [`03af552`](https://github.com/LedgerHQ/ledger-live/commit/03af552b621e19e31747a65b1870dfe8d3bb005b) Thanks [@Justkant](https://github.com/Justkant)! - feat: new signRawTransaction to support any XRP transaction with wallet-api
8
+
61
9
  - [#12196](https://github.com/LedgerHQ/ledger-live/pull/12196) [`565da80`](https://github.com/LedgerHQ/ledger-live/commit/565da807b1ebbfc830fd0e47b3d8856f88d410a6) Thanks [@gre-ledger](https://github.com/gre-ledger)! - Remove deprecated getTokenById and hasTokenId functions
62
10
 
63
11
  ### Patch Changes
64
12
 
65
- - Updated dependencies [[`c6a676f`](https://github.com/LedgerHQ/ledger-live/commit/c6a676ff80581ac19b896adf44d54812983b72da), [`565da80`](https://github.com/LedgerHQ/ledger-live/commit/565da807b1ebbfc830fd0e47b3d8856f88d410a6)]:
66
- - @ledgerhq/coin-framework@6.7.0-nightly.2
67
- - @ledgerhq/cryptoassets@13.31.0-nightly.2
13
+ - Updated dependencies [[`ea16f59`](https://github.com/LedgerHQ/ledger-live/commit/ea16f592e85019a1b77287a7f2b975c6fcffc74c), [`cfe65ca`](https://github.com/LedgerHQ/ledger-live/commit/cfe65cafa268be4e53197ee163ce78f28ed72592), [`a9aacdb`](https://github.com/LedgerHQ/ledger-live/commit/a9aacdb330700f0a294833f7d77de17f179229b2), [`3979c07`](https://github.com/LedgerHQ/ledger-live/commit/3979c0715e4f54165c89d00ebe1441e064e1a110), [`f1f3845`](https://github.com/LedgerHQ/ledger-live/commit/f1f3845942e4cbce9c585dc65f6170ddbc319f19), [`c6a676f`](https://github.com/LedgerHQ/ledger-live/commit/c6a676ff80581ac19b896adf44d54812983b72da), [`b5fc1bd`](https://github.com/LedgerHQ/ledger-live/commit/b5fc1bd28fff091241905fec5ff8dc8af4c99b79), [`03af552`](https://github.com/LedgerHQ/ledger-live/commit/03af552b621e19e31747a65b1870dfe8d3bb005b), [`89ac0ed`](https://github.com/LedgerHQ/ledger-live/commit/89ac0eddc145dcf5c7cf240aa8be4301372c8f33), [`565da80`](https://github.com/LedgerHQ/ledger-live/commit/565da807b1ebbfc830fd0e47b3d8856f88d410a6), [`1d9860c`](https://github.com/LedgerHQ/ledger-live/commit/1d9860cd1688131d391579955b40c6710b667db8), [`d2b12e7`](https://github.com/LedgerHQ/ledger-live/commit/d2b12e70bba9e772d078d1fe4d9c537b8d316a87), [`c8dbf40`](https://github.com/LedgerHQ/ledger-live/commit/c8dbf402268359e225a94782420111e786f875fa), [`cab7d97`](https://github.com/LedgerHQ/ledger-live/commit/cab7d9794e7babb8220c6d339fb08e618e3d4202)]:
14
+ - @ledgerhq/cryptoassets@13.31.0
15
+ - @ledgerhq/coin-framework@6.7.0
16
+ - @ledgerhq/live-env@2.19.0
17
+ - @ledgerhq/live-network@2.0.20
68
18
 
69
- ## 2.11.0-nightly.1
19
+ ## 2.11.0-next.1
70
20
 
71
21
  ### Patch Changes
72
22
 
73
- - Updated dependencies [[`ea16f59`](https://github.com/LedgerHQ/ledger-live/commit/ea16f592e85019a1b77287a7f2b975c6fcffc74c), [`a9aacdb`](https://github.com/LedgerHQ/ledger-live/commit/a9aacdb330700f0a294833f7d77de17f179229b2), [`f1f3845`](https://github.com/LedgerHQ/ledger-live/commit/f1f3845942e4cbce9c585dc65f6170ddbc319f19), [`89ac0ed`](https://github.com/LedgerHQ/ledger-live/commit/89ac0eddc145dcf5c7cf240aa8be4301372c8f33)]:
74
- - @ledgerhq/cryptoassets@13.31.0-nightly.1
75
- - @ledgerhq/live-env@2.19.0-nightly.0
76
- - @ledgerhq/coin-framework@6.7.0-nightly.1
77
- - @ledgerhq/live-network@2.0.20-nightly.0
23
+ - Updated dependencies []:
24
+ - @ledgerhq/coin-framework@6.7.0-next.1
25
+ - @ledgerhq/cryptoassets@13.31.0-next.1
78
26
 
79
- ## 2.11.0-nightly.0
27
+ ## 2.11.0-next.0
80
28
 
81
29
  ### Minor Changes
82
30
 
83
31
  - [#12015](https://github.com/LedgerHQ/ledger-live/pull/12015) [`03af552`](https://github.com/LedgerHQ/ledger-live/commit/03af552b621e19e31747a65b1870dfe8d3bb005b) Thanks [@Justkant](https://github.com/Justkant)! - feat: new signRawTransaction to support any XRP transaction with wallet-api
84
32
 
33
+ - [#12196](https://github.com/LedgerHQ/ledger-live/pull/12196) [`565da80`](https://github.com/LedgerHQ/ledger-live/commit/565da807b1ebbfc830fd0e47b3d8856f88d410a6) Thanks [@gre-ledger](https://github.com/gre-ledger)! - Remove deprecated getTokenById and hasTokenId functions
34
+
85
35
  ### Patch Changes
86
36
 
87
- - Updated dependencies [[`cfe65ca`](https://github.com/LedgerHQ/ledger-live/commit/cfe65cafa268be4e53197ee163ce78f28ed72592), [`b5fc1bd`](https://github.com/LedgerHQ/ledger-live/commit/b5fc1bd28fff091241905fec5ff8dc8af4c99b79), [`03af552`](https://github.com/LedgerHQ/ledger-live/commit/03af552b621e19e31747a65b1870dfe8d3bb005b), [`d2b12e7`](https://github.com/LedgerHQ/ledger-live/commit/d2b12e70bba9e772d078d1fe4d9c537b8d316a87), [`cab7d97`](https://github.com/LedgerHQ/ledger-live/commit/cab7d9794e7babb8220c6d339fb08e618e3d4202)]:
88
- - @ledgerhq/cryptoassets@13.31.0-nightly.0
89
- - @ledgerhq/coin-framework@6.7.0-nightly.0
37
+ - Updated dependencies [[`ea16f59`](https://github.com/LedgerHQ/ledger-live/commit/ea16f592e85019a1b77287a7f2b975c6fcffc74c), [`cfe65ca`](https://github.com/LedgerHQ/ledger-live/commit/cfe65cafa268be4e53197ee163ce78f28ed72592), [`a9aacdb`](https://github.com/LedgerHQ/ledger-live/commit/a9aacdb330700f0a294833f7d77de17f179229b2), [`3979c07`](https://github.com/LedgerHQ/ledger-live/commit/3979c0715e4f54165c89d00ebe1441e064e1a110), [`f1f3845`](https://github.com/LedgerHQ/ledger-live/commit/f1f3845942e4cbce9c585dc65f6170ddbc319f19), [`c6a676f`](https://github.com/LedgerHQ/ledger-live/commit/c6a676ff80581ac19b896adf44d54812983b72da), [`b5fc1bd`](https://github.com/LedgerHQ/ledger-live/commit/b5fc1bd28fff091241905fec5ff8dc8af4c99b79), [`03af552`](https://github.com/LedgerHQ/ledger-live/commit/03af552b621e19e31747a65b1870dfe8d3bb005b), [`89ac0ed`](https://github.com/LedgerHQ/ledger-live/commit/89ac0eddc145dcf5c7cf240aa8be4301372c8f33), [`565da80`](https://github.com/LedgerHQ/ledger-live/commit/565da807b1ebbfc830fd0e47b3d8856f88d410a6), [`1d9860c`](https://github.com/LedgerHQ/ledger-live/commit/1d9860cd1688131d391579955b40c6710b667db8), [`d2b12e7`](https://github.com/LedgerHQ/ledger-live/commit/d2b12e70bba9e772d078d1fe4d9c537b8d316a87), [`c8dbf40`](https://github.com/LedgerHQ/ledger-live/commit/c8dbf402268359e225a94782420111e786f875fa), [`cab7d97`](https://github.com/LedgerHQ/ledger-live/commit/cab7d9794e7babb8220c6d339fb08e618e3d4202)]:
38
+ - @ledgerhq/cryptoassets@13.31.0-next.0
39
+ - @ledgerhq/coin-framework@6.7.0-next.0
40
+ - @ledgerhq/live-env@2.19.0-next.0
41
+ - @ledgerhq/live-network@2.0.20-next.0
90
42
 
91
43
  ## 2.10.1
92
44
 
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=broadcast.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broadcast.test.d.ts","sourceRoot":"","sources":["../../src/bridge/broadcast.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
7
+ const broadcast_1 = require("./broadcast");
8
+ const operation_1 = require("@ledgerhq/coin-framework/operation");
9
+ const network_1 = require("../network");
10
+ const types_1 = require("../types");
11
+ // Mock dependencies
12
+ jest.mock("@ledgerhq/coin-framework/operation");
13
+ jest.mock("../network");
14
+ jest.mock("../types", () => ({
15
+ ...jest.requireActual("../types"),
16
+ VechainSDKTransaction: {
17
+ of: jest.fn(),
18
+ },
19
+ }));
20
+ const mockedPatchOperationWithHash = jest.mocked(operation_1.patchOperationWithHash);
21
+ const mockedSubmit = jest.mocked(network_1.submit);
22
+ const mockedVechainSDKTransaction = jest.mocked(types_1.VechainSDKTransaction);
23
+ describe("broadcast", () => {
24
+ const mockAccount = {
25
+ type: "Account",
26
+ id: "vechain:1:0x123:",
27
+ seedIdentifier: "seed123",
28
+ derivationMode: "",
29
+ index: 0,
30
+ freshAddress: "0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4",
31
+ freshAddressPath: "44'/818'/0'/0/0",
32
+ used: true,
33
+ balance: new bignumber_js_1.default("5000000000000000000"),
34
+ spendableBalance: new bignumber_js_1.default("5000000000000000000"),
35
+ creationDate: new Date("2022-01-01"),
36
+ blockHeight: 12345,
37
+ currency: {},
38
+ operationsCount: 10,
39
+ operations: [],
40
+ pendingOperations: [],
41
+ lastSyncDate: new Date("2022-01-01"),
42
+ balanceHistoryCache: { HOUR: {}, DAY: {}, WEEK: {} },
43
+ swapHistory: [],
44
+ subAccounts: [],
45
+ };
46
+ const mockOperation = {
47
+ id: "vechain:1:0x123:0xtxhash:OUT",
48
+ hash: "",
49
+ type: "OUT",
50
+ value: new bignumber_js_1.default("1000000000000000000"),
51
+ fee: new bignumber_js_1.default("21000000000000000"),
52
+ blockHash: null,
53
+ blockHeight: null,
54
+ senders: ["0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4"],
55
+ recipients: ["0x456789012345678901234567890123456789abcd"],
56
+ accountId: "vechain:1:0x123:",
57
+ date: new Date("2022-01-01"),
58
+ extra: {},
59
+ };
60
+ const mockTransactionBody = {
61
+ chainTag: 74,
62
+ blockRef: "0x00000000000b2bce",
63
+ expiration: 18,
64
+ clauses: [
65
+ {
66
+ to: "0x456789012345678901234567890123456789abcd",
67
+ value: "1000000000000000000",
68
+ data: "0x",
69
+ },
70
+ ],
71
+ maxFeePerGas: 10000000000000,
72
+ maxPriorityFeePerGas: 1000000000000,
73
+ gas: 21000,
74
+ dependsOn: null,
75
+ nonce: "0x12345678",
76
+ };
77
+ const mockSignedOperation = {
78
+ operation: mockOperation,
79
+ signature: "1234567890abcdef",
80
+ rawData: {
81
+ family: "vechain",
82
+ body: mockTransactionBody,
83
+ },
84
+ };
85
+ const mockTransaction = {
86
+ body: mockTransactionBody,
87
+ };
88
+ beforeEach(() => {
89
+ jest.clearAllMocks();
90
+ });
91
+ it("should broadcast a signed transaction successfully", async () => {
92
+ const mockTxHash = "0xabcdef1234567890";
93
+ const mockPatchedOperation = { ...mockOperation, hash: mockTxHash };
94
+ mockedVechainSDKTransaction.of.mockReturnValue(mockTransaction);
95
+ mockedSubmit.mockResolvedValue(mockTxHash);
96
+ mockedPatchOperationWithHash.mockReturnValue(mockPatchedOperation);
97
+ const result = await (0, broadcast_1.broadcast)({ account: mockAccount, signedOperation: mockSignedOperation });
98
+ expect(mockedVechainSDKTransaction.of).toHaveBeenCalledWith(mockTransactionBody, Buffer.from("1234567890abcdef", "hex"));
99
+ expect(mockedSubmit).toHaveBeenCalledWith(mockTransaction);
100
+ expect(mockedPatchOperationWithHash).toHaveBeenCalledWith(mockOperation, mockTxHash);
101
+ expect(result).toEqual(mockPatchedOperation);
102
+ });
103
+ it("should handle transaction creation from raw data", async () => {
104
+ const mockTxHash = "0x123456789abcdef0";
105
+ const mockPatchedOperation = { ...mockOperation, hash: mockTxHash };
106
+ mockedVechainSDKTransaction.of.mockReturnValue(mockTransaction);
107
+ mockedSubmit.mockResolvedValue(mockTxHash);
108
+ mockedPatchOperationWithHash.mockReturnValue(mockPatchedOperation);
109
+ await (0, broadcast_1.broadcast)({ account: mockAccount, signedOperation: mockSignedOperation });
110
+ expect(mockedVechainSDKTransaction.of).toHaveBeenCalledWith(mockTransactionBody, expect.any(Buffer));
111
+ });
112
+ it("should convert hex signature to Buffer correctly", async () => {
113
+ const hexSignature = "abcdef1234567890";
114
+ const signedOpWithHexSig = {
115
+ ...mockSignedOperation,
116
+ signature: hexSignature,
117
+ };
118
+ mockedVechainSDKTransaction.of.mockReturnValue(mockTransaction);
119
+ mockedSubmit.mockResolvedValue("0xhash");
120
+ mockedPatchOperationWithHash.mockReturnValue(mockOperation);
121
+ await (0, broadcast_1.broadcast)({ account: mockAccount, signedOperation: signedOpWithHexSig });
122
+ expect(mockedVechainSDKTransaction.of).toHaveBeenCalledWith(mockTransactionBody, Buffer.from(hexSignature, "hex"));
123
+ });
124
+ it("should propagate errors from submit", async () => {
125
+ const errorMessage = "Network error during submission";
126
+ mockedVechainSDKTransaction.of.mockReturnValue(mockTransaction);
127
+ mockedSubmit.mockRejectedValue(new Error(errorMessage));
128
+ await expect((0, broadcast_1.broadcast)({ account: mockAccount, signedOperation: mockSignedOperation })).rejects.toThrow(errorMessage);
129
+ });
130
+ it("should propagate errors from VechainSDKTransaction.of", async () => {
131
+ const errorMessage = "Invalid transaction body";
132
+ mockedVechainSDKTransaction.of.mockImplementation(() => {
133
+ throw new Error(errorMessage);
134
+ });
135
+ await expect((0, broadcast_1.broadcast)({ account: mockAccount, signedOperation: mockSignedOperation })).rejects.toThrow(errorMessage);
136
+ });
137
+ it("should handle different signature formats", async () => {
138
+ const signatures = ["12ab", "1234567890abcdef", "ff".repeat(32)];
139
+ for (const signature of signatures) {
140
+ const signedOp = { ...mockSignedOperation, signature };
141
+ mockedVechainSDKTransaction.of.mockReturnValue(mockTransaction);
142
+ mockedSubmit.mockResolvedValue("0xhash");
143
+ mockedPatchOperationWithHash.mockReturnValue(mockOperation);
144
+ await (0, broadcast_1.broadcast)({ account: mockAccount, signedOperation: signedOp });
145
+ expect(mockedVechainSDKTransaction.of).toHaveBeenCalledWith(mockTransactionBody, Buffer.from(signature, "hex"));
146
+ }
147
+ });
148
+ it("should handle complex transaction bodies", async () => {
149
+ const complexBody = {
150
+ ...mockTransactionBody,
151
+ clauses: [
152
+ {
153
+ to: "0x456789012345678901234567890123456789abcd",
154
+ value: "1000000000000000000",
155
+ data: "0xa9059cbb000000000000000000000000742d35cc6634c0532925a3b8d0b251d8c1743ec40000000000000000000000000000000000000000000000000de0b6b3a7640000",
156
+ },
157
+ {
158
+ to: "0x0000000000000000000000000000456e65726779",
159
+ value: "0",
160
+ data: "0x",
161
+ },
162
+ ],
163
+ dependsOn: "0xprevious123",
164
+ };
165
+ const complexSignedOp = {
166
+ ...mockSignedOperation,
167
+ rawData: { ...mockSignedOperation.rawData, body: complexBody },
168
+ };
169
+ mockedVechainSDKTransaction.of.mockReturnValue({ body: complexBody });
170
+ mockedSubmit.mockResolvedValue("0xhash");
171
+ mockedPatchOperationWithHash.mockReturnValue(mockOperation);
172
+ await (0, broadcast_1.broadcast)({ account: mockAccount, signedOperation: complexSignedOp });
173
+ expect(mockedVechainSDKTransaction.of).toHaveBeenCalledWith(complexBody, expect.any(Buffer));
174
+ });
175
+ it("should return the exact result from patchOperationWithHash", async () => {
176
+ const specificPatchedOp = {
177
+ ...mockOperation,
178
+ hash: "0xspecifichash",
179
+ blockHeight: 12345,
180
+ };
181
+ mockedVechainSDKTransaction.of.mockReturnValue(mockTransaction);
182
+ mockedSubmit.mockResolvedValue("0xspecifichash");
183
+ mockedPatchOperationWithHash.mockReturnValue(specificPatchedOp);
184
+ const result = await (0, broadcast_1.broadcast)({ account: mockAccount, signedOperation: mockSignedOperation });
185
+ expect(result).toBe(specificPatchedOp);
186
+ });
187
+ });
188
+ //# sourceMappingURL=broadcast.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broadcast.test.js","sourceRoot":"","sources":["../../src/bridge/broadcast.test.ts"],"names":[],"mappings":";;;;;AAAA,gEAAqC;AACrC,2CAAwC;AACxC,kEAA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M,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=buildOptimisticOperatioin.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildOptimisticOperatioin.test.d.ts","sourceRoot":"","sources":["../../src/bridge/buildOptimisticOperatioin.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,286 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
7
+ const buildOptimisticOperatioin_1 = require("./buildOptimisticOperatioin");
8
+ const operation_1 = require("@ledgerhq/coin-framework/operation");
9
+ // Mock dependencies
10
+ jest.mock("@ledgerhq/coin-framework/operation");
11
+ const mockedEncodeOperationId = jest.mocked(operation_1.encodeOperationId);
12
+ describe("buildOptimisticOperation", () => {
13
+ const mockAccount = {
14
+ type: "Account",
15
+ id: "vechain:1:0x123:",
16
+ seedIdentifier: "seed123",
17
+ derivationMode: "",
18
+ index: 0,
19
+ freshAddress: "0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4",
20
+ freshAddressPath: "44'/818'/0'/0/0",
21
+ used: true,
22
+ balance: new bignumber_js_1.default("5000000000000000000"),
23
+ spendableBalance: new bignumber_js_1.default("5000000000000000000"),
24
+ creationDate: new Date("2022-01-01"),
25
+ blockHeight: 12345,
26
+ currency: {},
27
+ operationsCount: 10,
28
+ operations: [],
29
+ pendingOperations: [],
30
+ lastSyncDate: new Date("2022-01-01"),
31
+ balanceHistoryCache: { HOUR: {}, DAY: {}, WEEK: {} },
32
+ swapHistory: [],
33
+ subAccounts: [],
34
+ };
35
+ const mockVetTransaction = {
36
+ family: "vechain",
37
+ recipient: "0x456789012345678901234567890123456789abcd",
38
+ amount: new bignumber_js_1.default("1000000000000000000"),
39
+ estimatedFees: "210000000000000000",
40
+ body: {
41
+ chainTag: 74,
42
+ blockRef: "0x00000000000b2bce",
43
+ expiration: 18,
44
+ clauses: [],
45
+ maxFeePerGas: 10000000000000,
46
+ maxPriorityFeePerGas: 1000000000000,
47
+ gas: 21000,
48
+ dependsOn: null,
49
+ nonce: "0x12345678",
50
+ },
51
+ };
52
+ const mockTokenTransaction = {
53
+ ...mockVetTransaction,
54
+ subAccountId: "vechain:1:0x123:+vtho",
55
+ };
56
+ beforeEach(() => {
57
+ jest.clearAllMocks();
58
+ mockedEncodeOperationId.mockImplementation((accountId, hash, type) => `${accountId}${hash}${type}`);
59
+ });
60
+ describe("VET transactions", () => {
61
+ it("should build optimistic operation for VET transaction", async () => {
62
+ const result = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, mockVetTransaction);
63
+ expect(result).toEqual({
64
+ id: "vechain:1:0x123:OUT",
65
+ hash: "",
66
+ type: "OUT",
67
+ value: new bignumber_js_1.default("1000000000000000000"),
68
+ fee: new bignumber_js_1.default("210000000000000000"),
69
+ blockHash: null,
70
+ blockHeight: null,
71
+ senders: ["0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4"],
72
+ recipients: ["0x456789012345678901234567890123456789abcd"],
73
+ accountId: "vechain:1:0x123:",
74
+ date: expect.any(Date),
75
+ extra: {},
76
+ subOperations: [],
77
+ });
78
+ expect(mockedEncodeOperationId).toHaveBeenCalledWith("vechain:1:0x123:", "", "OUT");
79
+ });
80
+ it("should set correct value and fee for VET transaction", async () => {
81
+ const result = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, mockVetTransaction);
82
+ expect(result.value).toEqual(new bignumber_js_1.default("1000000000000000000"));
83
+ expect(result.fee).toEqual(new bignumber_js_1.default("210000000000000000"));
84
+ });
85
+ it("should have empty subOperations for VET transaction", async () => {
86
+ const result = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, mockVetTransaction);
87
+ expect(result.subOperations).toEqual([]);
88
+ });
89
+ });
90
+ describe("Token transactions", () => {
91
+ it("should build optimistic operation for token transaction", async () => {
92
+ const result = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, mockTokenTransaction);
93
+ expect(result).toEqual({
94
+ id: "vechain:1:0x123:OUT",
95
+ hash: "",
96
+ type: "NONE",
97
+ value: new bignumber_js_1.default("0"),
98
+ fee: new bignumber_js_1.default("0"),
99
+ blockHash: null,
100
+ blockHeight: null,
101
+ senders: ["0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4"],
102
+ recipients: ["0x456789012345678901234567890123456789abcd"],
103
+ accountId: "vechain:1:0x123:",
104
+ date: expect.any(Date),
105
+ extra: {},
106
+ subOperations: [
107
+ {
108
+ id: "vechain:1:0x123:+vthoOUT",
109
+ hash: "",
110
+ type: "OUT",
111
+ value: new bignumber_js_1.default("1000000000000000000"),
112
+ fee: new bignumber_js_1.default("210000000000000000"),
113
+ blockHash: null,
114
+ blockHeight: null,
115
+ senders: ["0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4"],
116
+ recipients: ["0x456789012345678901234567890123456789abcd"],
117
+ accountId: "vechain:1:0x123:+vtho",
118
+ date: expect.any(Date),
119
+ extra: {},
120
+ },
121
+ ],
122
+ });
123
+ expect(mockedEncodeOperationId).toHaveBeenCalledWith("vechain:1:0x123:", "", "OUT");
124
+ expect(mockedEncodeOperationId).toHaveBeenCalledWith("vechain:1:0x123:+vtho", "", "OUT");
125
+ });
126
+ it("should set type to NONE for token transaction main operation", async () => {
127
+ const result = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, mockTokenTransaction);
128
+ expect(result.type).toBe("NONE");
129
+ });
130
+ it("should have zero value and fee for token transaction main operation", async () => {
131
+ const result = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, mockTokenTransaction);
132
+ expect(result.value).toEqual(new bignumber_js_1.default("0"));
133
+ expect(result.fee).toEqual(new bignumber_js_1.default("0"));
134
+ });
135
+ it("should create correct subOperation for token transaction", async () => {
136
+ const result = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, mockTokenTransaction);
137
+ expect(result.subOperations).toHaveLength(1);
138
+ const subOp = result.subOperations[0];
139
+ expect(subOp.type).toBe("OUT");
140
+ expect(subOp.value).toEqual(new bignumber_js_1.default("1000000000000000000"));
141
+ expect(subOp.fee).toEqual(new bignumber_js_1.default("210000000000000000"));
142
+ expect(subOp.accountId).toBe("vechain:1:0x123:+vtho");
143
+ });
144
+ });
145
+ describe("Common operation properties", () => {
146
+ it("should set empty hash for both transaction types", async () => {
147
+ const vetResult = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, mockVetTransaction);
148
+ const tokenResult = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, mockTokenTransaction);
149
+ expect(vetResult.hash).toBe("");
150
+ expect(tokenResult.hash).toBe("");
151
+ if (tokenResult.subOperations && tokenResult.subOperations[0]) {
152
+ expect(tokenResult.subOperations[0].hash).toBe("");
153
+ }
154
+ });
155
+ it("should set null blockHash and blockHeight", async () => {
156
+ const result = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, mockVetTransaction);
157
+ expect(result.blockHash).toBe(null);
158
+ expect(result.blockHeight).toBe(null);
159
+ });
160
+ it("should set senders from account freshAddress", async () => {
161
+ const result = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, mockVetTransaction);
162
+ expect(result.senders).toEqual(["0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4"]);
163
+ });
164
+ it("should set recipients from transaction recipient", async () => {
165
+ const result = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, mockVetTransaction);
166
+ expect(result.recipients).toEqual(["0x456789012345678901234567890123456789abcd"]);
167
+ });
168
+ it("should filter out empty recipients", async () => {
169
+ const transactionWithoutRecipient = {
170
+ ...mockVetTransaction,
171
+ recipient: "",
172
+ };
173
+ const result = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, transactionWithoutRecipient);
174
+ expect(result.recipients).toEqual([]);
175
+ });
176
+ it("should set accountId from account", async () => {
177
+ const result = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, mockVetTransaction);
178
+ expect(result.accountId).toBe("vechain:1:0x123:");
179
+ });
180
+ it("should set current date", async () => {
181
+ const before = new Date();
182
+ const result = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, mockVetTransaction);
183
+ const after = new Date();
184
+ expect(result.date.getTime()).toBeGreaterThanOrEqual(before.getTime());
185
+ expect(result.date.getTime()).toBeLessThanOrEqual(after.getTime());
186
+ });
187
+ it("should set empty extra object", async () => {
188
+ const result = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, mockVetTransaction);
189
+ expect(result.extra).toEqual({});
190
+ });
191
+ });
192
+ describe("encodeOperationId calls", () => {
193
+ it("should call encodeOperationId with correct parameters for VET transaction", async () => {
194
+ await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, mockVetTransaction);
195
+ expect(mockedEncodeOperationId).toHaveBeenCalledTimes(1);
196
+ expect(mockedEncodeOperationId).toHaveBeenCalledWith("vechain:1:0x123:", "", "OUT");
197
+ });
198
+ it("should call encodeOperationId twice for token transaction", async () => {
199
+ await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, mockTokenTransaction);
200
+ expect(mockedEncodeOperationId).toHaveBeenCalledTimes(2);
201
+ expect(mockedEncodeOperationId).toHaveBeenNthCalledWith(1, "vechain:1:0x123:", "", "OUT");
202
+ expect(mockedEncodeOperationId).toHaveBeenNthCalledWith(2, "vechain:1:0x123:+vtho", "", "OUT");
203
+ });
204
+ });
205
+ describe("different transaction amounts and fees", () => {
206
+ it("should handle different transaction amounts", async () => {
207
+ const customAmountTransaction = {
208
+ ...mockVetTransaction,
209
+ amount: new bignumber_js_1.default("2500000000000000000"), // 2.5 VET
210
+ };
211
+ const result = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, customAmountTransaction);
212
+ expect(result.value).toEqual(new bignumber_js_1.default("2500000000000000000"));
213
+ });
214
+ it("should handle different estimated fees", async () => {
215
+ const customFeeTransaction = {
216
+ ...mockVetTransaction,
217
+ estimatedFees: "420000000000000000", // 0.42 VET
218
+ };
219
+ const result = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, customFeeTransaction);
220
+ expect(result.fee).toEqual(new bignumber_js_1.default("420000000000000000"));
221
+ });
222
+ it("should handle zero amounts", async () => {
223
+ const zeroAmountTransaction = {
224
+ ...mockVetTransaction,
225
+ amount: new bignumber_js_1.default("0"),
226
+ };
227
+ const result = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, zeroAmountTransaction);
228
+ expect(result.value).toEqual(new bignumber_js_1.default("0"));
229
+ });
230
+ it("should handle very large amounts", async () => {
231
+ const largeAmountTransaction = {
232
+ ...mockVetTransaction,
233
+ amount: new bignumber_js_1.default("1000000000000000000000000"), // 1M VET
234
+ };
235
+ const result = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, largeAmountTransaction);
236
+ expect(result.value).toEqual(new bignumber_js_1.default("1000000000000000000000000"));
237
+ });
238
+ });
239
+ describe("different account and subAccount IDs", () => {
240
+ it("should handle different account IDs", async () => {
241
+ const customAccount = {
242
+ ...mockAccount,
243
+ id: "vechain:2:0xabc:",
244
+ };
245
+ const result = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(customAccount, mockVetTransaction);
246
+ expect(result.accountId).toBe("vechain:2:0xabc:");
247
+ expect(mockedEncodeOperationId).toHaveBeenCalledWith("vechain:2:0xabc:", "", "OUT");
248
+ });
249
+ it("should handle different subAccount IDs", async () => {
250
+ const customSubAccountTransaction = {
251
+ ...mockTokenTransaction,
252
+ subAccountId: "vechain:1:0x123:+customtoken",
253
+ };
254
+ const result = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, customSubAccountTransaction);
255
+ expect(result.subOperations[0].accountId).toBe("vechain:1:0x123:+customtoken");
256
+ expect(mockedEncodeOperationId).toHaveBeenCalledWith("vechain:1:0x123:+customtoken", "", "OUT");
257
+ });
258
+ });
259
+ describe("edge cases", () => {
260
+ it("should handle transaction with null recipient", async () => {
261
+ const nullRecipientTransaction = {
262
+ ...mockVetTransaction,
263
+ recipient: null,
264
+ };
265
+ const result = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, nullRecipientTransaction);
266
+ expect(result.recipients).toEqual([]);
267
+ });
268
+ it("should handle transaction with undefined recipient", async () => {
269
+ const undefinedRecipientTransaction = {
270
+ ...mockVetTransaction,
271
+ recipient: undefined,
272
+ };
273
+ const result = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(mockAccount, undefinedRecipientTransaction);
274
+ expect(result.recipients).toEqual([]);
275
+ });
276
+ it("should handle different fresh addresses", async () => {
277
+ const customAccount = {
278
+ ...mockAccount,
279
+ freshAddress: "0x999888777666555444333222111000aaabbbcccd",
280
+ };
281
+ const result = await (0, buildOptimisticOperatioin_1.buildOptimisticOperation)(customAccount, mockVetTransaction);
282
+ expect(result.senders).toEqual(["0x999888777666555444333222111000aaabbbcccd"]);
283
+ });
284
+ });
285
+ });
286
+ //# sourceMappingURL=buildOptimisticOperatioin.test.js.map