@ledgerhq/coin-celo 1.3.0-nightly.4 → 1.3.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 (188) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.unimportedrc.json +6 -3
  3. package/CHANGELOG.md +27 -35
  4. package/lib/bridge/buildOptimisticOperation.d.ts.map +1 -1
  5. package/lib/bridge/buildOptimisticOperation.js +2 -5
  6. package/lib/bridge/buildOptimisticOperation.js.map +1 -1
  7. package/lib/bridge/buildTransaction.d.ts.map +1 -1
  8. package/lib/bridge/buildTransaction.js +6 -29
  9. package/lib/bridge/buildTransaction.js.map +1 -1
  10. package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -1
  11. package/lib/bridge/estimateMaxSpendable.js +1 -9
  12. package/lib/bridge/estimateMaxSpendable.js.map +1 -1
  13. package/lib/bridge/getFeesForTransaction.d.ts.map +1 -1
  14. package/lib/bridge/getFeesForTransaction.js +5 -32
  15. package/lib/bridge/getFeesForTransaction.js.map +1 -1
  16. package/lib/bridge/getTransactionStatus.d.ts.map +1 -1
  17. package/lib/bridge/getTransactionStatus.js +4 -18
  18. package/lib/bridge/getTransactionStatus.js.map +1 -1
  19. package/lib/bridge/index.d.ts.map +1 -1
  20. package/lib/bridge/index.js.map +1 -1
  21. package/lib/bridge/prepareTransaction.d.ts.map +1 -1
  22. package/lib/bridge/prepareTransaction.js +4 -33
  23. package/lib/bridge/prepareTransaction.js.map +1 -1
  24. package/lib/bridge/signOperation.d.ts.map +1 -1
  25. package/lib/bridge/signOperation.js +3 -11
  26. package/lib/bridge/signOperation.js.map +1 -1
  27. package/lib/bridge/synchronisation.d.ts.map +1 -1
  28. package/lib/bridge/synchronisation.js +3 -7
  29. package/lib/bridge/synchronisation.js.map +1 -1
  30. package/lib/config.d.ts.map +1 -1
  31. package/lib/config.js +0 -8
  32. package/lib/config.js.map +1 -1
  33. package/lib/test/please-add-coverage.test.d.ts +2 -0
  34. package/lib/test/please-add-coverage.test.d.ts.map +1 -0
  35. package/lib/test/please-add-coverage.test.js +6 -0
  36. package/lib/test/please-add-coverage.test.js.map +1 -0
  37. package/lib/types/types.d.ts +0 -1
  38. package/lib/types/types.d.ts.map +1 -1
  39. package/lib/types/types.js.map +1 -1
  40. package/lib-es/bridge/buildOptimisticOperation.d.ts.map +1 -1
  41. package/lib-es/bridge/buildOptimisticOperation.js +2 -5
  42. package/lib-es/bridge/buildOptimisticOperation.js.map +1 -1
  43. package/lib-es/bridge/buildTransaction.d.ts.map +1 -1
  44. package/lib-es/bridge/buildTransaction.js +6 -29
  45. package/lib-es/bridge/buildTransaction.js.map +1 -1
  46. package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -1
  47. package/lib-es/bridge/estimateMaxSpendable.js +2 -10
  48. package/lib-es/bridge/estimateMaxSpendable.js.map +1 -1
  49. package/lib-es/bridge/getFeesForTransaction.d.ts.map +1 -1
  50. package/lib-es/bridge/getFeesForTransaction.js +5 -29
  51. package/lib-es/bridge/getFeesForTransaction.js.map +1 -1
  52. package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -1
  53. package/lib-es/bridge/getTransactionStatus.js +4 -18
  54. package/lib-es/bridge/getTransactionStatus.js.map +1 -1
  55. package/lib-es/bridge/index.d.ts.map +1 -1
  56. package/lib-es/bridge/index.js.map +1 -1
  57. package/lib-es/bridge/prepareTransaction.d.ts.map +1 -1
  58. package/lib-es/bridge/prepareTransaction.js +4 -33
  59. package/lib-es/bridge/prepareTransaction.js.map +1 -1
  60. package/lib-es/bridge/signOperation.d.ts.map +1 -1
  61. package/lib-es/bridge/signOperation.js +3 -11
  62. package/lib-es/bridge/signOperation.js.map +1 -1
  63. package/lib-es/bridge/synchronisation.d.ts.map +1 -1
  64. package/lib-es/bridge/synchronisation.js +3 -7
  65. package/lib-es/bridge/synchronisation.js.map +1 -1
  66. package/lib-es/config.d.ts.map +1 -1
  67. package/lib-es/config.js +0 -8
  68. package/lib-es/config.js.map +1 -1
  69. package/lib-es/test/please-add-coverage.test.d.ts +1 -0
  70. package/lib-es/test/please-add-coverage.test.d.ts.map +1 -0
  71. package/lib-es/test/please-add-coverage.test.js +5 -0
  72. package/lib-es/test/please-add-coverage.test.js.map +1 -0
  73. package/lib-es/types/types.d.ts +0 -1
  74. package/lib-es/types/types.d.ts.map +1 -1
  75. package/lib-es/types/types.js.map +1 -1
  76. package/package.json +17 -18
  77. package/src/bridge/buildOptimisticOperation.ts +2 -6
  78. package/src/bridge/buildTransaction.ts +7 -38
  79. package/src/bridge/estimateMaxSpendable.ts +2 -18
  80. package/src/bridge/getFeesForTransaction.ts +5 -39
  81. package/src/bridge/getTransactionStatus.ts +4 -21
  82. package/src/bridge/index.ts +1 -0
  83. package/src/bridge/prepareTransaction.ts +6 -39
  84. package/src/bridge/signOperation.ts +4 -19
  85. package/src/bridge/synchronisation.ts +4 -10
  86. package/src/config.ts +0 -8
  87. package/src/logic.ts +1 -1
  88. package/src/test/please-add-coverage.test.ts +3 -0
  89. package/src/types/types.ts +0 -1
  90. package/lib/__tests__/bridge/buildOptimisticOperation.test.d.ts +0 -2
  91. package/lib/__tests__/bridge/buildOptimisticOperation.test.d.ts.map +0 -1
  92. package/lib/__tests__/bridge/buildOptimisticOperation.test.js +0 -23
  93. package/lib/__tests__/bridge/buildOptimisticOperation.test.js.map +0 -1
  94. package/lib/__tests__/bridge/buildTransaction.test.d.ts +0 -2
  95. package/lib/__tests__/bridge/buildTransaction.test.d.ts.map +0 -1
  96. package/lib/__tests__/bridge/buildTransaction.test.js +0 -412
  97. package/lib/__tests__/bridge/buildTransaction.test.js.map +0 -1
  98. package/lib/__tests__/bridge/createTransaction.test.d.ts +0 -2
  99. package/lib/__tests__/bridge/createTransaction.test.d.ts.map +0 -1
  100. package/lib/__tests__/bridge/createTransaction.test.js +0 -22
  101. package/lib/__tests__/bridge/createTransaction.test.js.map +0 -1
  102. package/lib/__tests__/bridge/deviceTransactionConfig.test.d.ts +0 -2
  103. package/lib/__tests__/bridge/deviceTransactionConfig.test.d.ts.map +0 -1
  104. package/lib/__tests__/bridge/deviceTransactionConfig.test.js +0 -21
  105. package/lib/__tests__/bridge/deviceTransactionConfig.test.js.map +0 -1
  106. package/lib/__tests__/bridge/estimateMaxSpendable.test.d.ts +0 -2
  107. package/lib/__tests__/bridge/estimateMaxSpendable.test.d.ts.map +0 -1
  108. package/lib/__tests__/bridge/estimateMaxSpendable.test.js +0 -108
  109. package/lib/__tests__/bridge/estimateMaxSpendable.test.js.map +0 -1
  110. package/lib/__tests__/bridge/getFeesForTransaction.test.d.ts +0 -2
  111. package/lib/__tests__/bridge/getFeesForTransaction.test.d.ts.map +0 -1
  112. package/lib/__tests__/bridge/getFeesForTransaction.test.js +0 -211
  113. package/lib/__tests__/bridge/getFeesForTransaction.test.js.map +0 -1
  114. package/lib/__tests__/bridge/getTransactionStatus.test.d.ts +0 -2
  115. package/lib/__tests__/bridge/getTransactionStatus.test.d.ts.map +0 -1
  116. package/lib/__tests__/bridge/getTransactionStatus.test.js +0 -214
  117. package/lib/__tests__/bridge/getTransactionStatus.test.js.map +0 -1
  118. package/lib/__tests__/bridge/logic.test.d.ts +0 -2
  119. package/lib/__tests__/bridge/logic.test.d.ts.map +0 -1
  120. package/lib/__tests__/bridge/logic.test.js +0 -490
  121. package/lib/__tests__/bridge/logic.test.js.map +0 -1
  122. package/lib/__tests__/bridge/prepareTransaction.test.d.ts +0 -2
  123. package/lib/__tests__/bridge/prepareTransaction.test.d.ts.map +0 -1
  124. package/lib/__tests__/bridge/prepareTransaction.test.js +0 -239
  125. package/lib/__tests__/bridge/prepareTransaction.test.js.map +0 -1
  126. package/lib/bridge/fixtures.d.ts +0 -36
  127. package/lib/bridge/fixtures.d.ts.map +0 -1
  128. package/lib/bridge/fixtures.js +0 -98
  129. package/lib/bridge/fixtures.js.map +0 -1
  130. package/lib/constants.d.ts +0 -6
  131. package/lib/constants.d.ts.map +0 -1
  132. package/lib/constants.js +0 -15
  133. package/lib/constants.js.map +0 -1
  134. package/lib-es/__tests__/bridge/buildOptimisticOperation.test.d.ts +0 -2
  135. package/lib-es/__tests__/bridge/buildOptimisticOperation.test.d.ts.map +0 -1
  136. package/lib-es/__tests__/bridge/buildOptimisticOperation.test.js +0 -18
  137. package/lib-es/__tests__/bridge/buildOptimisticOperation.test.js.map +0 -1
  138. package/lib-es/__tests__/bridge/buildTransaction.test.d.ts +0 -2
  139. package/lib-es/__tests__/bridge/buildTransaction.test.d.ts.map +0 -1
  140. package/lib-es/__tests__/bridge/buildTransaction.test.js +0 -407
  141. package/lib-es/__tests__/bridge/buildTransaction.test.js.map +0 -1
  142. package/lib-es/__tests__/bridge/createTransaction.test.d.ts +0 -2
  143. package/lib-es/__tests__/bridge/createTransaction.test.d.ts.map +0 -1
  144. package/lib-es/__tests__/bridge/createTransaction.test.js +0 -17
  145. package/lib-es/__tests__/bridge/createTransaction.test.js.map +0 -1
  146. package/lib-es/__tests__/bridge/deviceTransactionConfig.test.d.ts +0 -2
  147. package/lib-es/__tests__/bridge/deviceTransactionConfig.test.d.ts.map +0 -1
  148. package/lib-es/__tests__/bridge/deviceTransactionConfig.test.js +0 -16
  149. package/lib-es/__tests__/bridge/deviceTransactionConfig.test.js.map +0 -1
  150. package/lib-es/__tests__/bridge/estimateMaxSpendable.test.d.ts +0 -2
  151. package/lib-es/__tests__/bridge/estimateMaxSpendable.test.d.ts.map +0 -1
  152. package/lib-es/__tests__/bridge/estimateMaxSpendable.test.js +0 -103
  153. package/lib-es/__tests__/bridge/estimateMaxSpendable.test.js.map +0 -1
  154. package/lib-es/__tests__/bridge/getFeesForTransaction.test.d.ts +0 -2
  155. package/lib-es/__tests__/bridge/getFeesForTransaction.test.d.ts.map +0 -1
  156. package/lib-es/__tests__/bridge/getFeesForTransaction.test.js +0 -206
  157. package/lib-es/__tests__/bridge/getFeesForTransaction.test.js.map +0 -1
  158. package/lib-es/__tests__/bridge/getTransactionStatus.test.d.ts +0 -2
  159. package/lib-es/__tests__/bridge/getTransactionStatus.test.d.ts.map +0 -1
  160. package/lib-es/__tests__/bridge/getTransactionStatus.test.js +0 -209
  161. package/lib-es/__tests__/bridge/getTransactionStatus.test.js.map +0 -1
  162. package/lib-es/__tests__/bridge/logic.test.d.ts +0 -2
  163. package/lib-es/__tests__/bridge/logic.test.d.ts.map +0 -1
  164. package/lib-es/__tests__/bridge/logic.test.js +0 -485
  165. package/lib-es/__tests__/bridge/logic.test.js.map +0 -1
  166. package/lib-es/__tests__/bridge/prepareTransaction.test.d.ts +0 -2
  167. package/lib-es/__tests__/bridge/prepareTransaction.test.d.ts.map +0 -1
  168. package/lib-es/__tests__/bridge/prepareTransaction.test.js +0 -234
  169. package/lib-es/__tests__/bridge/prepareTransaction.test.js.map +0 -1
  170. package/lib-es/bridge/fixtures.d.ts +0 -36
  171. package/lib-es/bridge/fixtures.d.ts.map +0 -1
  172. package/lib-es/bridge/fixtures.js +0 -89
  173. package/lib-es/bridge/fixtures.js.map +0 -1
  174. package/lib-es/constants.d.ts +0 -6
  175. package/lib-es/constants.d.ts.map +0 -1
  176. package/lib-es/constants.js +0 -11
  177. package/lib-es/constants.js.map +0 -1
  178. package/src/__tests__/bridge/buildOptimisticOperation.test.ts +0 -29
  179. package/src/__tests__/bridge/buildTransaction.test.ts +0 -502
  180. package/src/__tests__/bridge/createTransaction.test.ts +0 -17
  181. package/src/__tests__/bridge/deviceTransactionConfig.test.ts +0 -16
  182. package/src/__tests__/bridge/estimateMaxSpendable.test.ts +0 -112
  183. package/src/__tests__/bridge/getFeesForTransaction.test.ts +0 -233
  184. package/src/__tests__/bridge/getTransactionStatus.test.ts +0 -261
  185. package/src/__tests__/bridge/logic.test.ts +0 -538
  186. package/src/__tests__/bridge/prepareTransaction.test.ts +0 -261
  187. package/src/bridge/fixtures.ts +0 -103
  188. package/src/constants.ts +0 -15
@@ -1,538 +0,0 @@
1
- import BigNumber from "bignumber.js";
2
- import { accountFixture } from "../../bridge/fixtures";
3
- import {
4
- activatableVotes,
5
- availablePendingWithdrawals,
6
- defaultValidatorGroupAddress,
7
- fallbackValidatorGroup,
8
- getPendingStakingOperationAmounts,
9
- getValidatorGroupsWithoutVotes,
10
- getValidatorGroupsWithVotes,
11
- getVote,
12
- hasActivatableVotes,
13
- hasRevokableVotes,
14
- hasWithdrawableBalance,
15
- isAccountRegistrationPending,
16
- isDefaultValidatorGroup,
17
- isDefaultValidatorGroupAddress,
18
- revokableVotes,
19
- voteStatus,
20
- withdrawableBalance,
21
- } from "../../logic";
22
- import { CeloAccount } from "../../types";
23
- import { Operation } from "@ledgerhq/types-live";
24
-
25
- jest.useFakeTimers().setSystemTime(new Date("2020-01-01"));
26
-
27
- describe("logic", () => {
28
- it("availablePendingWithdrawals", () => {
29
- const result = availablePendingWithdrawals({
30
- ...accountFixture,
31
- celoResources: {
32
- ...accountFixture.celoResources,
33
- pendingWithdrawals: [
34
- {
35
- value: BigNumber(123123123),
36
- time: BigNumber(31231),
37
- index: 0,
38
- },
39
- {
40
- value: BigNumber(123123123),
41
- time: BigNumber(23214451),
42
- index: 0,
43
- },
44
- {
45
- value: BigNumber(123123123),
46
- time: BigNumber(1577836900000),
47
- index: 0,
48
- },
49
- ],
50
- },
51
- });
52
-
53
- expect(result).toHaveLength(2);
54
- });
55
-
56
- it("withdrawableBalance", () => {
57
- const account = {
58
- ...accountFixture,
59
- celoResources: {
60
- ...accountFixture.celoResources,
61
- pendingWithdrawals: [
62
- {
63
- value: BigNumber(123123123),
64
- time: BigNumber(31231),
65
- index: 0,
66
- },
67
- {
68
- value: BigNumber(123123123),
69
- time: BigNumber(23214451),
70
- index: 0,
71
- },
72
- {
73
- value: BigNumber(123123123),
74
- time: BigNumber(1577836900000),
75
- index: 0,
76
- },
77
- ],
78
- },
79
- };
80
-
81
- expect(withdrawableBalance(account)).toEqual(BigNumber(246246246));
82
- expect(hasWithdrawableBalance(account)).toBeTruthy();
83
- });
84
-
85
- it("isDefaultValidatorGroupAddress", () => {
86
- expect(isDefaultValidatorGroupAddress("other_address")).toBeFalsy();
87
- expect(isDefaultValidatorGroupAddress(defaultValidatorGroupAddress())).toBeTruthy();
88
- expect(
89
- isDefaultValidatorGroup({
90
- address: "validator_address",
91
- name: "validator1",
92
- votes: BigNumber(8484848),
93
- }),
94
- ).toBeFalsy();
95
- expect(
96
- isDefaultValidatorGroup({
97
- address: defaultValidatorGroupAddress(),
98
- name: "validator1",
99
- votes: BigNumber(8484848),
100
- }),
101
- ).toBeTruthy();
102
- });
103
-
104
- it("activatableVotes", () => {
105
- const account = {
106
- ...accountFixture,
107
- celoResources: {
108
- ...accountFixture.celoResources,
109
- votes: [
110
- {
111
- validatorGroup: "1",
112
- amount: BigNumber(123),
113
- activatable: true,
114
- revokable: false,
115
- type: "active",
116
- index: 0,
117
- },
118
- {
119
- validatorGroup: "2",
120
- amount: BigNumber(123213),
121
- activatable: false,
122
- revokable: true,
123
- type: "pending",
124
- index: 0,
125
- },
126
- {
127
- validatorGroup: "3",
128
- amount: BigNumber(1232223),
129
- activatable: true,
130
- revokable: false,
131
- type: "active",
132
- index: 0,
133
- },
134
- ],
135
- },
136
- } as CeloAccount;
137
- const result = activatableVotes(account);
138
-
139
- expect(result).toMatchObject([
140
- {
141
- validatorGroup: "1",
142
- amount: BigNumber(123),
143
- activatable: true,
144
- revokable: false,
145
- type: "active",
146
- index: 0,
147
- },
148
- {
149
- validatorGroup: "3",
150
- amount: BigNumber(1232223),
151
- activatable: true,
152
- revokable: false,
153
- type: "active",
154
- index: 0,
155
- },
156
- ]);
157
- expect(hasActivatableVotes(account)).toBeTruthy();
158
- expect(revokableVotes(account)).toMatchObject([
159
- {
160
- validatorGroup: "2",
161
- amount: BigNumber(123213),
162
- activatable: false,
163
- revokable: true,
164
- type: "pending",
165
- index: 0,
166
- },
167
- ]);
168
- expect(hasRevokableVotes(account)).toBeTruthy();
169
- });
170
-
171
- it("getVote", () => {
172
- const account = {
173
- ...accountFixture,
174
- celoResources: {
175
- ...accountFixture.celoResources,
176
- votes: [
177
- {
178
- validatorGroup: "1",
179
- amount: BigNumber(123),
180
- activatable: true,
181
- revokable: false,
182
- type: "active",
183
- index: 0,
184
- },
185
- {
186
- validatorGroup: "2",
187
- amount: BigNumber(123213),
188
- activatable: false,
189
- revokable: true,
190
- type: "pending",
191
- index: 0,
192
- },
193
- {
194
- validatorGroup: "3",
195
- amount: BigNumber(1232223),
196
- activatable: true,
197
- revokable: false,
198
- type: "active",
199
- index: 0,
200
- },
201
- ],
202
- },
203
- } as CeloAccount;
204
- const result = getVote(account, "2", 0);
205
-
206
- expect(result).toMatchObject({
207
- validatorGroup: "2",
208
- amount: BigNumber(123213),
209
- activatable: false,
210
- revokable: true,
211
- type: "pending",
212
- index: 0,
213
- });
214
- });
215
-
216
- it("voteStatus", () => {
217
- expect(
218
- voteStatus({
219
- validatorGroup: "2",
220
- amount: BigNumber(123213),
221
- activatable: true,
222
- revokable: true,
223
- type: "pending",
224
- index: 0,
225
- }),
226
- ).toEqual("awaitingActivation");
227
- expect(
228
- voteStatus({
229
- validatorGroup: "2",
230
- amount: BigNumber(123213),
231
- activatable: false,
232
- revokable: true,
233
- type: "pending",
234
- index: 0,
235
- }),
236
- ).toEqual("pending");
237
- });
238
-
239
- it("fallbackValidatorGroup", () => {
240
- expect(fallbackValidatorGroup("address")).toMatchObject({
241
- address: "address",
242
- name: "address",
243
- votes: BigNumber(0),
244
- });
245
- });
246
-
247
- it("isAccountRegistrationPending", () => {
248
- const account = {
249
- ...accountFixture,
250
- pendingOperations: [
251
- {
252
- id: "pendingOperation1",
253
- accountId: accountFixture.id,
254
- blockHash: "block_hash",
255
- blockHeight: 1,
256
- date: new Date(),
257
- type: "REGISTER",
258
- senders: [],
259
- recipients: [],
260
- fee: BigNumber(0),
261
- value: BigNumber(1),
262
- hash: "hash",
263
- extra: "extra",
264
- } as Operation,
265
- ],
266
- celoResources: {
267
- ...accountFixture.celoResources,
268
- registrationStatus: false,
269
- },
270
- } as CeloAccount;
271
-
272
- expect(isAccountRegistrationPending(account)).toBeTruthy();
273
- });
274
-
275
- it("getPendingStakingOperationAmounts", () => {
276
- const account = {
277
- ...accountFixture,
278
- pendingOperations: [
279
- {
280
- id: "pendingOperation1",
281
- accountId: accountFixture.id,
282
- blockHash: "block_hash",
283
- blockHeight: 1,
284
- date: new Date(),
285
- type: "VOTE",
286
- senders: [],
287
- recipients: [],
288
- fee: BigNumber(0),
289
- value: BigNumber(2),
290
- hash: "hash",
291
- extra: "extra",
292
- } as Operation,
293
- {
294
- id: "pendingOperation1",
295
- accountId: accountFixture.id,
296
- blockHash: "block_hash",
297
- blockHeight: 1,
298
- date: new Date(),
299
- type: "VOTE",
300
- senders: [],
301
- recipients: [],
302
- fee: BigNumber(0),
303
- value: BigNumber(10),
304
- hash: "hash",
305
- extra: "extra",
306
- } as Operation,
307
- {
308
- id: "pendingOperation1",
309
- accountId: accountFixture.id,
310
- blockHash: "block_hash",
311
- blockHeight: 1,
312
- date: new Date(),
313
- type: "LOCK",
314
- senders: [],
315
- recipients: [],
316
- fee: BigNumber(0),
317
- value: BigNumber(30),
318
- hash: "hash",
319
- extra: "extra",
320
- } as Operation,
321
- {
322
- id: "pendingOperation1",
323
- accountId: accountFixture.id,
324
- blockHash: "block_hash",
325
- blockHeight: 1,
326
- date: new Date(),
327
- type: "REGISTER",
328
- senders: [],
329
- recipients: [],
330
- fee: BigNumber(0),
331
- value: BigNumber(30),
332
- hash: "hash",
333
- extra: "extra",
334
- } as Operation,
335
- ],
336
- celoResources: {
337
- ...accountFixture.celoResources,
338
- registrationStatus: false,
339
- },
340
- } as CeloAccount;
341
- const result = getPendingStakingOperationAmounts(account);
342
- expect(result).toMatchObject({
343
- vote: BigNumber(12),
344
- lock: BigNumber(30),
345
- });
346
- });
347
-
348
- it("getPendingStakingOperationAmounts", () => {
349
- const account = {
350
- ...accountFixture,
351
- pendingOperations: [
352
- {
353
- id: "pendingOperation1",
354
- accountId: accountFixture.id,
355
- blockHash: "block_hash",
356
- blockHeight: 1,
357
- date: new Date(),
358
- type: "VOTE",
359
- senders: [],
360
- recipients: [],
361
- fee: BigNumber(0),
362
- value: BigNumber(2),
363
- hash: "hash",
364
- extra: "extra",
365
- } as Operation,
366
- {
367
- id: "pendingOperation1",
368
- accountId: accountFixture.id,
369
- blockHash: "block_hash",
370
- blockHeight: 1,
371
- date: new Date(),
372
- type: "VOTE",
373
- senders: [],
374
- recipients: [],
375
- fee: BigNumber(0),
376
- value: BigNumber(10),
377
- hash: "hash",
378
- extra: "extra",
379
- } as Operation,
380
- {
381
- id: "pendingOperation1",
382
- accountId: accountFixture.id,
383
- blockHash: "block_hash",
384
- blockHeight: 1,
385
- date: new Date(),
386
- type: "LOCK",
387
- senders: [],
388
- recipients: [],
389
- fee: BigNumber(0),
390
- value: BigNumber(30),
391
- hash: "hash",
392
- extra: "extra",
393
- } as Operation,
394
- {
395
- id: "pendingOperation1",
396
- accountId: accountFixture.id,
397
- blockHash: "block_hash",
398
- blockHeight: 1,
399
- date: new Date(),
400
- type: "REGISTER",
401
- senders: [],
402
- recipients: [],
403
- fee: BigNumber(0),
404
- value: BigNumber(30),
405
- hash: "hash",
406
- extra: "extra",
407
- } as Operation,
408
- ],
409
- celoResources: {
410
- ...accountFixture.celoResources,
411
- registrationStatus: false,
412
- },
413
- operations: [
414
- {
415
- id: "operation1",
416
- accountId: accountFixture.id,
417
- blockHash: "block_hash",
418
- blockHeight: 1,
419
- date: new Date(),
420
- type: "LOCK",
421
- senders: [],
422
- recipients: [],
423
- fee: BigNumber(0),
424
- value: BigNumber(1),
425
- hash: "hash",
426
- extra: "extra",
427
- } as Operation,
428
- ],
429
- operationsCount: 1,
430
- } as CeloAccount;
431
- const result = getPendingStakingOperationAmounts(account);
432
- expect(result).toMatchObject({
433
- vote: BigNumber(0),
434
- lock: BigNumber(0),
435
- });
436
- });
437
-
438
- it("getValidatorGroupsWithVotes", () => {
439
- const result = getValidatorGroupsWithVotes(
440
- [
441
- {
442
- address: "validator1",
443
- name: "validator1",
444
- votes: BigNumber(3),
445
- },
446
- {
447
- address: "validator2",
448
- name: "validator2",
449
- votes: BigNumber(4),
450
- },
451
- {
452
- address: "validator3",
453
- name: "validator3",
454
- votes: BigNumber(0),
455
- },
456
- ],
457
- [
458
- {
459
- validatorGroup: "validator1",
460
- amount: BigNumber(1),
461
- activatable: true,
462
- revokable: true,
463
- type: "active",
464
- index: 0,
465
- },
466
- {
467
- validatorGroup: "validator2",
468
- amount: BigNumber(2),
469
- activatable: true,
470
- revokable: true,
471
- type: "active",
472
- index: 0,
473
- },
474
- ],
475
- );
476
-
477
- expect(result).toMatchObject([
478
- {
479
- address: "validator1",
480
- name: "validator1",
481
- votes: BigNumber(3),
482
- },
483
- {
484
- address: "validator2",
485
- name: "validator2",
486
- votes: BigNumber(4),
487
- },
488
- ]);
489
- });
490
-
491
- it("getValidatorGroupsWithoutVotes", () => {
492
- const result = getValidatorGroupsWithoutVotes(
493
- [
494
- {
495
- address: "validator1",
496
- name: "validator1",
497
- votes: BigNumber(3),
498
- },
499
- {
500
- address: "validator2",
501
- name: "validator2",
502
- votes: BigNumber(4),
503
- },
504
- {
505
- address: "validator3",
506
- name: "validator3",
507
- votes: BigNumber(0),
508
- },
509
- ],
510
- [
511
- {
512
- validatorGroup: "validator1",
513
- amount: BigNumber(1),
514
- activatable: true,
515
- revokable: true,
516
- type: "active",
517
- index: 0,
518
- },
519
- {
520
- validatorGroup: "validator2",
521
- amount: BigNumber(2),
522
- activatable: true,
523
- revokable: true,
524
- type: "active",
525
- index: 0,
526
- },
527
- ],
528
- );
529
-
530
- expect(result).toMatchObject([
531
- {
532
- address: "validator3",
533
- name: "validator3",
534
- votes: BigNumber(0),
535
- },
536
- ]);
537
- });
538
- });