@ledgerhq/coin-aptos 2.0.0-nightly.4 → 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 +9 -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,12 +1,12 @@
|
|
|
1
1
|
import BigNumber from "bignumber.js";
|
|
2
|
-
import { createFixtureAccount,
|
|
2
|
+
import { createFixtureAccount, createFixtureTransaction } from "../../bridge/bridge.fixture";
|
|
3
3
|
import getTransactionStatus from "../../bridge/getTransactionStatus";
|
|
4
|
-
import { AmountRequired, FeeNotLoaded, InvalidAddress, InvalidAddressBecauseDestinationIsAlsoSource, NotEnoughBalance,
|
|
4
|
+
import { AmountRequired, FeeNotLoaded, InvalidAddress, InvalidAddressBecauseDestinationIsAlsoSource, NotEnoughBalance, RecipientRequired, } from "@ledgerhq/errors";
|
|
5
5
|
describe("getTransactionStatus Test", () => {
|
|
6
|
-
it("should return
|
|
6
|
+
it("should return errors for AmountRequired", async () => {
|
|
7
7
|
const account = createFixtureAccount();
|
|
8
8
|
const transaction = createFixtureTransaction();
|
|
9
|
-
transaction.fees = BigNumber(2);
|
|
9
|
+
transaction.fees = new BigNumber(2);
|
|
10
10
|
transaction.recipient = "0x" + "0".repeat(64);
|
|
11
11
|
const result = await getTransactionStatus(account, transaction);
|
|
12
12
|
const expected = {
|
|
@@ -14,18 +14,18 @@ describe("getTransactionStatus Test", () => {
|
|
|
14
14
|
amount: new AmountRequired(),
|
|
15
15
|
},
|
|
16
16
|
warnings: {},
|
|
17
|
-
estimatedFees: BigNumber(2),
|
|
18
|
-
amount: BigNumber(0),
|
|
19
|
-
totalSpent: BigNumber(2),
|
|
17
|
+
estimatedFees: new BigNumber(2),
|
|
18
|
+
amount: new BigNumber(0),
|
|
19
|
+
totalSpent: new BigNumber(2),
|
|
20
20
|
};
|
|
21
21
|
expect(result).toEqual(expected);
|
|
22
22
|
});
|
|
23
|
-
it("should return
|
|
23
|
+
it("should return errors for FeeNotLoaded", async () => {
|
|
24
24
|
const account = createFixtureAccount();
|
|
25
|
-
account.
|
|
25
|
+
account.balance = new BigNumber(10);
|
|
26
26
|
const transaction = createFixtureTransaction();
|
|
27
27
|
transaction.fees = null;
|
|
28
|
-
transaction.amount = BigNumber(2);
|
|
28
|
+
transaction.amount = new BigNumber(2);
|
|
29
29
|
transaction.recipient = "0x" + "0".repeat(64);
|
|
30
30
|
const result = await getTransactionStatus(account, transaction);
|
|
31
31
|
const expected = {
|
|
@@ -33,154 +33,54 @@ describe("getTransactionStatus Test", () => {
|
|
|
33
33
|
fees: new FeeNotLoaded(),
|
|
34
34
|
},
|
|
35
35
|
warnings: {},
|
|
36
|
-
estimatedFees: BigNumber(0),
|
|
37
|
-
amount: BigNumber(2),
|
|
38
|
-
totalSpent: BigNumber(2),
|
|
36
|
+
estimatedFees: new BigNumber(0),
|
|
37
|
+
amount: new BigNumber(2),
|
|
38
|
+
totalSpent: new BigNumber(2),
|
|
39
39
|
};
|
|
40
40
|
expect(result).toEqual(expected);
|
|
41
41
|
});
|
|
42
|
-
it("should return
|
|
42
|
+
it("should return errors for NotEnoughBalance", async () => {
|
|
43
43
|
const account = createFixtureAccount();
|
|
44
|
-
account.
|
|
44
|
+
account.balance = new BigNumber(1);
|
|
45
45
|
const transaction = createFixtureTransaction();
|
|
46
46
|
transaction.recipient = "0x" + "0".repeat(64);
|
|
47
|
-
transaction.amount = BigNumber(2);
|
|
48
|
-
transaction.fees = BigNumber(2);
|
|
47
|
+
transaction.amount = new BigNumber(2);
|
|
48
|
+
transaction.fees = new BigNumber(2);
|
|
49
49
|
const result = await getTransactionStatus(account, transaction);
|
|
50
50
|
const expected = {
|
|
51
51
|
errors: {
|
|
52
52
|
amount: new NotEnoughBalance(),
|
|
53
53
|
},
|
|
54
54
|
warnings: {},
|
|
55
|
-
estimatedFees: BigNumber(2),
|
|
56
|
-
amount: BigNumber(2),
|
|
57
|
-
totalSpent: BigNumber(4),
|
|
55
|
+
estimatedFees: new BigNumber(2),
|
|
56
|
+
amount: new BigNumber(2),
|
|
57
|
+
totalSpent: new BigNumber(4),
|
|
58
58
|
};
|
|
59
59
|
expect(result).toEqual(expected);
|
|
60
60
|
});
|
|
61
|
-
it("should return
|
|
61
|
+
it("should return errors for RecipientRequired", async () => {
|
|
62
62
|
const account = createFixtureAccount();
|
|
63
|
-
account.
|
|
63
|
+
account.balance = new BigNumber(10);
|
|
64
64
|
const transaction = createFixtureTransaction();
|
|
65
|
-
transaction.
|
|
66
|
-
transaction.
|
|
67
|
-
transaction.fees = BigNumber(2);
|
|
68
|
-
transaction.useAllAmount = true;
|
|
69
|
-
const result = await getTransactionStatus(account, transaction);
|
|
70
|
-
const expected = {
|
|
71
|
-
errors: {
|
|
72
|
-
amount: new NotEnoughBalance(),
|
|
73
|
-
},
|
|
74
|
-
warnings: {},
|
|
75
|
-
estimatedFees: BigNumber(2),
|
|
76
|
-
amount: BigNumber(0),
|
|
77
|
-
totalSpent: BigNumber(2),
|
|
78
|
-
};
|
|
79
|
-
expect(result).toEqual(expected);
|
|
80
|
-
});
|
|
81
|
-
it("should return error for NotEnoughBalance for token account when not enough tokens", async () => {
|
|
82
|
-
const account = createFixtureAccountWithSubAccount("coin");
|
|
83
|
-
account.spendableBalance = BigNumber(300);
|
|
84
|
-
const transaction = createFixtureTransactionWithSubAccount();
|
|
85
|
-
transaction.recipient = "0x" + "0".repeat(64);
|
|
86
|
-
transaction.amount = BigNumber(2000);
|
|
87
|
-
transaction.fees = BigNumber(200);
|
|
88
|
-
const result = await getTransactionStatus(account, transaction);
|
|
89
|
-
const expected = {
|
|
90
|
-
errors: {
|
|
91
|
-
amount: new NotEnoughBalance(),
|
|
92
|
-
},
|
|
93
|
-
warnings: {},
|
|
94
|
-
estimatedFees: BigNumber(200),
|
|
95
|
-
amount: BigNumber(2000),
|
|
96
|
-
totalSpent: BigNumber(2000),
|
|
97
|
-
};
|
|
98
|
-
expect(result).toEqual(expected);
|
|
99
|
-
});
|
|
100
|
-
it("should return error for NotEnoughBalance with use all amount option", async () => {
|
|
101
|
-
const account = createFixtureAccount();
|
|
102
|
-
account.spendableBalance = BigNumber(1);
|
|
103
|
-
const transaction = createFixtureTransaction();
|
|
104
|
-
transaction.recipient = "0x" + "0".repeat(64);
|
|
105
|
-
transaction.amount = BigNumber(2);
|
|
106
|
-
transaction.fees = BigNumber(2);
|
|
107
|
-
transaction.useAllAmount = true;
|
|
108
|
-
const result = await getTransactionStatus(account, transaction);
|
|
109
|
-
const expected = {
|
|
110
|
-
errors: {
|
|
111
|
-
amount: new NotEnoughBalance(),
|
|
112
|
-
},
|
|
113
|
-
warnings: {},
|
|
114
|
-
estimatedFees: BigNumber(2),
|
|
115
|
-
amount: BigNumber(0),
|
|
116
|
-
totalSpent: BigNumber(2),
|
|
117
|
-
};
|
|
118
|
-
expect(result).toEqual(expected);
|
|
119
|
-
});
|
|
120
|
-
it("should return error for NotEnoughBalance for token account with use all amount option when not enough fees", async () => {
|
|
121
|
-
const account = createFixtureAccountWithSubAccount("coin");
|
|
122
|
-
account.spendableBalance = BigNumber(10);
|
|
123
|
-
const transaction = createFixtureTransactionWithSubAccount();
|
|
124
|
-
transaction.recipient = "0x" + "0".repeat(64);
|
|
125
|
-
transaction.amount = BigNumber(2000);
|
|
126
|
-
transaction.fees = BigNumber(200);
|
|
127
|
-
transaction.useAllAmount = true;
|
|
128
|
-
const result = await getTransactionStatus(account, transaction);
|
|
129
|
-
const expected = {
|
|
130
|
-
errors: {
|
|
131
|
-
amount: new NotEnoughBalance(),
|
|
132
|
-
},
|
|
133
|
-
warnings: {},
|
|
134
|
-
estimatedFees: BigNumber(200),
|
|
135
|
-
amount: BigNumber(1000),
|
|
136
|
-
totalSpent: BigNumber(1000),
|
|
137
|
-
};
|
|
138
|
-
expect(result).toEqual(expected);
|
|
139
|
-
});
|
|
140
|
-
it("should return error for NotEnoughBalanceFees", async () => {
|
|
141
|
-
const account = createFixtureAccountWithSubAccount("coin");
|
|
142
|
-
account.spendableBalance = BigNumber(1);
|
|
143
|
-
const transaction = createFixtureTransactionWithSubAccount();
|
|
144
|
-
transaction.recipient = "0x" + "0".repeat(64);
|
|
145
|
-
transaction.amount = BigNumber(2);
|
|
146
|
-
transaction.fees = BigNumber(0);
|
|
147
|
-
transaction.errors = { maxGasAmount: "GasInsufficientBalance" };
|
|
148
|
-
const result = await getTransactionStatus(account, transaction);
|
|
149
|
-
const expected = {
|
|
150
|
-
errors: {
|
|
151
|
-
amount: new NotEnoughBalanceFees(),
|
|
152
|
-
},
|
|
153
|
-
warnings: {},
|
|
154
|
-
estimatedFees: BigNumber(0),
|
|
155
|
-
amount: BigNumber(2),
|
|
156
|
-
totalSpent: BigNumber(2),
|
|
157
|
-
};
|
|
158
|
-
expect(result).toEqual(expected);
|
|
159
|
-
});
|
|
160
|
-
it("should return error for RecipientRequired", async () => {
|
|
161
|
-
const account = createFixtureAccount();
|
|
162
|
-
account.spendableBalance = BigNumber(10);
|
|
163
|
-
const transaction = createFixtureTransaction();
|
|
164
|
-
transaction.amount = BigNumber(2);
|
|
165
|
-
transaction.fees = BigNumber(2);
|
|
166
|
-
transaction.recipient = "";
|
|
65
|
+
transaction.amount = new BigNumber(2);
|
|
66
|
+
transaction.fees = new BigNumber(2);
|
|
167
67
|
const result = await getTransactionStatus(account, transaction);
|
|
168
68
|
const expected = {
|
|
169
69
|
errors: {
|
|
170
70
|
recipient: new RecipientRequired(),
|
|
171
71
|
},
|
|
172
72
|
warnings: {},
|
|
173
|
-
estimatedFees: BigNumber(2),
|
|
174
|
-
amount: BigNumber(2),
|
|
175
|
-
totalSpent: BigNumber(4),
|
|
73
|
+
estimatedFees: new BigNumber(2),
|
|
74
|
+
amount: new BigNumber(2),
|
|
75
|
+
totalSpent: new BigNumber(4),
|
|
176
76
|
};
|
|
177
77
|
expect(result).toEqual(expected);
|
|
178
78
|
});
|
|
179
|
-
it("should return
|
|
79
|
+
it("should return errors for InvalidAddress", async () => {
|
|
180
80
|
const account = createFixtureAccount();
|
|
181
81
|
const transaction = createFixtureTransaction();
|
|
182
|
-
transaction.amount = BigNumber(2);
|
|
183
|
-
transaction.fees = BigNumber(2);
|
|
82
|
+
transaction.amount = new BigNumber(2);
|
|
83
|
+
transaction.fees = new BigNumber(2);
|
|
184
84
|
transaction.recipient = "0x";
|
|
185
85
|
const result = await getTransactionStatus(account, transaction);
|
|
186
86
|
const expected = {
|
|
@@ -189,17 +89,17 @@ describe("getTransactionStatus Test", () => {
|
|
|
189
89
|
amount: new NotEnoughBalance(),
|
|
190
90
|
},
|
|
191
91
|
warnings: {},
|
|
192
|
-
estimatedFees: BigNumber(2),
|
|
193
|
-
amount: BigNumber(2),
|
|
194
|
-
totalSpent: BigNumber(4),
|
|
92
|
+
estimatedFees: new BigNumber(2),
|
|
93
|
+
amount: new BigNumber(2),
|
|
94
|
+
totalSpent: new BigNumber(4),
|
|
195
95
|
};
|
|
196
96
|
expect(result).toEqual(expected);
|
|
197
97
|
});
|
|
198
|
-
it("should return
|
|
98
|
+
it("should return errors for InvalidAddressBecauseDestinationIsAlsoSource", async () => {
|
|
199
99
|
const account = createFixtureAccount();
|
|
200
100
|
const transaction = createFixtureTransaction();
|
|
201
|
-
transaction.amount = BigNumber(2);
|
|
202
|
-
transaction.fees = BigNumber(2);
|
|
101
|
+
transaction.amount = new BigNumber(2);
|
|
102
|
+
transaction.fees = new BigNumber(2);
|
|
203
103
|
transaction.recipient = "0x" + "0".repeat(64);
|
|
204
104
|
account.freshAddress = transaction.recipient;
|
|
205
105
|
const result = await getTransactionStatus(account, transaction);
|
|
@@ -209,47 +109,9 @@ describe("getTransactionStatus Test", () => {
|
|
|
209
109
|
amount: new NotEnoughBalance(),
|
|
210
110
|
},
|
|
211
111
|
warnings: {},
|
|
212
|
-
estimatedFees: BigNumber(2),
|
|
213
|
-
amount: BigNumber(2),
|
|
214
|
-
totalSpent: BigNumber(4),
|
|
215
|
-
};
|
|
216
|
-
expect(result).toEqual(expected);
|
|
217
|
-
});
|
|
218
|
-
it("should return error for RecipientRequired", async () => {
|
|
219
|
-
const account = createFixtureAccount();
|
|
220
|
-
const transaction = createFixtureTransaction();
|
|
221
|
-
transaction.amount = BigNumber(2);
|
|
222
|
-
transaction.fees = BigNumber(2);
|
|
223
|
-
transaction.recipient = "";
|
|
224
|
-
account.freshAddress = transaction.recipient;
|
|
225
|
-
const result = await getTransactionStatus(account, transaction);
|
|
226
|
-
const expected = {
|
|
227
|
-
errors: {
|
|
228
|
-
recipient: new RecipientRequired(),
|
|
229
|
-
amount: new NotEnoughBalance(),
|
|
230
|
-
},
|
|
231
|
-
warnings: {},
|
|
232
|
-
estimatedFees: BigNumber(2),
|
|
233
|
-
amount: BigNumber(2),
|
|
234
|
-
totalSpent: BigNumber(4),
|
|
235
|
-
};
|
|
236
|
-
expect(result).toEqual(expected);
|
|
237
|
-
});
|
|
238
|
-
it("should return right amount and total spent with use all amount option", async () => {
|
|
239
|
-
const account = createFixtureAccount();
|
|
240
|
-
account.spendableBalance = BigNumber(10);
|
|
241
|
-
const transaction = createFixtureTransaction();
|
|
242
|
-
transaction.recipient = "0x" + "0".repeat(64);
|
|
243
|
-
transaction.amount = BigNumber(2);
|
|
244
|
-
transaction.fees = BigNumber(2);
|
|
245
|
-
transaction.useAllAmount = true;
|
|
246
|
-
const result = await getTransactionStatus(account, transaction);
|
|
247
|
-
const expected = {
|
|
248
|
-
errors: {},
|
|
249
|
-
warnings: {},
|
|
250
|
-
estimatedFees: BigNumber(2),
|
|
251
|
-
amount: BigNumber(8),
|
|
252
|
-
totalSpent: BigNumber(10),
|
|
112
|
+
estimatedFees: new BigNumber(2),
|
|
113
|
+
amount: new BigNumber(2),
|
|
114
|
+
totalSpent: new BigNumber(4),
|
|
253
115
|
};
|
|
254
116
|
expect(result).toEqual(expected);
|
|
255
117
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTransactionStatus.test.js","sourceRoot":"","sources":["../../../src/__tests__/bridge/getTransactionStatus.test.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,
|
|
1
|
+
{"version":3,"file":"getTransactionStatus.test.js","sourceRoot":"","sources":["../../../src/__tests__/bridge/getTransactionStatus.test.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAC7F,OAAO,oBAAoB,MAAM,mCAAmC,CAAC;AACrE,OAAO,EACL,cAAc,EACd,YAAY,EACZ,cAAc,EACd,4CAA4C,EAC5C,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,EAAE,CAAC,yCAAyC,EAAE,KAAK,IAAI,EAAE;QACvD,MAAM,OAAO,GAAG,oBAAoB,EAAE,CAAC;QACvC,MAAM,WAAW,GAAG,wBAAwB,EAAE,CAAC;QAE/C,WAAW,CAAC,IAAI,GAAG,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;QACpC,WAAW,CAAC,SAAS,GAAG,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAE9C,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAEhE,MAAM,QAAQ,GAAG;YACf,MAAM,EAAE;gBACN,MAAM,EAAE,IAAI,cAAc,EAAE;aAC7B;YACD,QAAQ,EAAE,EAAE;YACZ,aAAa,EAAE,IAAI,SAAS,CAAC,CAAC,CAAC;YAC/B,MAAM,EAAE,IAAI,SAAS,CAAC,CAAC,CAAC;YACxB,UAAU,EAAE,IAAI,SAAS,CAAC,CAAC,CAAC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