@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
|
@@ -6,11 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
7
7
|
const constants_1 = require("../../constants");
|
|
8
8
|
const logic_1 = require("../../bridge/logic");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
jest.mock("@ledgerhq/cryptoassets");
|
|
13
|
-
jest.mock("@ledgerhq/coin-framework/account/index");
|
|
9
|
+
jest.mock("@ledgerhq/cryptoassets", () => ({
|
|
10
|
+
getCryptoCurrencyById: jest.fn(),
|
|
11
|
+
}));
|
|
14
12
|
describe("Aptos logic ", () => {
|
|
15
13
|
describe("isTestnet", () => {
|
|
16
14
|
it("should return true for testnet currencies", () => {
|
|
@@ -23,44 +21,37 @@ describe("Aptos logic ", () => {
|
|
|
23
21
|
describe("getMaxSendBalance", () => {
|
|
24
22
|
it("should return the correct max send balance when amount is greater than total gas", () => {
|
|
25
23
|
const amount = new bignumber_js_1.default(1000000);
|
|
26
|
-
const account = (0, bridge_fixture_1.createFixtureAccount)({ balance: amount, spendableBalance: amount });
|
|
27
|
-
const transaction = (0, bridge_fixture_1.createFixtureTransaction)();
|
|
28
24
|
const gas = new bignumber_js_1.default(200);
|
|
29
25
|
const gasPrice = new bignumber_js_1.default(100);
|
|
30
|
-
const result = (0, logic_1.getMaxSendBalance)(gas, gasPrice
|
|
26
|
+
const result = (0, logic_1.getMaxSendBalance)(amount, gas, gasPrice);
|
|
31
27
|
expect(result.isEqualTo(amount.minus(gas.multipliedBy(gasPrice)))).toBe(true);
|
|
32
28
|
});
|
|
33
29
|
it("should return zero when amount is less than total gas", () => {
|
|
34
|
-
const
|
|
35
|
-
const transaction = (0, bridge_fixture_1.createFixtureTransaction)();
|
|
30
|
+
const amount = new bignumber_js_1.default(1000);
|
|
36
31
|
const gas = new bignumber_js_1.default(200);
|
|
37
32
|
const gasPrice = new bignumber_js_1.default(100);
|
|
38
|
-
const result = (0, logic_1.getMaxSendBalance)(gas, gasPrice
|
|
33
|
+
const result = (0, logic_1.getMaxSendBalance)(amount, gas, gasPrice);
|
|
39
34
|
expect(result.isEqualTo(new bignumber_js_1.default(0))).toBe(true);
|
|
40
35
|
});
|
|
41
36
|
it("should return zero when amount is equal to total gas", () => {
|
|
42
|
-
const
|
|
43
|
-
const transaction = (0, bridge_fixture_1.createFixtureTransaction)();
|
|
37
|
+
const amount = new bignumber_js_1.default(20000);
|
|
44
38
|
const gas = new bignumber_js_1.default(200);
|
|
45
39
|
const gasPrice = new bignumber_js_1.default(100);
|
|
46
|
-
const result = (0, logic_1.getMaxSendBalance)(gas, gasPrice
|
|
40
|
+
const result = (0, logic_1.getMaxSendBalance)(amount, gas, gasPrice);
|
|
47
41
|
expect(result.isEqualTo(new bignumber_js_1.default(0))).toBe(true);
|
|
48
42
|
});
|
|
49
43
|
it("should handle zero amount", () => {
|
|
50
|
-
const
|
|
51
|
-
const transaction = (0, bridge_fixture_1.createFixtureTransaction)();
|
|
44
|
+
const amount = new bignumber_js_1.default(0);
|
|
52
45
|
const gas = new bignumber_js_1.default(200);
|
|
53
46
|
const gasPrice = new bignumber_js_1.default(100);
|
|
54
|
-
const result = (0, logic_1.getMaxSendBalance)(gas, gasPrice
|
|
47
|
+
const result = (0, logic_1.getMaxSendBalance)(amount, gas, gasPrice);
|
|
55
48
|
expect(result.isEqualTo(new bignumber_js_1.default(0))).toBe(true);
|
|
56
49
|
});
|
|
57
50
|
it("should handle zero gas and gas price", () => {
|
|
58
51
|
const amount = new bignumber_js_1.default(1000000);
|
|
59
|
-
const account = (0, bridge_fixture_1.createFixtureAccount)({ balance: amount, spendableBalance: amount });
|
|
60
|
-
const transaction = (0, bridge_fixture_1.createFixtureTransaction)();
|
|
61
52
|
const gas = new bignumber_js_1.default(0);
|
|
62
53
|
const gasPrice = new bignumber_js_1.default(0);
|
|
63
|
-
const result = (0, logic_1.getMaxSendBalance)(gas, gasPrice
|
|
54
|
+
const result = (0, logic_1.getMaxSendBalance)(amount, gas, gasPrice);
|
|
64
55
|
expect(result.isEqualTo(amount)).toBe(true);
|
|
65
56
|
});
|
|
66
57
|
});
|
|
@@ -94,7 +85,7 @@ describe("Aptos logic ", () => {
|
|
|
94
85
|
sequence_number: "1",
|
|
95
86
|
version: "1",
|
|
96
87
|
};
|
|
97
|
-
const id = "
|
|
88
|
+
const id = "test-id";
|
|
98
89
|
const result = (0, logic_1.getBlankOperation)(tx, id);
|
|
99
90
|
expect(result).toEqual({
|
|
100
91
|
id: "",
|
|
@@ -119,7 +110,7 @@ describe("Aptos logic ", () => {
|
|
|
119
110
|
timestamp: "1000000",
|
|
120
111
|
sequence_number: "1",
|
|
121
112
|
};
|
|
122
|
-
const id = "
|
|
113
|
+
const id = "test-id";
|
|
123
114
|
const result = (0, logic_1.getBlankOperation)(tx, id);
|
|
124
115
|
expect(result).toEqual({
|
|
125
116
|
id: "",
|
|
@@ -248,18 +239,9 @@ describe("Aptos sync logic ", () => {
|
|
|
248
239
|
(0, logic_1.processRecipients)(payload, "0x11", op, "0x2");
|
|
249
240
|
expect(op.recipients).toContain("0x2");
|
|
250
241
|
});
|
|
251
|
-
it("should add recipient for fungible assets transfer-like functions", () => {
|
|
252
|
-
const payload = {
|
|
253
|
-
function: "0x1::primary_fungible_store::transfer",
|
|
254
|
-
typeArguments: [],
|
|
255
|
-
functionArguments: [["0xfff"], "0x13"],
|
|
256
|
-
};
|
|
257
|
-
(0, logic_1.processRecipients)(payload, "0x13", op, "0x1");
|
|
258
|
-
expect(op.recipients).toContain("0x13");
|
|
259
|
-
});
|
|
260
242
|
});
|
|
261
|
-
describe("
|
|
262
|
-
it("should return
|
|
243
|
+
describe("isChangeOfAptos", () => {
|
|
244
|
+
it("should return true for a valid change of Aptos", () => {
|
|
263
245
|
const change = {
|
|
264
246
|
type: "write_resource",
|
|
265
247
|
data: {
|
|
@@ -276,14 +258,6 @@ describe("Aptos sync logic ", () => {
|
|
|
276
258
|
},
|
|
277
259
|
},
|
|
278
260
|
};
|
|
279
|
-
const tx = {
|
|
280
|
-
hash: "0x123",
|
|
281
|
-
block: { hash: "0xabc", height: 1 },
|
|
282
|
-
timestamp: "1000000",
|
|
283
|
-
sequence_number: "1",
|
|
284
|
-
version: "1",
|
|
285
|
-
changes: [change],
|
|
286
|
-
};
|
|
287
261
|
const event = {
|
|
288
262
|
guid: {
|
|
289
263
|
account_address: "0x11",
|
|
@@ -291,10 +265,10 @@ describe("Aptos sync logic ", () => {
|
|
|
291
265
|
},
|
|
292
266
|
type: "0x1::coin::WithdrawEvent",
|
|
293
267
|
};
|
|
294
|
-
const result = (0, logic_1.
|
|
295
|
-
expect(result).
|
|
268
|
+
const result = (0, logic_1.isChangeOfAptos)(change, event, "withdraw_events");
|
|
269
|
+
expect(result).toBe(true);
|
|
296
270
|
});
|
|
297
|
-
it("should return
|
|
271
|
+
it("should return false for an invalid change of Aptos", () => {
|
|
298
272
|
const change = {
|
|
299
273
|
type: "write_resource",
|
|
300
274
|
data: {
|
|
@@ -311,14 +285,6 @@ describe("Aptos sync logic ", () => {
|
|
|
311
285
|
},
|
|
312
286
|
},
|
|
313
287
|
};
|
|
314
|
-
const tx = {
|
|
315
|
-
hash: "0x123",
|
|
316
|
-
block: { hash: "0xabc", height: 1 },
|
|
317
|
-
timestamp: "1000000",
|
|
318
|
-
sequence_number: "1",
|
|
319
|
-
version: "1",
|
|
320
|
-
changes: [change],
|
|
321
|
-
};
|
|
322
288
|
const event = {
|
|
323
289
|
guid: {
|
|
324
290
|
account_address: "0x11",
|
|
@@ -326,152 +292,94 @@ describe("Aptos sync logic ", () => {
|
|
|
326
292
|
},
|
|
327
293
|
type: "0x1::coin::WithdrawEvent",
|
|
328
294
|
};
|
|
329
|
-
const result = (0, logic_1.
|
|
330
|
-
expect(result).toBe(
|
|
295
|
+
const result = (0, logic_1.isChangeOfAptos)(change, event, "withdraw_events");
|
|
296
|
+
expect(result).toBe(false);
|
|
331
297
|
});
|
|
332
|
-
it("should return
|
|
298
|
+
it("should return false for a change with a different WriteSet type", () => {
|
|
333
299
|
const change = {
|
|
334
|
-
type: "
|
|
335
|
-
data: {
|
|
336
|
-
type: constants_1.APTOS_COIN_CHANGE,
|
|
337
|
-
data: {
|
|
338
|
-
other_events: {
|
|
339
|
-
guid: {
|
|
340
|
-
id: {
|
|
341
|
-
addr: "0x12",
|
|
342
|
-
creation_num: "2",
|
|
343
|
-
},
|
|
344
|
-
},
|
|
345
|
-
},
|
|
346
|
-
},
|
|
347
|
-
},
|
|
348
|
-
};
|
|
349
|
-
const tx = {
|
|
350
|
-
hash: "0x123",
|
|
351
|
-
block: { hash: "0xabc", height: 1 },
|
|
352
|
-
timestamp: "1000000",
|
|
353
|
-
sequence_number: "1",
|
|
354
|
-
version: "1",
|
|
355
|
-
changes: [change],
|
|
300
|
+
type: "write_module",
|
|
301
|
+
data: {},
|
|
356
302
|
};
|
|
357
303
|
const event = {
|
|
358
304
|
guid: {
|
|
359
|
-
account_address: "
|
|
305
|
+
account_address: "0x1",
|
|
360
306
|
creation_number: "1",
|
|
361
307
|
},
|
|
362
308
|
type: "0x1::coin::WithdrawEvent",
|
|
363
309
|
};
|
|
364
|
-
const result = (0, logic_1.
|
|
365
|
-
expect(result).toBe(
|
|
310
|
+
const result = (0, logic_1.isChangeOfAptos)(change, event, "withdraw_events");
|
|
311
|
+
expect(result).toBe(false);
|
|
366
312
|
});
|
|
367
|
-
it("should return
|
|
313
|
+
it("should return false if no data in WriteSet Change", () => {
|
|
368
314
|
const change = {
|
|
369
315
|
type: "write_resource",
|
|
370
|
-
address: "0xsomeaddress",
|
|
371
|
-
data: {
|
|
372
|
-
type: constants_1.APTOS_FUNGIBLE_STORE,
|
|
373
|
-
data: {
|
|
374
|
-
metadata: {
|
|
375
|
-
inner: "0xassetaddress",
|
|
376
|
-
},
|
|
377
|
-
},
|
|
378
|
-
},
|
|
379
|
-
};
|
|
380
|
-
const tx = {
|
|
381
|
-
hash: "0x123",
|
|
382
|
-
block: { hash: "0xabc", height: 1 },
|
|
383
|
-
timestamp: "1000000",
|
|
384
|
-
sequence_number: "1",
|
|
385
|
-
version: "1",
|
|
386
|
-
changes: [change],
|
|
387
316
|
};
|
|
388
317
|
const event = {
|
|
389
318
|
guid: {
|
|
390
|
-
account_address: "
|
|
391
|
-
creation_number: "
|
|
392
|
-
},
|
|
393
|
-
type: "0x1::fungible_asset::Deposit",
|
|
394
|
-
data: {
|
|
395
|
-
amount: "100",
|
|
396
|
-
store: "0xsomeaddress",
|
|
319
|
+
account_address: "0x11",
|
|
320
|
+
creation_number: "2",
|
|
397
321
|
},
|
|
322
|
+
type: "0x1::coin::WithdrawEvent",
|
|
398
323
|
};
|
|
399
|
-
const result = (0, logic_1.
|
|
400
|
-
expect(result).
|
|
324
|
+
const result = (0, logic_1.isChangeOfAptos)(change, event, "withdraw_events");
|
|
325
|
+
expect(result).toBe(false);
|
|
401
326
|
});
|
|
402
|
-
it("should return
|
|
327
|
+
it("should return false if no type in change data", () => {
|
|
403
328
|
const change = {
|
|
404
329
|
type: "write_resource",
|
|
405
|
-
address: "0xsomeaddress",
|
|
406
330
|
data: {
|
|
407
|
-
type: constants_1.APTOS_COIN_CHANGE,
|
|
408
331
|
data: {
|
|
409
|
-
|
|
410
|
-
|
|
332
|
+
withdraw_events: {
|
|
333
|
+
guid: {
|
|
334
|
+
id: {
|
|
335
|
+
addr: "0x11",
|
|
336
|
+
creation_num: "2",
|
|
337
|
+
},
|
|
338
|
+
},
|
|
411
339
|
},
|
|
412
340
|
},
|
|
413
341
|
},
|
|
414
342
|
};
|
|
415
|
-
const tx = {
|
|
416
|
-
hash: "0x123",
|
|
417
|
-
block: { hash: "0xabc", height: 1 },
|
|
418
|
-
timestamp: "1000000",
|
|
419
|
-
sequence_number: "1",
|
|
420
|
-
version: "1",
|
|
421
|
-
changes: [change],
|
|
422
|
-
};
|
|
423
343
|
const event = {
|
|
424
344
|
guid: {
|
|
425
|
-
account_address: "
|
|
426
|
-
creation_number: "
|
|
427
|
-
},
|
|
428
|
-
type: "0x1::fungible_asset::Deposit",
|
|
429
|
-
data: {
|
|
430
|
-
amount: "100",
|
|
431
|
-
store: "0xsomeaddress",
|
|
345
|
+
account_address: "0x11",
|
|
346
|
+
creation_number: "2",
|
|
432
347
|
},
|
|
348
|
+
type: "0x1::coin::WithdrawEvent",
|
|
433
349
|
};
|
|
434
|
-
const result = (0, logic_1.
|
|
435
|
-
expect(result).
|
|
350
|
+
const result = (0, logic_1.isChangeOfAptos)(change, event, "withdraw_events");
|
|
351
|
+
expect(result).toBe(false);
|
|
436
352
|
});
|
|
437
|
-
it("should return
|
|
353
|
+
it("should return false for a change with a different WriteSet Change type", () => {
|
|
438
354
|
const change = {
|
|
439
355
|
type: "write_resource",
|
|
440
|
-
address: "0xsomeaddress",
|
|
441
356
|
data: {
|
|
442
|
-
type:
|
|
357
|
+
type: "0x1::coin::CoinStore<0x1::aptos_coin::ANY_OTHER_COIN>",
|
|
443
358
|
data: {
|
|
444
|
-
|
|
445
|
-
|
|
359
|
+
withdraw_events: {
|
|
360
|
+
guid: {
|
|
361
|
+
id: {
|
|
362
|
+
addr: "0x11",
|
|
363
|
+
creation_num: "2",
|
|
364
|
+
},
|
|
365
|
+
},
|
|
446
366
|
},
|
|
447
367
|
},
|
|
448
368
|
},
|
|
449
369
|
};
|
|
450
|
-
const tx = {
|
|
451
|
-
hash: "0x123",
|
|
452
|
-
block: { hash: "0xabc", height: 1 },
|
|
453
|
-
timestamp: "1000000",
|
|
454
|
-
sequence_number: "1",
|
|
455
|
-
version: "1",
|
|
456
|
-
changes: [change],
|
|
457
|
-
};
|
|
458
370
|
const event = {
|
|
459
371
|
guid: {
|
|
460
|
-
account_address: "
|
|
461
|
-
creation_number: "
|
|
462
|
-
},
|
|
463
|
-
type: "0x1::fungible_asset::Deposit",
|
|
464
|
-
data: {
|
|
465
|
-
amount: "100",
|
|
466
|
-
store: "0xwrongaddress",
|
|
372
|
+
account_address: "0x11",
|
|
373
|
+
creation_number: "2",
|
|
467
374
|
},
|
|
375
|
+
type: "0x1::coin::WithdrawEvent",
|
|
468
376
|
};
|
|
469
|
-
const result = (0, logic_1.
|
|
470
|
-
expect(result).
|
|
377
|
+
const result = (0, logic_1.isChangeOfAptos)(change, event, "withdraw_events");
|
|
378
|
+
expect(result).toBe(false);
|
|
471
379
|
});
|
|
472
380
|
});
|
|
473
|
-
describe("
|
|
474
|
-
it("should calculate the correct
|
|
381
|
+
describe("getAptosAmounts", () => {
|
|
382
|
+
it("should calculate the correct amounts for withdraw and deposit events", () => {
|
|
475
383
|
const tx = {
|
|
476
384
|
events: [
|
|
477
385
|
{
|
|
@@ -523,76 +431,35 @@ describe("Aptos sync logic ", () => {
|
|
|
523
431
|
],
|
|
524
432
|
};
|
|
525
433
|
const address = "0x11";
|
|
526
|
-
const result = (0, logic_1.
|
|
434
|
+
const result = (0, logic_1.getAptosAmounts)(tx, address);
|
|
527
435
|
expect(result.amount_in).toEqual(new bignumber_js_1.default(50));
|
|
528
436
|
expect(result.amount_out).toEqual(new bignumber_js_1.default(100));
|
|
529
|
-
expect(result.coin_id).toEqual(constants_1.APTOS_ASSET_ID);
|
|
530
437
|
});
|
|
531
|
-
it("should
|
|
438
|
+
it("should return zero amounts if no matching events are found", () => {
|
|
532
439
|
const tx = {
|
|
533
440
|
events: [
|
|
534
441
|
{
|
|
535
|
-
type: "0x1::
|
|
442
|
+
type: "0x1::coin::WithdrawEvent",
|
|
536
443
|
guid: {
|
|
537
444
|
account_address: "0x11",
|
|
538
445
|
creation_number: "1",
|
|
539
446
|
},
|
|
540
447
|
data: {
|
|
541
448
|
amount: "100",
|
|
542
|
-
store: "0x22",
|
|
543
449
|
},
|
|
544
450
|
},
|
|
545
451
|
{
|
|
546
|
-
type: "0x1::
|
|
452
|
+
type: "0x1::coin::DepositEvent",
|
|
547
453
|
guid: {
|
|
548
454
|
account_address: "0x11",
|
|
549
455
|
creation_number: "2",
|
|
550
456
|
},
|
|
551
457
|
data: {
|
|
552
458
|
amount: "50",
|
|
553
|
-
store: "0x33",
|
|
554
459
|
},
|
|
555
460
|
},
|
|
556
461
|
],
|
|
557
462
|
changes: [
|
|
558
|
-
{
|
|
559
|
-
type: "write_resource",
|
|
560
|
-
address: "0x22",
|
|
561
|
-
data: {
|
|
562
|
-
type: constants_1.APTOS_FUNGIBLE_STORE,
|
|
563
|
-
data: {
|
|
564
|
-
metadata: {
|
|
565
|
-
inner: "0x44",
|
|
566
|
-
},
|
|
567
|
-
transfer_events: {
|
|
568
|
-
guid: {
|
|
569
|
-
id: {
|
|
570
|
-
addr: "0x11",
|
|
571
|
-
creation_num: "2",
|
|
572
|
-
},
|
|
573
|
-
},
|
|
574
|
-
},
|
|
575
|
-
},
|
|
576
|
-
},
|
|
577
|
-
},
|
|
578
|
-
{
|
|
579
|
-
type: "write_resource",
|
|
580
|
-
address: "0x22",
|
|
581
|
-
data: {
|
|
582
|
-
type: constants_1.APTOS_OBJECT_CORE,
|
|
583
|
-
data: {
|
|
584
|
-
owner: "0x11",
|
|
585
|
-
transfer_events: {
|
|
586
|
-
guid: {
|
|
587
|
-
id: {
|
|
588
|
-
addr: "0x22",
|
|
589
|
-
creation_num: "2",
|
|
590
|
-
},
|
|
591
|
-
},
|
|
592
|
-
},
|
|
593
|
-
},
|
|
594
|
-
},
|
|
595
|
-
},
|
|
596
463
|
{
|
|
597
464
|
type: "write_resource",
|
|
598
465
|
data: {
|
|
@@ -601,7 +468,7 @@ describe("Aptos sync logic ", () => {
|
|
|
601
468
|
withdraw_events: {
|
|
602
469
|
guid: {
|
|
603
470
|
id: {
|
|
604
|
-
addr: "
|
|
471
|
+
addr: "0x12", // should fail by address check
|
|
605
472
|
creation_num: "1",
|
|
606
473
|
},
|
|
607
474
|
},
|
|
@@ -610,7 +477,7 @@ describe("Aptos sync logic ", () => {
|
|
|
610
477
|
guid: {
|
|
611
478
|
id: {
|
|
612
479
|
addr: "0x11",
|
|
613
|
-
creation_num: "
|
|
480
|
+
creation_num: "3", // should fail by number check
|
|
614
481
|
},
|
|
615
482
|
},
|
|
616
483
|
},
|
|
@@ -620,10 +487,9 @@ describe("Aptos sync logic ", () => {
|
|
|
620
487
|
],
|
|
621
488
|
};
|
|
622
489
|
const address = "0x11";
|
|
623
|
-
const result = (0, logic_1.
|
|
490
|
+
const result = (0, logic_1.getAptosAmounts)(tx, address);
|
|
624
491
|
expect(result.amount_in).toEqual(new bignumber_js_1.default(0));
|
|
625
|
-
expect(result.amount_out).toEqual(new bignumber_js_1.default(
|
|
626
|
-
expect(result.coin_id).toEqual("0x44");
|
|
492
|
+
expect(result.amount_out).toEqual(new bignumber_js_1.default(0));
|
|
627
493
|
});
|
|
628
494
|
it("should handle transactions with other events", () => {
|
|
629
495
|
const tx = {
|
|
@@ -641,53 +507,56 @@ describe("Aptos sync logic ", () => {
|
|
|
641
507
|
],
|
|
642
508
|
};
|
|
643
509
|
const address = "0x1";
|
|
644
|
-
const result = (0, logic_1.
|
|
510
|
+
const result = (0, logic_1.getAptosAmounts)(tx, address);
|
|
645
511
|
expect(result.amount_in).toEqual(new bignumber_js_1.default(0));
|
|
646
512
|
expect(result.amount_out).toEqual(new bignumber_js_1.default(0));
|
|
647
|
-
expect(result.coin_id).toEqual(null);
|
|
648
513
|
});
|
|
649
514
|
});
|
|
650
515
|
describe("calculateAmount", () => {
|
|
651
516
|
it("should calculate the correct amount when the address is the sender", () => {
|
|
652
517
|
const address = "0x11";
|
|
653
518
|
const sender = "0x11";
|
|
519
|
+
const fee = new bignumber_js_1.default(10); // account pays fees
|
|
654
520
|
const amount_in = new bignumber_js_1.default(50);
|
|
655
521
|
const amount_out = new bignumber_js_1.default(100);
|
|
656
|
-
const result = (0, logic_1.calculateAmount)(sender, address, amount_in, amount_out);
|
|
522
|
+
const result = (0, logic_1.calculateAmount)(sender, address, fee, amount_in, amount_out);
|
|
657
523
|
// LL negates the amount for SEND transactions during output
|
|
658
|
-
expect(result).toEqual(new bignumber_js_1.default(
|
|
524
|
+
expect(result).toEqual(new bignumber_js_1.default(60)); // -(50 - 100 - 10)
|
|
659
525
|
});
|
|
660
526
|
it("should calculate the correct amount when the address is not the sender", () => {
|
|
661
527
|
const address = "0x11";
|
|
662
528
|
const sender = "0x12";
|
|
529
|
+
const fee = new bignumber_js_1.default(10); // sender pays fees
|
|
663
530
|
const amount_in = new bignumber_js_1.default(100);
|
|
664
531
|
const amount_out = new bignumber_js_1.default(50);
|
|
665
|
-
const result = (0, logic_1.calculateAmount)(sender, address, amount_in, amount_out);
|
|
532
|
+
const result = (0, logic_1.calculateAmount)(sender, address, fee, amount_in, amount_out);
|
|
666
533
|
expect(result).toEqual(new bignumber_js_1.default(50)); // 100 - 50
|
|
667
534
|
});
|
|
668
535
|
it("should handle transactions with zero amounts", () => {
|
|
669
536
|
const address = "0x11";
|
|
670
537
|
const sender = "0x11";
|
|
538
|
+
const fee = new bignumber_js_1.default(10);
|
|
671
539
|
const amount_in = new bignumber_js_1.default(0);
|
|
672
540
|
const amount_out = new bignumber_js_1.default(0);
|
|
673
|
-
const result = (0, logic_1.calculateAmount)(sender, address, amount_in, amount_out);
|
|
541
|
+
const result = (0, logic_1.calculateAmount)(sender, address, fee, amount_in, amount_out);
|
|
674
542
|
// LL negates the amount for SEND transactions during output
|
|
675
|
-
expect(result).toEqual(new bignumber_js_1.default(
|
|
543
|
+
expect(result).toEqual(new bignumber_js_1.default(10)); // -(0 - 0 - 10)
|
|
676
544
|
});
|
|
677
545
|
it("should get negative numbers (for send tx with deposit to account)", () => {
|
|
678
546
|
const address = "0x11";
|
|
679
547
|
const sender = "0x11";
|
|
548
|
+
const fee = new bignumber_js_1.default(10);
|
|
680
549
|
const amount_in = new bignumber_js_1.default(100);
|
|
681
550
|
const amount_out = new bignumber_js_1.default(0);
|
|
682
|
-
const result = (0, logic_1.calculateAmount)(sender, address, amount_in, amount_out);
|
|
551
|
+
const result = (0, logic_1.calculateAmount)(sender, address, fee, amount_in, amount_out);
|
|
683
552
|
// LL negates the amount for SEND transactions during output
|
|
684
|
-
expect(result).toEqual(new bignumber_js_1.default(
|
|
553
|
+
expect(result).toEqual(new bignumber_js_1.default(90).negated()); // 100 - 10
|
|
685
554
|
});
|
|
686
555
|
});
|
|
687
556
|
describe("txsToOps", () => {
|
|
688
|
-
it("should convert
|
|
557
|
+
it("should convert transactions to operations correctly", () => {
|
|
689
558
|
const address = "0x11";
|
|
690
|
-
const id = "
|
|
559
|
+
const id = "test-id";
|
|
691
560
|
const txs = [
|
|
692
561
|
{
|
|
693
562
|
hash: "0x123",
|
|
@@ -754,13 +623,13 @@ describe("Aptos sync logic ", () => {
|
|
|
754
623
|
sequence_number: "1",
|
|
755
624
|
},
|
|
756
625
|
];
|
|
757
|
-
const
|
|
626
|
+
const result = (0, logic_1.txsToOps)({ address }, id, txs);
|
|
758
627
|
expect(result).toHaveLength(1);
|
|
759
628
|
expect(result[0]).toEqual({
|
|
760
629
|
id: expect.any(String),
|
|
761
630
|
hash: "0x123",
|
|
762
631
|
type: constants_1.DIRECTION.OUT,
|
|
763
|
-
value: new bignumber_js_1.default(
|
|
632
|
+
value: new bignumber_js_1.default(20100),
|
|
764
633
|
fee: new bignumber_js_1.default(20000),
|
|
765
634
|
blockHash: "0xabc",
|
|
766
635
|
blockHeight: 1,
|
|
@@ -775,7 +644,7 @@ describe("Aptos sync logic ", () => {
|
|
|
775
644
|
});
|
|
776
645
|
it("should skip transactions without functions in payload", () => {
|
|
777
646
|
const address = "0x11";
|
|
778
|
-
const id = "
|
|
647
|
+
const id = "test-id";
|
|
779
648
|
const txs = [
|
|
780
649
|
{
|
|
781
650
|
hash: "0x123",
|
|
@@ -784,6 +653,12 @@ describe("Aptos sync logic ", () => {
|
|
|
784
653
|
gas_unit_price: "100",
|
|
785
654
|
success: true,
|
|
786
655
|
payload: {},
|
|
656
|
+
// payload: {
|
|
657
|
+
// type: "entry_function_payload",
|
|
658
|
+
// function: "0x1::coin::transfer",
|
|
659
|
+
// type_arguments: [],
|
|
660
|
+
// arguments: ["0x12", 100],
|
|
661
|
+
// } as EntryFunctionPayloadResponse,
|
|
787
662
|
events: [],
|
|
788
663
|
changes: [],
|
|
789
664
|
block: { hash: "0xabc", height: 1 },
|
|
@@ -791,12 +666,12 @@ describe("Aptos sync logic ", () => {
|
|
|
791
666
|
sequence_number: "1",
|
|
792
667
|
},
|
|
793
668
|
];
|
|
794
|
-
const
|
|
669
|
+
const result = (0, logic_1.txsToOps)({ address }, id, txs);
|
|
795
670
|
expect(result).toHaveLength(0);
|
|
796
671
|
});
|
|
797
672
|
it("should skip transactions that result in no Aptos change", () => {
|
|
798
673
|
const address = "0x11";
|
|
799
|
-
const id = "
|
|
674
|
+
const id = "test-id";
|
|
800
675
|
const txs = [
|
|
801
676
|
{
|
|
802
677
|
hash: "0x123",
|
|
@@ -817,704 +692,71 @@ describe("Aptos sync logic ", () => {
|
|
|
817
692
|
sequence_number: "1",
|
|
818
693
|
},
|
|
819
694
|
];
|
|
820
|
-
const
|
|
695
|
+
const result = (0, logic_1.txsToOps)({ address }, id, txs);
|
|
821
696
|
expect(result).toHaveLength(0);
|
|
822
697
|
});
|
|
823
698
|
it("should handle failed transactions", () => {
|
|
824
|
-
const address = "
|
|
825
|
-
const id = "
|
|
826
|
-
const txs = [
|
|
827
|
-
{
|
|
828
|
-
hash: "0x0189",
|
|
829
|
-
sender: "0xa0d8",
|
|
830
|
-
gas_used: "200",
|
|
831
|
-
gas_unit_price: "100",
|
|
832
|
-
success: false,
|
|
833
|
-
payload: {
|
|
834
|
-
function: "0x1::coin::transfer",
|
|
835
|
-
type_arguments: ["0xd111::staked_coin::StakedAptos"],
|
|
836
|
-
arguments: ["0x4e5e", "50000000"],
|
|
837
|
-
type: "entry_function_payload",
|
|
838
|
-
},
|
|
839
|
-
events: [
|
|
840
|
-
{
|
|
841
|
-
guid: {
|
|
842
|
-
creation_number: "0",
|
|
843
|
-
account_address: "0x0",
|
|
844
|
-
},
|
|
845
|
-
sequence_number: "0",
|
|
846
|
-
type: "0x1::transaction_fee::FeeStatement",
|
|
847
|
-
data: {
|
|
848
|
-
execution_gas_units: "5",
|
|
849
|
-
io_gas_units: "4",
|
|
850
|
-
storage_fee_octas: "0",
|
|
851
|
-
storage_fee_refund_octas: "0",
|
|
852
|
-
total_charge_gas_units: "8",
|
|
853
|
-
},
|
|
854
|
-
},
|
|
855
|
-
],
|
|
856
|
-
changes: [
|
|
857
|
-
{
|
|
858
|
-
address: "0xa0d8",
|
|
859
|
-
state_key_hash: "0x1709",
|
|
860
|
-
data: {
|
|
861
|
-
type: "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
|
|
862
|
-
data: {
|
|
863
|
-
coin: {
|
|
864
|
-
value: "573163341",
|
|
865
|
-
},
|
|
866
|
-
deposit_events: {
|
|
867
|
-
counter: "45",
|
|
868
|
-
guid: {
|
|
869
|
-
id: {
|
|
870
|
-
addr: "0xa0d8",
|
|
871
|
-
creation_num: "2",
|
|
872
|
-
},
|
|
873
|
-
},
|
|
874
|
-
},
|
|
875
|
-
frozen: false,
|
|
876
|
-
withdraw_events: {
|
|
877
|
-
counter: "82",
|
|
878
|
-
guid: {
|
|
879
|
-
id: {
|
|
880
|
-
addr: "0xa0d8",
|
|
881
|
-
creation_num: "3",
|
|
882
|
-
},
|
|
883
|
-
},
|
|
884
|
-
},
|
|
885
|
-
},
|
|
886
|
-
},
|
|
887
|
-
type: "write_resource",
|
|
888
|
-
},
|
|
889
|
-
{
|
|
890
|
-
address: "0xa0d8",
|
|
891
|
-
state_key_hash: "0x6f1e",
|
|
892
|
-
data: {
|
|
893
|
-
type: "0x1::account::Account",
|
|
894
|
-
data: {
|
|
895
|
-
authentication_key: "0xa0d8",
|
|
896
|
-
coin_register_events: {
|
|
897
|
-
counter: "5",
|
|
898
|
-
guid: {
|
|
899
|
-
id: {
|
|
900
|
-
addr: "0xa0d8",
|
|
901
|
-
creation_num: "0",
|
|
902
|
-
},
|
|
903
|
-
},
|
|
904
|
-
},
|
|
905
|
-
guid_creation_num: "12",
|
|
906
|
-
key_rotation_events: {
|
|
907
|
-
counter: "0",
|
|
908
|
-
guid: {
|
|
909
|
-
id: {
|
|
910
|
-
addr: "0xa0d8",
|
|
911
|
-
creation_num: "1",
|
|
912
|
-
},
|
|
913
|
-
},
|
|
914
|
-
},
|
|
915
|
-
rotation_capability_offer: {
|
|
916
|
-
for: {
|
|
917
|
-
vec: [],
|
|
918
|
-
},
|
|
919
|
-
},
|
|
920
|
-
sequence_number: "83",
|
|
921
|
-
signer_capability_offer: {
|
|
922
|
-
for: {
|
|
923
|
-
vec: [],
|
|
924
|
-
},
|
|
925
|
-
},
|
|
926
|
-
},
|
|
927
|
-
},
|
|
928
|
-
type: "write_resource",
|
|
929
|
-
},
|
|
930
|
-
{
|
|
931
|
-
state_key_hash: "0x6e4b",
|
|
932
|
-
handle: "0x1b85",
|
|
933
|
-
key: "0x0619",
|
|
934
|
-
value: "0x72c5e483c25c96010000000000000000",
|
|
935
|
-
data: null,
|
|
936
|
-
type: "write_table_item",
|
|
937
|
-
},
|
|
938
|
-
],
|
|
939
|
-
block: {
|
|
940
|
-
hash: "0xc496",
|
|
941
|
-
height: 1,
|
|
942
|
-
},
|
|
943
|
-
timestamp: "1000000",
|
|
944
|
-
sequence_number: "1",
|
|
945
|
-
},
|
|
946
|
-
];
|
|
947
|
-
const [result] = (0, logic_1.txsToOps)({ address }, id, txs);
|
|
948
|
-
expect(result).toHaveLength(1);
|
|
949
|
-
expect(result[0]).toEqual({
|
|
950
|
-
id: expect.any(String),
|
|
951
|
-
hash: "0x0189",
|
|
952
|
-
type: constants_1.DIRECTION.OUT,
|
|
953
|
-
value: new bignumber_js_1.default(20000),
|
|
954
|
-
fee: new bignumber_js_1.default(20000),
|
|
955
|
-
blockHash: "0xc496",
|
|
956
|
-
blockHeight: 1,
|
|
957
|
-
senders: ["0xa0d8"],
|
|
958
|
-
recipients: ["0x4e5e"],
|
|
959
|
-
accountId: id,
|
|
960
|
-
date: new Date(1000),
|
|
961
|
-
extra: { version: undefined },
|
|
962
|
-
transactionSequenceNumber: 1,
|
|
963
|
-
hasFailed: true,
|
|
964
|
-
});
|
|
965
|
-
});
|
|
966
|
-
it("should convert Aptos token transactions to operations correctly", () => {
|
|
967
|
-
cryptoassets_1.findTokenByAddressInCurrency.mockReturnValue({
|
|
968
|
-
type: "TokenCurrency",
|
|
969
|
-
id: "aptos/coin/dstapt::staked_coin::stakedaptos",
|
|
970
|
-
contractAddress: "0xd111::staked_coin::StakedAptos",
|
|
971
|
-
parentCurrency: {
|
|
972
|
-
type: "CryptoCurrency",
|
|
973
|
-
id: "aptos",
|
|
974
|
-
coinType: 637,
|
|
975
|
-
name: "Aptos",
|
|
976
|
-
managerAppName: "Aptos",
|
|
977
|
-
ticker: "APT",
|
|
978
|
-
scheme: "aptos",
|
|
979
|
-
color: "#231F20",
|
|
980
|
-
family: "aptos",
|
|
981
|
-
units: [
|
|
982
|
-
{
|
|
983
|
-
name: "APT",
|
|
984
|
-
code: "APT",
|
|
985
|
-
magnitude: 8,
|
|
986
|
-
},
|
|
987
|
-
],
|
|
988
|
-
explorerViews: [
|
|
989
|
-
{
|
|
990
|
-
address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
|
|
991
|
-
tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
|
|
992
|
-
},
|
|
993
|
-
],
|
|
994
|
-
},
|
|
995
|
-
name: "dstAPT",
|
|
996
|
-
tokenType: "coin",
|
|
997
|
-
ticker: "dstAPT",
|
|
998
|
-
disableCountervalue: false,
|
|
999
|
-
delisted: false,
|
|
1000
|
-
units: [
|
|
1001
|
-
{
|
|
1002
|
-
name: "dstAPT",
|
|
1003
|
-
code: "dstAPT",
|
|
1004
|
-
magnitude: 8,
|
|
1005
|
-
},
|
|
1006
|
-
],
|
|
1007
|
-
});
|
|
1008
|
-
jest.mock("../../bridge/logic", () => ({
|
|
1009
|
-
...jest.requireActual("../../bridge/logic"),
|
|
1010
|
-
getResourceAddress: jest.fn().mockReturnValue("0xd111::staked_coin::StakedAptos"),
|
|
1011
|
-
}));
|
|
1012
|
-
index_1.decodeTokenAccountId.mockReturnValue({
|
|
1013
|
-
accountId: "token_account_id",
|
|
1014
|
-
});
|
|
1015
|
-
const address = "0xa0d";
|
|
1016
|
-
const id = "test_id";
|
|
699
|
+
const address = "0x11";
|
|
700
|
+
const id = "test-id";
|
|
1017
701
|
const txs = [
|
|
1018
702
|
{
|
|
1019
703
|
hash: "0x123",
|
|
1020
|
-
sender:
|
|
704
|
+
sender: "0x11",
|
|
1021
705
|
gas_used: "200",
|
|
1022
706
|
gas_unit_price: "100",
|
|
1023
|
-
success:
|
|
707
|
+
success: false,
|
|
1024
708
|
payload: {
|
|
1025
|
-
function: "0x1::aptos_account::transfer_coins",
|
|
1026
|
-
type_arguments: ["0xd111::staked_coin::StakedAptos"],
|
|
1027
|
-
arguments: ["0x4e5", "1500000"],
|
|
1028
709
|
type: "entry_function_payload",
|
|
710
|
+
function: "0x1::coin::transfer",
|
|
711
|
+
type_arguments: [],
|
|
712
|
+
arguments: ["0x12", 100],
|
|
1029
713
|
},
|
|
1030
714
|
events: [
|
|
1031
715
|
{
|
|
1032
|
-
guid: {
|
|
1033
|
-
creation_number: "11",
|
|
1034
|
-
account_address: "0xa0d",
|
|
1035
|
-
},
|
|
1036
|
-
sequence_number: "12",
|
|
1037
716
|
type: "0x1::coin::WithdrawEvent",
|
|
1038
|
-
data: {
|
|
1039
|
-
amount: "1500000",
|
|
1040
|
-
},
|
|
1041
|
-
},
|
|
1042
|
-
{
|
|
1043
717
|
guid: {
|
|
1044
|
-
|
|
1045
|
-
|
|
718
|
+
account_address: "0x11",
|
|
719
|
+
creation_number: "1",
|
|
1046
720
|
},
|
|
1047
|
-
sequence_number: "8",
|
|
1048
|
-
type: "0x1::coin::DepositEvent",
|
|
1049
721
|
data: {
|
|
1050
|
-
amount: "
|
|
722
|
+
amount: "100",
|
|
1051
723
|
},
|
|
1052
724
|
},
|
|
1053
725
|
{
|
|
726
|
+
type: "0x1::coin::DepositEvent",
|
|
1054
727
|
guid: {
|
|
1055
|
-
|
|
1056
|
-
|
|
728
|
+
account_address: "0x12",
|
|
729
|
+
creation_number: "2",
|
|
1057
730
|
},
|
|
1058
|
-
sequence_number: "0",
|
|
1059
|
-
type: "0x1::transaction_fee::FeeStatement",
|
|
1060
731
|
data: {
|
|
1061
|
-
|
|
1062
|
-
io_gas_units: "6",
|
|
1063
|
-
storage_fee_octas: "0",
|
|
1064
|
-
storage_fee_refund_octas: "0",
|
|
1065
|
-
total_charge_gas_units: "12",
|
|
732
|
+
amount: "100",
|
|
1066
733
|
},
|
|
1067
734
|
},
|
|
1068
735
|
],
|
|
1069
736
|
changes: [
|
|
1070
737
|
{
|
|
1071
|
-
address: "0x4e5",
|
|
1072
|
-
state_key_hash: "0x3c0",
|
|
1073
|
-
data: {
|
|
1074
|
-
type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
|
|
1075
|
-
data: {
|
|
1076
|
-
coin: {
|
|
1077
|
-
value: "4000000",
|
|
1078
|
-
},
|
|
1079
|
-
deposit_events: {
|
|
1080
|
-
counter: "9",
|
|
1081
|
-
guid: {
|
|
1082
|
-
id: {
|
|
1083
|
-
addr: "0x4e5",
|
|
1084
|
-
creation_num: "4",
|
|
1085
|
-
},
|
|
1086
|
-
},
|
|
1087
|
-
},
|
|
1088
|
-
frozen: false,
|
|
1089
|
-
withdraw_events: {
|
|
1090
|
-
counter: "6",
|
|
1091
|
-
guid: {
|
|
1092
|
-
id: {
|
|
1093
|
-
addr: "0x4e5",
|
|
1094
|
-
creation_num: "5",
|
|
1095
|
-
},
|
|
1096
|
-
},
|
|
1097
|
-
},
|
|
1098
|
-
},
|
|
1099
|
-
},
|
|
1100
|
-
type: "write_resource",
|
|
1101
|
-
},
|
|
1102
|
-
{
|
|
1103
|
-
address: "0xa0d",
|
|
1104
|
-
state_key_hash: "0x1709",
|
|
1105
|
-
data: {
|
|
1106
|
-
type: "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
|
|
1107
|
-
data: {
|
|
1108
|
-
coin: {
|
|
1109
|
-
value: "68254118",
|
|
1110
|
-
},
|
|
1111
|
-
deposit_events: {
|
|
1112
|
-
counter: "46",
|
|
1113
|
-
guid: {
|
|
1114
|
-
id: {
|
|
1115
|
-
addr: "0xa0d",
|
|
1116
|
-
creation_num: "2",
|
|
1117
|
-
},
|
|
1118
|
-
},
|
|
1119
|
-
},
|
|
1120
|
-
frozen: false,
|
|
1121
|
-
withdraw_events: {
|
|
1122
|
-
counter: "89",
|
|
1123
|
-
guid: {
|
|
1124
|
-
id: {
|
|
1125
|
-
addr: "0xa0d",
|
|
1126
|
-
creation_num: "3",
|
|
1127
|
-
},
|
|
1128
|
-
},
|
|
1129
|
-
},
|
|
1130
|
-
},
|
|
1131
|
-
},
|
|
1132
738
|
type: "write_resource",
|
|
1133
|
-
},
|
|
1134
|
-
{
|
|
1135
|
-
address: "0xa0d",
|
|
1136
|
-
state_key_hash: "0x5520",
|
|
1137
739
|
data: {
|
|
1138
|
-
type:
|
|
740
|
+
type: constants_1.APTOS_COIN_CHANGE,
|
|
1139
741
|
data: {
|
|
1140
|
-
coin: {
|
|
1141
|
-
value: "1000000",
|
|
1142
|
-
},
|
|
1143
|
-
deposit_events: {
|
|
1144
|
-
counter: "7",
|
|
1145
|
-
guid: {
|
|
1146
|
-
id: {
|
|
1147
|
-
addr: "0xa0d",
|
|
1148
|
-
creation_num: "10",
|
|
1149
|
-
},
|
|
1150
|
-
},
|
|
1151
|
-
},
|
|
1152
|
-
frozen: false,
|
|
1153
742
|
withdraw_events: {
|
|
1154
|
-
counter: "13",
|
|
1155
743
|
guid: {
|
|
1156
744
|
id: {
|
|
1157
|
-
addr: "
|
|
1158
|
-
creation_num: "11",
|
|
1159
|
-
},
|
|
1160
|
-
},
|
|
1161
|
-
},
|
|
1162
|
-
},
|
|
1163
|
-
},
|
|
1164
|
-
type: "write_resource",
|
|
1165
|
-
},
|
|
1166
|
-
{
|
|
1167
|
-
address: "0xa0d",
|
|
1168
|
-
state_key_hash: "0x6f1e",
|
|
1169
|
-
data: {
|
|
1170
|
-
type: "0x1::account::Account",
|
|
1171
|
-
data: {
|
|
1172
|
-
authentication_key: "0xa0d",
|
|
1173
|
-
coin_register_events: {
|
|
1174
|
-
counter: "5",
|
|
1175
|
-
guid: {
|
|
1176
|
-
id: {
|
|
1177
|
-
addr: "0xa0d",
|
|
1178
|
-
creation_num: "0",
|
|
1179
|
-
},
|
|
1180
|
-
},
|
|
1181
|
-
},
|
|
1182
|
-
guid_creation_num: "12",
|
|
1183
|
-
key_rotation_events: {
|
|
1184
|
-
counter: "0",
|
|
1185
|
-
guid: {
|
|
1186
|
-
id: {
|
|
1187
|
-
addr: "0xa0d",
|
|
745
|
+
addr: "0x11",
|
|
1188
746
|
creation_num: "1",
|
|
1189
747
|
},
|
|
1190
748
|
},
|
|
1191
749
|
},
|
|
1192
|
-
rotation_capability_offer: {
|
|
1193
|
-
for: {
|
|
1194
|
-
vec: [],
|
|
1195
|
-
},
|
|
1196
|
-
},
|
|
1197
|
-
sequence_number: "122",
|
|
1198
|
-
signer_capability_offer: {
|
|
1199
|
-
for: {
|
|
1200
|
-
vec: [],
|
|
1201
|
-
},
|
|
1202
|
-
},
|
|
1203
|
-
},
|
|
1204
|
-
},
|
|
1205
|
-
type: "write_resource",
|
|
1206
|
-
},
|
|
1207
|
-
{
|
|
1208
|
-
state_key_hash: "0x6e4b",
|
|
1209
|
-
handle: "0x1b85",
|
|
1210
|
-
key: "0x0619",
|
|
1211
|
-
value: "0x1ddaf8da3b1497010000000000000000",
|
|
1212
|
-
data: null,
|
|
1213
|
-
type: "write_table_item",
|
|
1214
|
-
},
|
|
1215
|
-
],
|
|
1216
|
-
block: { hash: "0xabc", height: 1 },
|
|
1217
|
-
timestamp: "1000000",
|
|
1218
|
-
sequence_number: "1",
|
|
1219
|
-
},
|
|
1220
|
-
];
|
|
1221
|
-
const [ops, tokenOps] = (0, logic_1.txsToOps)({ address }, id, txs);
|
|
1222
|
-
expect(ops).toHaveLength(1);
|
|
1223
|
-
expect(ops[0]).toEqual({
|
|
1224
|
-
id: expect.any(String),
|
|
1225
|
-
hash: "0x123",
|
|
1226
|
-
type: "FEES",
|
|
1227
|
-
value: new bignumber_js_1.default(20000),
|
|
1228
|
-
fee: new bignumber_js_1.default(20000),
|
|
1229
|
-
blockHash: "0xabc",
|
|
1230
|
-
blockHeight: 1,
|
|
1231
|
-
senders: ["0xa0d"],
|
|
1232
|
-
recipients: ["0x4e5"],
|
|
1233
|
-
accountId: "token_account_id",
|
|
1234
|
-
date: new Date(1000),
|
|
1235
|
-
extra: { version: undefined },
|
|
1236
|
-
transactionSequenceNumber: 1,
|
|
1237
|
-
hasFailed: false,
|
|
1238
|
-
});
|
|
1239
|
-
expect(tokenOps).toHaveLength(1);
|
|
1240
|
-
expect(tokenOps[0]).toEqual({
|
|
1241
|
-
id: expect.any(String),
|
|
1242
|
-
hash: "0x123",
|
|
1243
|
-
type: constants_1.DIRECTION.OUT,
|
|
1244
|
-
value: new bignumber_js_1.default(1500000),
|
|
1245
|
-
fee: new bignumber_js_1.default(20000),
|
|
1246
|
-
blockHash: "0xabc",
|
|
1247
|
-
blockHeight: 1,
|
|
1248
|
-
senders: ["0xa0d"],
|
|
1249
|
-
recipients: ["0x4e5"],
|
|
1250
|
-
date: new Date(1000),
|
|
1251
|
-
extra: { version: undefined },
|
|
1252
|
-
transactionSequenceNumber: 1,
|
|
1253
|
-
hasFailed: false,
|
|
1254
|
-
});
|
|
1255
|
-
});
|
|
1256
|
-
it("should convert Aptos token transactions to operations correctly", () => {
|
|
1257
|
-
cryptoassets_1.findTokenByAddressInCurrency.mockReturnValue({
|
|
1258
|
-
type: "TokenCurrency",
|
|
1259
|
-
id: "aptos/fungible_asset/cellana_0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12",
|
|
1260
|
-
contractAddress: "0x2ebb",
|
|
1261
|
-
parentCurrency: {
|
|
1262
|
-
type: "CryptoCurrency",
|
|
1263
|
-
id: "aptos",
|
|
1264
|
-
coinType: 637,
|
|
1265
|
-
name: "Aptos",
|
|
1266
|
-
managerAppName: "Aptos",
|
|
1267
|
-
ticker: "APT",
|
|
1268
|
-
scheme: "aptos",
|
|
1269
|
-
color: "#231F20",
|
|
1270
|
-
family: "aptos",
|
|
1271
|
-
units: [
|
|
1272
|
-
{
|
|
1273
|
-
name: "APT",
|
|
1274
|
-
code: "APT",
|
|
1275
|
-
magnitude: 8,
|
|
1276
|
-
},
|
|
1277
|
-
],
|
|
1278
|
-
explorerViews: [
|
|
1279
|
-
{
|
|
1280
|
-
address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
|
|
1281
|
-
tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
|
|
1282
|
-
},
|
|
1283
|
-
],
|
|
1284
|
-
},
|
|
1285
|
-
name: "CELLANA",
|
|
1286
|
-
tokenType: "fungible_asset",
|
|
1287
|
-
ticker: "CELL",
|
|
1288
|
-
disableCountervalue: false,
|
|
1289
|
-
delisted: false,
|
|
1290
|
-
units: [
|
|
1291
|
-
{
|
|
1292
|
-
name: "CELLANA",
|
|
1293
|
-
code: "CELL",
|
|
1294
|
-
magnitude: 8,
|
|
1295
|
-
},
|
|
1296
|
-
],
|
|
1297
|
-
});
|
|
1298
|
-
jest.mock("../../bridge/logic", () => ({
|
|
1299
|
-
...jest.requireActual("../../bridge/logic"),
|
|
1300
|
-
getResourceAddress: jest.fn().mockReturnValue("0x2ebb"),
|
|
1301
|
-
}));
|
|
1302
|
-
index_1.encodeTokenAccountId.mockReturnValue("token_account_id");
|
|
1303
|
-
const txs = [
|
|
1304
|
-
{
|
|
1305
|
-
hash: "0x10c9",
|
|
1306
|
-
sender: "0xa0d8",
|
|
1307
|
-
gas_used: "200",
|
|
1308
|
-
gas_unit_price: "100",
|
|
1309
|
-
success: true,
|
|
1310
|
-
payload: {
|
|
1311
|
-
function: "0x1::primary_fungible_store::transfer",
|
|
1312
|
-
type_arguments: ["0x1::fungible_asset::Metadata"],
|
|
1313
|
-
arguments: [
|
|
1314
|
-
{
|
|
1315
|
-
inner: "0x2ebb",
|
|
1316
|
-
},
|
|
1317
|
-
"0x6b8c",
|
|
1318
|
-
"193",
|
|
1319
|
-
],
|
|
1320
|
-
type: "entry_function_payload",
|
|
1321
|
-
},
|
|
1322
|
-
events: [
|
|
1323
|
-
{
|
|
1324
|
-
guid: {
|
|
1325
|
-
creation_number: "0",
|
|
1326
|
-
account_address: "0x0",
|
|
1327
|
-
},
|
|
1328
|
-
sequence_number: "0",
|
|
1329
|
-
type: "0x1::fungible_asset::Withdraw",
|
|
1330
|
-
data: {
|
|
1331
|
-
amount: "193",
|
|
1332
|
-
store: "0xd475",
|
|
1333
|
-
},
|
|
1334
|
-
},
|
|
1335
|
-
{
|
|
1336
|
-
guid: {
|
|
1337
|
-
creation_number: "0",
|
|
1338
|
-
account_address: "0x0",
|
|
1339
|
-
},
|
|
1340
|
-
sequence_number: "0",
|
|
1341
|
-
type: "0x1::fungible_asset::Deposit",
|
|
1342
|
-
data: {
|
|
1343
|
-
amount: "193",
|
|
1344
|
-
store: "0xaaa9",
|
|
1345
|
-
},
|
|
1346
|
-
},
|
|
1347
|
-
{
|
|
1348
|
-
guid: {
|
|
1349
|
-
creation_number: "0",
|
|
1350
|
-
account_address: "0x0",
|
|
1351
|
-
},
|
|
1352
|
-
sequence_number: "0",
|
|
1353
|
-
type: "0x1::transaction_fee::FeeStatement",
|
|
1354
|
-
data: {
|
|
1355
|
-
execution_gas_units: "4",
|
|
1356
|
-
io_gas_units: "6",
|
|
1357
|
-
storage_fee_octas: "0",
|
|
1358
|
-
storage_fee_refund_octas: "0",
|
|
1359
|
-
total_charge_gas_units: "10",
|
|
1360
|
-
},
|
|
1361
|
-
},
|
|
1362
|
-
],
|
|
1363
|
-
changes: [
|
|
1364
|
-
{
|
|
1365
|
-
address: "0xaaa9",
|
|
1366
|
-
state_key_hash: "0x9a17",
|
|
1367
|
-
data: {
|
|
1368
|
-
type: "0x1::fungible_asset::FungibleStore",
|
|
1369
|
-
data: {
|
|
1370
|
-
balance: "10044959",
|
|
1371
|
-
frozen: false,
|
|
1372
|
-
metadata: {
|
|
1373
|
-
inner: "0x2ebb",
|
|
1374
|
-
},
|
|
1375
|
-
},
|
|
1376
|
-
},
|
|
1377
|
-
type: "write_resource",
|
|
1378
|
-
},
|
|
1379
|
-
{
|
|
1380
|
-
address: "0xaaa9",
|
|
1381
|
-
state_key_hash: "0x9a17",
|
|
1382
|
-
data: {
|
|
1383
|
-
type: "0x1::object::ObjectCore",
|
|
1384
|
-
data: {
|
|
1385
|
-
allow_ungated_transfer: false,
|
|
1386
|
-
guid_creation_num: "1125899906842625",
|
|
1387
|
-
owner: "0x6b8c",
|
|
1388
|
-
transfer_events: {
|
|
1389
|
-
counter: "0",
|
|
1390
|
-
guid: {
|
|
1391
|
-
id: {
|
|
1392
|
-
addr: "0xaaa9",
|
|
1393
|
-
creation_num: "1125899906842624",
|
|
1394
|
-
},
|
|
1395
|
-
},
|
|
1396
|
-
},
|
|
1397
|
-
},
|
|
1398
|
-
},
|
|
1399
|
-
type: "write_resource",
|
|
1400
|
-
},
|
|
1401
|
-
{
|
|
1402
|
-
address: "0xa0d8",
|
|
1403
|
-
state_key_hash: "0x1709",
|
|
1404
|
-
data: {
|
|
1405
|
-
type: "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
|
|
1406
|
-
data: {
|
|
1407
|
-
coin: {
|
|
1408
|
-
value: "98423118",
|
|
1409
|
-
},
|
|
1410
750
|
deposit_events: {
|
|
1411
|
-
counter: "46",
|
|
1412
751
|
guid: {
|
|
1413
752
|
id: {
|
|
1414
|
-
addr: "
|
|
753
|
+
addr: "0x12",
|
|
1415
754
|
creation_num: "2",
|
|
1416
755
|
},
|
|
1417
756
|
},
|
|
1418
757
|
},
|
|
1419
|
-
frozen: false,
|
|
1420
|
-
withdraw_events: {
|
|
1421
|
-
counter: "88",
|
|
1422
|
-
guid: {
|
|
1423
|
-
id: {
|
|
1424
|
-
addr: "0xa0d8",
|
|
1425
|
-
creation_num: "3",
|
|
1426
|
-
},
|
|
1427
|
-
},
|
|
1428
|
-
},
|
|
1429
|
-
},
|
|
1430
|
-
},
|
|
1431
|
-
type: "write_resource",
|
|
1432
|
-
},
|
|
1433
|
-
{
|
|
1434
|
-
address: "0xa0d8",
|
|
1435
|
-
state_key_hash: "0x6f1e",
|
|
1436
|
-
data: {
|
|
1437
|
-
type: "0x1::account::Account",
|
|
1438
|
-
data: {
|
|
1439
|
-
authentication_key: "0xa0d8",
|
|
1440
|
-
coin_register_events: {
|
|
1441
|
-
counter: "5",
|
|
1442
|
-
guid: {
|
|
1443
|
-
id: {
|
|
1444
|
-
addr: "0xa0d8",
|
|
1445
|
-
creation_num: "0",
|
|
1446
|
-
},
|
|
1447
|
-
},
|
|
1448
|
-
},
|
|
1449
|
-
guid_creation_num: "12",
|
|
1450
|
-
key_rotation_events: {
|
|
1451
|
-
counter: "0",
|
|
1452
|
-
guid: {
|
|
1453
|
-
id: {
|
|
1454
|
-
addr: "0xa0d8",
|
|
1455
|
-
creation_num: "1",
|
|
1456
|
-
},
|
|
1457
|
-
},
|
|
1458
|
-
},
|
|
1459
|
-
rotation_capability_offer: {
|
|
1460
|
-
for: {
|
|
1461
|
-
vec: [],
|
|
1462
|
-
},
|
|
1463
|
-
},
|
|
1464
|
-
sequence_number: "108",
|
|
1465
|
-
signer_capability_offer: {
|
|
1466
|
-
for: {
|
|
1467
|
-
vec: [],
|
|
1468
|
-
},
|
|
1469
|
-
},
|
|
1470
758
|
},
|
|
1471
759
|
},
|
|
1472
|
-
type: "write_resource",
|
|
1473
|
-
},
|
|
1474
|
-
{
|
|
1475
|
-
address: "0xd475",
|
|
1476
|
-
state_key_hash: "0x7567",
|
|
1477
|
-
data: {
|
|
1478
|
-
type: "0x1::fungible_asset::FungibleStore",
|
|
1479
|
-
data: {
|
|
1480
|
-
balance: "14000",
|
|
1481
|
-
frozen: false,
|
|
1482
|
-
metadata: {
|
|
1483
|
-
inner: "0x2ebb",
|
|
1484
|
-
},
|
|
1485
|
-
},
|
|
1486
|
-
},
|
|
1487
|
-
type: "write_resource",
|
|
1488
|
-
},
|
|
1489
|
-
{
|
|
1490
|
-
address: "0xd475",
|
|
1491
|
-
state_key_hash: "0x7567",
|
|
1492
|
-
data: {
|
|
1493
|
-
type: "0x1::object::ObjectCore",
|
|
1494
|
-
data: {
|
|
1495
|
-
allow_ungated_transfer: false,
|
|
1496
|
-
guid_creation_num: "1125899906842625",
|
|
1497
|
-
owner: "0xa0d8",
|
|
1498
|
-
transfer_events: {
|
|
1499
|
-
counter: "0",
|
|
1500
|
-
guid: {
|
|
1501
|
-
id: {
|
|
1502
|
-
addr: "0xd475",
|
|
1503
|
-
creation_num: "1125899906842624",
|
|
1504
|
-
},
|
|
1505
|
-
},
|
|
1506
|
-
},
|
|
1507
|
-
},
|
|
1508
|
-
},
|
|
1509
|
-
type: "write_resource",
|
|
1510
|
-
},
|
|
1511
|
-
{
|
|
1512
|
-
state_key_hash: "0x6e4b",
|
|
1513
|
-
handle: "0x1b85",
|
|
1514
|
-
key: "0x0619",
|
|
1515
|
-
value: "0xad4388dc7daf96010000000000000000",
|
|
1516
|
-
data: null,
|
|
1517
|
-
type: "write_table_item",
|
|
1518
760
|
},
|
|
1519
761
|
],
|
|
1520
762
|
block: { hash: "0xabc", height: 1 },
|
|
@@ -1522,25 +764,9 @@ describe("Aptos sync logic ", () => {
|
|
|
1522
764
|
sequence_number: "1",
|
|
1523
765
|
},
|
|
1524
766
|
];
|
|
1525
|
-
const
|
|
1526
|
-
expect(
|
|
1527
|
-
expect(
|
|
1528
|
-
expect(tokenOps[0]).toEqual({
|
|
1529
|
-
id: expect.any(String),
|
|
1530
|
-
accountId: "token_account_id",
|
|
1531
|
-
hash: "0x10c9",
|
|
1532
|
-
type: constants_1.DIRECTION.IN,
|
|
1533
|
-
value: new bignumber_js_1.default(193),
|
|
1534
|
-
fee: new bignumber_js_1.default(20000),
|
|
1535
|
-
blockHash: "0xabc",
|
|
1536
|
-
blockHeight: 1,
|
|
1537
|
-
senders: ["0xa0d8"],
|
|
1538
|
-
recipients: ["0x6b8c"],
|
|
1539
|
-
date: new Date(1000),
|
|
1540
|
-
extra: { version: undefined },
|
|
1541
|
-
transactionSequenceNumber: 1,
|
|
1542
|
-
hasFailed: false,
|
|
1543
|
-
});
|
|
767
|
+
const result = (0, logic_1.txsToOps)({ address }, id, txs);
|
|
768
|
+
expect(result).toHaveLength(1);
|
|
769
|
+
expect(result[0].hasFailed).toBe(true);
|
|
1544
770
|
});
|
|
1545
771
|
});
|
|
1546
772
|
});
|