@ledgerhq/coin-aptos 2.0.0-nightly.3 → 2.0.0-nightly.5
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.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +17 -0
- package/lib/__tests__/api/index.test.js +5 -61
- package/lib/__tests__/api/index.test.js.map +1 -1
- package/lib/__tests__/bridge/buildTransaction.test.js +2 -57
- package/lib/__tests__/bridge/buildTransaction.test.js.map +1 -1
- package/lib/__tests__/bridge/getFeesForTransaction.test.js +8 -109
- package/lib/__tests__/bridge/getFeesForTransaction.test.js.map +1 -1
- package/lib/__tests__/bridge/getTransactionStatus.test.js +37 -175
- package/lib/__tests__/bridge/getTransactionStatus.test.js.map +1 -1
- package/lib/__tests__/bridge/logic.test.js +115 -889
- package/lib/__tests__/bridge/logic.test.js.map +1 -1
- package/lib/__tests__/bridge/signOperation.test.js +2 -128
- package/lib/__tests__/bridge/signOperation.test.js.map +1 -1
- package/lib/__tests__/bridge/synchronisation.test.js +67 -1214
- package/lib/__tests__/bridge/synchronisation.test.js.map +1 -1
- package/lib/api/graphql/queries.js +6 -6
- package/lib/api/graphql/types.d.ts +9 -9
- package/lib/api/graphql/types.d.ts.map +1 -1
- package/lib/api/index.d.ts +2 -5
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +4 -30
- package/lib/api/index.js.map +1 -1
- package/lib/bridge/bridge.fixture.d.ts +0 -2
- package/lib/bridge/bridge.fixture.d.ts.map +1 -1
- package/lib/bridge/bridge.fixture.js +13 -85
- package/lib/bridge/bridge.fixture.js.map +1 -1
- package/lib/bridge/buildTransaction.d.ts.map +1 -1
- package/lib/bridge/buildTransaction.js +3 -29
- package/lib/bridge/buildTransaction.js.map +1 -1
- package/lib/bridge/estimateMaxSpendable.js +1 -1
- package/lib/bridge/estimateMaxSpendable.js.map +1 -1
- package/lib/bridge/getFeesForTransaction.d.ts.map +1 -1
- package/lib/bridge/getFeesForTransaction.js +7 -12
- package/lib/bridge/getFeesForTransaction.js.map +1 -1
- package/lib/bridge/getTransactionStatus.d.ts.map +1 -1
- package/lib/bridge/getTransactionStatus.js +14 -28
- package/lib/bridge/getTransactionStatus.js.map +1 -1
- package/lib/bridge/logic.d.ts +8 -13
- package/lib/bridge/logic.d.ts.map +1 -1
- package/lib/bridge/logic.js +54 -152
- package/lib/bridge/logic.js.map +1 -1
- package/lib/bridge/prepareTransaction.d.ts.map +1 -1
- package/lib/bridge/prepareTransaction.js +2 -2
- package/lib/bridge/prepareTransaction.js.map +1 -1
- package/lib/bridge/signOperation.d.ts.map +1 -1
- package/lib/bridge/signOperation.js +3 -17
- package/lib/bridge/signOperation.js.map +1 -1
- package/lib/bridge/synchronisation.d.ts +0 -15
- package/lib/bridge/synchronisation.d.ts.map +1 -1
- package/lib/bridge/synchronisation.js +4 -127
- package/lib/bridge/synchronisation.js.map +1 -1
- package/lib/constants.d.ts +1 -5
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +2 -6
- package/lib/constants.js.map +1 -1
- package/lib/test/bot-specs.d.ts.map +1 -1
- package/lib/test/bot-specs.js +1 -40
- package/lib/test/bot-specs.js.map +1 -1
- package/lib/test/bridgeDatasetTest.d.ts.map +1 -1
- package/lib/test/bridgeDatasetTest.js +62 -43
- package/lib/test/bridgeDatasetTest.js.map +1 -1
- package/lib/test/speculos-deviceActions.d.ts +0 -1
- package/lib/test/speculos-deviceActions.d.ts.map +1 -1
- package/lib/test/speculos-deviceActions.js +5 -37
- package/lib/test/speculos-deviceActions.js.map +1 -1
- package/lib/types/index.d.ts +7 -18
- package/lib/types/index.d.ts.map +1 -1
- package/lib-es/__tests__/api/index.test.js +5 -61
- package/lib-es/__tests__/api/index.test.js.map +1 -1
- package/lib-es/__tests__/bridge/buildTransaction.test.js +3 -58
- package/lib-es/__tests__/bridge/buildTransaction.test.js.map +1 -1
- package/lib-es/__tests__/bridge/getFeesForTransaction.test.js +9 -110
- package/lib-es/__tests__/bridge/getFeesForTransaction.test.js.map +1 -1
- package/lib-es/__tests__/bridge/getTransactionStatus.test.js +39 -177
- package/lib-es/__tests__/bridge/getTransactionStatus.test.js.map +1 -1
- package/lib-es/__tests__/bridge/logic.test.js +117 -891
- package/lib-es/__tests__/bridge/logic.test.js.map +1 -1
- package/lib-es/__tests__/bridge/signOperation.test.js +2 -128
- package/lib-es/__tests__/bridge/signOperation.test.js.map +1 -1
- package/lib-es/__tests__/bridge/synchronisation.test.js +69 -1213
- package/lib-es/__tests__/bridge/synchronisation.test.js.map +1 -1
- package/lib-es/api/graphql/queries.js +6 -6
- package/lib-es/api/graphql/types.d.ts +9 -9
- package/lib-es/api/graphql/types.d.ts.map +1 -1
- package/lib-es/api/index.d.ts +2 -5
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +4 -30
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/bridge/bridge.fixture.d.ts +0 -2
- package/lib-es/bridge/bridge.fixture.d.ts.map +1 -1
- package/lib-es/bridge/bridge.fixture.js +12 -82
- package/lib-es/bridge/bridge.fixture.js.map +1 -1
- package/lib-es/bridge/buildTransaction.d.ts.map +1 -1
- package/lib-es/bridge/buildTransaction.js +4 -30
- package/lib-es/bridge/buildTransaction.js.map +1 -1
- package/lib-es/bridge/estimateMaxSpendable.js +1 -1
- package/lib-es/bridge/estimateMaxSpendable.js.map +1 -1
- package/lib-es/bridge/getFeesForTransaction.d.ts.map +1 -1
- package/lib-es/bridge/getFeesForTransaction.js +8 -13
- package/lib-es/bridge/getFeesForTransaction.js.map +1 -1
- package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -1
- package/lib-es/bridge/getTransactionStatus.js +14 -28
- package/lib-es/bridge/getTransactionStatus.js.map +1 -1
- package/lib-es/bridge/logic.d.ts +8 -13
- package/lib-es/bridge/logic.d.ts.map +1 -1
- package/lib-es/bridge/logic.js +52 -146
- package/lib-es/bridge/logic.js.map +1 -1
- package/lib-es/bridge/prepareTransaction.d.ts.map +1 -1
- package/lib-es/bridge/prepareTransaction.js +2 -2
- package/lib-es/bridge/prepareTransaction.js.map +1 -1
- package/lib-es/bridge/signOperation.d.ts.map +1 -1
- package/lib-es/bridge/signOperation.js +3 -17
- package/lib-es/bridge/signOperation.js.map +1 -1
- package/lib-es/bridge/synchronisation.d.ts +0 -15
- package/lib-es/bridge/synchronisation.d.ts.map +1 -1
- package/lib-es/bridge/synchronisation.js +3 -123
- package/lib-es/bridge/synchronisation.js.map +1 -1
- package/lib-es/constants.d.ts +1 -5
- package/lib-es/constants.d.ts.map +1 -1
- package/lib-es/constants.js +1 -5
- package/lib-es/constants.js.map +1 -1
- package/lib-es/test/bot-specs.d.ts.map +1 -1
- package/lib-es/test/bot-specs.js +2 -41
- package/lib-es/test/bot-specs.js.map +1 -1
- package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -1
- package/lib-es/test/bridgeDatasetTest.js +59 -43
- package/lib-es/test/bridgeDatasetTest.js.map +1 -1
- package/lib-es/test/speculos-deviceActions.d.ts +0 -1
- package/lib-es/test/speculos-deviceActions.d.ts.map +1 -1
- package/lib-es/test/speculos-deviceActions.js +4 -36
- package/lib-es/test/speculos-deviceActions.js.map +1 -1
- package/lib-es/types/index.d.ts +7 -18
- package/lib-es/types/index.d.ts.map +1 -1
- package/package.json +5 -6
- package/src/__tests__/api/index.test.ts +5 -75
- package/src/__tests__/bridge/buildTransaction.test.ts +3 -85
- package/src/__tests__/bridge/getFeesForTransaction.test.ts +9 -144
- package/src/__tests__/bridge/getTransactionStatus.test.ts +38 -217
- package/src/__tests__/bridge/logic.test.ts +118 -922
- package/src/__tests__/bridge/signOperation.test.ts +2 -141
- package/src/__tests__/bridge/synchronisation.test.ts +71 -1265
- package/src/api/graphql/queries.ts +6 -6
- package/src/api/graphql/types.ts +9 -9
- package/src/api/index.ts +5 -32
- package/src/bridge/bridge.fixture.ts +12 -91
- package/src/bridge/buildTransaction.ts +6 -39
- package/src/bridge/estimateMaxSpendable.ts +1 -1
- package/src/bridge/getFeesForTransaction.ts +9 -14
- package/src/bridge/getTransactionStatus.ts +13 -35
- package/src/bridge/logic.ts +63 -202
- package/src/bridge/prepareTransaction.ts +3 -4
- package/src/bridge/signOperation.ts +3 -19
- package/src/bridge/synchronisation.ts +3 -170
- package/src/constants.ts +1 -12
- package/src/test/bot-specs.ts +3 -63
- package/src/test/bridgeDatasetTest.ts +59 -45
- package/src/test/speculos-deviceActions.ts +4 -40
- package/src/types/index.ts +1 -15
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import BigNumber from "bignumber.js";
|
|
2
|
-
import {
|
|
3
|
-
createFixtureAccount,
|
|
4
|
-
createFixtureAccountWithSubAccount,
|
|
5
|
-
createFixtureTransaction,
|
|
6
|
-
createFixtureTransactionWithSubAccount,
|
|
7
|
-
} from "../../bridge/bridge.fixture";
|
|
2
|
+
import { createFixtureAccount, createFixtureTransaction } from "../../bridge/bridge.fixture";
|
|
8
3
|
import getTransactionStatus from "../../bridge/getTransactionStatus";
|
|
9
4
|
import {
|
|
10
5
|
AmountRequired,
|
|
@@ -12,16 +7,15 @@ import {
|
|
|
12
7
|
InvalidAddress,
|
|
13
8
|
InvalidAddressBecauseDestinationIsAlsoSource,
|
|
14
9
|
NotEnoughBalance,
|
|
15
|
-
NotEnoughBalanceFees,
|
|
16
10
|
RecipientRequired,
|
|
17
11
|
} from "@ledgerhq/errors";
|
|
18
12
|
|
|
19
13
|
describe("getTransactionStatus Test", () => {
|
|
20
|
-
it("should return
|
|
14
|
+
it("should return errors for AmountRequired", async () => {
|
|
21
15
|
const account = createFixtureAccount();
|
|
22
16
|
const transaction = createFixtureTransaction();
|
|
23
17
|
|
|
24
|
-
transaction.fees = BigNumber(2);
|
|
18
|
+
transaction.fees = new BigNumber(2);
|
|
25
19
|
transaction.recipient = "0x" + "0".repeat(64);
|
|
26
20
|
|
|
27
21
|
const result = await getTransactionStatus(account, transaction);
|
|
@@ -31,21 +25,21 @@ describe("getTransactionStatus Test", () => {
|
|
|
31
25
|
amount: new AmountRequired(),
|
|
32
26
|
},
|
|
33
27
|
warnings: {},
|
|
34
|
-
estimatedFees: BigNumber(2),
|
|
35
|
-
amount: BigNumber(0),
|
|
36
|
-
totalSpent: BigNumber(2),
|
|
28
|
+
estimatedFees: new BigNumber(2),
|
|
29
|
+
amount: new BigNumber(0),
|
|
30
|
+
totalSpent: new BigNumber(2),
|
|
37
31
|
};
|
|
38
32
|
|
|
39
33
|
expect(result).toEqual(expected);
|
|
40
34
|
});
|
|
41
35
|
|
|
42
|
-
it("should return
|
|
36
|
+
it("should return errors for FeeNotLoaded", async () => {
|
|
43
37
|
const account = createFixtureAccount();
|
|
44
|
-
account.
|
|
38
|
+
account.balance = new BigNumber(10);
|
|
45
39
|
|
|
46
40
|
const transaction = createFixtureTransaction();
|
|
47
41
|
transaction.fees = null;
|
|
48
|
-
transaction.amount = BigNumber(2);
|
|
42
|
+
transaction.amount = new BigNumber(2);
|
|
49
43
|
transaction.recipient = "0x" + "0".repeat(64);
|
|
50
44
|
|
|
51
45
|
const result = await getTransactionStatus(account, transaction);
|
|
@@ -55,71 +49,22 @@ describe("getTransactionStatus Test", () => {
|
|
|
55
49
|
fees: new FeeNotLoaded(),
|
|
56
50
|
},
|
|
57
51
|
warnings: {},
|
|
58
|
-
estimatedFees: BigNumber(0),
|
|
59
|
-
amount: BigNumber(2),
|
|
60
|
-
totalSpent: BigNumber(2),
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
expect(result).toEqual(expected);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("should return error for NotEnoughBalance", async () => {
|
|
67
|
-
const account = createFixtureAccount();
|
|
68
|
-
account.spendableBalance = BigNumber(1);
|
|
69
|
-
|
|
70
|
-
const transaction = createFixtureTransaction();
|
|
71
|
-
transaction.recipient = "0x" + "0".repeat(64);
|
|
72
|
-
transaction.amount = BigNumber(2);
|
|
73
|
-
transaction.fees = BigNumber(2);
|
|
74
|
-
|
|
75
|
-
const result = await getTransactionStatus(account, transaction);
|
|
76
|
-
|
|
77
|
-
const expected = {
|
|
78
|
-
errors: {
|
|
79
|
-
amount: new NotEnoughBalance(),
|
|
80
|
-
},
|
|
81
|
-
warnings: {},
|
|
82
|
-
estimatedFees: BigNumber(2),
|
|
83
|
-
amount: BigNumber(2),
|
|
84
|
-
totalSpent: BigNumber(4),
|
|
52
|
+
estimatedFees: new BigNumber(0),
|
|
53
|
+
amount: new BigNumber(2),
|
|
54
|
+
totalSpent: new BigNumber(2),
|
|
85
55
|
};
|
|
86
56
|
|
|
87
57
|
expect(result).toEqual(expected);
|
|
88
58
|
});
|
|
89
59
|
|
|
90
|
-
it("should return
|
|
60
|
+
it("should return errors for NotEnoughBalance", async () => {
|
|
91
61
|
const account = createFixtureAccount();
|
|
92
|
-
account.
|
|
62
|
+
account.balance = new BigNumber(1);
|
|
93
63
|
|
|
94
64
|
const transaction = createFixtureTransaction();
|
|
95
65
|
transaction.recipient = "0x" + "0".repeat(64);
|
|
96
|
-
transaction.amount = BigNumber(2);
|
|
97
|
-
transaction.fees = BigNumber(2);
|
|
98
|
-
transaction.useAllAmount = true;
|
|
99
|
-
|
|
100
|
-
const result = await getTransactionStatus(account, transaction);
|
|
101
|
-
|
|
102
|
-
const expected = {
|
|
103
|
-
errors: {
|
|
104
|
-
amount: new NotEnoughBalance(),
|
|
105
|
-
},
|
|
106
|
-
warnings: {},
|
|
107
|
-
estimatedFees: BigNumber(2),
|
|
108
|
-
amount: BigNumber(0),
|
|
109
|
-
totalSpent: BigNumber(2),
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
expect(result).toEqual(expected);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it("should return error for NotEnoughBalance for token account when not enough tokens", async () => {
|
|
116
|
-
const account = createFixtureAccountWithSubAccount("coin");
|
|
117
|
-
account.spendableBalance = BigNumber(300);
|
|
118
|
-
|
|
119
|
-
const transaction = createFixtureTransactionWithSubAccount();
|
|
120
|
-
transaction.recipient = "0x" + "0".repeat(64);
|
|
121
|
-
transaction.amount = BigNumber(2000);
|
|
122
|
-
transaction.fees = BigNumber(200);
|
|
66
|
+
transaction.amount = new BigNumber(2);
|
|
67
|
+
transaction.fees = new BigNumber(2);
|
|
123
68
|
|
|
124
69
|
const result = await getTransactionStatus(account, transaction);
|
|
125
70
|
|
|
@@ -128,97 +73,21 @@ describe("getTransactionStatus Test", () => {
|
|
|
128
73
|
amount: new NotEnoughBalance(),
|
|
129
74
|
},
|
|
130
75
|
warnings: {},
|
|
131
|
-
estimatedFees: BigNumber(
|
|
132
|
-
amount: BigNumber(
|
|
133
|
-
totalSpent: BigNumber(
|
|
76
|
+
estimatedFees: new BigNumber(2),
|
|
77
|
+
amount: new BigNumber(2),
|
|
78
|
+
totalSpent: new BigNumber(4),
|
|
134
79
|
};
|
|
135
80
|
|
|
136
81
|
expect(result).toEqual(expected);
|
|
137
82
|
});
|
|
138
83
|
|
|
139
|
-
it("should return
|
|
84
|
+
it("should return errors for RecipientRequired", async () => {
|
|
140
85
|
const account = createFixtureAccount();
|
|
141
|
-
account.
|
|
86
|
+
account.balance = new BigNumber(10);
|
|
142
87
|
|
|
143
88
|
const transaction = createFixtureTransaction();
|
|
144
|
-
transaction.
|
|
145
|
-
transaction.
|
|
146
|
-
transaction.fees = BigNumber(2);
|
|
147
|
-
transaction.useAllAmount = true;
|
|
148
|
-
|
|
149
|
-
const result = await getTransactionStatus(account, transaction);
|
|
150
|
-
|
|
151
|
-
const expected = {
|
|
152
|
-
errors: {
|
|
153
|
-
amount: new NotEnoughBalance(),
|
|
154
|
-
},
|
|
155
|
-
warnings: {},
|
|
156
|
-
estimatedFees: BigNumber(2),
|
|
157
|
-
amount: BigNumber(0),
|
|
158
|
-
totalSpent: BigNumber(2),
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
expect(result).toEqual(expected);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it("should return error for NotEnoughBalance for token account with use all amount option when not enough fees", async () => {
|
|
165
|
-
const account = createFixtureAccountWithSubAccount("coin");
|
|
166
|
-
account.spendableBalance = BigNumber(10);
|
|
167
|
-
|
|
168
|
-
const transaction = createFixtureTransactionWithSubAccount();
|
|
169
|
-
transaction.recipient = "0x" + "0".repeat(64);
|
|
170
|
-
transaction.amount = BigNumber(2000);
|
|
171
|
-
transaction.fees = BigNumber(200);
|
|
172
|
-
transaction.useAllAmount = true;
|
|
173
|
-
|
|
174
|
-
const result = await getTransactionStatus(account, transaction);
|
|
175
|
-
|
|
176
|
-
const expected = {
|
|
177
|
-
errors: {
|
|
178
|
-
amount: new NotEnoughBalance(),
|
|
179
|
-
},
|
|
180
|
-
warnings: {},
|
|
181
|
-
estimatedFees: BigNumber(200),
|
|
182
|
-
amount: BigNumber(1000),
|
|
183
|
-
totalSpent: BigNumber(1000),
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
expect(result).toEqual(expected);
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it("should return error for NotEnoughBalanceFees", async () => {
|
|
190
|
-
const account = createFixtureAccountWithSubAccount("coin");
|
|
191
|
-
account.spendableBalance = BigNumber(1);
|
|
192
|
-
|
|
193
|
-
const transaction = createFixtureTransactionWithSubAccount();
|
|
194
|
-
transaction.recipient = "0x" + "0".repeat(64);
|
|
195
|
-
transaction.amount = BigNumber(2);
|
|
196
|
-
transaction.fees = BigNumber(0);
|
|
197
|
-
transaction.errors = { maxGasAmount: "GasInsufficientBalance" };
|
|
198
|
-
|
|
199
|
-
const result = await getTransactionStatus(account, transaction);
|
|
200
|
-
|
|
201
|
-
const expected = {
|
|
202
|
-
errors: {
|
|
203
|
-
amount: new NotEnoughBalanceFees(),
|
|
204
|
-
},
|
|
205
|
-
warnings: {},
|
|
206
|
-
estimatedFees: BigNumber(0),
|
|
207
|
-
amount: BigNumber(2),
|
|
208
|
-
totalSpent: BigNumber(2),
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
expect(result).toEqual(expected);
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
it("should return error for RecipientRequired", async () => {
|
|
215
|
-
const account = createFixtureAccount();
|
|
216
|
-
account.spendableBalance = BigNumber(10);
|
|
217
|
-
|
|
218
|
-
const transaction = createFixtureTransaction();
|
|
219
|
-
transaction.amount = BigNumber(2);
|
|
220
|
-
transaction.fees = BigNumber(2);
|
|
221
|
-
transaction.recipient = "";
|
|
89
|
+
transaction.amount = new BigNumber(2);
|
|
90
|
+
transaction.fees = new BigNumber(2);
|
|
222
91
|
|
|
223
92
|
const result = await getTransactionStatus(account, transaction);
|
|
224
93
|
|
|
@@ -227,20 +96,20 @@ describe("getTransactionStatus Test", () => {
|
|
|
227
96
|
recipient: new RecipientRequired(),
|
|
228
97
|
},
|
|
229
98
|
warnings: {},
|
|
230
|
-
estimatedFees: BigNumber(2),
|
|
231
|
-
amount: BigNumber(2),
|
|
232
|
-
totalSpent: BigNumber(4),
|
|
99
|
+
estimatedFees: new BigNumber(2),
|
|
100
|
+
amount: new BigNumber(2),
|
|
101
|
+
totalSpent: new BigNumber(4),
|
|
233
102
|
};
|
|
234
103
|
|
|
235
104
|
expect(result).toEqual(expected);
|
|
236
105
|
});
|
|
237
106
|
|
|
238
|
-
it("should return
|
|
107
|
+
it("should return errors for InvalidAddress", async () => {
|
|
239
108
|
const account = createFixtureAccount();
|
|
240
109
|
const transaction = createFixtureTransaction();
|
|
241
110
|
|
|
242
|
-
transaction.amount = BigNumber(2);
|
|
243
|
-
transaction.fees = BigNumber(2);
|
|
111
|
+
transaction.amount = new BigNumber(2);
|
|
112
|
+
transaction.fees = new BigNumber(2);
|
|
244
113
|
transaction.recipient = "0x";
|
|
245
114
|
|
|
246
115
|
const result = await getTransactionStatus(account, transaction);
|
|
@@ -251,20 +120,20 @@ describe("getTransactionStatus Test", () => {
|
|
|
251
120
|
amount: new NotEnoughBalance(),
|
|
252
121
|
},
|
|
253
122
|
warnings: {},
|
|
254
|
-
estimatedFees: BigNumber(2),
|
|
255
|
-
amount: BigNumber(2),
|
|
256
|
-
totalSpent: BigNumber(4),
|
|
123
|
+
estimatedFees: new BigNumber(2),
|
|
124
|
+
amount: new BigNumber(2),
|
|
125
|
+
totalSpent: new BigNumber(4),
|
|
257
126
|
};
|
|
258
127
|
|
|
259
128
|
expect(result).toEqual(expected);
|
|
260
129
|
});
|
|
261
130
|
|
|
262
|
-
it("should return
|
|
131
|
+
it("should return errors for InvalidAddressBecauseDestinationIsAlsoSource", async () => {
|
|
263
132
|
const account = createFixtureAccount();
|
|
264
133
|
const transaction = createFixtureTransaction();
|
|
265
134
|
|
|
266
|
-
transaction.amount = BigNumber(2);
|
|
267
|
-
transaction.fees = BigNumber(2);
|
|
135
|
+
transaction.amount = new BigNumber(2);
|
|
136
|
+
transaction.fees = new BigNumber(2);
|
|
268
137
|
transaction.recipient = "0x" + "0".repeat(64);
|
|
269
138
|
account.freshAddress = transaction.recipient;
|
|
270
139
|
|
|
@@ -276,57 +145,9 @@ describe("getTransactionStatus Test", () => {
|
|
|
276
145
|
amount: new NotEnoughBalance(),
|
|
277
146
|
},
|
|
278
147
|
warnings: {},
|
|
279
|
-
estimatedFees: BigNumber(2),
|
|
280
|
-
amount: BigNumber(2),
|
|
281
|
-
totalSpent: BigNumber(4),
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
expect(result).toEqual(expected);
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
it("should return error for RecipientRequired", async () => {
|
|
288
|
-
const account = createFixtureAccount();
|
|
289
|
-
const transaction = createFixtureTransaction();
|
|
290
|
-
|
|
291
|
-
transaction.amount = BigNumber(2);
|
|
292
|
-
transaction.fees = BigNumber(2);
|
|
293
|
-
transaction.recipient = "";
|
|
294
|
-
account.freshAddress = transaction.recipient;
|
|
295
|
-
|
|
296
|
-
const result = await getTransactionStatus(account, transaction);
|
|
297
|
-
|
|
298
|
-
const expected = {
|
|
299
|
-
errors: {
|
|
300
|
-
recipient: new RecipientRequired(),
|
|
301
|
-
amount: new NotEnoughBalance(),
|
|
302
|
-
},
|
|
303
|
-
warnings: {},
|
|
304
|
-
estimatedFees: BigNumber(2),
|
|
305
|
-
amount: BigNumber(2),
|
|
306
|
-
totalSpent: BigNumber(4),
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
expect(result).toEqual(expected);
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
it("should return right amount and total spent with use all amount option", async () => {
|
|
313
|
-
const account = createFixtureAccount();
|
|
314
|
-
account.spendableBalance = BigNumber(10);
|
|
315
|
-
|
|
316
|
-
const transaction = createFixtureTransaction();
|
|
317
|
-
transaction.recipient = "0x" + "0".repeat(64);
|
|
318
|
-
transaction.amount = BigNumber(2);
|
|
319
|
-
transaction.fees = BigNumber(2);
|
|
320
|
-
transaction.useAllAmount = true;
|
|
321
|
-
|
|
322
|
-
const result = await getTransactionStatus(account, transaction);
|
|
323
|
-
|
|
324
|
-
const expected = {
|
|
325
|
-
errors: {},
|
|
326
|
-
warnings: {},
|
|
327
|
-
estimatedFees: BigNumber(2),
|
|
328
|
-
amount: BigNumber(8),
|
|
329
|
-
totalSpent: BigNumber(10),
|
|
148
|
+
estimatedFees: new BigNumber(2),
|
|
149
|
+
amount: new BigNumber(2),
|
|
150
|
+
totalSpent: new BigNumber(4),
|
|
330
151
|
};
|
|
331
152
|
|
|
332
153
|
expect(result).toEqual(expected);
|