@ledgerhq/live-common 21.21.3 → 21.23.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 (266) hide show
  1. package/lib/account/formatters.d.ts.map +1 -1
  2. package/lib/account/formatters.js +1 -0
  3. package/lib/account/formatters.js.map +1 -1
  4. package/lib/account/support.d.ts.map +1 -1
  5. package/lib/account/support.js +1 -0
  6. package/lib/account/support.js.map +1 -1
  7. package/lib/apps/polyfill.d.ts.map +1 -1
  8. package/lib/apps/polyfill.js +1 -0
  9. package/lib/apps/polyfill.js.map +1 -1
  10. package/lib/bot/engine.js +1 -1
  11. package/lib/bot/engine.js.map +1 -1
  12. package/lib/bot/specs.d.ts +1 -0
  13. package/lib/bot/specs.d.ts.map +1 -1
  14. package/lib/bot/specs.js +3 -1
  15. package/lib/bot/specs.js.map +1 -1
  16. package/lib/data/icons/react/sol.js +4 -2
  17. package/lib/data/icons/react/sol.js.map +1 -1
  18. package/lib/data/icons/reactNative/sol.js +4 -2
  19. package/lib/data/icons/reactNative/sol.js.map +1 -1
  20. package/lib/derivation.d.ts.map +1 -1
  21. package/lib/derivation.js +0 -3
  22. package/lib/derivation.js.map +1 -1
  23. package/lib/env.d.ts +5 -10
  24. package/lib/env.d.ts.map +1 -1
  25. package/lib/env.js +1 -6
  26. package/lib/env.js.map +1 -1
  27. package/lib/env.react.d.ts +1 -1
  28. package/lib/env.react.d.ts.map +1 -1
  29. package/lib/families/algorand/account.d.ts.map +1 -1
  30. package/lib/families/algorand/account.js +0 -4
  31. package/lib/families/algorand/account.js.map +1 -1
  32. package/lib/families/algorand/api/algodv2.d.ts +5 -0
  33. package/lib/families/algorand/api/algodv2.d.ts.map +1 -0
  34. package/lib/families/algorand/api/algodv2.js +118 -0
  35. package/lib/families/algorand/api/algodv2.js.map +1 -0
  36. package/lib/families/algorand/api/algodv2.types.d.ts +24 -0
  37. package/lib/families/algorand/api/algodv2.types.d.ts.map +1 -0
  38. package/lib/families/algorand/api/algodv2.types.js +3 -0
  39. package/lib/families/algorand/api/algodv2.types.js.map +1 -0
  40. package/lib/families/algorand/api/index.d.ts +5 -0
  41. package/lib/families/algorand/api/index.d.ts.map +1 -0
  42. package/lib/families/algorand/api/index.js +17 -0
  43. package/lib/families/algorand/api/index.js.map +1 -0
  44. package/lib/families/algorand/api/indexer.d.ts +3 -0
  45. package/lib/families/algorand/api/indexer.d.ts.map +1 -0
  46. package/lib/families/algorand/api/indexer.js +134 -0
  47. package/lib/families/algorand/api/indexer.js.map +1 -0
  48. package/lib/families/algorand/api/indexer.types.d.ts +35 -0
  49. package/lib/families/algorand/api/indexer.types.d.ts.map +1 -0
  50. package/lib/families/algorand/api/indexer.types.js +10 -0
  51. package/lib/families/algorand/api/indexer.types.js.map +1 -0
  52. package/lib/families/algorand/bridge/js.d.ts +8 -0
  53. package/lib/families/algorand/bridge/js.d.ts.map +1 -0
  54. package/lib/families/algorand/bridge/js.js +85 -0
  55. package/lib/families/algorand/bridge/js.js.map +1 -0
  56. package/lib/families/algorand/bridge/libcore.d.ts +3 -3
  57. package/lib/families/algorand/bridge/libcore.d.ts.map +1 -1
  58. package/lib/families/algorand/bridge/libcore.js.map +1 -1
  59. package/lib/families/algorand/bridge/mock.d.ts +2 -2
  60. package/lib/families/algorand/bridge/mock.d.ts.map +1 -1
  61. package/lib/families/algorand/bridge/mock.js.map +1 -1
  62. package/lib/families/algorand/buildTransaction.d.ts +8 -0
  63. package/lib/families/algorand/buildTransaction.d.ts.map +1 -0
  64. package/lib/families/algorand/buildTransaction.js +101 -0
  65. package/lib/families/algorand/buildTransaction.js.map +1 -0
  66. package/lib/families/algorand/cli-transaction.js +1 -1
  67. package/lib/families/algorand/cli-transaction.js.map +1 -1
  68. package/lib/families/algorand/deviceTransactionConfig.d.ts +2 -2
  69. package/lib/families/algorand/deviceTransactionConfig.d.ts.map +1 -1
  70. package/lib/families/algorand/deviceTransactionConfig.js +0 -13
  71. package/lib/families/algorand/deviceTransactionConfig.js.map +1 -1
  72. package/lib/families/algorand/hw-getAddress.d.ts.map +1 -1
  73. package/lib/families/algorand/hw-getAddress.js +2 -24
  74. package/lib/families/algorand/hw-getAddress.js.map +1 -1
  75. package/lib/families/algorand/js-broadcast.d.ts +9 -0
  76. package/lib/families/algorand/js-broadcast.d.ts.map +1 -0
  77. package/lib/families/algorand/js-broadcast.js +63 -0
  78. package/lib/families/algorand/js-broadcast.js.map +1 -0
  79. package/lib/families/algorand/js-estimateMaxSpendable.d.ts +9 -0
  80. package/lib/families/algorand/js-estimateMaxSpendable.d.ts.map +1 -0
  81. package/lib/families/algorand/js-estimateMaxSpendable.js +89 -0
  82. package/lib/families/algorand/js-estimateMaxSpendable.js.map +1 -0
  83. package/lib/families/algorand/js-getFeesForTransaction.d.ts +5 -0
  84. package/lib/families/algorand/js-getFeesForTransaction.d.ts.map +1 -0
  85. package/lib/families/algorand/js-getFeesForTransaction.js +69 -0
  86. package/lib/families/algorand/js-getFeesForTransaction.js.map +1 -0
  87. package/lib/families/algorand/js-getTransactionStatus.d.ts +11 -0
  88. package/lib/families/algorand/js-getTransactionStatus.d.ts.map +1 -0
  89. package/lib/families/algorand/js-getTransactionStatus.js +201 -0
  90. package/lib/families/algorand/js-getTransactionStatus.js.map +1 -0
  91. package/lib/families/algorand/js-prepareTransaction.d.ts +5 -0
  92. package/lib/families/algorand/js-prepareTransaction.d.ts.map +1 -0
  93. package/lib/families/algorand/js-prepareTransaction.js +101 -0
  94. package/lib/families/algorand/js-prepareTransaction.js.map +1 -0
  95. package/lib/families/algorand/js-signOperation.d.ts +10 -0
  96. package/lib/families/algorand/js-signOperation.d.ts.map +1 -0
  97. package/lib/families/algorand/js-signOperation.js +164 -0
  98. package/lib/families/algorand/js-signOperation.js.map +1 -0
  99. package/lib/families/algorand/js-synchronization.d.ts +10 -0
  100. package/lib/families/algorand/js-synchronization.d.ts.map +1 -0
  101. package/lib/families/algorand/js-synchronization.js +411 -0
  102. package/lib/families/algorand/js-synchronization.js.map +1 -0
  103. package/lib/families/algorand/libcore-buildTransaction.d.ts +2 -2
  104. package/lib/families/algorand/libcore-buildTransaction.d.ts.map +1 -1
  105. package/lib/families/algorand/libcore-getFeesForTransaction.d.ts +4 -4
  106. package/lib/families/algorand/libcore-getFeesForTransaction.d.ts.map +1 -1
  107. package/lib/families/algorand/libcore-getFeesForTransaction.js +2 -2
  108. package/lib/families/algorand/libcore-getFeesForTransaction.js.map +1 -1
  109. package/lib/families/algorand/libcore-postBuildAccount.d.ts.map +1 -1
  110. package/lib/families/algorand/libcore-postBuildAccount.js +5 -11
  111. package/lib/families/algorand/libcore-postBuildAccount.js.map +1 -1
  112. package/lib/families/algorand/libcore-signOperation.d.ts +2 -2
  113. package/lib/families/algorand/libcore-signOperation.d.ts.map +1 -1
  114. package/lib/families/algorand/libcore-signOperation.js.map +1 -1
  115. package/lib/families/algorand/logic.d.ts +10 -0
  116. package/lib/families/algorand/logic.d.ts.map +1 -1
  117. package/lib/families/algorand/logic.js +79 -1
  118. package/lib/families/algorand/logic.js.map +1 -1
  119. package/lib/families/algorand/mock.d.ts.map +1 -1
  120. package/lib/families/algorand/mock.js +4 -11
  121. package/lib/families/algorand/mock.js.map +1 -1
  122. package/lib/families/algorand/serialization.js +4 -4
  123. package/lib/families/algorand/serialization.js.map +1 -1
  124. package/lib/families/algorand/specs.d.ts +2 -2
  125. package/lib/families/algorand/specs.d.ts.map +1 -1
  126. package/lib/families/algorand/specs.js +8 -16
  127. package/lib/families/algorand/specs.js.map +1 -1
  128. package/lib/families/algorand/speculos-deviceActions.d.ts +2 -2
  129. package/lib/families/algorand/speculos-deviceActions.d.ts.map +1 -1
  130. package/lib/families/algorand/speculos-deviceActions.js +4 -0
  131. package/lib/families/algorand/speculos-deviceActions.js.map +1 -1
  132. package/lib/families/algorand/test-dataset.d.ts +2 -2
  133. package/lib/families/algorand/test-dataset.d.ts.map +1 -1
  134. package/lib/families/algorand/test-dataset.js +1 -2
  135. package/lib/families/algorand/test-dataset.js.map +1 -1
  136. package/lib/families/algorand/tokens.d.ts.map +1 -1
  137. package/lib/families/algorand/tokens.js.map +1 -1
  138. package/lib/families/algorand/transaction.d.ts +5 -5
  139. package/lib/families/algorand/transaction.d.ts.map +1 -1
  140. package/lib/families/algorand/transaction.js.map +1 -1
  141. package/lib/families/algorand/types.d.ts +7 -5
  142. package/lib/families/algorand/types.d.ts.map +1 -1
  143. package/lib/families/algorand/types.js.map +1 -1
  144. package/lib/families/bitcoin/js-prepareTransaction.d.ts.map +1 -1
  145. package/lib/families/bitcoin/js-prepareTransaction.js +3 -2
  146. package/lib/families/bitcoin/js-prepareTransaction.js.map +1 -1
  147. package/lib/families/bitcoin/js-synchronisation.d.ts.map +1 -1
  148. package/lib/families/bitcoin/js-synchronisation.js +3 -2
  149. package/lib/families/bitcoin/js-synchronisation.js.map +1 -1
  150. package/lib/families/bitcoin/wallet-btc/crypto/decred.d.ts.map +1 -1
  151. package/lib/families/bitcoin/wallet-btc/crypto/decred.js +3 -4
  152. package/lib/families/bitcoin/wallet-btc/crypto/decred.js.map +1 -1
  153. package/lib/families/tezos/bridge/js.d.ts.map +1 -1
  154. package/lib/families/tezos/bridge/js.js +90 -50
  155. package/lib/families/tezos/bridge/js.js.map +1 -1
  156. package/lib/families/tezos/bridge/libcore.d.ts.map +1 -1
  157. package/lib/families/tezos/bridge/libcore.js +2 -1
  158. package/lib/families/tezos/bridge/libcore.js.map +1 -1
  159. package/lib/families/tezos/bridge/mock.d.ts.map +1 -1
  160. package/lib/families/tezos/bridge/mock.js +2 -1
  161. package/lib/families/tezos/bridge/mock.js.map +1 -1
  162. package/lib/families/tezos/signOperation.d.ts.map +1 -1
  163. package/lib/families/tezos/signOperation.js +28 -19
  164. package/lib/families/tezos/signOperation.js.map +1 -1
  165. package/lib/families/tezos/specs.d.ts.map +1 -1
  166. package/lib/families/tezos/specs.js +8 -4
  167. package/lib/families/tezos/specs.js.map +1 -1
  168. package/lib/families/tezos/speculos-deviceActions.js +6 -7
  169. package/lib/families/tezos/speculos-deviceActions.js.map +1 -1
  170. package/lib/families/tezos/synchronisation.d.ts.map +1 -1
  171. package/lib/families/tezos/synchronisation.js +7 -4
  172. package/lib/families/tezos/synchronisation.js.map +1 -1
  173. package/lib/families/tezos/synchronisation.test.d.ts.map +1 -1
  174. package/lib/families/tezos/synchronisation.test.js +0 -3
  175. package/lib/families/tezos/synchronisation.test.js.map +1 -1
  176. package/lib/families/tezos/test-dataset.d.ts +2 -2
  177. package/lib/families/tezos/test-dataset.d.ts.map +1 -1
  178. package/lib/families/tezos/test-dataset.js +45 -319
  179. package/lib/families/tezos/test-dataset.js.map +1 -1
  180. package/lib/families/tezos/transaction.d.ts +2 -2
  181. package/lib/families/tezos/transaction.d.ts.map +1 -1
  182. package/lib/families/tezos/transaction.js +4 -4
  183. package/lib/families/tezos/transaction.js.map +1 -1
  184. package/lib/families/tezos/types.d.ts +2 -0
  185. package/lib/families/tezos/types.d.ts.map +1 -1
  186. package/lib/families/tezos/types.js.map +1 -1
  187. package/lib/generated/bridge/js.d.ts +4 -0
  188. package/lib/generated/bridge/js.d.ts.map +1 -1
  189. package/lib/generated/bridge/js.js +26 -24
  190. package/lib/generated/bridge/js.js.map +1 -1
  191. package/lib/generated/bridge/libcore.d.ts +1 -1
  192. package/lib/generated/bridge/mock.d.ts +1 -1
  193. package/lib/generated/specs.d.ts +1 -1
  194. package/lib/generated/speculos-deviceActions.d.ts +1 -1
  195. package/lib/generated/test-dataset.d.ts +1 -1
  196. package/lib/generated/transaction.d.ts +4 -4
  197. package/lib/libcore/buildAccount/index.d.ts.map +1 -1
  198. package/lib/libcore/buildAccount/index.js +0 -1
  199. package/lib/libcore/buildAccount/index.js.map +1 -1
  200. package/lib/mock/account.js +21 -21
  201. package/lib/mock/account.js.map +1 -1
  202. package/lib/types/operation.d.ts +1 -1
  203. package/lib/types/operation.d.ts.map +1 -1
  204. package/package.json +10 -9
  205. package/src/__tests__/__snapshots__/all.libcore.ts.snap +0 -107
  206. package/src/account/formatters.ts +1 -0
  207. package/src/account/support.ts +1 -0
  208. package/src/apps/polyfill.ts +1 -0
  209. package/src/bot/engine.ts +1 -1
  210. package/src/bot/specs.ts +7 -1
  211. package/src/data/icons/react/sol.tsx +1 -1
  212. package/src/data/icons/reactNative/sol.tsx +1 -1
  213. package/src/data/icons/svg/SOL.svg +1 -3
  214. package/src/derivation.ts +0 -2
  215. package/src/env.ts +1 -6
  216. package/src/families/algorand/account.ts +0 -9
  217. package/src/families/algorand/api/algodv2.ts +68 -0
  218. package/src/families/algorand/api/algodv2.types.ts +27 -0
  219. package/src/families/algorand/api/index.ts +4 -0
  220. package/src/families/algorand/api/indexer.ts +99 -0
  221. package/src/families/algorand/api/indexer.types.ts +41 -0
  222. package/src/families/algorand/bridge/js.ts +46 -0
  223. package/src/families/algorand/bridge/libcore.ts +4 -4
  224. package/src/families/algorand/bridge/mock.ts +3 -3
  225. package/src/families/algorand/buildTransaction.ts +100 -0
  226. package/src/families/algorand/cli-transaction.ts +1 -1
  227. package/src/families/algorand/deviceTransactionConfig.ts +2 -16
  228. package/src/families/algorand/hw-getAddress.ts +1 -10
  229. package/src/families/algorand/js-broadcast.ts +17 -0
  230. package/src/families/algorand/js-estimateMaxSpendable.ts +51 -0
  231. package/src/families/algorand/js-getFeesForTransaction.ts +25 -0
  232. package/src/families/algorand/js-getTransactionStatus.ts +178 -0
  233. package/src/families/algorand/js-prepareTransaction.ts +42 -0
  234. package/src/families/algorand/js-signOperation.ts +145 -0
  235. package/src/families/algorand/js-synchronization.ts +433 -0
  236. package/src/families/algorand/libcore-buildTransaction.ts +2 -2
  237. package/src/families/algorand/libcore-getFeesForTransaction.ts +4 -4
  238. package/src/families/algorand/libcore-postBuildAccount.ts +2 -7
  239. package/src/families/algorand/libcore-signOperation.ts +2 -2
  240. package/src/families/algorand/logic.ts +47 -0
  241. package/src/families/algorand/mock.ts +2 -12
  242. package/src/families/algorand/serialization.ts +4 -4
  243. package/src/families/algorand/specs.ts +16 -22
  244. package/src/families/algorand/speculos-deviceActions.ts +87 -82
  245. package/src/families/algorand/test-dataset.ts +5 -6
  246. package/src/families/algorand/tokens.ts +1 -0
  247. package/src/families/algorand/transaction.ts +13 -4
  248. package/src/families/algorand/types.ts +10 -5
  249. package/src/families/bitcoin/js-prepareTransaction.ts +3 -2
  250. package/src/families/bitcoin/js-synchronisation.ts +3 -2
  251. package/src/families/bitcoin/wallet-btc/crypto/decred.ts +3 -4
  252. package/src/families/tezos/bridge/js.ts +77 -36
  253. package/src/families/tezos/bridge/libcore.ts +1 -0
  254. package/src/families/tezos/bridge/mock.ts +1 -0
  255. package/src/families/tezos/signOperation.ts +19 -8
  256. package/src/families/tezos/specs.ts +16 -5
  257. package/src/families/tezos/speculos-deviceActions.ts +5 -5
  258. package/src/families/tezos/synchronisation.test.ts +0 -3
  259. package/src/families/tezos/synchronisation.ts +6 -3
  260. package/src/families/tezos/test-dataset.ts +33 -363
  261. package/src/families/tezos/transaction.ts +7 -1
  262. package/src/families/tezos/types.ts +2 -0
  263. package/src/generated/bridge/js.ts +3 -0
  264. package/src/libcore/buildAccount/index.ts +1 -2
  265. package/src/mock/account.ts +27 -27
  266. package/src/types/operation.ts +9 -4
@@ -7,7 +7,7 @@ interface Props {
7
7
  };
8
8
 
9
9
  function sol({ size, color }: Props) {
10
- return <Svg width={size} height={size} viewBox="0 0 24 24" fill="none"><Path d="M9.925 18.687a.59.59 0 01.415-.17h14.366a.29.29 0 01.207.497l-2.838 2.815a.59.59 0 01-.415.171H7.294a.291.291 0 01-.207-.498l2.838-2.815zm0-10.517A.59.59 0 0110.34 8h14.366c.261 0 .392.314.207.498l-2.838 2.815a.59.59 0 01-.415.17H7.294a.291.291 0 01-.207-.497L9.925 8.17zm12.15 5.225a.59.59 0 00-.415-.17H7.294a.291.291 0 00-.207.498l2.838 2.815c.11.109.26.17.415.17h14.366a.291.291 0 00.207-.498l-2.838-2.815z" fill={color} fillRule="nonzero" /></Svg>;
10
+ return <Svg width={size} height={size} viewBox="0 0 24 24"><Path d="M2.41,7.77H18.09a.51.51,0,0,0,.37-.16l3.43-3.67a.4.4,0,0,0-.3-.67H5.91a.51.51,0,0,0-.37.16L2.11,7.1A.4.4,0,0,0,2.41,7.77Z" /><Path d="M2.41,20.77H18.09a.51.51,0,0,0,.37-.16l3.43-3.67a.4.4,0,0,0-.3-.67H5.91a.51.51,0,0,0-.37.16L2.11,20.1A.4.4,0,0,0,2.41,20.77Z" /><Path d="M21.59,14.27H5.91a.51.51,0,0,1-.37-.16L2.11,10.44a.4.4,0,0,1,.3-.67H18.09a.51.51,0,0,1,.37.16l3.43,3.67A.4.4,0,0,1,21.59,14.27Z" /></Svg>;
11
11
  }
12
12
 
13
13
  export default sol;
@@ -1,3 +1 @@
1
- <svg width="24" height="24" viewBox="0 0 24 24" fill="none">
2
- <path d="M9.925 18.687a.59.59 0 01.415-.17h14.366a.29.29 0 01.207.497l-2.838 2.815a.59.59 0 01-.415.171H7.294a.291.291 0 01-.207-.498l2.838-2.815zm0-10.517A.59.59 0 0110.34 8h14.366c.261 0 .392.314.207.498l-2.838 2.815a.59.59 0 01-.415.17H7.294a.291.291 0 01-.207-.497L9.925 8.17zm12.15 5.225a.59.59 0 00-.415-.17H7.294a.291.291 0 00-.207.498l2.838 2.815c.11.109.26.17.415.17h14.366a.291.291 0 00.207-.498l-2.838-2.815z" fill="#FFF" fill-rule="nonzero"/>
3
- </svg>
1
+ <svg width="24" height="24" viewBox="0 0 24 24"><path d="M2.41,7.77H18.09a.51.51,0,0,0,.37-.16l3.43-3.67a.4.4,0,0,0-.3-.67H5.91a.51.51,0,0,0-.37.16L2.11,7.1A.4.4,0,0,0,2.41,7.77Z"/><path d="M2.41,20.77H18.09a.51.51,0,0,0,.37-.16l3.43-3.67a.4.4,0,0,0-.3-.67H5.91a.51.51,0,0,0-.37.16L2.11,20.1A.4.4,0,0,0,2.41,20.77Z"/><path d="M21.59,14.27H5.91a.51.51,0,0,1-.37-.16L2.11,10.44a.4.4,0,0,1,.3-.67H18.09a.51.51,0,0,1,.37.16l3.43,3.67A.4.4,0,0,1,21.59,14.27Z"/></svg>
package/src/derivation.ts CHANGED
@@ -59,8 +59,6 @@ const extraConfigPerCurrency: Record<string, LibcoreConfig> = {
59
59
  algorand: {
60
60
  BLOCKCHAIN_EXPLORER_API_ENDPOINT: () =>
61
61
  getEnv("API_ALGORAND_BLOCKCHAIN_EXPLORER_API_ENDPOINT"),
62
- BLOCKCHAIN_EXPLORER_API_KEY: () =>
63
- getEnv("API_ALGORAND_BLOCKCHAIN_EXPLORER_API_KEY"),
64
62
  },
65
63
  };
66
64
  const modes = Object.freeze({
package/src/env.ts CHANGED
@@ -40,11 +40,6 @@ const envDefinitions = {
40
40
  parser: stringParser,
41
41
  desc: "Node API endpoint for algorand",
42
42
  },
43
- API_ALGORAND_BLOCKCHAIN_EXPLORER_API_KEY: {
44
- def: "",
45
- parser: stringParser,
46
- desc: "Node API key for algorand",
47
- },
48
43
  API_COSMOS_BLOCKCHAIN_EXPLORER_API_ENDPOINT: {
49
44
  def: "https://cosmoshub4.coin.ledger.com/",
50
45
  parser: stringParser,
@@ -111,7 +106,7 @@ const envDefinitions = {
111
106
  desc: "Ledger explorer API for tezos",
112
107
  },
113
108
  API_TEZOS_TZKT_API: {
114
- def: "http://xtz-tzkt-explorer.api-01.live.ledger-stg.com",
109
+ def: "https://xtz-tzkt-explorer.api.live.ledger.com",
115
110
  parser: stringParser,
116
111
  desc: "tzkt.io explorer",
117
112
  },
@@ -46,15 +46,6 @@ function formatAccountSpecifics(account: Account): string {
46
46
  ) + " rewards. ";
47
47
  }
48
48
 
49
- if ((algorandResources as AlgorandResources).rewardsAccumulated.gt(0)) {
50
- str +=
51
- formatCurrencyUnit(
52
- unit,
53
- (algorandResources as AlgorandResources).rewardsAccumulated,
54
- formatConfig
55
- ) + " rewardsAccumulated. ";
56
- }
57
-
58
49
  return str;
59
50
  }
60
51
 
@@ -0,0 +1,68 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ import { getEnv } from "../../../env";
3
+ import network from "../../../network";
4
+ import {
5
+ AlgoAccount,
6
+ AlgoAsset,
7
+ AlgoTransactionParams,
8
+ AlgoTransactionBroadcastResponse,
9
+ } from "./algodv2.types";
10
+
11
+ const BASE_URL = getEnv("API_ALGORAND_BLOCKCHAIN_EXPLORER_API_ENDPOINT");
12
+ const NODE_URL = `${BASE_URL}/ps2/v2`;
13
+
14
+ const fullUrl = (route: string): string => `${NODE_URL}${route}`;
15
+
16
+ export const getAccount = async (address: string): Promise<AlgoAccount> => {
17
+ const { data } = await network({
18
+ method: "GET",
19
+ url: fullUrl(`/accounts/${address}`),
20
+ });
21
+
22
+ const assets: AlgoAsset[] = data.assets
23
+ ? data.assets.map((a): AlgoAsset => {
24
+ return {
25
+ assetId: a["asset-id"].toString(),
26
+ balance: new BigNumber(a.amount),
27
+ };
28
+ })
29
+ : [];
30
+
31
+ return {
32
+ round: data.round,
33
+ address: data.address,
34
+ balance: new BigNumber(data.amount),
35
+ pendingRewards: new BigNumber(data["pending-rewards"]),
36
+ assets,
37
+ };
38
+ };
39
+
40
+ // TODO Cache
41
+ export const getTransactionParams =
42
+ async (): Promise<AlgoTransactionParams> => {
43
+ const { data } = await network({
44
+ method: "GET",
45
+ url: fullUrl(`/transactions/params`),
46
+ });
47
+
48
+ return {
49
+ fee: data["fee"],
50
+ minFee: data["min-fee"],
51
+ firstRound: data["first-round"] ?? 0,
52
+ lastRound: data["last-round"],
53
+ genesisID: data["genesis-id"],
54
+ genesisHash: data["genesis-hash"],
55
+ };
56
+ };
57
+
58
+ export const broadcastTransaction = async (
59
+ payload: string
60
+ ): Promise<string> => {
61
+ const { data }: { data: AlgoTransactionBroadcastResponse } = await network({
62
+ method: "POST",
63
+ url: fullUrl(`/transactions`),
64
+ data: payload,
65
+ });
66
+
67
+ return data.txId;
68
+ };
@@ -0,0 +1,27 @@
1
+ import { BigNumber } from "bignumber.js";
2
+
3
+ export interface AlgoAccount {
4
+ round: number;
5
+ address: string;
6
+ balance: BigNumber;
7
+ pendingRewards: BigNumber;
8
+ assets: AlgoAsset[];
9
+ }
10
+
11
+ export interface AlgoAsset {
12
+ assetId: string;
13
+ balance: BigNumber;
14
+ }
15
+
16
+ export interface AlgoTransactionParams {
17
+ fee: number;
18
+ minFee: number;
19
+ firstRound: number;
20
+ lastRound: number;
21
+ genesisHash: string;
22
+ genesisID: string;
23
+ }
24
+
25
+ export interface AlgoTransactionBroadcastResponse {
26
+ txId: string;
27
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./algodv2.types";
2
+ export * from "./algodv2";
3
+ export * from "./indexer.types";
4
+ export * from "./indexer";
@@ -0,0 +1,99 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ import { getEnv } from "../../../env";
3
+ import network from "../../../network";
4
+ import {
5
+ AlgoTransaction,
6
+ AlgoTransactionDetails,
7
+ AlgoPaymentInfo,
8
+ AlgoAssetTransferInfo,
9
+ } from "./indexer.types";
10
+
11
+ const LIMIT = 100; // Max nb of transactions per request
12
+
13
+ const BASE_URL = getEnv("API_ALGORAND_BLOCKCHAIN_EXPLORER_API_ENDPOINT");
14
+ const INDEXER_URL = `${BASE_URL}/idx2/v2`;
15
+
16
+ const fullUrl = (route: string): string =>
17
+ `${INDEXER_URL}${route}?limit=${LIMIT}`;
18
+
19
+ export const getAccountTransactions = async (
20
+ address: string,
21
+ startAt?: number
22
+ ): Promise<AlgoTransaction[]> => {
23
+ const url = fullUrl(`/accounts/${address}/transactions`);
24
+
25
+ let nextToken: string | undefined;
26
+ let newRawTxs: any[] = [];
27
+ const mergedTxs: AlgoTransaction[] = [];
28
+ do {
29
+ let nextUrl: string = url;
30
+ if (startAt) {
31
+ nextUrl = nextUrl.concat(`&min-round=${startAt}`);
32
+ }
33
+ if (nextToken) {
34
+ nextUrl = nextUrl.concat(`&next=${nextToken}`);
35
+ }
36
+ const { data }: { data: { transactions: any[] } } = await network({
37
+ method: "GET",
38
+ url: nextUrl,
39
+ });
40
+ nextToken = data["next-token"];
41
+ newRawTxs = data.transactions;
42
+ newRawTxs.map(parseRawTransaction).forEach((tx) => mergedTxs.push(tx));
43
+ } while (newRawTxs.length >= LIMIT);
44
+
45
+ return mergedTxs;
46
+ };
47
+
48
+ const parseRawTransaction = (tx: any): AlgoTransaction => {
49
+ let details: AlgoTransactionDetails | undefined = undefined;
50
+ if (tx["tx-type"] === "pay") {
51
+ const info = tx["payment-transaction"];
52
+ const paymentInfo: AlgoPaymentInfo = {
53
+ amount: new BigNumber(info.amount),
54
+ recipientAddress: info.receiver,
55
+ closeAmount:
56
+ info["close-amount"] === undefined
57
+ ? undefined
58
+ : new BigNumber(info["close-amount"]),
59
+ closeToAddress: info["close-remainder-to"],
60
+ };
61
+ details = paymentInfo;
62
+ } else if (tx["tx-type"] === "axfer") {
63
+ const info = tx["asset-transfer-transaction"];
64
+ const assetTransferInfo: AlgoAssetTransferInfo = {
65
+ assetAmount: new BigNumber(info.amount),
66
+ assetId: info["asset-id"],
67
+ assetRecipientAddress: info.receiver,
68
+ assetSenderAddress: info.sender,
69
+ assetCloseAmount:
70
+ info["close-amount"] === undefined
71
+ ? undefined
72
+ : new BigNumber(info["close-amount"]),
73
+ assetCloseToAddress: tx["close-to"],
74
+ };
75
+ details = assetTransferInfo;
76
+ }
77
+
78
+ return {
79
+ id: tx.id,
80
+ timestamp: tx["round-time"],
81
+ round: tx["confirmed-round"],
82
+ senderAddress: tx.sender,
83
+ senderRewards: new BigNumber(tx["sender-rewards"]),
84
+ recipientRewards: new BigNumber(tx["receiver-rewards"]),
85
+ closeRewards:
86
+ tx["close-rewards"] === undefined
87
+ ? undefined
88
+ : new BigNumber(tx["close-rewards"]),
89
+ closeAmount:
90
+ tx["closing-amount"] === undefined
91
+ ? undefined
92
+ : new BigNumber(tx["closing-amount"]),
93
+ fee: new BigNumber(tx.fee),
94
+ note: tx.note,
95
+
96
+ type: tx["tx-type"],
97
+ details,
98
+ };
99
+ };
@@ -0,0 +1,41 @@
1
+ import { BigNumber } from "bignumber.js";
2
+
3
+ export type AlgoTransactionDetails = AlgoPaymentInfo | AlgoAssetTransferInfo;
4
+
5
+ // Define only types we explicitely support
6
+ export enum AlgoTransactionType {
7
+ PAYMENT = "pay",
8
+ ASSET_TRANSFER = "axfer",
9
+ }
10
+
11
+ export interface AlgoTransaction {
12
+ id: string;
13
+ timestamp: string; // 'round-time': 1597933539,
14
+ round: number; // 'confirmed-round': 8575676,
15
+ senderAddress: string; // sender: 'RGX5XA7DWZOZ5SLG4WQSNIFKIG4CNX4VOH23YCEX56523DQEAL3QL56XZM',
16
+ senderRewards: BigNumber; // 'sender-rewards': 0,
17
+ recipientRewards: BigNumber; //'receiver-rewards': 0,
18
+ closeRewards?: BigNumber; // 'close-rewards': 0,
19
+ closeAmount?: BigNumber; //'closing-amount': 0,
20
+ fee: BigNumber;
21
+ note: string;
22
+
23
+ type: string; // 'tx-type': 'pay'
24
+ details?: AlgoTransactionDetails;
25
+ }
26
+
27
+ export interface AlgoPaymentInfo {
28
+ amount: BigNumber;
29
+ recipientAddress: string; // receiver
30
+ closeAmount?: BigNumber; // close-amount
31
+ closeToAddress?: string; // close-remainder-to
32
+ }
33
+
34
+ export interface AlgoAssetTransferInfo {
35
+ assetId: string; // asset-id
36
+ assetAmount: BigNumber; // amount
37
+ assetRecipientAddress: string; // receiver
38
+ assetSenderAddress?: string; // sender
39
+ assetCloseAmount?: BigNumber; // close-amount
40
+ assetCloseToAddress?: string; // close-to
41
+ }
@@ -0,0 +1,46 @@
1
+ import type { AccountBridge, CurrencyBridge } from "../../../types";
2
+ import { makeAccountBridgeReceive } from "../../../bridge/jsHelpers";
3
+
4
+ import type { AlgorandTransaction } from "../types";
5
+ import { sync, scanAccounts } from "../js-synchronization";
6
+ import {
7
+ createTransaction,
8
+ prepareTransaction,
9
+ } from "../js-prepareTransaction";
10
+ import { estimateMaxSpendable } from "../js-estimateMaxSpendable";
11
+ import { getTransactionStatus } from "../js-getTransactionStatus";
12
+ import { signOperation } from "../js-signOperation";
13
+ import { broadcast } from "../js-broadcast";
14
+
15
+ const receive = makeAccountBridgeReceive();
16
+
17
+ const updateTransaction = (t, patch) => {
18
+ return { ...t, ...patch };
19
+ };
20
+
21
+ const preload = async () => Promise.resolve({});
22
+
23
+ const hydrate = () => {};
24
+
25
+ const currencyBridge: CurrencyBridge = {
26
+ preload,
27
+ hydrate,
28
+ scanAccounts,
29
+ };
30
+
31
+ const accountBridge: AccountBridge<AlgorandTransaction> = {
32
+ createTransaction,
33
+ updateTransaction,
34
+ prepareTransaction,
35
+ getTransactionStatus,
36
+ sync,
37
+ receive,
38
+ signOperation,
39
+ broadcast,
40
+ estimateMaxSpendable,
41
+ };
42
+
43
+ export default {
44
+ currencyBridge,
45
+ accountBridge,
46
+ };
@@ -13,7 +13,7 @@ import {
13
13
  import { AlgorandASANotOptInInRecipient } from "../../../errors";
14
14
  import { validateRecipient } from "../../../bridge/shared";
15
15
  import type { AccountBridge, CurrencyBridge, Account } from "../../../types";
16
- import type { AlgorandResources, Transaction } from "../types";
16
+ import type { AlgorandResources, AlgorandTransaction } from "../types";
17
17
  import { AlgorandOperationTypeEnum } from "../types";
18
18
  import { scanAccounts } from "../../../libcore/scanAccounts";
19
19
  import { sync } from "../../../libcore/syncAccount";
@@ -34,7 +34,7 @@ const receive = makeAccountBridgeReceive();
34
34
  export const calculateFees: CacheRes<
35
35
  Array<{
36
36
  a: Account;
37
- t: Transaction;
37
+ t: AlgorandTransaction;
38
38
  }>,
39
39
  {
40
40
  estimatedFees: BigNumber;
@@ -72,7 +72,7 @@ const getSpendableMaxForOptIn = async (account) =>
72
72
  return spendableBalance;
73
73
  });
74
74
 
75
- const createTransaction = (): Transaction => ({
75
+ const createTransaction = (): AlgorandTransaction => ({
76
76
  family: "algorand",
77
77
  amount: new BigNumber(0),
78
78
  fees: null,
@@ -328,7 +328,7 @@ const currencyBridge: CurrencyBridge = {
328
328
  hydrate,
329
329
  scanAccounts,
330
330
  };
331
- const accountBridge: AccountBridge<Transaction> = {
331
+ const accountBridge: AccountBridge<AlgorandTransaction> = {
332
332
  createTransaction,
333
333
  updateTransaction,
334
334
  prepareTransaction,
@@ -5,7 +5,7 @@ import {
5
5
  InvalidAddress,
6
6
  FeeTooHigh,
7
7
  } from "@ledgerhq/errors";
8
- import type { Transaction } from "../types";
8
+ import type { AlgorandTransaction } from "../types";
9
9
  import type { AccountBridge, CurrencyBridge } from "../../../types";
10
10
  import {
11
11
  scanAccounts,
@@ -20,7 +20,7 @@ const receive = makeAccountBridgeReceive();
20
20
 
21
21
  const defaultGetFees = (a, t) => t.fees || new BigNumber(0);
22
22
 
23
- const createTransaction = (): Transaction => ({
23
+ const createTransaction = (): AlgorandTransaction => ({
24
24
  family: "algorand",
25
25
  mode: "send",
26
26
  amount: new BigNumber(0),
@@ -88,7 +88,7 @@ const prepareTransaction = async (a, t) => {
88
88
  return t;
89
89
  };
90
90
 
91
- const accountBridge: AccountBridge<Transaction> = {
91
+ const accountBridge: AccountBridge<AlgorandTransaction> = {
92
92
  estimateMaxSpendable,
93
93
  createTransaction,
94
94
  updateTransaction,
@@ -0,0 +1,100 @@
1
+ import { encode as msgpackEncode } from "algo-msgpack-with-bigint";
2
+ import type {
3
+ SuggestedParams as AlgoSuggestedParams,
4
+ Transaction as AlgoTransaction,
5
+ EncodedTransaction as AlgoTransactionPayload,
6
+ EncodedSignedTransaction as AlgoSignedTransactionPayload,
7
+ } from "algosdk";
8
+ import {
9
+ makePaymentTxnWithSuggestedParams,
10
+ makeAssetTransferTxnWithSuggestedParams,
11
+ } from "algosdk";
12
+
13
+ import type { Account } from "../../types";
14
+ import type { Transaction } from "./types";
15
+
16
+ import { extractTokenId } from "./tokens";
17
+ import { getTransactionParams } from "./api";
18
+
19
+ export const buildTransactionPayload = async (
20
+ account: Account,
21
+ transaction: Transaction
22
+ ): Promise<AlgoTransactionPayload> => {
23
+ const { amount, recipient, mode, memo, assetId, subAccountId } = transaction;
24
+ const subAccount = subAccountId
25
+ ? account.subAccounts &&
26
+ account.subAccounts.find((t) => t.id === subAccountId)
27
+ : null;
28
+
29
+ const note = memo ? new TextEncoder().encode(memo) : undefined;
30
+
31
+ // Minor hack: cast the result as a algosdk.SuggestedParams, while it's actually a TransactionParametersResponse
32
+ const params = (await getTransactionParams()) as AlgoSuggestedParams;
33
+
34
+ let algoTxn: AlgoTransaction;
35
+ if (subAccount || (assetId && mode === "optIn")) {
36
+ const targetAssetId =
37
+ subAccount && subAccount.type === "TokenAccount"
38
+ ? extractTokenId(subAccount.token.id)
39
+ : assetId
40
+ ? extractTokenId(assetId)
41
+ : "";
42
+
43
+ if (!targetAssetId) {
44
+ throw new Error("Token Asset Id not found");
45
+ }
46
+
47
+ algoTxn = makeAssetTransferTxnWithSuggestedParams(
48
+ account.freshAddress,
49
+ recipient,
50
+ undefined,
51
+ undefined,
52
+ amount.toNumber(),
53
+ note,
54
+ Number(targetAssetId),
55
+ params,
56
+ undefined
57
+ );
58
+ } else {
59
+ algoTxn = makePaymentTxnWithSuggestedParams(
60
+ account.freshAddress,
61
+ recipient,
62
+ amount.toNumber(),
63
+ undefined,
64
+ note,
65
+ params
66
+ );
67
+ }
68
+
69
+ // Bit of safety: set tx validity to the next 1000 blocks
70
+ algoTxn.firstRound = params.lastRound;
71
+ algoTxn.lastRound = params.lastRound + 1000;
72
+
73
+ // Flaw in the SDK: payload isn't sorted, but it needs to be for msgPack encoding
74
+ const sorted = Object.fromEntries(
75
+ Object.entries(algoTxn.get_obj_for_encoding()).sort()
76
+ ) as AlgoTransactionPayload;
77
+
78
+ return sorted;
79
+ };
80
+
81
+ export const encodeToSign = async (
82
+ payload: AlgoTransactionPayload
83
+ ): Promise<string> => {
84
+ const msgPackEncoded = msgpackEncode(payload);
85
+
86
+ return Buffer.from(msgPackEncoded).toString("hex");
87
+ };
88
+
89
+ export const encodeToBroadcast = async (
90
+ payload: AlgoTransactionPayload,
91
+ signature: Buffer
92
+ ): Promise<Buffer> => {
93
+ const signedPayload: AlgoSignedTransactionPayload = {
94
+ sig: signature,
95
+ txn: payload,
96
+ };
97
+ const msgPackEncoded = msgpackEncode(signedPayload);
98
+
99
+ return Buffer.from(msgPackEncoded);
100
+ };
@@ -102,7 +102,7 @@ function inferTransactions(
102
102
  memo: opts.memo,
103
103
  mode: opts.mode || "send",
104
104
  subAccountId: account.type === "TokenAccount" ? account.id : null,
105
- assetId: "algorand/asa/" + opts.token,
105
+ assetId: opts.token ? "algorand/asa/" + opts.token : null,
106
106
  };
107
107
  });
108
108
  }
@@ -3,7 +3,7 @@ import type {
3
3
  TransactionStatus,
4
4
  TokenCurrency,
5
5
  } from "../../types";
6
- import type { Transaction } from "./types";
6
+ import type { AlgorandTransaction } from "./types";
7
7
  import type { DeviceTransactionField } from "../../transaction";
8
8
  import { getAccountUnit } from "../../account";
9
9
  import { formatCurrencyUnit, findTokenById } from "../../currencies";
@@ -68,7 +68,7 @@ function getDeviceTransactionConfig({
68
68
  status,
69
69
  }: {
70
70
  account: AccountLike;
71
- transaction: Transaction;
71
+ transaction: AlgorandTransaction;
72
72
  status: TransactionStatus;
73
73
  }): Array<DeviceTransactionField> {
74
74
  const { mode, assetId } = transaction;
@@ -121,20 +121,6 @@ function getDeviceTransactionConfig({
121
121
  });
122
122
  break;
123
123
 
124
- case "optOut":
125
- fields.push({
126
- type: "text",
127
- label: "Type",
128
- value: "Opt out",
129
- });
130
- if (assetId)
131
- fields.push({
132
- type: "text",
133
- label: "Asset id",
134
- value: assetId,
135
- });
136
- break;
137
-
138
124
  default:
139
125
  break;
140
126
  }
@@ -1,20 +1,11 @@
1
1
  import Algorand from "@ledgerhq/hw-app-algorand";
2
2
  import type { Resolver } from "../../hw/getAddress/types";
3
- import { withLibcore } from "../../libcore/access";
4
-
5
- const convertPubkeyToAddress = async (pubkey) => {
6
- return await withLibcore(async (core) => {
7
- const address = await core.AlgorandAddress.fromPublicKey(pubkey);
8
- return address;
9
- });
10
- };
11
3
 
12
4
  const resolver: Resolver = async (transport, { path, verify }) => {
13
5
  const algorand = new Algorand(transport);
14
6
  const r = await algorand.getAddress(path, verify || false);
15
- const address = await convertPubkeyToAddress(r.publicKey);
16
7
  return {
17
- address: address,
8
+ address: r.address,
18
9
  publicKey: r.publicKey,
19
10
  path,
20
11
  };
@@ -0,0 +1,17 @@
1
+ import { patchOperationWithHash } from "../../operation";
2
+ import type { Operation, SignedOperation } from "../../types";
3
+ import { broadcastTransaction as apiBroadcast } from "./api";
4
+
5
+ /**
6
+ * Broadcast a signed transaction
7
+ * @param {signature: string, operation: string} signedOperation
8
+ */
9
+ export const broadcast = async ({
10
+ signedOperation,
11
+ }: {
12
+ signedOperation: SignedOperation;
13
+ }): Promise<Operation> => {
14
+ const { signature, operation } = signedOperation;
15
+ const hash = await apiBroadcast(signature);
16
+ return patchOperationWithHash(operation, hash);
17
+ };
@@ -0,0 +1,51 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ import type { Account, AccountLike } from "../../types";
3
+ import { getMainAccount } from "../../account";
4
+ import type { AlgorandTransaction } from "./types";
5
+ import { computeAlgoMaxSpendable } from "./logic";
6
+ import { createTransaction } from "./js-prepareTransaction";
7
+ import { getAbandonSeedAddress } from "@ledgerhq/cryptoassets";
8
+
9
+ export const estimateMaxSpendable = async ({
10
+ account,
11
+ parentAccount,
12
+ transaction,
13
+ }: {
14
+ account: AccountLike;
15
+ parentAccount?: Account | null | undefined;
16
+ transaction?: AlgorandTransaction | null | undefined;
17
+ }): Promise<BigNumber> => {
18
+ const mainAccount = getMainAccount(account, parentAccount);
19
+ const { algorandResources } = mainAccount;
20
+ if (!algorandResources) {
21
+ throw new Error("Algorand account expected");
22
+ }
23
+
24
+ const tx = {
25
+ ...createTransaction(),
26
+ subAccountId: account.type === "Account" ? null : account.id,
27
+ ...transaction,
28
+ recipient:
29
+ transaction?.recipient || getAbandonSeedAddress(mainAccount.currency.id),
30
+ useAllAmount: true,
31
+ };
32
+
33
+ const tokenAccount =
34
+ tx.subAccountId &&
35
+ mainAccount.subAccounts &&
36
+ mainAccount.subAccounts.find((ta) => ta.id === tx.subAccountId);
37
+
38
+ if (tokenAccount) {
39
+ return tokenAccount.balance;
40
+ } else {
41
+ let maxSpendable = computeAlgoMaxSpendable({
42
+ accountBalance: mainAccount.balance,
43
+ nbAccountAssets: algorandResources.nbAssets,
44
+ mode: tx.mode,
45
+ });
46
+ if (tx.fees) {
47
+ maxSpendable = maxSpendable.minus(tx.fees);
48
+ }
49
+ return maxSpendable.gte(0) ? maxSpendable : new BigNumber(0);
50
+ }
51
+ };