@ledgerhq/coin-vechain 3.0.0 → 4.0.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 (249) hide show
  1. package/.unimportedrc.json +2 -1
  2. package/CHANGELOG.md +42 -2699
  3. package/lib/api/index.d.ts +2 -2
  4. package/lib/api/index.d.ts.map +1 -1
  5. package/lib/api/index.js +25 -22
  6. package/lib/api/index.js.map +1 -1
  7. package/lib/bridge/broadcast.d.ts.map +1 -1
  8. package/lib/bridge/broadcast.js +2 -1
  9. package/lib/bridge/broadcast.js.map +1 -1
  10. package/lib/bridge/createTransaction.js +1 -1
  11. package/lib/bridge/createTransaction.js.map +1 -1
  12. package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -1
  13. package/lib/bridge/estimateMaxSpendable.js +2 -1
  14. package/lib/bridge/estimateMaxSpendable.js.map +1 -1
  15. package/lib/bridge/getTransactionStatus.d.ts.map +1 -1
  16. package/lib/bridge/getTransactionStatus.js +2 -1
  17. package/lib/bridge/getTransactionStatus.js.map +1 -1
  18. package/lib/bridge/prepareTransaction.d.ts.map +1 -1
  19. package/lib/bridge/prepareTransaction.js +4 -2
  20. package/lib/bridge/prepareTransaction.js.map +1 -1
  21. package/lib/bridge/synchronisation.d.ts.map +1 -1
  22. package/lib/bridge/synchronisation.js +6 -4
  23. package/lib/bridge/synchronisation.js.map +1 -1
  24. package/lib/common-logic/calculateGasFees.d.ts +2 -1
  25. package/lib/common-logic/calculateGasFees.d.ts.map +1 -1
  26. package/lib/common-logic/calculateGasFees.js +3 -3
  27. package/lib/common-logic/calculateGasFees.js.map +1 -1
  28. package/lib/common-logic/calculateTransactionInfo.d.ts +2 -1
  29. package/lib/common-logic/calculateTransactionInfo.d.ts.map +1 -1
  30. package/lib/common-logic/calculateTransactionInfo.js +2 -2
  31. package/lib/common-logic/calculateTransactionInfo.js.map +1 -1
  32. package/lib/common-logic/estimateGas.d.ts +2 -1
  33. package/lib/common-logic/estimateGas.d.ts.map +1 -1
  34. package/lib/common-logic/estimateGas.js +2 -2
  35. package/lib/common-logic/estimateGas.js.map +1 -1
  36. package/lib/common-logic/getThorClient.d.ts +2 -1
  37. package/lib/common-logic/getThorClient.d.ts.map +1 -1
  38. package/lib/common-logic/getThorClient.js +2 -2
  39. package/lib/common-logic/getThorClient.js.map +1 -1
  40. package/lib/common-logic/mapTransfersToOperations.d.ts +3 -2
  41. package/lib/common-logic/mapTransfersToOperations.d.ts.map +1 -1
  42. package/lib/common-logic/mapTransfersToOperations.js +4 -4
  43. package/lib/common-logic/mapTransfersToOperations.js.map +1 -1
  44. package/lib/config.d.ts +10 -4
  45. package/lib/config.d.ts.map +1 -1
  46. package/lib/config.js +9 -5
  47. package/lib/config.js.map +1 -1
  48. package/lib/logic/account/getBalance.d.ts +2 -1
  49. package/lib/logic/account/getBalance.d.ts.map +1 -1
  50. package/lib/logic/account/getBalance.js +3 -2
  51. package/lib/logic/account/getBalance.js.map +1 -1
  52. package/lib/logic/history/getBlock.d.ts +2 -1
  53. package/lib/logic/history/getBlock.d.ts.map +1 -1
  54. package/lib/logic/history/getBlock.js +3 -2
  55. package/lib/logic/history/getBlock.js.map +1 -1
  56. package/lib/logic/history/getBlockInfo.d.ts +2 -1
  57. package/lib/logic/history/getBlockInfo.d.ts.map +1 -1
  58. package/lib/logic/history/getBlockInfo.js +3 -2
  59. package/lib/logic/history/getBlockInfo.js.map +1 -1
  60. package/lib/logic/history/lastBlock.d.ts +2 -1
  61. package/lib/logic/history/lastBlock.d.ts.map +1 -1
  62. package/lib/logic/history/lastBlock.js +4 -3
  63. package/lib/logic/history/lastBlock.js.map +1 -1
  64. package/lib/logic/history/listOperations.d.ts +2 -1
  65. package/lib/logic/history/listOperations.d.ts.map +1 -1
  66. package/lib/logic/history/listOperations.js +5 -4
  67. package/lib/logic/history/listOperations.js.map +1 -1
  68. package/lib/logic/transaction/broadcast.d.ts +2 -1
  69. package/lib/logic/transaction/broadcast.d.ts.map +1 -1
  70. package/lib/logic/transaction/broadcast.js +3 -2
  71. package/lib/logic/transaction/broadcast.js.map +1 -1
  72. package/lib/logic/transaction/combine.d.ts +1 -1
  73. package/lib/logic/transaction/combine.d.ts.map +1 -1
  74. package/lib/logic/transaction/combine.js +4 -1
  75. package/lib/logic/transaction/combine.js.map +1 -1
  76. package/lib/logic/transaction/craftTransaction.d.ts +2 -1
  77. package/lib/logic/transaction/craftTransaction.d.ts.map +1 -1
  78. package/lib/logic/transaction/craftTransaction.js +11 -10
  79. package/lib/logic/transaction/craftTransaction.js.map +1 -1
  80. package/lib/logic/transaction/estimateFees.d.ts +2 -1
  81. package/lib/logic/transaction/estimateFees.d.ts.map +1 -1
  82. package/lib/logic/transaction/estimateFees.js +2 -2
  83. package/lib/logic/transaction/estimateFees.js.map +1 -1
  84. package/lib/network/getBlock.d.ts +2 -1
  85. package/lib/network/getBlock.d.ts.map +1 -1
  86. package/lib/network/getBlock.js +2 -2
  87. package/lib/network/getBlock.js.map +1 -1
  88. package/lib/network/getFees.d.ts +2 -1
  89. package/lib/network/getFees.d.ts.map +1 -1
  90. package/lib/network/getFees.js +2 -2
  91. package/lib/network/getFees.js.map +1 -1
  92. package/lib/network/sdk.d.ts +7 -6
  93. package/lib/network/sdk.d.ts.map +1 -1
  94. package/lib/network/sdk.js +18 -18
  95. package/lib/network/sdk.js.map +1 -1
  96. package/lib/test/context.d.ts +6 -0
  97. package/lib/test/context.d.ts.map +1 -0
  98. package/lib/test/context.js +15 -0
  99. package/lib/test/context.js.map +1 -0
  100. package/lib-es/api/index.d.ts +2 -2
  101. package/lib-es/api/index.d.ts.map +1 -1
  102. package/lib-es/api/index.js +25 -22
  103. package/lib-es/api/index.js.map +1 -1
  104. package/lib-es/bridge/broadcast.d.ts.map +1 -1
  105. package/lib-es/bridge/broadcast.js +2 -1
  106. package/lib-es/bridge/broadcast.js.map +1 -1
  107. package/lib-es/bridge/createTransaction.js +2 -2
  108. package/lib-es/bridge/createTransaction.js.map +1 -1
  109. package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -1
  110. package/lib-es/bridge/estimateMaxSpendable.js +2 -1
  111. package/lib-es/bridge/estimateMaxSpendable.js.map +1 -1
  112. package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -1
  113. package/lib-es/bridge/getTransactionStatus.js +2 -1
  114. package/lib-es/bridge/getTransactionStatus.js.map +1 -1
  115. package/lib-es/bridge/prepareTransaction.d.ts.map +1 -1
  116. package/lib-es/bridge/prepareTransaction.js +4 -2
  117. package/lib-es/bridge/prepareTransaction.js.map +1 -1
  118. package/lib-es/bridge/synchronisation.d.ts.map +1 -1
  119. package/lib-es/bridge/synchronisation.js +6 -4
  120. package/lib-es/bridge/synchronisation.js.map +1 -1
  121. package/lib-es/common-logic/calculateGasFees.d.ts +2 -1
  122. package/lib-es/common-logic/calculateGasFees.d.ts.map +1 -1
  123. package/lib-es/common-logic/calculateGasFees.js +3 -3
  124. package/lib-es/common-logic/calculateGasFees.js.map +1 -1
  125. package/lib-es/common-logic/calculateTransactionInfo.d.ts +2 -1
  126. package/lib-es/common-logic/calculateTransactionInfo.d.ts.map +1 -1
  127. package/lib-es/common-logic/calculateTransactionInfo.js +2 -2
  128. package/lib-es/common-logic/calculateTransactionInfo.js.map +1 -1
  129. package/lib-es/common-logic/estimateGas.d.ts +2 -1
  130. package/lib-es/common-logic/estimateGas.d.ts.map +1 -1
  131. package/lib-es/common-logic/estimateGas.js +2 -2
  132. package/lib-es/common-logic/estimateGas.js.map +1 -1
  133. package/lib-es/common-logic/getThorClient.d.ts +2 -1
  134. package/lib-es/common-logic/getThorClient.d.ts.map +1 -1
  135. package/lib-es/common-logic/getThorClient.js +2 -2
  136. package/lib-es/common-logic/getThorClient.js.map +1 -1
  137. package/lib-es/common-logic/mapTransfersToOperations.d.ts +3 -2
  138. package/lib-es/common-logic/mapTransfersToOperations.d.ts.map +1 -1
  139. package/lib-es/common-logic/mapTransfersToOperations.js +4 -4
  140. package/lib-es/common-logic/mapTransfersToOperations.js.map +1 -1
  141. package/lib-es/config.d.ts +10 -4
  142. package/lib-es/config.d.ts.map +1 -1
  143. package/lib-es/config.js +9 -5
  144. package/lib-es/config.js.map +1 -1
  145. package/lib-es/logic/account/getBalance.d.ts +2 -1
  146. package/lib-es/logic/account/getBalance.d.ts.map +1 -1
  147. package/lib-es/logic/account/getBalance.js +3 -2
  148. package/lib-es/logic/account/getBalance.js.map +1 -1
  149. package/lib-es/logic/history/getBlock.d.ts +2 -1
  150. package/lib-es/logic/history/getBlock.d.ts.map +1 -1
  151. package/lib-es/logic/history/getBlock.js +3 -2
  152. package/lib-es/logic/history/getBlock.js.map +1 -1
  153. package/lib-es/logic/history/getBlockInfo.d.ts +2 -1
  154. package/lib-es/logic/history/getBlockInfo.d.ts.map +1 -1
  155. package/lib-es/logic/history/getBlockInfo.js +3 -2
  156. package/lib-es/logic/history/getBlockInfo.js.map +1 -1
  157. package/lib-es/logic/history/lastBlock.d.ts +2 -1
  158. package/lib-es/logic/history/lastBlock.d.ts.map +1 -1
  159. package/lib-es/logic/history/lastBlock.js +4 -3
  160. package/lib-es/logic/history/lastBlock.js.map +1 -1
  161. package/lib-es/logic/history/listOperations.d.ts +2 -1
  162. package/lib-es/logic/history/listOperations.d.ts.map +1 -1
  163. package/lib-es/logic/history/listOperations.js +5 -4
  164. package/lib-es/logic/history/listOperations.js.map +1 -1
  165. package/lib-es/logic/transaction/broadcast.d.ts +2 -1
  166. package/lib-es/logic/transaction/broadcast.d.ts.map +1 -1
  167. package/lib-es/logic/transaction/broadcast.js +3 -2
  168. package/lib-es/logic/transaction/broadcast.js.map +1 -1
  169. package/lib-es/logic/transaction/combine.d.ts +1 -1
  170. package/lib-es/logic/transaction/combine.d.ts.map +1 -1
  171. package/lib-es/logic/transaction/combine.js +4 -1
  172. package/lib-es/logic/transaction/combine.js.map +1 -1
  173. package/lib-es/logic/transaction/craftTransaction.d.ts +2 -1
  174. package/lib-es/logic/transaction/craftTransaction.d.ts.map +1 -1
  175. package/lib-es/logic/transaction/craftTransaction.js +11 -10
  176. package/lib-es/logic/transaction/craftTransaction.js.map +1 -1
  177. package/lib-es/logic/transaction/estimateFees.d.ts +2 -1
  178. package/lib-es/logic/transaction/estimateFees.d.ts.map +1 -1
  179. package/lib-es/logic/transaction/estimateFees.js +2 -2
  180. package/lib-es/logic/transaction/estimateFees.js.map +1 -1
  181. package/lib-es/network/getBlock.d.ts +2 -1
  182. package/lib-es/network/getBlock.d.ts.map +1 -1
  183. package/lib-es/network/getBlock.js +2 -2
  184. package/lib-es/network/getBlock.js.map +1 -1
  185. package/lib-es/network/getFees.d.ts +2 -1
  186. package/lib-es/network/getFees.d.ts.map +1 -1
  187. package/lib-es/network/getFees.js +2 -2
  188. package/lib-es/network/getFees.js.map +1 -1
  189. package/lib-es/network/sdk.d.ts +7 -6
  190. package/lib-es/network/sdk.d.ts.map +1 -1
  191. package/lib-es/network/sdk.js +18 -18
  192. package/lib-es/network/sdk.js.map +1 -1
  193. package/lib-es/test/context.d.ts +6 -0
  194. package/lib-es/test/context.d.ts.map +1 -0
  195. package/lib-es/test/context.js +11 -0
  196. package/lib-es/test/context.js.map +1 -0
  197. package/package.json +6 -6
  198. package/src/api/index.integ.test.ts +21 -24
  199. package/src/api/index.ts +74 -27
  200. package/src/api/index.unit.test.ts +68 -48
  201. package/src/bridge/broadcast.integ.test.ts +2 -1
  202. package/src/bridge/broadcast.test.ts +1 -1
  203. package/src/bridge/broadcast.ts +2 -1
  204. package/src/bridge/createTransaction.ts +2 -2
  205. package/src/bridge/estimateMaxSpendable.test.ts +19 -3
  206. package/src/bridge/estimateMaxSpendable.ts +2 -0
  207. package/src/bridge/getTransactionStatus.test.ts +11 -6
  208. package/src/bridge/getTransactionStatus.ts +2 -0
  209. package/src/bridge/prepareTransaction.test.ts +5 -1
  210. package/src/bridge/prepareTransaction.ts +4 -2
  211. package/src/bridge/synchronisation.ts +7 -3
  212. package/src/common-logic/calculateGasFees.test.ts +101 -27
  213. package/src/common-logic/calculateGasFees.ts +4 -2
  214. package/src/common-logic/calculateTransactionInfo.test.ts +71 -16
  215. package/src/common-logic/calculateTransactionInfo.ts +3 -1
  216. package/src/common-logic/estimateGas.test.ts +13 -10
  217. package/src/common-logic/estimateGas.ts +3 -1
  218. package/src/common-logic/getThorClient.test.ts +7 -7
  219. package/src/common-logic/getThorClient.ts +3 -3
  220. package/src/common-logic/mapTransfersToOperations.test.ts +48 -13
  221. package/src/common-logic/mapTransfersToOperations.ts +5 -2
  222. package/src/config.test.ts +3 -3
  223. package/src/config.ts +13 -6
  224. package/src/logic/account/getBalance.ts +4 -2
  225. package/src/logic/account/getBalance.unit.test.ts +6 -4
  226. package/src/logic/history/getBlock.ts +4 -2
  227. package/src/logic/history/getBlock.unit.test.ts +8 -5
  228. package/src/logic/history/getBlockInfo.ts +4 -2
  229. package/src/logic/history/getBlockInfo.unit.test.ts +6 -3
  230. package/src/logic/history/lastBlock.ts +5 -3
  231. package/src/logic/history/lastBlock.unit.test.ts +6 -3
  232. package/src/logic/history/listOperations.ts +6 -3
  233. package/src/logic/history/listOperations.unit.test.ts +10 -6
  234. package/src/logic/transaction/broadcast.msw.test.ts +7 -2
  235. package/src/logic/transaction/broadcast.ts +8 -2
  236. package/src/logic/transaction/broadcast.unit.test.ts +6 -3
  237. package/src/logic/transaction/combine.ts +6 -2
  238. package/src/logic/transaction/combine.unit.test.ts +3 -3
  239. package/src/logic/transaction/craftTransaction.ts +16 -9
  240. package/src/logic/transaction/craftTransaction.unit.test.ts +29 -28
  241. package/src/logic/transaction/estimateFees.ts +3 -0
  242. package/src/logic/transaction/estimateFees.unit.test.ts +15 -12
  243. package/src/network/getBlock.ts +3 -2
  244. package/src/network/getBlock.unit.test.ts +11 -6
  245. package/src/network/getFees.ts +6 -3
  246. package/src/network/sdk.integ.test.ts +8 -1
  247. package/src/network/sdk.test.ts +18 -7
  248. package/src/network/sdk.ts +25 -15
  249. package/src/test/context.ts +15 -0
@@ -1,3 +1,4 @@
1
+ import { type VechainCurrencyConfig } from "../config";
1
2
  import type { ApiResponseBlock } from "../types";
2
- export declare const getBlock: (revision: number, expanded?: boolean) => Promise<ApiResponseBlock | null>;
3
+ export declare const getBlock: (config: VechainCurrencyConfig, revision: number, expanded?: boolean) => Promise<ApiResponseBlock | null>;
3
4
  //# sourceMappingURL=getBlock.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getBlock.d.ts","sourceRoot":"","sources":["../../src/network/getBlock.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAIjD,eAAO,MAAM,QAAQ,aACT,MAAM,yBAEf,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAajC,CAAC"}
1
+ {"version":3,"file":"getBlock.d.ts","sourceRoot":"","sources":["../../src/network/getBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,qBAAqB,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAIjD,eAAO,MAAM,QAAQ,WACX,qBAAqB,YACnB,MAAM,yBAEf,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAajC,CAAC"}
@@ -2,14 +2,14 @@ import network from "@ledgerhq/live-network";
2
2
  import { getNodeUrl } from "../config";
3
3
  // Thor GET /blocks/{revision}. `expanded` returns full clause/output detail (getBlock) vs. tx
4
4
  // hashes only (getBlockInfo/lastBlock).
5
- export const getBlock = async (revision, expanded = false) => {
5
+ export const getBlock = async (config, revision, expanded = false) => {
6
6
  if (!Number.isInteger(revision) || revision < 0) {
7
7
  throw new Error(`vechain: getBlock: invalid revision ${revision}`);
8
8
  }
9
9
  const query = new URLSearchParams({ expanded: String(expanded) });
10
10
  const { data } = await network({
11
11
  method: "GET",
12
- url: `${getNodeUrl()}/blocks/${revision}?${query}`,
12
+ url: `${getNodeUrl(config)}/blocks/${revision}?${query}`,
13
13
  });
14
14
  return data;
15
15
  };
@@ -1 +1 @@
1
- {"version":3,"file":"getBlock.js","sourceRoot":"","sources":["../../src/network/getBlock.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGvC,8FAA8F;AAC9F,wCAAwC;AACxC,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAC3B,QAAgB,EAChB,QAAQ,GAAG,KAAK,EACkB,EAAE;IACpC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,uCAAuC,QAAQ,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,eAAe,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAElE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,CAA0B;QACtD,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,GAAG,UAAU,EAAE,WAAW,QAAQ,IAAI,KAAK,EAAE;KACnD,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
1
+ {"version":3,"file":"getBlock.js","sourceRoot":"","sources":["../../src/network/getBlock.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAA8B,MAAM,WAAW,CAAC;AAGnE,8FAA8F;AAC9F,wCAAwC;AACxC,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAC3B,MAA6B,EAC7B,QAAgB,EAChB,QAAQ,GAAG,KAAK,EACkB,EAAE;IACpC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,uCAAuC,QAAQ,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,eAAe,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAElE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,CAA0B;QACtD,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,WAAW,QAAQ,IAAI,KAAK,EAAE;KACzD,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
@@ -1,8 +1,9 @@
1
1
  import BigNumber from "bignumber.js";
2
+ import { type VechainCurrencyConfig } from "../config";
2
3
  /**
3
4
  * Get fees paid for the transaction
4
5
  * @param transactionId - the id of the transaction
5
6
  * @return the fee paid in VTHO or 0
6
7
  */
7
- export declare const getFees: (transactionId: string) => Promise<BigNumber>;
8
+ export declare const getFees: (config: VechainCurrencyConfig, transactionId: string) => Promise<BigNumber>;
8
9
  //# sourceMappingURL=getFees.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getFees.d.ts","sourceRoot":"","sources":["../../src/network/getFees.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAIrC;;;;GAIG;AACH,eAAO,MAAM,OAAO,kBAAyB,MAAM,KAAG,OAAO,CAAC,SAAS,CAStE,CAAC"}
1
+ {"version":3,"file":"getFees.d.ts","sourceRoot":"","sources":["../../src/network/getFees.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAAO,EAAc,KAAK,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEnE;;;;GAIG;AACH,eAAO,MAAM,OAAO,WACV,qBAAqB,iBACd,MAAM,KACpB,OAAO,CAAC,SAAS,CASnB,CAAC"}
@@ -6,10 +6,10 @@ import { getNodeUrl } from "../config";
6
6
  * @param transactionId - the id of the transaction
7
7
  * @return the fee paid in VTHO or 0
8
8
  */
9
- export const getFees = async (transactionId) => {
9
+ export const getFees = async (config, transactionId) => {
10
10
  const { data } = await network({
11
11
  method: "GET",
12
- url: `${getNodeUrl()}/transactions/${transactionId}/receipt`,
12
+ url: `${getNodeUrl(config)}/transactions/${transactionId}/receipt`,
13
13
  params: { id: transactionId },
14
14
  });
15
15
  if (!data || !data.paid)
@@ -1 +1 @@
1
- {"version":3,"file":"getFees.js","sourceRoot":"","sources":["../../src/network/getFees.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAAE,aAAqB,EAAsB,EAAE;IACzE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,CAAmB;QAC/C,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,GAAG,UAAU,EAAE,iBAAiB,aAAa,UAAU;QAC5D,MAAM,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE;KAC9B,CAAC,CAAC;IAEH,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;IACjD,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC,CAAC"}
1
+ {"version":3,"file":"getFees.js","sourceRoot":"","sources":["../../src/network/getFees.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAA8B,MAAM,WAAW,CAAC;AAEnE;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAC1B,MAA6B,EAC7B,aAAqB,EACD,EAAE;IACtB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,CAAmB;QAC/C,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,iBAAiB,aAAa,UAAU;QAClE,MAAM,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE;KAC9B,CAAC,CAAC;IAEH,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;IACjD,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC,CAAC"}
@@ -1,7 +1,8 @@
1
1
  import type { AccountResponse, VechainSDKTransaction } from "../types";
2
2
  import type { Operation } from "@ledgerhq/types-live";
3
- export declare const getAccount: (address: string) => Promise<AccountResponse>;
4
- export declare const getLastBlockHeight: () => Promise<number>;
3
+ import { type VechainCurrencyConfig } from "../config";
4
+ export declare const getAccount: (config: VechainCurrencyConfig, address: string) => Promise<AccountResponse>;
5
+ export declare const getLastBlockHeight: (config: VechainCurrencyConfig) => Promise<number>;
5
6
  /**
6
7
  * Get VET operations
7
8
  *
@@ -12,7 +13,7 @@ export declare const getLastBlockHeight: () => Promise<number>;
12
13
  * @param fetchRangeOfLogs
13
14
  * @returns an array of operations
14
15
  */
15
- export declare const getOperations: (accountId: string, addr: string, startAt: number, stopAt: number) => Promise<Operation[]>;
16
+ export declare const getOperations: (config: VechainCurrencyConfig, accountId: string, addr: string, startAt: number, stopAt: number) => Promise<Operation[]>;
16
17
  /**
17
18
  * Get operations for a fungible token
18
19
  *
@@ -23,16 +24,16 @@ export declare const getOperations: (accountId: string, addr: string, startAt: n
23
24
  * @param stopAt
24
25
  * @returns an array of operations
25
26
  */
26
- export declare const getTokenOperations: (accountId: string, addr: string, tokenAddr: string, startAt: number, stopAt: number) => Promise<Operation[]>;
27
+ export declare const getTokenOperations: (config: VechainCurrencyConfig, accountId: string, addr: string, tokenAddr: string, startAt: number, stopAt: number) => Promise<Operation[]>;
27
28
  /**
28
29
  * Submit a transaction and return the ID
29
30
  * @param transaction - The transaction to submit
30
31
  * @returns transaction ID
31
32
  */
32
- export declare const submit: (transaction: VechainSDKTransaction) => Promise<string>;
33
+ export declare const submit: (config: VechainCurrencyConfig, transaction: VechainSDKTransaction) => Promise<string>;
33
34
  /**
34
35
  * Get the block ref to use in a transaction
35
36
  * @returns the block ref of head
36
37
  */
37
- export declare const getBlockRef: () => Promise<string>;
38
+ export declare const getBlockRef: (config: VechainCurrencyConfig) => Promise<string>;
38
39
  //# sourceMappingURL=sdk.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/network/sdk.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EAKf,qBAAqB,EACtB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAatD,eAAO,MAAM,UAAU,YAAmB,MAAM,KAAG,OAAO,CAAC,eAAe,CAOzE,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAa,OAAO,CAAC,MAAM,CAOzD,CAAC;AAsKF;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,cACb,MAAM,QACX,MAAM,WACH,MAAM,UACP,MAAM,KACb,OAAO,CAAC,SAAS,EAAE,CAIrB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,cAClB,MAAM,QACX,MAAM,aACD,MAAM,WACR,MAAM,UACP,MAAM,KACb,OAAO,CAAC,SAAS,EAAE,CAIrB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,MAAM,gBAAuB,qBAAqB,KAAG,OAAO,CAAC,MAAM,CAe/E,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,QAAa,OAAO,CAAC,MAAM,CAOlD,CAAC"}
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/network/sdk.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EAKf,qBAAqB,EACtB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAMtD,OAAO,EAAc,KAAK,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAOnE,eAAO,MAAM,UAAU,WACb,qBAAqB,WACpB,MAAM,KACd,OAAO,CAAC,eAAe,CAOzB,CAAC;AAEF,eAAO,MAAM,kBAAkB,WAAkB,qBAAqB,KAAG,OAAO,CAAC,MAAM,CAOtF,CAAC;AAwKF;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,WAChB,qBAAqB,aAClB,MAAM,QACX,MAAM,WACH,MAAM,UACP,MAAM,KACb,OAAO,CAAC,SAAS,EAAE,CAIrB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,WACrB,qBAAqB,aAClB,MAAM,QACX,MAAM,aACD,MAAM,WACR,MAAM,UACP,MAAM,KACb,OAAO,CAAC,SAAS,EAAE,CAIrB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,MAAM,WACT,qBAAqB,eAChB,qBAAqB,KACjC,OAAO,CAAC,MAAM,CAehB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,WAAkB,qBAAqB,KAAG,OAAO,CAAC,MAAM,CAO/E,CAAC"}
@@ -5,17 +5,17 @@ const NET_ERROR_LOG_TRANSFERS_LIMIT = {
5
5
  status: 403,
6
6
  msgPattern: /exceeds the maximum allowed/,
7
7
  };
8
- export const getAccount = async (address) => {
8
+ export const getAccount = async (config, address) => {
9
9
  const { data } = await network({
10
10
  method: "GET",
11
- url: `${getNodeUrl()}/accounts/${address}`,
11
+ url: `${getNodeUrl(config)}/accounts/${address}`,
12
12
  });
13
13
  return data;
14
14
  };
15
- export const getLastBlockHeight = async () => {
15
+ export const getLastBlockHeight = async (config) => {
16
16
  const { data } = await network({
17
17
  method: "GET",
18
- url: `${getNodeUrl()}/blocks/best`,
18
+ url: `${getNodeUrl(config)}/blocks/best`,
19
19
  });
20
20
  return data.number;
21
21
  };
@@ -27,7 +27,7 @@ export const getLastBlockHeight = async () => {
27
27
  * @param stopAt
28
28
  * @returns an array of operations
29
29
  */
30
- const fetchRangeOfOperations = async (accountId, addr, startAt, stopAt) => {
30
+ const fetchRangeOfOperations = async (config, accountId, addr, startAt, stopAt) => {
31
31
  const query = {
32
32
  range: {
33
33
  unit: "block",
@@ -39,10 +39,10 @@ const fetchRangeOfOperations = async (accountId, addr, startAt, stopAt) => {
39
39
  };
40
40
  const { data } = await network({
41
41
  method: "POST",
42
- url: `${getNodeUrl()}/logs/transfer`,
42
+ url: `${getNodeUrl(config)}/logs/transfer`,
43
43
  data: JSON.stringify(query),
44
44
  });
45
- return mapVetTransfersToOperations(data, accountId, addr);
45
+ return mapVetTransfersToOperations(config, data, accountId, addr);
46
46
  };
47
47
  /**
48
48
  * Get VTHO token events (transfer events log)
@@ -52,7 +52,7 @@ const fetchRangeOfOperations = async (accountId, addr, startAt, stopAt) => {
52
52
  * @param stopAt
53
53
  * @returns an array of operations
54
54
  */
55
- const fetchRangeOfTokenOperations = async (accountId, addr, tokenAddr, startAt, stopAt) => {
55
+ const fetchRangeOfTokenOperations = async (config, accountId, addr, tokenAddr, startAt, stopAt) => {
56
56
  const paddedAddress = padAddress(addr);
57
57
  const TransferEventSignature = "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef";
58
58
  const query = {
@@ -77,10 +77,10 @@ const fetchRangeOfTokenOperations = async (accountId, addr, tokenAddr, startAt,
77
77
  };
78
78
  const { data } = await network({
79
79
  method: "POST",
80
- url: `${getNodeUrl()}/logs/event`,
80
+ url: `${getNodeUrl(config)}/logs/event`,
81
81
  data: JSON.stringify(query),
82
82
  });
83
- return mapTokenTransfersToOperations(data, accountId, addr);
83
+ return mapTokenTransfersToOperations(config, data, accountId, addr);
84
84
  };
85
85
  /**
86
86
  * Utility for retrieving logs (transfer logs or transfer event logs) with pagination.
@@ -157,8 +157,8 @@ const getLogsWithPagination = async (startAt, stopAt, fetchRangeOfLogs) => {
157
157
  * @param fetchRangeOfLogs
158
158
  * @returns an array of operations
159
159
  */
160
- export const getOperations = async (accountId, addr, startAt, stopAt) => {
161
- const fetchRange = async (from, to) => fetchRangeOfOperations(accountId, addr, from, to);
160
+ export const getOperations = async (config, accountId, addr, startAt, stopAt) => {
161
+ const fetchRange = async (from, to) => fetchRangeOfOperations(config, accountId, addr, from, to);
162
162
  return getLogsWithPagination(startAt, stopAt, fetchRange);
163
163
  };
164
164
  /**
@@ -171,8 +171,8 @@ export const getOperations = async (accountId, addr, startAt, stopAt) => {
171
171
  * @param stopAt
172
172
  * @returns an array of operations
173
173
  */
174
- export const getTokenOperations = async (accountId, addr, tokenAddr, startAt, stopAt) => {
175
- const fetchRange = async (from, to) => fetchRangeOfTokenOperations(accountId, addr, tokenAddr, from, to);
174
+ export const getTokenOperations = async (config, accountId, addr, tokenAddr, startAt, stopAt) => {
175
+ const fetchRange = async (from, to) => fetchRangeOfTokenOperations(config, accountId, addr, tokenAddr, from, to);
176
176
  return getLogsWithPagination(startAt, stopAt, fetchRange);
177
177
  };
178
178
  /**
@@ -180,13 +180,13 @@ export const getTokenOperations = async (accountId, addr, tokenAddr, startAt, st
180
180
  * @param transaction - The transaction to submit
181
181
  * @returns transaction ID
182
182
  */
183
- export const submit = async (transaction) => {
183
+ export const submit = async (config, transaction) => {
184
184
  const encodedRawTx = {
185
185
  raw: `0x${Buffer.from(transaction.encoded).toString("hex")}`,
186
186
  };
187
187
  const { data } = await network({
188
188
  method: "POST",
189
- url: `${getNodeUrl()}/transactions`,
189
+ url: `${getNodeUrl(config)}/transactions`,
190
190
  data: encodedRawTx,
191
191
  });
192
192
  // Expect a transaction ID
@@ -198,10 +198,10 @@ export const submit = async (transaction) => {
198
198
  * Get the block ref to use in a transaction
199
199
  * @returns the block ref of head
200
200
  */
201
- export const getBlockRef = async () => {
201
+ export const getBlockRef = async (config) => {
202
202
  const { data } = await network({
203
203
  method: "GET",
204
- url: `${getNodeUrl()}/blocks/best`,
204
+ url: `${getNodeUrl(config)}/blocks/best`,
205
205
  });
206
206
  return data.id.slice(0, 18);
207
207
  };
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/network/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAU7C,OAAO,EACL,2BAA2B,EAC3B,6BAA6B,EAC7B,UAAU,GACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,6BAA6B,GAAG;IACpC,MAAM,EAAE,GAAG;IACX,UAAU,EAAE,6BAA6B;CAC1C,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,OAAe,EAA4B,EAAE;IAC5E,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,CAAkB;QAC9C,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,GAAG,UAAU,EAAE,aAAa,OAAO,EAAE;KAC3C,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,IAAqB,EAAE;IAC5D,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,CAAqB;QACjD,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,GAAG,UAAU,EAAE,cAAc;KACnC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC,MAAM,CAAC;AACrB,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,sBAAsB,GAAG,KAAK,EAClC,SAAiB,EACjB,IAAY,EACZ,OAAe,EACf,MAAc,EACQ,EAAE;IACxB,MAAM,KAAK,GAAgB;QACzB,KAAK,EAAE;YACL,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,OAAO;YACb,EAAE,EAAE,MAAM;SACX;QACD,WAAW,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,SA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,EAAE,IAAY,EAAE,EAAU,EAAE,EAAE,CACpD,2BAA2B,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IAC5E,OAAO,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;AAC5D,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,EACzB,MAA6B,EAC7B,WAAkC,EACjB,EAAE;IACnB,MAAM,YAAY,GAAG;QACnB,GAAG,EAAE,KAAK,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;KAC7D,CAAC;IAEF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,CAAiB;QAC7C,MAAM,EAAE,MAAM;QACd,GAAG,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,eAAe;QACzC,IAAI,EAAE,YAAY;KACnB,CAAC,CAAC;IAEH,0BAA0B;IAC1B,IAAI,CAAC,IAAI,CAAC,EAAE;QAAE,MAAM,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAE3D,OAAO,IAAI,CAAC,EAAE,CAAC;AACjB,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAAE,MAA6B,EAAmB,EAAE;IAClF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,CAAiB;QAC7C,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,cAAc;KACzC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC9B,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { VechainContext, VechainCurrencyConfig } from "../config";
2
+ /** The resolved config every mocked endpoint points at. */
3
+ export declare const mockVechainConfig: VechainCurrencyConfig;
4
+ /** A {@link VechainContext} backed by the mocked config, for api tests. */
5
+ export declare const createMockVechainContext: (config?: VechainCurrencyConfig) => VechainContext;
6
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/test/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEvE,2DAA2D;AAC3D,eAAO,MAAM,iBAAiB,EAAE,qBAG/B,CAAC;AAEF,2EAA2E;AAC3E,eAAO,MAAM,wBAAwB,YAC3B,qBAAqB,KAC5B,cAGD,CAAC"}
@@ -0,0 +1,11 @@
1
+ /** The resolved config every mocked endpoint points at. */
2
+ export const mockVechainConfig = {
3
+ status: { type: "active" },
4
+ node: { url: "https://vechain.coin.ledger.com" },
5
+ };
6
+ /** A {@link VechainContext} backed by the mocked config, for api tests. */
7
+ export const createMockVechainContext = (config = mockVechainConfig) => ({
8
+ config: async () => config,
9
+ logger: () => { },
10
+ });
11
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/test/context.ts"],"names":[],"mappings":"AAEA,2DAA2D;AAC3D,MAAM,CAAC,MAAM,iBAAiB,GAA0B;IACtD,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC1B,IAAI,EAAE,EAAE,GAAG,EAAE,iCAAiC,EAAE;CACjD,CAAC;AAEF,2EAA2E;AAC3E,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,MAAM,GAA0B,iBAAiB,EACjC,EAAE,CAAC,CAAC;IACpB,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM;IAC1B,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC;CACjB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/coin-vechain",
3
- "version": "3.0.0",
3
+ "version": "4.0.0",
4
4
  "description": "Ledger VeChain Coin integration",
5
5
  "keywords": [
6
6
  "Ledger",
@@ -87,7 +87,7 @@
87
87
  },
88
88
  "license": "Apache-2.0",
89
89
  "dependencies": {
90
- "@ledgerhq/coin-module-framework": "5.0.0",
90
+ "@ledgerhq/coin-module-framework": "8.0.0",
91
91
  "@vechain/sdk-core": "2.0.0",
92
92
  "@vechain/sdk-network": "2.0.0",
93
93
  "bignumber.js": "^9.1.2",
@@ -96,8 +96,8 @@
96
96
  "lodash": "4.17.21",
97
97
  "rxjs": "7.8.2",
98
98
  "@ledgerhq/devices": "8.17.0",
99
- "@ledgerhq/live-network": "^3.0.0",
100
- "@ledgerhq/ledger-wallet-framework": "^2.8.0"
99
+ "@ledgerhq/ledger-wallet-framework": "^3.0.0",
100
+ "@ledgerhq/live-network": "^3.0.0"
101
101
  },
102
102
  "devDependencies": {
103
103
  "@swc/core": "1.15.11",
@@ -111,9 +111,9 @@
111
111
  "msw": "^2.7.3",
112
112
  "oxfmt": "0.36.0",
113
113
  "oxlint": "1.51.0",
114
- "@ledgerhq/types-live": "^6.119.0",
115
114
  "@ledgerhq/disable-network-setup": "^0.3.0",
116
- "@ledgerhq/wallet-framework-test-setup": "^0.1.5"
115
+ "@ledgerhq/types-live": "^6.120.0",
116
+ "@ledgerhq/wallet-framework-test-setup": "^0.1.6"
117
117
  },
118
118
  "scripts": {
119
119
  "clean": "rimraf lib lib-es",
@@ -1,11 +1,7 @@
1
1
  import type { CoinModuleApi } from "@ledgerhq/coin-module-framework/api/types";
2
- import type { VechainCoinConfig } from "../config";
2
+ import type { VechainCurrencyConfig } from "../config";
3
3
  import { createApi } from "./index";
4
-
5
- const config: VechainCoinConfig = () => ({
6
- status: { type: "active" },
7
- node: { url: "https://vechain.coin.ledger.com" },
8
- });
4
+ import { createMockVechainContext } from "../test/context";
9
5
 
10
6
  // Repo-committed VeChain mainnet address, already used by src/datasets/vechain.ts for bridge
11
7
  // integration/dataset testing ("account information is fetched from the blockchain"). Reused
@@ -15,40 +11,41 @@ const config: VechainCoinConfig = () => ({
15
11
  const KNOWN_ADDRESS = "0x0fe6688548f0C303932bB197B0A96034f1d74dba";
16
12
 
17
13
  describe("createApi (integration)", () => {
18
- let api: CoinModuleApi;
14
+ let api: CoinModuleApi<VechainCurrencyConfig>;
15
+ const context = createMockVechainContext();
19
16
 
20
17
  beforeAll(() => {
21
- api = createApi(config, "vechain");
18
+ api = createApi();
22
19
  });
23
20
 
24
21
  // These methods throw synchronously (they never return a promise), so they are asserted with a
25
22
  // synchronous `expect(() => …).toThrow`, not `.rejects` (mirrors coin-kaspa's api integ test).
26
23
  it("getNextSequence throws (not applicable to Vechain's account model)", () => {
27
- expect(() => api.getNextSequence(KNOWN_ADDRESS)).toThrow(
24
+ expect(() => api.getNextSequence(context, KNOWN_ADDRESS)).toThrow(
28
25
  "getNextSequence is not applicable for Vechain",
29
26
  );
30
27
  });
31
28
 
32
29
  it("validates addresses via parseAddress", async () => {
33
- await expect(api.validateAddress(KNOWN_ADDRESS, {})).resolves.toBe(true);
34
- await expect(api.validateAddress("0xnot-an-address", {})).resolves.toBe(false);
30
+ await expect(api.validateAddress(context, KNOWN_ADDRESS, {})).resolves.toBe(true);
31
+ await expect(api.validateAddress(context, "0xnot-an-address", {})).resolves.toBe(false);
35
32
  });
36
33
 
37
34
  it("getStakes / getRewards / getValidators throw (not supported)", () => {
38
- expect(() => api.getStakes(KNOWN_ADDRESS)).toThrow("getStakes is not supported");
39
- expect(() => api.getRewards(KNOWN_ADDRESS)).toThrow("getRewards is not supported");
40
- expect(() => api.getValidators()).toThrow("getValidators is not supported");
35
+ expect(() => api.getStakes(context, KNOWN_ADDRESS)).toThrow("getStakes is not supported");
36
+ expect(() => api.getRewards(context, KNOWN_ADDRESS)).toThrow("getRewards is not supported");
37
+ expect(() => api.getValidators(context)).toThrow("getValidators is not supported");
41
38
  });
42
39
 
43
40
  it("craftRawTransaction throws (not supported)", () => {
44
- expect(() => api.craftRawTransaction("raw", KNOWN_ADDRESS, "pubkey", 0n)).toThrow(
41
+ expect(() => api.craftRawTransaction(context, "raw", KNOWN_ADDRESS, "pubkey", 0n)).toThrow(
45
42
  "craftRawTransaction is not supported",
46
43
  );
47
44
  });
48
45
 
49
46
  describe("account & block methods (real network)", () => {
50
47
  it("getBalance returns both VET and VTHO balances", async () => {
51
- const balances = await api.getBalance(KNOWN_ADDRESS);
48
+ const balances = await api.getBalance(context, KNOWN_ADDRESS);
52
49
 
53
50
  expect(balances).toHaveLength(2);
54
51
  expect(balances.some(b => b.asset.type === "native")).toBe(true);
@@ -60,7 +57,7 @@ describe("createApi (integration)", () => {
60
57
  });
61
58
 
62
59
  it("lastBlock returns the latest confirmed block", async () => {
63
- const info = await api.lastBlock();
60
+ const info = await api.lastBlock(context);
64
61
 
65
62
  expect(info.height).toBeGreaterThan(0);
66
63
  expect(typeof info.hash).toBe("string");
@@ -68,11 +65,11 @@ describe("createApi (integration)", () => {
68
65
  });
69
66
 
70
67
  it("getBlockInfo/getBlock agree on the same known height", async () => {
71
- const lastBlockInfo = await api.lastBlock();
68
+ const lastBlockInfo = await api.lastBlock(context);
72
69
  const knownHeight = lastBlockInfo.height - 100;
73
70
 
74
- const info = await api.getBlockInfo(knownHeight);
75
- const block = await api.getBlock(knownHeight);
71
+ const info = await api.getBlockInfo(context, knownHeight);
72
+ const block = await api.getBlock(context, knownHeight);
76
73
 
77
74
  expect(info.height).toBe(knownHeight);
78
75
  expect(block.info).toEqual(info);
@@ -80,7 +77,7 @@ describe("createApi (integration)", () => {
80
77
  });
81
78
 
82
79
  it("listOperations returns a page shape for a known address", async () => {
83
- const page = await api.listOperations(KNOWN_ADDRESS, { minHeight: 0 });
80
+ const page = await api.listOperations(context, KNOWN_ADDRESS, { minHeight: 0 });
84
81
 
85
82
  expect(Array.isArray(page.items)).toBe(true);
86
83
  for (const op of page.items) {
@@ -92,7 +89,7 @@ describe("createApi (integration)", () => {
92
89
 
93
90
  it("craftTransaction fails clearly for an intent with no recipient", async () => {
94
91
  await expect(
95
- api.craftTransaction({
92
+ api.craftTransaction(context, {
96
93
  intentType: "transaction",
97
94
  type: "send",
98
95
  sender: KNOWN_ADDRESS,
@@ -104,7 +101,7 @@ describe("createApi (integration)", () => {
104
101
  });
105
102
 
106
103
  it("crafts a native VET transaction and combines it into a signed hex payload", async () => {
107
- const crafted = await api.craftTransaction({
104
+ const crafted = await api.craftTransaction(context, {
108
105
  intentType: "transaction",
109
106
  type: "send",
110
107
  sender: KNOWN_ADDRESS,
@@ -120,7 +117,7 @@ describe("createApi (integration)", () => {
120
117
 
121
118
  // combine attaches a (dummy) 65-byte signature and returns the hex-encoded signed tx that
122
119
  // broadcast would submit — exercising the full craft → combine round trip.
123
- const signed = api.combine(crafted.transaction, "aa".repeat(65));
120
+ const signed = api.combine(context, crafted.transaction, ["aa".repeat(65)]);
124
121
  expect(signed).toMatch(/^0x[0-9a-f]+$/);
125
122
  });
126
123
  });
package/src/api/index.ts CHANGED
@@ -4,18 +4,24 @@ import type {
4
4
  AddressValidationCurrencyParameters,
5
5
  Balance,
6
6
  BalanceOptions,
7
+ Block,
8
+ BlockInfo,
9
+ BroadcastConfig,
7
10
  CoinModuleApi,
8
11
  CraftedTransaction,
9
12
  Cursor,
10
13
  FeeEstimation,
14
+ ListOperationsOptions,
15
+ Operation,
11
16
  Page,
12
17
  Reward,
13
18
  Stake,
19
+ StakingTransactionIntent,
14
20
  TransactionIntent,
15
21
  TransactionValidation,
16
22
  Validator,
17
23
  } from "@ledgerhq/coin-module-framework/api/index";
18
- import { setCoinConfig, type VechainCoinConfig } from "../config";
24
+ import { type VechainContext, type VechainCurrencyConfig } from "../config";
19
25
  import {
20
26
  broadcast,
21
27
  combine,
@@ -30,42 +36,69 @@ import {
30
36
  validateIntent,
31
37
  } from "../logic";
32
38
 
33
- // CoinModuleApi (Alpaca) factory for VET + VTHO. `config` is re-wrapped to force `status: active`.
34
- export function createApi(config: VechainCoinConfig, _currencyId: string): CoinModuleApi {
35
- setCoinConfig(() => ({ ...config(), status: { type: "active" } }));
36
-
39
+ // CoinModuleApi (Alpaca) factory for VET + VTHO. Each method resolves its config from
40
+ // `context.config()` and threads it explicitly to the logic/network layers — the module never
41
+ // seeds or reads the coin-config singleton on this path (the classic bridge still does).
42
+ export function createApi(): CoinModuleApi<VechainCurrencyConfig> {
37
43
  return {
38
- lastBlock,
39
- getBlockInfo,
40
- getBlock,
41
- getBalance: (address: string, options?: BalanceOptions): Promise<Balance[]> =>
42
- rejectBalanceOptions(() => getBalance(address), options),
43
- listOperations,
44
+ lastBlock: (context: VechainContext): Promise<BlockInfo> => lastBlock(context),
45
+ getBlockInfo: (context: VechainContext, height: number): Promise<BlockInfo> =>
46
+ getBlockInfo(context, height),
47
+ getBlock: (context: VechainContext, height: number): Promise<Block> =>
48
+ getBlock(context, height),
49
+ getBalance: (
50
+ context: VechainContext,
51
+ address: string,
52
+ options?: BalanceOptions,
53
+ ): Promise<Balance[]> => rejectBalanceOptions(() => getBalance(context, address), options),
54
+ listOperations: (
55
+ context: VechainContext,
56
+ address: string,
57
+ options: ListOperationsOptions,
58
+ ): Promise<Page<Operation>> => listOperations(context, address, options),
44
59
  craftTransaction: (
45
- transactionIntent: TransactionIntent,
46
- customFees?: FeeEstimation,
47
- ): Promise<CraftedTransaction> => craftTransaction(transactionIntent, customFees),
60
+ context: VechainContext,
61
+ transactionIntent: TransactionIntent | StakingTransactionIntent,
62
+ options?: { customFees?: FeeEstimation },
63
+ ): Promise<CraftedTransaction> =>
64
+ craftTransaction(context, transactionIntent as TransactionIntent, options?.customFees),
48
65
  estimateFees: (
66
+ context: VechainContext,
49
67
  transactionIntent: TransactionIntent,
50
- customFeesParameters?: FeeEstimation["parameters"],
51
- ): Promise<FeeEstimation> => estimateFees(transactionIntent, customFeesParameters),
52
- combine,
53
- broadcast,
68
+ options?: { customFeesParameters?: FeeEstimation["parameters"] },
69
+ ): Promise<FeeEstimation> =>
70
+ estimateFees(context, transactionIntent, options?.customFeesParameters),
71
+ combine: (
72
+ _context: VechainContext,
73
+ tx: string,
74
+ signature: string[],
75
+ _options?: { pubkey?: string },
76
+ ): string => combine(tx, signature),
77
+ broadcast: (
78
+ context: VechainContext,
79
+ signedTx: string,
80
+ options?: { broadcastConfig?: BroadcastConfig },
81
+ ): Promise<string> => broadcast(context, signedTx, options?.broadcastConfig),
54
82
  validateIntent: (
55
- transactionIntent: TransactionIntent,
83
+ _context: VechainContext,
84
+ transactionIntent: TransactionIntent | StakingTransactionIntent,
56
85
  balances: Balance[],
57
- customFees?: FeeEstimation,
58
- ): Promise<TransactionValidation> => validateIntent(transactionIntent, balances, customFees),
59
- craftTransactionData,
86
+ options?: { customFees?: FeeEstimation },
87
+ ): Promise<TransactionValidation> =>
88
+ validateIntent(transactionIntent as TransactionIntent, balances, options?.customFees),
89
+ craftTransactionData: (_context: VechainContext, intent: TransactionIntent) =>
90
+ craftTransactionData(intent),
60
91
  validateAddress: (
92
+ _context: VechainContext,
61
93
  address: string,
62
94
  parameters: Partial<AddressValidationCurrencyParameters>,
63
95
  ): Promise<boolean> => validateAddress(address, parameters),
64
96
  // --- Not applicable / not supported for VeChain ---
65
- getNextSequence: (_address: string): Promise<bigint> => {
97
+ getNextSequence: (_context: VechainContext, _address: string): Promise<bigint> => {
66
98
  throw new Error("getNextSequence is not applicable for Vechain");
67
99
  },
68
100
  craftRawTransaction: (
101
+ _context: VechainContext,
69
102
  _transaction: string,
70
103
  _sender: string,
71
104
  _publicKey: string,
@@ -73,16 +106,30 @@ export function createApi(config: VechainCoinConfig, _currencyId: string): CoinM
73
106
  ): Promise<CraftedTransaction> => {
74
107
  throw new Error("craftRawTransaction is not supported");
75
108
  },
76
- call: () => {
109
+ call: (_context: VechainContext) => {
77
110
  throw new Error("call is not supported");
78
111
  },
79
- getStakes: (_address: string, _cursor?: Cursor): Promise<Page<Stake>> => {
112
+ async register() {
113
+ throw new Error("register is not supported");
114
+ },
115
+ getStakes: (
116
+ _context: VechainContext,
117
+ _address: string,
118
+ _options?: { cursor?: Cursor },
119
+ ): Promise<Page<Stake>> => {
80
120
  throw new Error("getStakes is not supported");
81
121
  },
82
- getRewards: (_address: string, _cursor?: Cursor): Promise<Page<Reward>> => {
122
+ getRewards: (
123
+ _context: VechainContext,
124
+ _address: string,
125
+ _options?: { cursor?: Cursor },
126
+ ): Promise<Page<Reward>> => {
83
127
  throw new Error("getRewards is not supported");
84
128
  },
85
- getValidators: (_cursor?: Cursor): Promise<Page<Validator>> => {
129
+ getValidators: (
130
+ _context: VechainContext,
131
+ _options?: { cursor?: Cursor },
132
+ ): Promise<Page<Validator>> => {
86
133
  throw new Error("getValidators is not supported");
87
134
  },
88
135
  };