@ledgerhq/live-common 31.6.0 → 31.7.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 (255) hide show
  1. package/lib/account/helpers.d.ts.map +1 -1
  2. package/lib/account/helpers.js +0 -5
  3. package/lib/account/helpers.js.map +1 -1
  4. package/lib/bot/engine.d.ts.map +1 -1
  5. package/lib/bot/engine.js +6 -0
  6. package/lib/bot/engine.js.map +1 -1
  7. package/lib/config/defaultConfig.js +1 -1
  8. package/lib/config/defaultConfig.js.map +1 -1
  9. package/lib/cross.d.ts +6 -1
  10. package/lib/cross.d.ts.map +1 -1
  11. package/lib/cross.js +12 -2
  12. package/lib/cross.js.map +1 -1
  13. package/lib/cross.test.js +7 -0
  14. package/lib/cross.test.js.map +1 -1
  15. package/lib/exchange/swap/api/v5/__tests__/fetchCurrencyFrom.spec.js +3 -2
  16. package/lib/exchange/swap/api/v5/__tests__/fetchCurrencyFrom.spec.js.map +1 -1
  17. package/lib/exchange/swap/api/v5/__tests__/fetchCurrencyTo.spec.js +5 -4
  18. package/lib/exchange/swap/api/v5/__tests__/fetchCurrencyTo.spec.js.map +1 -1
  19. package/lib/exchange/swap/api/v5/fetchCurrencyFrom.d.ts +1 -1
  20. package/lib/exchange/swap/api/v5/fetchCurrencyFrom.d.ts.map +1 -1
  21. package/lib/exchange/swap/api/v5/fetchCurrencyFrom.js +5 -3
  22. package/lib/exchange/swap/api/v5/fetchCurrencyFrom.js.map +1 -1
  23. package/lib/exchange/swap/api/v5/fetchCurrencyTo.d.ts +2 -2
  24. package/lib/exchange/swap/api/v5/fetchCurrencyTo.d.ts.map +1 -1
  25. package/lib/exchange/swap/api/v5/fetchCurrencyTo.js +7 -5
  26. package/lib/exchange/swap/api/v5/fetchCurrencyTo.js.map +1 -1
  27. package/lib/exchange/swap/api/v5/fetchRates.d.ts +10 -0
  28. package/lib/exchange/swap/api/v5/fetchRates.d.ts.map +1 -0
  29. package/lib/exchange/swap/api/v5/fetchRates.js +53 -0
  30. package/lib/exchange/swap/api/v5/fetchRates.js.map +1 -0
  31. package/lib/exchange/swap/completeExchange.d.ts.map +1 -1
  32. package/lib/exchange/swap/completeExchange.js +2 -1
  33. package/lib/exchange/swap/completeExchange.js.map +1 -1
  34. package/lib/exchange/swap/hooks/v5/useFetchCurrencyFrom.d.ts +13 -0
  35. package/lib/exchange/swap/hooks/v5/useFetchCurrencyFrom.d.ts.map +1 -0
  36. package/lib/exchange/swap/hooks/v5/useFetchCurrencyFrom.js +21 -0
  37. package/lib/exchange/swap/hooks/v5/useFetchCurrencyFrom.js.map +1 -0
  38. package/lib/exchange/swap/hooks/v5/useFetchCurrencyTo.d.ts +13 -0
  39. package/lib/exchange/swap/hooks/v5/useFetchCurrencyTo.d.ts.map +1 -0
  40. package/lib/exchange/swap/hooks/v5/useFetchCurrencyTo.js +25 -0
  41. package/lib/exchange/swap/hooks/v5/useFetchCurrencyTo.js.map +1 -0
  42. package/lib/exchange/swap/hooks/v5/useFetchRates.d.ts +18 -0
  43. package/lib/exchange/swap/hooks/v5/useFetchRates.d.ts.map +1 -0
  44. package/lib/exchange/swap/hooks/v5/useFetchRates.js +28 -0
  45. package/lib/exchange/swap/hooks/v5/useFetchRates.js.map +1 -0
  46. package/lib/exchange/swap/types.d.ts +24 -0
  47. package/lib/exchange/swap/types.d.ts.map +1 -1
  48. package/lib/exchange/swap/utils/flattenV5CurrenciesToAndFrom.d.ts +4 -0
  49. package/lib/exchange/swap/utils/flattenV5CurrenciesToAndFrom.d.ts.map +1 -0
  50. package/lib/exchange/swap/utils/flattenV5CurrenciesToAndFrom.js +9 -0
  51. package/lib/exchange/swap/utils/flattenV5CurrenciesToAndFrom.js.map +1 -0
  52. package/lib/exchange/swap/webApp/index.d.ts +2 -0
  53. package/lib/exchange/swap/webApp/index.d.ts.map +1 -0
  54. package/lib/exchange/swap/webApp/index.js +18 -0
  55. package/lib/exchange/swap/webApp/index.js.map +1 -0
  56. package/lib/exchange/swap/webApp/utils.d.ts +31 -0
  57. package/lib/exchange/swap/webApp/utils.d.ts.map +1 -0
  58. package/lib/exchange/swap/webApp/utils.js +43 -0
  59. package/lib/exchange/swap/webApp/utils.js.map +1 -0
  60. package/lib/families/cosmos/account.js +8 -8
  61. package/lib/families/cosmos/account.js.map +1 -1
  62. package/lib/families/cosmos/api/Cosmos.d.ts +4 -0
  63. package/lib/families/cosmos/api/Cosmos.d.ts.map +1 -1
  64. package/lib/families/cosmos/api/Cosmos.js +3 -1
  65. package/lib/families/cosmos/api/Cosmos.js.map +1 -1
  66. package/lib/families/cosmos/banner.test.js +1 -0
  67. package/lib/families/cosmos/banner.test.js.map +1 -1
  68. package/lib/families/cosmos/chain/Osmosis.d.ts.map +1 -1
  69. package/lib/families/cosmos/chain/Osmosis.js +0 -2
  70. package/lib/families/cosmos/chain/Osmosis.js.map +1 -1
  71. package/lib/families/cosmos/chain/cosmosBase.d.ts +0 -2
  72. package/lib/families/cosmos/chain/cosmosBase.d.ts.map +1 -1
  73. package/lib/families/cosmos/chain/cosmosBase.js +0 -2
  74. package/lib/families/cosmos/chain/cosmosBase.js.map +1 -1
  75. package/lib/families/cosmos/datasets/cosmos.d.ts.map +1 -1
  76. package/lib/families/cosmos/datasets/cosmos.js +15 -13
  77. package/lib/families/cosmos/datasets/cosmos.js.map +1 -1
  78. package/lib/families/cosmos/js-synchronisation.d.ts.map +1 -1
  79. package/lib/families/cosmos/js-synchronisation.js +2 -1
  80. package/lib/families/cosmos/js-synchronisation.js.map +1 -1
  81. package/lib/families/cosmos/js-synchronisation.unit.test.js +1 -0
  82. package/lib/families/cosmos/js-synchronisation.unit.test.js.map +1 -1
  83. package/lib/families/cosmos/mock.d.ts.map +1 -1
  84. package/lib/families/cosmos/mock.js +6 -0
  85. package/lib/families/cosmos/mock.js.map +1 -1
  86. package/lib/families/cosmos/serialization.d.ts.map +1 -1
  87. package/lib/families/cosmos/serialization.js +4 -2
  88. package/lib/families/cosmos/serialization.js.map +1 -1
  89. package/lib/families/cosmos/specs.d.ts +45 -33
  90. package/lib/families/cosmos/specs.d.ts.map +1 -1
  91. package/lib/families/cosmos/specs.js +102 -41
  92. package/lib/families/cosmos/specs.js.map +1 -1
  93. package/lib/families/cosmos/types.d.ts +2 -0
  94. package/lib/families/cosmos/types.d.ts.map +1 -1
  95. package/lib/families/elrond/specs.d.ts.map +1 -1
  96. package/lib/families/elrond/specs.js.map +1 -1
  97. package/lib/families/polkadot/bridge/mock.d.ts.map +1 -1
  98. package/lib/families/polkadot/bridge/mock.js +105 -102
  99. package/lib/families/polkadot/bridge/mock.js.map +1 -1
  100. package/lib/generated/specs.d.ts +44 -33
  101. package/lib/generated/specs.d.ts.map +1 -1
  102. package/lib/hooks/useAPI.d.ts +20 -0
  103. package/lib/hooks/useAPI.d.ts.map +1 -0
  104. package/lib/hooks/useAPI.js +62 -0
  105. package/lib/hooks/useAPI.js.map +1 -0
  106. package/lib/mock/account.d.ts.map +1 -1
  107. package/lib/mock/account.js +1 -0
  108. package/lib/mock/account.js.map +1 -1
  109. package/lib-es/account/helpers.d.ts.map +1 -1
  110. package/lib-es/account/helpers.js +0 -5
  111. package/lib-es/account/helpers.js.map +1 -1
  112. package/lib-es/bot/engine.d.ts.map +1 -1
  113. package/lib-es/bot/engine.js +6 -0
  114. package/lib-es/bot/engine.js.map +1 -1
  115. package/lib-es/config/defaultConfig.js +1 -1
  116. package/lib-es/config/defaultConfig.js.map +1 -1
  117. package/lib-es/cross.d.ts +6 -1
  118. package/lib-es/cross.d.ts.map +1 -1
  119. package/lib-es/cross.js +12 -2
  120. package/lib-es/cross.js.map +1 -1
  121. package/lib-es/cross.test.js +7 -0
  122. package/lib-es/cross.test.js.map +1 -1
  123. package/lib-es/exchange/swap/api/v5/__tests__/fetchCurrencyFrom.spec.js +3 -2
  124. package/lib-es/exchange/swap/api/v5/__tests__/fetchCurrencyFrom.spec.js.map +1 -1
  125. package/lib-es/exchange/swap/api/v5/__tests__/fetchCurrencyTo.spec.js +5 -4
  126. package/lib-es/exchange/swap/api/v5/__tests__/fetchCurrencyTo.spec.js.map +1 -1
  127. package/lib-es/exchange/swap/api/v5/fetchCurrencyFrom.d.ts +1 -1
  128. package/lib-es/exchange/swap/api/v5/fetchCurrencyFrom.d.ts.map +1 -1
  129. package/lib-es/exchange/swap/api/v5/fetchCurrencyFrom.js +5 -3
  130. package/lib-es/exchange/swap/api/v5/fetchCurrencyFrom.js.map +1 -1
  131. package/lib-es/exchange/swap/api/v5/fetchCurrencyTo.d.ts +2 -2
  132. package/lib-es/exchange/swap/api/v5/fetchCurrencyTo.d.ts.map +1 -1
  133. package/lib-es/exchange/swap/api/v5/fetchCurrencyTo.js +7 -5
  134. package/lib-es/exchange/swap/api/v5/fetchCurrencyTo.js.map +1 -1
  135. package/lib-es/exchange/swap/api/v5/fetchRates.d.ts +10 -0
  136. package/lib-es/exchange/swap/api/v5/fetchRates.d.ts.map +1 -0
  137. package/lib-es/exchange/swap/api/v5/fetchRates.js +46 -0
  138. package/lib-es/exchange/swap/api/v5/fetchRates.js.map +1 -0
  139. package/lib-es/exchange/swap/completeExchange.d.ts.map +1 -1
  140. package/lib-es/exchange/swap/completeExchange.js +2 -1
  141. package/lib-es/exchange/swap/completeExchange.js.map +1 -1
  142. package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyFrom.d.ts +13 -0
  143. package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyFrom.d.ts.map +1 -0
  144. package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyFrom.js +17 -0
  145. package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyFrom.js.map +1 -0
  146. package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyTo.d.ts +13 -0
  147. package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyTo.d.ts.map +1 -0
  148. package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyTo.js +21 -0
  149. package/lib-es/exchange/swap/hooks/v5/useFetchCurrencyTo.js.map +1 -0
  150. package/lib-es/exchange/swap/hooks/v5/useFetchRates.d.ts +18 -0
  151. package/lib-es/exchange/swap/hooks/v5/useFetchRates.d.ts.map +1 -0
  152. package/lib-es/exchange/swap/hooks/v5/useFetchRates.js +24 -0
  153. package/lib-es/exchange/swap/hooks/v5/useFetchRates.js.map +1 -0
  154. package/lib-es/exchange/swap/types.d.ts +24 -0
  155. package/lib-es/exchange/swap/types.d.ts.map +1 -1
  156. package/lib-es/exchange/swap/utils/flattenV5CurrenciesToAndFrom.d.ts +4 -0
  157. package/lib-es/exchange/swap/utils/flattenV5CurrenciesToAndFrom.d.ts.map +1 -0
  158. package/lib-es/exchange/swap/utils/flattenV5CurrenciesToAndFrom.js +5 -0
  159. package/lib-es/exchange/swap/utils/flattenV5CurrenciesToAndFrom.js.map +1 -0
  160. package/lib-es/exchange/swap/webApp/index.d.ts +2 -0
  161. package/lib-es/exchange/swap/webApp/index.d.ts.map +1 -0
  162. package/lib-es/exchange/swap/webApp/index.js +2 -0
  163. package/lib-es/exchange/swap/webApp/index.js.map +1 -0
  164. package/lib-es/exchange/swap/webApp/utils.d.ts +31 -0
  165. package/lib-es/exchange/swap/webApp/utils.d.ts.map +1 -0
  166. package/lib-es/exchange/swap/webApp/utils.js +38 -0
  167. package/lib-es/exchange/swap/webApp/utils.js.map +1 -0
  168. package/lib-es/families/cosmos/account.js +8 -8
  169. package/lib-es/families/cosmos/account.js.map +1 -1
  170. package/lib-es/families/cosmos/api/Cosmos.d.ts +4 -0
  171. package/lib-es/families/cosmos/api/Cosmos.d.ts.map +1 -1
  172. package/lib-es/families/cosmos/api/Cosmos.js +3 -1
  173. package/lib-es/families/cosmos/api/Cosmos.js.map +1 -1
  174. package/lib-es/families/cosmos/banner.test.js +1 -0
  175. package/lib-es/families/cosmos/banner.test.js.map +1 -1
  176. package/lib-es/families/cosmos/chain/Osmosis.d.ts.map +1 -1
  177. package/lib-es/families/cosmos/chain/Osmosis.js +0 -2
  178. package/lib-es/families/cosmos/chain/Osmosis.js.map +1 -1
  179. package/lib-es/families/cosmos/chain/cosmosBase.d.ts +0 -2
  180. package/lib-es/families/cosmos/chain/cosmosBase.d.ts.map +1 -1
  181. package/lib-es/families/cosmos/chain/cosmosBase.js +0 -2
  182. package/lib-es/families/cosmos/chain/cosmosBase.js.map +1 -1
  183. package/lib-es/families/cosmos/datasets/cosmos.d.ts.map +1 -1
  184. package/lib-es/families/cosmos/datasets/cosmos.js +15 -13
  185. package/lib-es/families/cosmos/datasets/cosmos.js.map +1 -1
  186. package/lib-es/families/cosmos/js-synchronisation.d.ts.map +1 -1
  187. package/lib-es/families/cosmos/js-synchronisation.js +2 -1
  188. package/lib-es/families/cosmos/js-synchronisation.js.map +1 -1
  189. package/lib-es/families/cosmos/js-synchronisation.unit.test.js +1 -0
  190. package/lib-es/families/cosmos/js-synchronisation.unit.test.js.map +1 -1
  191. package/lib-es/families/cosmos/mock.d.ts.map +1 -1
  192. package/lib-es/families/cosmos/mock.js +6 -0
  193. package/lib-es/families/cosmos/mock.js.map +1 -1
  194. package/lib-es/families/cosmos/serialization.d.ts.map +1 -1
  195. package/lib-es/families/cosmos/serialization.js +4 -2
  196. package/lib-es/families/cosmos/serialization.js.map +1 -1
  197. package/lib-es/families/cosmos/specs.d.ts +45 -33
  198. package/lib-es/families/cosmos/specs.d.ts.map +1 -1
  199. package/lib-es/families/cosmos/specs.js +102 -41
  200. package/lib-es/families/cosmos/specs.js.map +1 -1
  201. package/lib-es/families/cosmos/types.d.ts +2 -0
  202. package/lib-es/families/cosmos/types.d.ts.map +1 -1
  203. package/lib-es/families/elrond/specs.d.ts.map +1 -1
  204. package/lib-es/families/elrond/specs.js.map +1 -1
  205. package/lib-es/families/polkadot/bridge/mock.d.ts.map +1 -1
  206. package/lib-es/families/polkadot/bridge/mock.js +106 -103
  207. package/lib-es/families/polkadot/bridge/mock.js.map +1 -1
  208. package/lib-es/generated/specs.d.ts +44 -33
  209. package/lib-es/generated/specs.d.ts.map +1 -1
  210. package/lib-es/hooks/useAPI.d.ts +20 -0
  211. package/lib-es/hooks/useAPI.d.ts.map +1 -0
  212. package/lib-es/hooks/useAPI.js +58 -0
  213. package/lib-es/hooks/useAPI.js.map +1 -0
  214. package/lib-es/mock/account.d.ts.map +1 -1
  215. package/lib-es/mock/account.js +1 -0
  216. package/lib-es/mock/account.js.map +1 -1
  217. package/package.json +12 -12
  218. package/src/__snapshots__/cross.test.ts.snap +2 -0
  219. package/src/account/helpers.ts +0 -6
  220. package/src/bot/engine.ts +6 -0
  221. package/src/config/defaultConfig.ts +1 -1
  222. package/src/cross.test.ts +7 -0
  223. package/src/cross.ts +26 -2
  224. package/src/exchange/swap/api/v5/__tests__/fetchCurrencyFrom.spec.ts +3 -2
  225. package/src/exchange/swap/api/v5/__tests__/fetchCurrencyTo.spec.ts +5 -4
  226. package/src/exchange/swap/api/v5/fetchCurrencyFrom.ts +5 -3
  227. package/src/exchange/swap/api/v5/fetchCurrencyTo.ts +8 -5
  228. package/src/exchange/swap/api/v5/fetchRates.ts +48 -0
  229. package/src/exchange/swap/completeExchange.ts +2 -1
  230. package/src/exchange/swap/hooks/v5/useFetchCurrencyFrom.ts +23 -0
  231. package/src/exchange/swap/hooks/v5/useFetchCurrencyTo.ts +28 -0
  232. package/src/exchange/swap/hooks/v5/useFetchRates.ts +41 -0
  233. package/src/exchange/swap/types.ts +29 -0
  234. package/src/exchange/swap/utils/flattenV5CurrenciesToAndFrom.ts +7 -0
  235. package/src/exchange/swap/webApp/index.ts +1 -0
  236. package/src/exchange/swap/webApp/utils.ts +41 -0
  237. package/src/families/cosmos/account.ts +8 -8
  238. package/src/families/cosmos/api/Cosmos.ts +21 -10
  239. package/src/families/cosmos/banner.test.ts +1 -0
  240. package/src/families/cosmos/chain/Osmosis.ts +0 -2
  241. package/src/families/cosmos/chain/cosmosBase.ts +0 -3
  242. package/src/families/cosmos/datasets/__snapshots__/coreum.integration.test.ts.snap +0 -3
  243. package/src/families/cosmos/datasets/__snapshots__/cosmos.integration.test.ts.snap +259 -354
  244. package/src/families/cosmos/datasets/__snapshots__/onomy.integration.test.ts.snap +1 -235
  245. package/src/families/cosmos/datasets/cosmos.ts +15 -13
  246. package/src/families/cosmos/js-synchronisation.ts +11 -2
  247. package/src/families/cosmos/js-synchronisation.unit.test.ts +1 -0
  248. package/src/families/cosmos/mock.ts +6 -0
  249. package/src/families/cosmos/serialization.ts +4 -0
  250. package/src/families/cosmos/specs.ts +113 -54
  251. package/src/families/cosmos/types.ts +2 -0
  252. package/src/families/elrond/specs.ts +0 -1
  253. package/src/families/polkadot/bridge/mock.ts +109 -103
  254. package/src/hooks/useAPI.ts +81 -0
  255. package/src/mock/account.ts +1 -0
@@ -24,22 +24,37 @@ import type {
24
24
  Transaction,
25
25
  CosmosOperationRaw,
26
26
  } from "../../families/cosmos/types";
27
- import cryptoFactory from "./chain/chain";
28
27
  import { canDelegate, canRedelegate, canUndelegate, getMaxDelegationAvailable } from "./logic";
29
28
  import { acceptTransaction } from "./speculos-deviceActions";
30
29
  import { Operation } from "@ledgerhq/types-live";
30
+ import { BigNumber } from "bignumber.js";
31
+ import { log } from "@ledgerhq/logs";
31
32
 
32
33
  const maxAccounts = 16;
33
34
 
34
35
  // amounts of delegation are not exact so we are applying an approximation
35
- function approximateValue(value): string {
36
- return "~" + value.div(100).integerValue().times(100).toString();
36
+ function checkAmountsCloseEnough(amount1: BigNumber | string, amount2: BigNumber | string) {
37
+ amount1 = new BigNumber(amount1);
38
+ amount2 = new BigNumber(amount2);
39
+ expect(amount1.isNegative()).toBe(false);
40
+ expect(amount2.isNegative()).toBe(false);
41
+ const difference = amount1.minus(amount2).absoluteValue();
42
+ const onePercentOfLargerNumber = BigNumber.max(amount1, amount2).multipliedBy(0.01);
43
+ const isCloseEnough = difference.isLessThan(onePercentOfLargerNumber);
44
+ if (!isCloseEnough) {
45
+ log(
46
+ "bot",
47
+ "delegation amounts do not match",
48
+ `Amount1: ${amount1.toString()} , Amount2: ${amount2.toString()}`,
49
+ );
50
+ }
51
+ expect(isCloseEnough).toBe(true);
37
52
  }
38
53
 
39
- function approximateExtra(extra: CosmosOperationExtraRaw) {
54
+ function extraWithoutAmount(extra: CosmosOperationExtraRaw) {
40
55
  if (extra.validators && Array.isArray(extra.validators)) {
41
56
  extra.validators = extra.validators.map((validator: CosmosDelegationInfoRaw) => {
42
- return { ...validator, amount: approximateValue(validator.amount) };
57
+ return { ...validator, amount: "" };
43
58
  });
44
59
  }
45
60
  return extra;
@@ -74,18 +89,30 @@ const cosmosLikeTest: ({
74
89
  delete opExpected.blockHeight;
75
90
  delete opExpected.extra;
76
91
  delete opExpected.transactionSequenceNumber;
92
+ delete opExpected.nftOperations;
77
93
 
78
94
  const op: Partial<CosmosOperationRaw> = toOperationRaw(operation) as CosmosOperationRaw;
79
95
  const opExtra: CosmosOperationExtraRaw = op.extra || {};
80
96
  delete op.extra;
81
97
 
82
98
  botTest("optimistic operation matches op", () => expect(op).toMatchObject(opExpected));
83
- botTest("operation extra matches", () =>
84
- expect(approximateExtra(opExtra)).toMatchObject(approximateExtra(expectedExtra)),
85
- );
99
+ botTest("operation extra matches", () => {
100
+ // compare the validators amount firstly
101
+ if (
102
+ expectedExtra.validators &&
103
+ Array.isArray(expectedExtra.validators) &&
104
+ expectedExtra.validators.length > 0
105
+ ) {
106
+ for (let i = 0; i < expectedExtra.validators.length; i++) {
107
+ checkAmountsCloseEnough(opExtra.validators![i].amount, expectedExtra.validators[i].amount);
108
+ }
109
+ }
110
+ // compare the rest of the extra, except the amount
111
+ expect(extraWithoutAmount(opExtra)).toMatchObject(extraWithoutAmount(expectedExtra));
112
+ });
86
113
  };
87
114
 
88
- function cosmosLikeMutations(currency: string): MutationSpec<Transaction>[] {
115
+ function cosmosLikeMutations(minimalTransactionAmount: BigNumber): MutationSpec<Transaction>[] {
89
116
  return [
90
117
  {
91
118
  name: "send some",
@@ -97,6 +124,7 @@ function cosmosLikeMutations(currency: string): MutationSpec<Transaction>[] {
97
124
  );
98
125
  },
99
126
  transaction: ({ account, siblings, bridge, maxSpendable }) => {
127
+ invariant(maxSpendable.gt(minimalTransactionAmount), "balance is too low for send");
100
128
  const amount = maxSpendable.times(0.3 + 0.4 * Math.random()).integerValue();
101
129
  invariant(amount.gt(0), "random amount to be positive");
102
130
  return {
@@ -121,7 +149,8 @@ function cosmosLikeMutations(currency: string): MutationSpec<Transaction>[] {
121
149
  name: "send max",
122
150
  maxRun: 1,
123
151
  testDestination: genericTestDestination,
124
- transaction: ({ account, siblings, bridge }) => {
152
+ transaction: ({ account, siblings, bridge, maxSpendable }) => {
153
+ invariant(maxSpendable.gt(minimalTransactionAmount), "balance is too low for send max");
125
154
  return {
126
155
  transaction: bridge.createTransaction(account),
127
156
  updates: [
@@ -156,7 +185,7 @@ function cosmosLikeMutations(currency: string): MutationSpec<Transaction>[] {
156
185
  const data = getCurrentCosmosPreloadData()[account.currency.id];
157
186
  const count = 1; // we'r always going to have only one validator because of the new delegation flow.
158
187
  let remaining = getMaxDelegationAvailable(account as CosmosAccount, count)
159
- .minus(cryptoFactory(currency).minimalTransactionAmount.times(2))
188
+ .minus(minimalTransactionAmount.times(2))
160
189
  .times(0.1 * Math.random());
161
190
  invariant(remaining.gt(0), "not enough funds in account for delegate");
162
191
  const all = data.validators.filter(
@@ -201,25 +230,21 @@ function cosmosLikeMutations(currency: string): MutationSpec<Transaction>[] {
201
230
  d => d.validatorAddress === v.address,
202
231
  );
203
232
  invariant(d, "delegated %s must be found in account", v.address);
204
- botTest("delegator have planned address and amount", () =>
205
- expect({
206
- address: v.address,
207
- amount: approximateValue(v.amount),
208
- }).toMatchObject({
209
- address: (d as CosmosDelegation).validatorAddress,
210
- amount: approximateValue((d as CosmosDelegation).amount),
211
- }),
212
- );
233
+ botTest("delegator have planned address and amount", () => {
234
+ expect(v.address).toBe((d as CosmosDelegation).validatorAddress);
235
+ checkAmountsCloseEnough(v.amount, (d as CosmosDelegation).amount);
236
+ });
213
237
  });
214
238
  },
215
239
  },
216
240
  {
217
241
  name: "undelegate",
218
242
  maxRun: 5,
219
- transaction: ({ account, bridge }) => {
243
+ transaction: ({ account, bridge, maxSpendable }) => {
220
244
  invariant(canUndelegate(account as CosmosAccount), "can undelegate");
221
245
  const { cosmosResources } = account as CosmosAccount;
222
246
  invariant(cosmosResources, "cosmos");
247
+ invariant(maxSpendable.gt(minimalTransactionAmount.times(2)), "balance is too low");
223
248
  invariant(
224
249
  (cosmosResources as CosmosResources).delegations.length > 0,
225
250
  "already enough delegations",
@@ -270,24 +295,23 @@ function cosmosLikeMutations(currency: string): MutationSpec<Transaction>[] {
270
295
  d => d.validatorAddress === v.address,
271
296
  );
272
297
  invariant(d, "undelegated %s must be found in account", v.address);
273
- botTest("validator have planned address and amount", () =>
274
- expect({
275
- address: v.address,
276
- amount: approximateValue(v.amount),
277
- }).toMatchObject({
278
- address: (d as CosmosUnbonding).validatorAddress,
279
- amount: approximateValue((d as CosmosUnbonding).amount),
280
- }),
281
- );
298
+ botTest("validator have planned address and amount", () => {
299
+ expect(v.address).toBe((d as CosmosUnbonding).validatorAddress);
300
+ checkAmountsCloseEnough(v.amount, (d as CosmosUnbonding).amount);
301
+ });
282
302
  });
283
303
  },
284
304
  },
285
305
  {
286
306
  name: "redelegate",
287
307
  maxRun: 1,
288
- transaction: ({ account, bridge }) => {
308
+ transaction: ({ account, bridge, maxSpendable }) => {
289
309
  const { cosmosResources } = account as CosmosAccount;
290
310
  invariant(cosmosResources, "cosmos");
311
+ invariant(
312
+ maxSpendable.gt(minimalTransactionAmount.times(3)),
313
+ "balance is too low for redelegate",
314
+ );
291
315
  const sourceDelegation = sample(
292
316
  (cosmosResources as CosmosResources).delegations.filter(d =>
293
317
  canRedelegate(account as CosmosAccount, d),
@@ -346,15 +370,10 @@ function cosmosLikeMutations(currency: string): MutationSpec<Transaction>[] {
346
370
  d.validatorSrcAddress === transaction.sourceValidator,
347
371
  );
348
372
  invariant(d, "redelegated %s must be found in account", v.address);
349
- botTest("validator have planned address and amount", () =>
350
- expect({
351
- address: v.address,
352
- amount: approximateValue(v.amount),
353
- }).toMatchObject({
354
- address: (d as CosmosRedelegation).validatorDstAddress,
355
- amount: approximateValue((d as CosmosRedelegation).amount),
356
- }),
357
- );
373
+ botTest("validator have planned address and amount", () => {
374
+ expect(v.address).toBe((d as CosmosRedelegation).validatorDstAddress);
375
+ checkAmountsCloseEnough(v.amount, (d as CosmosRedelegation).amount);
376
+ });
358
377
  }
359
378
  });
360
379
  },
@@ -362,9 +381,13 @@ function cosmosLikeMutations(currency: string): MutationSpec<Transaction>[] {
362
381
  {
363
382
  name: "claim rewards",
364
383
  maxRun: 1,
365
- transaction: ({ account, bridge }) => {
384
+ transaction: ({ account, bridge, maxSpendable }) => {
366
385
  const { cosmosResources } = account as CosmosAccount;
367
386
  invariant(cosmosResources, "cosmos");
387
+ invariant(
388
+ maxSpendable.gt(minimalTransactionAmount.times(2)),
389
+ "balance is too low for claim rewards",
390
+ );
368
391
  const delegation = sample(
369
392
  (cosmosResources as CosmosResources).delegations.filter(d => d.pendingRewards.gt(1000)),
370
393
  ) as CosmosDelegation;
@@ -417,73 +440,109 @@ const generateGenericCosmosTest = (currencyId: string, config?: Partial<AppSpec<
417
440
  },
418
441
  genericDeviceAction: acceptTransaction,
419
442
  testTimeout: 2 * 60 * 1000,
420
- minViableAmount: cryptoFactory(currencyId).minimalTransactionAmount,
421
- transactionCheck: ({ maxSpendable }) => {
422
- invariant(
423
- maxSpendable.gt(cryptoFactory(currencyId).minimalTransactionAmount),
424
- "balance is too low",
425
- );
426
- },
427
443
  test: cosmosLikeTest,
428
- mutations: cosmosLikeMutations(currencyId),
429
444
  ...config,
430
445
  };
431
446
  };
432
447
 
448
+ // In the bot tests, when we make a transaction ,we should make sure that the spendable balance is greater than minimalTransactionAmount.
449
+ // We usually use the upper limit of send transaction fee as the minimalTransactionAmount. e.g. 5000 uatom for cosmos.
450
+ const cosmosMinimalTransactionAmount = new BigNumber(5000);
433
451
  const cosmos = {
434
- ...generateGenericCosmosTest("cosmos"),
452
+ ...generateGenericCosmosTest("cosmos", {
453
+ minViableAmount: cosmosMinimalTransactionAmount,
454
+ mutations: cosmosLikeMutations(cosmosMinimalTransactionAmount),
455
+ }),
435
456
  };
436
457
 
458
+ const osmosisMinimalTransactionAmount = new BigNumber(5000);
437
459
  const osmosis = {
438
460
  ...generateGenericCosmosTest("osmosis", {
461
+ minViableAmount: osmosisMinimalTransactionAmount,
462
+ mutations: cosmosLikeMutations(osmosisMinimalTransactionAmount),
439
463
  testTimeout: 8 * 60 * 1000,
440
464
  }),
441
465
  };
442
466
 
467
+ const desmosMinimalTransactionAmount = new BigNumber(500);
443
468
  const desmos = {
444
469
  ...generateGenericCosmosTest("desmos", {
470
+ minViableAmount: desmosMinimalTransactionAmount,
471
+ mutations: cosmosLikeMutations(desmosMinimalTransactionAmount),
445
472
  testTimeout: 8 * 60 * 1000,
473
+ skipOperationHistory: true,
446
474
  }),
447
475
  };
448
476
 
477
+ const umeeMinimalTransactionAmount = new BigNumber(15000);
449
478
  const umee = {
450
479
  ...generateGenericCosmosTest("umee", {
480
+ minViableAmount: umeeMinimalTransactionAmount,
481
+ mutations: cosmosLikeMutations(umeeMinimalTransactionAmount),
451
482
  testTimeout: 8 * 60 * 1000,
483
+ skipOperationHistory: true,
452
484
  }),
453
485
  };
454
486
 
487
+ const persistenceMinimalTransactionAmount = new BigNumber(5000);
455
488
  const persistence = {
456
489
  ...generateGenericCosmosTest("persistence", {
490
+ minViableAmount: persistenceMinimalTransactionAmount,
491
+ mutations: cosmosLikeMutations(persistenceMinimalTransactionAmount),
457
492
  testTimeout: 8 * 60 * 1000,
458
493
  }),
459
494
  };
460
495
 
496
+ const quicksilverMinimalTransactionAmount = new BigNumber(600);
461
497
  const quicksilver = {
462
498
  ...generateGenericCosmosTest("quicksilver", {
499
+ minViableAmount: quicksilverMinimalTransactionAmount,
500
+ mutations: cosmosLikeMutations(quicksilverMinimalTransactionAmount),
463
501
  testTimeout: 8 * 60 * 1000,
502
+ skipOperationHistory: true,
464
503
  }),
465
504
  };
466
505
 
506
+ const onomyMinimalTransactionAmount = new BigNumber(5000);
467
507
  const onomy = {
468
508
  ...generateGenericCosmosTest("onomy", {
509
+ minViableAmount: onomyMinimalTransactionAmount,
510
+ mutations: cosmosLikeMutations(onomyMinimalTransactionAmount),
469
511
  testTimeout: 8 * 60 * 1000,
470
512
  }),
471
513
  };
472
514
 
515
+ const axelarMinimalTransactionAmount = new BigNumber(10000);
473
516
  const axelar = {
474
- ...generateGenericCosmosTest("axelar"),
517
+ ...generateGenericCosmosTest("axelar", {
518
+ minViableAmount: axelarMinimalTransactionAmount,
519
+ mutations: cosmosLikeMutations(axelarMinimalTransactionAmount),
520
+ skipOperationHistory: true,
521
+ }),
475
522
  };
476
523
 
524
+ const secretNetworkMinimalTransactionAmount = new BigNumber(60000);
477
525
  const secretNetwork = {
478
- ...generateGenericCosmosTest("secret_network"),
526
+ ...generateGenericCosmosTest("secret_network", {
527
+ minViableAmount: secretNetworkMinimalTransactionAmount,
528
+ mutations: cosmosLikeMutations(secretNetworkMinimalTransactionAmount),
529
+ }),
479
530
  };
480
531
 
532
+ const stargazeMinimalTransactionAmount = new BigNumber(160000);
481
533
  const stargaze = {
482
- ...generateGenericCosmosTest("stargaze"),
534
+ ...generateGenericCosmosTest("stargaze", {
535
+ minViableAmount: stargazeMinimalTransactionAmount,
536
+ mutations: cosmosLikeMutations(stargazeMinimalTransactionAmount),
537
+ }),
483
538
  };
484
539
 
540
+ const coreumMinimalTransactionAmount = new BigNumber(20000);
485
541
  const coreum = {
486
- ...generateGenericCosmosTest("coreum"),
542
+ ...generateGenericCosmosTest("coreum", {
543
+ minViableAmount: coreumMinimalTransactionAmount,
544
+ mutations: cosmosLikeMutations(coreumMinimalTransactionAmount),
545
+ }),
487
546
  };
488
547
 
489
548
  export default {
@@ -62,6 +62,7 @@ export type CosmosResources = {
62
62
  pendingRewardsBalance: BigNumber;
63
63
  unbondingBalance: BigNumber;
64
64
  withdrawAddress: string;
65
+ sequence: number;
65
66
  };
66
67
  export type CosmosDelegationRaw = {
67
68
  validatorAddress: string;
@@ -88,6 +89,7 @@ export type CosmosResourcesRaw = {
88
89
  pendingRewardsBalance: string;
89
90
  unbondingBalance: string;
90
91
  withdrawAddress: string;
92
+ sequence: number;
91
93
  };
92
94
  // NB this must be serializable (no Date, no BigNumber)
93
95
  export type CosmosValidatorItem = {
@@ -121,7 +121,6 @@ function expectCorrectOptimisticOperation(input: TransactionTestInput<Transactio
121
121
  optimisticOperation.transactionSequenceNumber,
122
122
  ),
123
123
  );
124
-
125
124
  botTest("raw optimistic operation matches", () =>
126
125
  expect(toOperationRaw(operation)).toMatchObject(opExpected),
127
126
  );
@@ -64,7 +64,9 @@ const getTransactionStatus = (account: PolkadotAccount, t: Transaction) => {
64
64
  if (!t.recipient) {
65
65
  errors.recipient = new RecipientRequired("");
66
66
  } else if (isInvalidRecipient(t.recipient)) {
67
- errors.recipient = new InvalidAddress("");
67
+ errors.recipient = new InvalidAddress("", {
68
+ currencyName: account.currency.name,
69
+ });
68
70
  }
69
71
 
70
72
  return Promise.resolve({
@@ -97,111 +99,115 @@ const accountBridge: AccountBridge<Transaction> = {
97
99
  signOperation,
98
100
  broadcast,
99
101
  };
102
+
103
+ const preload = () => {
104
+ return Promise.resolve({
105
+ validators: [
106
+ {
107
+ address: "111B8CxcmnWbuDLyGvgUmRezDCK1brRZmvUuQ6SrFdMyc3S",
108
+ identity: "",
109
+ nominatorsCount: 84,
110
+ rewardPoints: "28220",
111
+ commission: "1",
112
+ totalBonded: "19189935927996803",
113
+ selfBonded: "0",
114
+ isElected: true,
115
+ isOversubscribed: false,
116
+ },
117
+ {
118
+ address: "114SUbKCXjmb9czpWTtS3JANSmNRwVa4mmsMrWYpRG1kDH5",
119
+ identity: "BINANCE_STAKE_9",
120
+ nominatorsCount: 58,
121
+ rewardPoints: "45700",
122
+ commission: "1",
123
+ totalBonded: "19978546965782204",
124
+ selfBonded: "0",
125
+ isElected: true,
126
+ isOversubscribed: false,
127
+ },
128
+ {
129
+ address: "11VR4pF6c7kfBhfmuwwjWY3FodeYBKWx7ix2rsRCU2q6hqJ",
130
+ identity: "🐑 HODL.FARM 🐑 - C",
131
+ nominatorsCount: 498,
132
+ rewardPoints: "35440",
133
+ commission: "0.008",
134
+ totalBonded: "19983183606433211",
135
+ selfBonded: "8214924206368",
136
+ isElected: true,
137
+ isOversubscribed: false,
138
+ },
139
+ {
140
+ address: "11uMPbeaEDJhUxzU4ZfWW9VQEsryP9XqFcNRfPdYda6aFWJ",
141
+ identity: "P2P.ORG - 4",
142
+ nominatorsCount: 406,
143
+ rewardPoints: "83240",
144
+ commission: "0.025",
145
+ totalBonded: "19983278498651499",
146
+ selfBonded: "0",
147
+ isElected: true,
148
+ isOversubscribed: false,
149
+ },
150
+ {
151
+ address: "13mK8AssyPekT5cFuYQ7ijKNXcjHPq8Gnx6TxF5eFCAwoLQ",
152
+ identity: "HYPERSPHERE - 5",
153
+ nominatorsCount: 457,
154
+ rewardPoints: "83100",
155
+ commission: "0.03",
156
+ totalBonded: "19983182481092181",
157
+ selfBonded: "11099882066510",
158
+ isElected: true,
159
+ isOversubscribed: false,
160
+ },
161
+ {
162
+ address: "14QRY2UTErfZCqVMFVRmgbeUt7XQdeCVgNUV1XqDcza4g9E",
163
+ identity: "",
164
+ nominatorsCount: 1,
165
+ rewardPoints: "64600",
166
+ commission: "1",
167
+ totalBonded: "20294901840238041",
168
+ selfBonded: "0",
169
+ isElected: true,
170
+ isOversubscribed: false,
171
+ },
172
+ {
173
+ address: "17bR6rzVsVrzVJS1hM4dSJU43z2MUmz7ZDpPLh8y2fqVg7m",
174
+ identity: "",
175
+ nominatorsCount: 3,
176
+ rewardPoints: "60160",
177
+ commission: "1",
178
+ totalBonded: "25412727149722391",
179
+ selfBonded: "15697837257290",
180
+ isElected: true,
181
+ isOversubscribed: false,
182
+ },
183
+ {
184
+ address: "19K3AKAkcrVWcXrXCXJ1fbaySuo58kUXhpsh7gBpa6emdgz",
185
+ identity: "",
186
+ nominatorsCount: 21,
187
+ rewardPoints: "36960",
188
+ commission: "1",
189
+ totalBonded: "17669588437879800",
190
+ selfBonded: "0",
191
+ isElected: true,
192
+ isOversubscribed: false,
193
+ },
194
+ ],
195
+ staking: {
196
+ activeEra: 1123,
197
+ electionClosed: true,
198
+ maxNominatorRewardedPerValidator: 512,
199
+ bondingDuration: 28,
200
+ },
201
+ minimumBondBalance: "2500000000000",
202
+ });
203
+ };
204
+
100
205
  const currencyBridge: CurrencyBridge = {
101
206
  scanAccounts,
102
- preload: () => {
103
- return Promise.resolve({
104
- validators: [
105
- {
106
- address: "111B8CxcmnWbuDLyGvgUmRezDCK1brRZmvUuQ6SrFdMyc3S",
107
- identity: "",
108
- nominatorsCount: 84,
109
- rewardPoints: "28220",
110
- commission: "1",
111
- totalBonded: "19189935927996803",
112
- selfBonded: "0",
113
- isElected: true,
114
- isOversubscribed: false,
115
- },
116
- {
117
- address: "114SUbKCXjmb9czpWTtS3JANSmNRwVa4mmsMrWYpRG1kDH5",
118
- identity: "BINANCE_STAKE_9",
119
- nominatorsCount: 58,
120
- rewardPoints: "45700",
121
- commission: "1",
122
- totalBonded: "19978546965782204",
123
- selfBonded: "0",
124
- isElected: true,
125
- isOversubscribed: false,
126
- },
127
- {
128
- address: "11VR4pF6c7kfBhfmuwwjWY3FodeYBKWx7ix2rsRCU2q6hqJ",
129
- identity: "🐑 HODL.FARM 🐑 - C",
130
- nominatorsCount: 498,
131
- rewardPoints: "35440",
132
- commission: "0.008",
133
- totalBonded: "19983183606433211",
134
- selfBonded: "8214924206368",
135
- isElected: true,
136
- isOversubscribed: false,
137
- },
138
- {
139
- address: "11uMPbeaEDJhUxzU4ZfWW9VQEsryP9XqFcNRfPdYda6aFWJ",
140
- identity: "P2P.ORG - 4",
141
- nominatorsCount: 406,
142
- rewardPoints: "83240",
143
- commission: "0.025",
144
- totalBonded: "19983278498651499",
145
- selfBonded: "0",
146
- isElected: true,
147
- isOversubscribed: false,
148
- },
149
- {
150
- address: "13mK8AssyPekT5cFuYQ7ijKNXcjHPq8Gnx6TxF5eFCAwoLQ",
151
- identity: "HYPERSPHERE - 5",
152
- nominatorsCount: 457,
153
- rewardPoints: "83100",
154
- commission: "0.03",
155
- totalBonded: "19983182481092181",
156
- selfBonded: "11099882066510",
157
- isElected: true,
158
- isOversubscribed: false,
159
- },
160
- {
161
- address: "14QRY2UTErfZCqVMFVRmgbeUt7XQdeCVgNUV1XqDcza4g9E",
162
- identity: "",
163
- nominatorsCount: 1,
164
- rewardPoints: "64600",
165
- commission: "1",
166
- totalBonded: "20294901840238041",
167
- selfBonded: "0",
168
- isElected: true,
169
- isOversubscribed: false,
170
- },
171
- {
172
- address: "17bR6rzVsVrzVJS1hM4dSJU43z2MUmz7ZDpPLh8y2fqVg7m",
173
- identity: "",
174
- nominatorsCount: 3,
175
- rewardPoints: "60160",
176
- commission: "1",
177
- totalBonded: "25412727149722391",
178
- selfBonded: "15697837257290",
179
- isElected: true,
180
- isOversubscribed: false,
181
- },
182
- {
183
- address: "19K3AKAkcrVWcXrXCXJ1fbaySuo58kUXhpsh7gBpa6emdgz",
184
- identity: "",
185
- nominatorsCount: 21,
186
- rewardPoints: "36960",
187
- commission: "1",
188
- totalBonded: "17669588437879800",
189
- selfBonded: "0",
190
- isElected: true,
191
- isOversubscribed: false,
192
- },
193
- ],
194
- staking: {
195
- activeEra: 1123,
196
- electionClosed: true,
197
- maxNominatorRewardedPerValidator: 512,
198
- bondingDuration: 28,
199
- },
200
- minimumBondBalance: "2500000000000",
201
- });
202
- },
203
- hydrate: hydrate,
207
+ preload,
208
+ hydrate,
204
209
  };
210
+
205
211
  export default {
206
212
  currencyBridge,
207
213
  accountBridge,
@@ -0,0 +1,81 @@
1
+ import { useState, useEffect, useCallback } from "react";
2
+
3
+ type AsyncFn<T, P = undefined> = P extends undefined ? () => Promise<T> : (props: P) => Promise<T>;
4
+
5
+ type UseAsyncReturn<T> = {
6
+ data: T | undefined;
7
+ isLoading: boolean;
8
+ error: Error | undefined;
9
+ refetch: () => void;
10
+ };
11
+
12
+ export type ApiOptions<T> = {
13
+ enabled?: boolean;
14
+ staleTimeout?: number;
15
+ onSuccess?(data: T): void;
16
+ onError?(error: unknown): void;
17
+ };
18
+
19
+ type Props<T, P> = ApiOptions<T> & {
20
+ queryFn: AsyncFn<T, P>;
21
+ queryProps?: P;
22
+ };
23
+
24
+ const apiCache = {};
25
+
26
+ export function useAPI<T, P extends Record<PropertyKey, unknown> | undefined>({
27
+ queryFn,
28
+ queryProps = {},
29
+ enabled = true,
30
+ staleTimeout = 5000,
31
+ onSuccess,
32
+ onError,
33
+ }: Props<T, P>): UseAsyncReturn<T> {
34
+ const [isLoading, setIsLoading] = useState(false);
35
+ const [data, setData] = useState<T | undefined>(undefined);
36
+ const [error, setError] = useState<Error | undefined>(undefined);
37
+
38
+ const cacheKey = queryFn.name + JSON.stringify(queryProps);
39
+
40
+ const fetch = useCallback(async () => {
41
+ setIsLoading(true);
42
+ setData(undefined);
43
+ setError(undefined);
44
+
45
+ try {
46
+ const res = await queryFn({ ...queryProps });
47
+ setData(res);
48
+ setIsLoading(false);
49
+ apiCache[cacheKey] = { data: res, timestamp: new Date().getTime() };
50
+ onSuccess?.(res);
51
+ } catch (e: unknown) {
52
+ if (e instanceof Error) {
53
+ setError(e);
54
+ onError?.(e);
55
+ }
56
+ } finally {
57
+ setIsLoading(false);
58
+ }
59
+ }, [cacheKey, onError, onSuccess, queryFn, queryProps]);
60
+
61
+ const execute = useCallback(() => {
62
+ if (enabled) {
63
+ const cachedItem = apiCache[cacheKey];
64
+ if (cachedItem && new Date().getTime() - cachedItem.timestamp < staleTimeout) {
65
+ // The cached item is still fresh, so we use it
66
+ setData(cachedItem.data);
67
+ onSuccess?.(cachedItem.data);
68
+ setIsLoading(false);
69
+ } else {
70
+ // The cached item is stale or doesn't exist, so we fetch fresh data
71
+ fetch();
72
+ }
73
+ }
74
+ }, [cacheKey, staleTimeout, enabled, fetch, onSuccess]);
75
+
76
+ useEffect(() => {
77
+ execute();
78
+ }, [execute]);
79
+
80
+ return { data, isLoading, error, refetch: execute };
81
+ }
@@ -57,6 +57,7 @@ export function genAccount(id: number | string, opts: GenAccountOptions = {}): A
57
57
  pendingRewardsBalance: new BigNumber(0),
58
58
  unbondingBalance: new BigNumber(0),
59
59
  withdrawAddress: address,
60
+ sequence: 0,
60
61
  };
61
62
  break;
62
63
  case "bitcoin":