@ledgerhq/coin-aptos 1.9.6-next.0 → 1.10.0-nightly.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -4
- package/lib/__tests__/api/index.test.js +61 -5
- package/lib/__tests__/api/index.test.js.map +1 -1
- package/lib/__tests__/bridge/buildTransaction.test.js +57 -2
- package/lib/__tests__/bridge/buildTransaction.test.js.map +1 -1
- package/lib/__tests__/bridge/getFeesForTransaction.test.js +109 -8
- package/lib/__tests__/bridge/getFeesForTransaction.test.js.map +1 -1
- package/lib/__tests__/bridge/getTransactionStatus.test.js +175 -37
- package/lib/__tests__/bridge/getTransactionStatus.test.js.map +1 -1
- package/lib/__tests__/bridge/logic.test.js +889 -115
- package/lib/__tests__/bridge/logic.test.js.map +1 -1
- package/lib/__tests__/bridge/signOperation.test.js +128 -2
- package/lib/__tests__/bridge/signOperation.test.js.map +1 -1
- package/lib/__tests__/bridge/synchronisation.test.js +1214 -67
- 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 +5 -2
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +30 -4
- package/lib/api/index.js.map +1 -1
- package/lib/bridge/bridge.fixture.d.ts +2 -0
- package/lib/bridge/bridge.fixture.d.ts.map +1 -1
- package/lib/bridge/bridge.fixture.js +85 -13
- package/lib/bridge/bridge.fixture.js.map +1 -1
- package/lib/bridge/buildTransaction.d.ts.map +1 -1
- package/lib/bridge/buildTransaction.js +29 -3
- 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 +12 -7
- package/lib/bridge/getFeesForTransaction.js.map +1 -1
- package/lib/bridge/getTransactionStatus.d.ts.map +1 -1
- package/lib/bridge/getTransactionStatus.js +28 -14
- package/lib/bridge/getTransactionStatus.js.map +1 -1
- package/lib/bridge/logic.d.ts +13 -8
- package/lib/bridge/logic.d.ts.map +1 -1
- package/lib/bridge/logic.js +152 -54
- 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 +17 -3
- package/lib/bridge/signOperation.js.map +1 -1
- package/lib/bridge/synchronisation.d.ts +15 -0
- package/lib/bridge/synchronisation.d.ts.map +1 -1
- package/lib/bridge/synchronisation.js +127 -4
- package/lib/bridge/synchronisation.js.map +1 -1
- package/lib/constants.d.ts +5 -1
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +6 -2
- package/lib/constants.js.map +1 -1
- package/lib/test/bot-specs.d.ts.map +1 -1
- package/lib/test/bot-specs.js +40 -1
- package/lib/test/bot-specs.js.map +1 -1
- package/lib/test/bridgeDatasetTest.d.ts.map +1 -1
- package/lib/test/bridgeDatasetTest.js +44 -62
- package/lib/test/bridgeDatasetTest.js.map +1 -1
- package/lib/test/speculos-deviceActions.d.ts +1 -0
- package/lib/test/speculos-deviceActions.d.ts.map +1 -1
- package/lib/test/speculos-deviceActions.js +37 -5
- package/lib/test/speculos-deviceActions.js.map +1 -1
- package/lib/types/index.d.ts +18 -7
- package/lib/types/index.d.ts.map +1 -1
- package/lib-es/__tests__/api/index.test.js +61 -5
- package/lib-es/__tests__/api/index.test.js.map +1 -1
- package/lib-es/__tests__/bridge/buildTransaction.test.js +58 -3
- package/lib-es/__tests__/bridge/buildTransaction.test.js.map +1 -1
- package/lib-es/__tests__/bridge/getFeesForTransaction.test.js +110 -9
- package/lib-es/__tests__/bridge/getFeesForTransaction.test.js.map +1 -1
- package/lib-es/__tests__/bridge/getTransactionStatus.test.js +177 -39
- package/lib-es/__tests__/bridge/getTransactionStatus.test.js.map +1 -1
- package/lib-es/__tests__/bridge/logic.test.js +891 -117
- package/lib-es/__tests__/bridge/logic.test.js.map +1 -1
- package/lib-es/__tests__/bridge/signOperation.test.js +128 -2
- package/lib-es/__tests__/bridge/signOperation.test.js.map +1 -1
- package/lib-es/__tests__/bridge/synchronisation.test.js +1213 -69
- 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 +5 -2
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +30 -4
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/bridge/bridge.fixture.d.ts +2 -0
- package/lib-es/bridge/bridge.fixture.d.ts.map +1 -1
- package/lib-es/bridge/bridge.fixture.js +82 -12
- 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 +30 -4
- 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 +13 -8
- 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 +28 -14
- package/lib-es/bridge/getTransactionStatus.js.map +1 -1
- package/lib-es/bridge/logic.d.ts +13 -8
- package/lib-es/bridge/logic.d.ts.map +1 -1
- package/lib-es/bridge/logic.js +146 -52
- 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 +17 -3
- package/lib-es/bridge/signOperation.js.map +1 -1
- package/lib-es/bridge/synchronisation.d.ts +15 -0
- package/lib-es/bridge/synchronisation.d.ts.map +1 -1
- package/lib-es/bridge/synchronisation.js +123 -3
- package/lib-es/bridge/synchronisation.js.map +1 -1
- package/lib-es/constants.d.ts +5 -1
- package/lib-es/constants.d.ts.map +1 -1
- package/lib-es/constants.js +5 -1
- 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 +41 -2
- 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 +44 -59
- package/lib-es/test/bridgeDatasetTest.js.map +1 -1
- package/lib-es/test/speculos-deviceActions.d.ts +1 -0
- package/lib-es/test/speculos-deviceActions.d.ts.map +1 -1
- package/lib-es/test/speculos-deviceActions.js +36 -4
- package/lib-es/test/speculos-deviceActions.js.map +1 -1
- package/lib-es/types/index.d.ts +18 -7
- package/lib-es/types/index.d.ts.map +1 -1
- package/package.json +9 -8
- package/src/__tests__/api/index.test.ts +75 -5
- package/src/__tests__/bridge/buildTransaction.test.ts +85 -3
- package/src/__tests__/bridge/getFeesForTransaction.test.ts +144 -9
- package/src/__tests__/bridge/getTransactionStatus.test.ts +217 -38
- package/src/__tests__/bridge/logic.test.ts +922 -118
- package/src/__tests__/bridge/signOperation.test.ts +141 -2
- package/src/__tests__/bridge/synchronisation.test.ts +1265 -71
- package/src/api/graphql/queries.ts +6 -6
- package/src/api/graphql/types.ts +9 -9
- package/src/api/index.ts +32 -5
- package/src/bridge/bridge.fixture.ts +91 -12
- package/src/bridge/buildTransaction.ts +39 -6
- package/src/bridge/estimateMaxSpendable.ts +1 -1
- package/src/bridge/getFeesForTransaction.ts +14 -9
- package/src/bridge/getTransactionStatus.ts +35 -13
- package/src/bridge/logic.ts +202 -63
- package/src/bridge/prepareTransaction.ts +4 -3
- package/src/bridge/signOperation.ts +19 -3
- package/src/bridge/synchronisation.ts +170 -3
- package/src/constants.ts +12 -1
- package/src/test/bot-specs.ts +63 -3
- package/src/test/bridgeDatasetTest.ts +46 -59
- package/src/test/speculos-deviceActions.ts +40 -4
- package/src/types/index.ts +15 -1
|
@@ -6,9 +6,11 @@ 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
|
-
|
|
9
|
+
const bridge_fixture_1 = require("../../bridge/bridge.fixture");
|
|
10
|
+
const cryptoassets_1 = require("@ledgerhq/cryptoassets");
|
|
11
|
+
const index_1 = require("@ledgerhq/coin-framework/account/index");
|
|
12
|
+
jest.mock("@ledgerhq/cryptoassets");
|
|
13
|
+
jest.mock("@ledgerhq/coin-framework/account/index");
|
|
12
14
|
describe("Aptos logic ", () => {
|
|
13
15
|
describe("isTestnet", () => {
|
|
14
16
|
it("should return true for testnet currencies", () => {
|
|
@@ -21,37 +23,44 @@ describe("Aptos logic ", () => {
|
|
|
21
23
|
describe("getMaxSendBalance", () => {
|
|
22
24
|
it("should return the correct max send balance when amount is greater than total gas", () => {
|
|
23
25
|
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)();
|
|
24
28
|
const gas = new bignumber_js_1.default(200);
|
|
25
29
|
const gasPrice = new bignumber_js_1.default(100);
|
|
26
|
-
const result = (0, logic_1.getMaxSendBalance)(
|
|
30
|
+
const result = (0, logic_1.getMaxSendBalance)(gas, gasPrice, account, transaction);
|
|
27
31
|
expect(result.isEqualTo(amount.minus(gas.multipliedBy(gasPrice)))).toBe(true);
|
|
28
32
|
});
|
|
29
33
|
it("should return zero when amount is less than total gas", () => {
|
|
30
|
-
const
|
|
34
|
+
const account = (0, bridge_fixture_1.createFixtureAccount)();
|
|
35
|
+
const transaction = (0, bridge_fixture_1.createFixtureTransaction)();
|
|
31
36
|
const gas = new bignumber_js_1.default(200);
|
|
32
37
|
const gasPrice = new bignumber_js_1.default(100);
|
|
33
|
-
const result = (0, logic_1.getMaxSendBalance)(
|
|
38
|
+
const result = (0, logic_1.getMaxSendBalance)(gas, gasPrice, account, transaction);
|
|
34
39
|
expect(result.isEqualTo(new bignumber_js_1.default(0))).toBe(true);
|
|
35
40
|
});
|
|
36
41
|
it("should return zero when amount is equal to total gas", () => {
|
|
37
|
-
const
|
|
42
|
+
const account = (0, bridge_fixture_1.createFixtureAccount)();
|
|
43
|
+
const transaction = (0, bridge_fixture_1.createFixtureTransaction)();
|
|
38
44
|
const gas = new bignumber_js_1.default(200);
|
|
39
45
|
const gasPrice = new bignumber_js_1.default(100);
|
|
40
|
-
const result = (0, logic_1.getMaxSendBalance)(
|
|
46
|
+
const result = (0, logic_1.getMaxSendBalance)(gas, gasPrice, account, transaction);
|
|
41
47
|
expect(result.isEqualTo(new bignumber_js_1.default(0))).toBe(true);
|
|
42
48
|
});
|
|
43
49
|
it("should handle zero amount", () => {
|
|
44
|
-
const
|
|
50
|
+
const account = (0, bridge_fixture_1.createFixtureAccount)();
|
|
51
|
+
const transaction = (0, bridge_fixture_1.createFixtureTransaction)();
|
|
45
52
|
const gas = new bignumber_js_1.default(200);
|
|
46
53
|
const gasPrice = new bignumber_js_1.default(100);
|
|
47
|
-
const result = (0, logic_1.getMaxSendBalance)(
|
|
54
|
+
const result = (0, logic_1.getMaxSendBalance)(gas, gasPrice, account, transaction);
|
|
48
55
|
expect(result.isEqualTo(new bignumber_js_1.default(0))).toBe(true);
|
|
49
56
|
});
|
|
50
57
|
it("should handle zero gas and gas price", () => {
|
|
51
58
|
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)();
|
|
52
61
|
const gas = new bignumber_js_1.default(0);
|
|
53
62
|
const gasPrice = new bignumber_js_1.default(0);
|
|
54
|
-
const result = (0, logic_1.getMaxSendBalance)(
|
|
63
|
+
const result = (0, logic_1.getMaxSendBalance)(gas, gasPrice, account, transaction);
|
|
55
64
|
expect(result.isEqualTo(amount)).toBe(true);
|
|
56
65
|
});
|
|
57
66
|
});
|
|
@@ -85,7 +94,7 @@ describe("Aptos logic ", () => {
|
|
|
85
94
|
sequence_number: "1",
|
|
86
95
|
version: "1",
|
|
87
96
|
};
|
|
88
|
-
const id = "
|
|
97
|
+
const id = "test_id";
|
|
89
98
|
const result = (0, logic_1.getBlankOperation)(tx, id);
|
|
90
99
|
expect(result).toEqual({
|
|
91
100
|
id: "",
|
|
@@ -110,7 +119,7 @@ describe("Aptos logic ", () => {
|
|
|
110
119
|
timestamp: "1000000",
|
|
111
120
|
sequence_number: "1",
|
|
112
121
|
};
|
|
113
|
-
const id = "
|
|
122
|
+
const id = "test_id";
|
|
114
123
|
const result = (0, logic_1.getBlankOperation)(tx, id);
|
|
115
124
|
expect(result).toEqual({
|
|
116
125
|
id: "",
|
|
@@ -239,9 +248,18 @@ describe("Aptos sync logic ", () => {
|
|
|
239
248
|
(0, logic_1.processRecipients)(payload, "0x11", op, "0x2");
|
|
240
249
|
expect(op.recipients).toContain("0x2");
|
|
241
250
|
});
|
|
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
|
+
});
|
|
242
260
|
});
|
|
243
|
-
describe("
|
|
244
|
-
it("should return
|
|
261
|
+
describe("getResourceAddress", () => {
|
|
262
|
+
it("should return coin name from the change", () => {
|
|
245
263
|
const change = {
|
|
246
264
|
type: "write_resource",
|
|
247
265
|
data: {
|
|
@@ -258,6 +276,14 @@ describe("Aptos sync logic ", () => {
|
|
|
258
276
|
},
|
|
259
277
|
},
|
|
260
278
|
};
|
|
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
|
+
};
|
|
261
287
|
const event = {
|
|
262
288
|
guid: {
|
|
263
289
|
account_address: "0x11",
|
|
@@ -265,10 +291,10 @@ describe("Aptos sync logic ", () => {
|
|
|
265
291
|
},
|
|
266
292
|
type: "0x1::coin::WithdrawEvent",
|
|
267
293
|
};
|
|
268
|
-
const result = (0, logic_1.
|
|
269
|
-
expect(result).
|
|
294
|
+
const result = (0, logic_1.getResourceAddress)(tx, event, "withdraw_events", logic_1.getEventCoinAddress);
|
|
295
|
+
expect(result).toEqual(constants_1.APTOS_ASSET_ID);
|
|
270
296
|
});
|
|
271
|
-
it("should return
|
|
297
|
+
it("should return null for not finding the valid coin in change", () => {
|
|
272
298
|
const change = {
|
|
273
299
|
type: "write_resource",
|
|
274
300
|
data: {
|
|
@@ -285,6 +311,14 @@ describe("Aptos sync logic ", () => {
|
|
|
285
311
|
},
|
|
286
312
|
},
|
|
287
313
|
};
|
|
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
|
+
};
|
|
288
322
|
const event = {
|
|
289
323
|
guid: {
|
|
290
324
|
account_address: "0x11",
|
|
@@ -292,94 +326,152 @@ describe("Aptos sync logic ", () => {
|
|
|
292
326
|
},
|
|
293
327
|
type: "0x1::coin::WithdrawEvent",
|
|
294
328
|
};
|
|
295
|
-
const result = (0, logic_1.
|
|
296
|
-
expect(result).toBe(
|
|
329
|
+
const result = (0, logic_1.getResourceAddress)(tx, event, "withdraw_events", logic_1.getEventCoinAddress);
|
|
330
|
+
expect(result).toBe(null);
|
|
297
331
|
});
|
|
298
|
-
it("should return
|
|
332
|
+
it("should return null for not finding the event name in change", () => {
|
|
299
333
|
const change = {
|
|
300
|
-
type: "
|
|
301
|
-
data: {
|
|
334
|
+
type: "write_resource",
|
|
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],
|
|
302
356
|
};
|
|
303
357
|
const event = {
|
|
304
358
|
guid: {
|
|
305
|
-
account_address: "
|
|
359
|
+
account_address: "0x11",
|
|
306
360
|
creation_number: "1",
|
|
307
361
|
},
|
|
308
362
|
type: "0x1::coin::WithdrawEvent",
|
|
309
363
|
};
|
|
310
|
-
const result = (0, logic_1.
|
|
311
|
-
expect(result).toBe(
|
|
364
|
+
const result = (0, logic_1.getResourceAddress)(tx, event, "withdraw_events", logic_1.getEventCoinAddress);
|
|
365
|
+
expect(result).toBe(null);
|
|
312
366
|
});
|
|
313
|
-
it("should return
|
|
367
|
+
it("should return fungible asset address", () => {
|
|
314
368
|
const change = {
|
|
315
369
|
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],
|
|
316
387
|
};
|
|
317
388
|
const event = {
|
|
318
389
|
guid: {
|
|
319
|
-
account_address: "
|
|
320
|
-
creation_number: "
|
|
390
|
+
account_address: "0x0",
|
|
391
|
+
creation_number: "0",
|
|
392
|
+
},
|
|
393
|
+
type: "0x1::fungible_asset::Deposit",
|
|
394
|
+
data: {
|
|
395
|
+
amount: "100",
|
|
396
|
+
store: "0xsomeaddress",
|
|
321
397
|
},
|
|
322
|
-
type: "0x1::coin::WithdrawEvent",
|
|
323
398
|
};
|
|
324
|
-
const result = (0, logic_1.
|
|
325
|
-
expect(result).
|
|
399
|
+
const result = (0, logic_1.getResourceAddress)(tx, event, "withdraw_events", logic_1.getEventFAAddress);
|
|
400
|
+
expect(result).toEqual("0xassetaddress");
|
|
326
401
|
});
|
|
327
|
-
it("should return
|
|
402
|
+
it("should return null address instead of fungible asset when wrong type", () => {
|
|
328
403
|
const change = {
|
|
329
404
|
type: "write_resource",
|
|
405
|
+
address: "0xsomeaddress",
|
|
330
406
|
data: {
|
|
407
|
+
type: constants_1.APTOS_COIN_CHANGE,
|
|
331
408
|
data: {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
id: {
|
|
335
|
-
addr: "0x11",
|
|
336
|
-
creation_num: "2",
|
|
337
|
-
},
|
|
338
|
-
},
|
|
409
|
+
metadata: {
|
|
410
|
+
inner: "0xassetaddress",
|
|
339
411
|
},
|
|
340
412
|
},
|
|
341
413
|
},
|
|
342
414
|
};
|
|
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
|
+
};
|
|
343
423
|
const event = {
|
|
344
424
|
guid: {
|
|
345
|
-
account_address: "
|
|
346
|
-
creation_number: "
|
|
425
|
+
account_address: "0x0",
|
|
426
|
+
creation_number: "0",
|
|
427
|
+
},
|
|
428
|
+
type: "0x1::fungible_asset::Deposit",
|
|
429
|
+
data: {
|
|
430
|
+
amount: "100",
|
|
431
|
+
store: "0xsomeaddress",
|
|
347
432
|
},
|
|
348
|
-
type: "0x1::coin::WithdrawEvent",
|
|
349
433
|
};
|
|
350
|
-
const result = (0, logic_1.
|
|
351
|
-
expect(result).
|
|
434
|
+
const result = (0, logic_1.getResourceAddress)(tx, event, "withdraw_events", logic_1.getEventFAAddress);
|
|
435
|
+
expect(result).toEqual(null);
|
|
352
436
|
});
|
|
353
|
-
it("should return
|
|
437
|
+
it("should return null address instead of fungible asset when wrong event address", () => {
|
|
354
438
|
const change = {
|
|
355
439
|
type: "write_resource",
|
|
440
|
+
address: "0xsomeaddress",
|
|
356
441
|
data: {
|
|
357
|
-
type:
|
|
442
|
+
type: constants_1.APTOS_FUNGIBLE_STORE,
|
|
358
443
|
data: {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
id: {
|
|
362
|
-
addr: "0x11",
|
|
363
|
-
creation_num: "2",
|
|
364
|
-
},
|
|
365
|
-
},
|
|
444
|
+
metadata: {
|
|
445
|
+
inner: "0xassetaddress",
|
|
366
446
|
},
|
|
367
447
|
},
|
|
368
448
|
},
|
|
369
449
|
};
|
|
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
|
+
};
|
|
370
458
|
const event = {
|
|
371
459
|
guid: {
|
|
372
|
-
account_address: "
|
|
373
|
-
creation_number: "
|
|
460
|
+
account_address: "0x0",
|
|
461
|
+
creation_number: "0",
|
|
462
|
+
},
|
|
463
|
+
type: "0x1::fungible_asset::Deposit",
|
|
464
|
+
data: {
|
|
465
|
+
amount: "100",
|
|
466
|
+
store: "0xwrongaddress",
|
|
374
467
|
},
|
|
375
|
-
type: "0x1::coin::WithdrawEvent",
|
|
376
468
|
};
|
|
377
|
-
const result = (0, logic_1.
|
|
378
|
-
expect(result).
|
|
469
|
+
const result = (0, logic_1.getResourceAddress)(tx, event, "withdraw_events", logic_1.getEventFAAddress);
|
|
470
|
+
expect(result).toEqual(null);
|
|
379
471
|
});
|
|
380
472
|
});
|
|
381
|
-
describe("
|
|
382
|
-
it("should calculate the correct amounts for withdraw and deposit events", () => {
|
|
473
|
+
describe("getCoinAndAmounts", () => {
|
|
474
|
+
it("should calculate the correct legacy coins amounts for withdraw and deposit events", () => {
|
|
383
475
|
const tx = {
|
|
384
476
|
events: [
|
|
385
477
|
{
|
|
@@ -431,35 +523,76 @@ describe("Aptos sync logic ", () => {
|
|
|
431
523
|
],
|
|
432
524
|
};
|
|
433
525
|
const address = "0x11";
|
|
434
|
-
const result = (0, logic_1.
|
|
526
|
+
const result = (0, logic_1.getCoinAndAmounts)(tx, address);
|
|
435
527
|
expect(result.amount_in).toEqual(new bignumber_js_1.default(50));
|
|
436
528
|
expect(result.amount_out).toEqual(new bignumber_js_1.default(100));
|
|
529
|
+
expect(result.coin_id).toEqual(constants_1.APTOS_ASSET_ID);
|
|
437
530
|
});
|
|
438
|
-
it("should
|
|
531
|
+
it("should calculate the correct fungible asset amounts for withdraw and deposit events", () => {
|
|
439
532
|
const tx = {
|
|
440
533
|
events: [
|
|
441
534
|
{
|
|
442
|
-
type: "0x1::
|
|
535
|
+
type: "0x1::fungible_asset::Withdraw",
|
|
443
536
|
guid: {
|
|
444
537
|
account_address: "0x11",
|
|
445
538
|
creation_number: "1",
|
|
446
539
|
},
|
|
447
540
|
data: {
|
|
448
541
|
amount: "100",
|
|
542
|
+
store: "0x22",
|
|
449
543
|
},
|
|
450
544
|
},
|
|
451
545
|
{
|
|
452
|
-
type: "0x1::
|
|
546
|
+
type: "0x1::fungible_asset::Deposit",
|
|
453
547
|
guid: {
|
|
454
548
|
account_address: "0x11",
|
|
455
549
|
creation_number: "2",
|
|
456
550
|
},
|
|
457
551
|
data: {
|
|
458
552
|
amount: "50",
|
|
553
|
+
store: "0x33",
|
|
459
554
|
},
|
|
460
555
|
},
|
|
461
556
|
],
|
|
462
557
|
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
|
+
},
|
|
463
596
|
{
|
|
464
597
|
type: "write_resource",
|
|
465
598
|
data: {
|
|
@@ -468,7 +601,7 @@ describe("Aptos sync logic ", () => {
|
|
|
468
601
|
withdraw_events: {
|
|
469
602
|
guid: {
|
|
470
603
|
id: {
|
|
471
|
-
addr: "
|
|
604
|
+
addr: "0x11",
|
|
472
605
|
creation_num: "1",
|
|
473
606
|
},
|
|
474
607
|
},
|
|
@@ -477,7 +610,7 @@ describe("Aptos sync logic ", () => {
|
|
|
477
610
|
guid: {
|
|
478
611
|
id: {
|
|
479
612
|
addr: "0x11",
|
|
480
|
-
creation_num: "
|
|
613
|
+
creation_num: "2",
|
|
481
614
|
},
|
|
482
615
|
},
|
|
483
616
|
},
|
|
@@ -487,9 +620,10 @@ describe("Aptos sync logic ", () => {
|
|
|
487
620
|
],
|
|
488
621
|
};
|
|
489
622
|
const address = "0x11";
|
|
490
|
-
const result = (0, logic_1.
|
|
623
|
+
const result = (0, logic_1.getCoinAndAmounts)(tx, address);
|
|
491
624
|
expect(result.amount_in).toEqual(new bignumber_js_1.default(0));
|
|
492
|
-
expect(result.amount_out).toEqual(new bignumber_js_1.default(
|
|
625
|
+
expect(result.amount_out).toEqual(new bignumber_js_1.default(100));
|
|
626
|
+
expect(result.coin_id).toEqual("0x44");
|
|
493
627
|
});
|
|
494
628
|
it("should handle transactions with other events", () => {
|
|
495
629
|
const tx = {
|
|
@@ -507,56 +641,53 @@ describe("Aptos sync logic ", () => {
|
|
|
507
641
|
],
|
|
508
642
|
};
|
|
509
643
|
const address = "0x1";
|
|
510
|
-
const result = (0, logic_1.
|
|
644
|
+
const result = (0, logic_1.getCoinAndAmounts)(tx, address);
|
|
511
645
|
expect(result.amount_in).toEqual(new bignumber_js_1.default(0));
|
|
512
646
|
expect(result.amount_out).toEqual(new bignumber_js_1.default(0));
|
|
647
|
+
expect(result.coin_id).toEqual(null);
|
|
513
648
|
});
|
|
514
649
|
});
|
|
515
650
|
describe("calculateAmount", () => {
|
|
516
651
|
it("should calculate the correct amount when the address is the sender", () => {
|
|
517
652
|
const address = "0x11";
|
|
518
653
|
const sender = "0x11";
|
|
519
|
-
const fee = new bignumber_js_1.default(10); // account pays fees
|
|
520
654
|
const amount_in = new bignumber_js_1.default(50);
|
|
521
655
|
const amount_out = new bignumber_js_1.default(100);
|
|
522
|
-
const result = (0, logic_1.calculateAmount)(sender, address,
|
|
656
|
+
const result = (0, logic_1.calculateAmount)(sender, address, amount_in, amount_out);
|
|
523
657
|
// LL negates the amount for SEND transactions during output
|
|
524
|
-
expect(result).toEqual(new bignumber_js_1.default(
|
|
658
|
+
expect(result).toEqual(new bignumber_js_1.default(50)); // -(50 - 100 - 10)
|
|
525
659
|
});
|
|
526
660
|
it("should calculate the correct amount when the address is not the sender", () => {
|
|
527
661
|
const address = "0x11";
|
|
528
662
|
const sender = "0x12";
|
|
529
|
-
const fee = new bignumber_js_1.default(10); // sender pays fees
|
|
530
663
|
const amount_in = new bignumber_js_1.default(100);
|
|
531
664
|
const amount_out = new bignumber_js_1.default(50);
|
|
532
|
-
const result = (0, logic_1.calculateAmount)(sender, address,
|
|
665
|
+
const result = (0, logic_1.calculateAmount)(sender, address, amount_in, amount_out);
|
|
533
666
|
expect(result).toEqual(new bignumber_js_1.default(50)); // 100 - 50
|
|
534
667
|
});
|
|
535
668
|
it("should handle transactions with zero amounts", () => {
|
|
536
669
|
const address = "0x11";
|
|
537
670
|
const sender = "0x11";
|
|
538
|
-
const fee = new bignumber_js_1.default(10);
|
|
539
671
|
const amount_in = new bignumber_js_1.default(0);
|
|
540
672
|
const amount_out = new bignumber_js_1.default(0);
|
|
541
|
-
const result = (0, logic_1.calculateAmount)(sender, address,
|
|
673
|
+
const result = (0, logic_1.calculateAmount)(sender, address, amount_in, amount_out);
|
|
542
674
|
// LL negates the amount for SEND transactions during output
|
|
543
|
-
expect(result).toEqual(new bignumber_js_1.default(
|
|
675
|
+
expect(result).toEqual(new bignumber_js_1.default(0)); // -(0 - 0 - 10)
|
|
544
676
|
});
|
|
545
677
|
it("should get negative numbers (for send tx with deposit to account)", () => {
|
|
546
678
|
const address = "0x11";
|
|
547
679
|
const sender = "0x11";
|
|
548
|
-
const fee = new bignumber_js_1.default(10);
|
|
549
680
|
const amount_in = new bignumber_js_1.default(100);
|
|
550
681
|
const amount_out = new bignumber_js_1.default(0);
|
|
551
|
-
const result = (0, logic_1.calculateAmount)(sender, address,
|
|
682
|
+
const result = (0, logic_1.calculateAmount)(sender, address, amount_in, amount_out);
|
|
552
683
|
// LL negates the amount for SEND transactions during output
|
|
553
|
-
expect(result).toEqual(new bignumber_js_1.default(
|
|
684
|
+
expect(result).toEqual(new bignumber_js_1.default(100).negated()); // 100 - 10
|
|
554
685
|
});
|
|
555
686
|
});
|
|
556
687
|
describe("txsToOps", () => {
|
|
557
|
-
it("should convert transactions to operations correctly", () => {
|
|
688
|
+
it("should convert Aptos transactions to operations correctly", () => {
|
|
558
689
|
const address = "0x11";
|
|
559
|
-
const id = "
|
|
690
|
+
const id = "test_id";
|
|
560
691
|
const txs = [
|
|
561
692
|
{
|
|
562
693
|
hash: "0x123",
|
|
@@ -623,13 +754,13 @@ describe("Aptos sync logic ", () => {
|
|
|
623
754
|
sequence_number: "1",
|
|
624
755
|
},
|
|
625
756
|
];
|
|
626
|
-
const result = (0, logic_1.txsToOps)({ address }, id, txs);
|
|
757
|
+
const [result] = (0, logic_1.txsToOps)({ address }, id, txs);
|
|
627
758
|
expect(result).toHaveLength(1);
|
|
628
759
|
expect(result[0]).toEqual({
|
|
629
760
|
id: expect.any(String),
|
|
630
761
|
hash: "0x123",
|
|
631
762
|
type: constants_1.DIRECTION.OUT,
|
|
632
|
-
value: new bignumber_js_1.default(
|
|
763
|
+
value: new bignumber_js_1.default(100),
|
|
633
764
|
fee: new bignumber_js_1.default(20000),
|
|
634
765
|
blockHash: "0xabc",
|
|
635
766
|
blockHeight: 1,
|
|
@@ -644,7 +775,7 @@ describe("Aptos sync logic ", () => {
|
|
|
644
775
|
});
|
|
645
776
|
it("should skip transactions without functions in payload", () => {
|
|
646
777
|
const address = "0x11";
|
|
647
|
-
const id = "
|
|
778
|
+
const id = "test_id";
|
|
648
779
|
const txs = [
|
|
649
780
|
{
|
|
650
781
|
hash: "0x123",
|
|
@@ -653,12 +784,6 @@ describe("Aptos sync logic ", () => {
|
|
|
653
784
|
gas_unit_price: "100",
|
|
654
785
|
success: true,
|
|
655
786
|
payload: {},
|
|
656
|
-
// payload: {
|
|
657
|
-
// type: "entry_function_payload",
|
|
658
|
-
// function: "0x1::coin::transfer",
|
|
659
|
-
// type_arguments: [],
|
|
660
|
-
// arguments: ["0x12", 100],
|
|
661
|
-
// } as EntryFunctionPayloadResponse,
|
|
662
787
|
events: [],
|
|
663
788
|
changes: [],
|
|
664
789
|
block: { hash: "0xabc", height: 1 },
|
|
@@ -666,12 +791,12 @@ describe("Aptos sync logic ", () => {
|
|
|
666
791
|
sequence_number: "1",
|
|
667
792
|
},
|
|
668
793
|
];
|
|
669
|
-
const result = (0, logic_1.txsToOps)({ address }, id, txs);
|
|
794
|
+
const [result] = (0, logic_1.txsToOps)({ address }, id, txs);
|
|
670
795
|
expect(result).toHaveLength(0);
|
|
671
796
|
});
|
|
672
797
|
it("should skip transactions that result in no Aptos change", () => {
|
|
673
798
|
const address = "0x11";
|
|
674
|
-
const id = "
|
|
799
|
+
const id = "test_id";
|
|
675
800
|
const txs = [
|
|
676
801
|
{
|
|
677
802
|
hash: "0x123",
|
|
@@ -692,71 +817,704 @@ describe("Aptos sync logic ", () => {
|
|
|
692
817
|
sequence_number: "1",
|
|
693
818
|
},
|
|
694
819
|
];
|
|
695
|
-
const result = (0, logic_1.txsToOps)({ address }, id, txs);
|
|
820
|
+
const [result] = (0, logic_1.txsToOps)({ address }, id, txs);
|
|
696
821
|
expect(result).toHaveLength(0);
|
|
697
822
|
});
|
|
698
823
|
it("should handle failed transactions", () => {
|
|
699
|
-
const address = "
|
|
700
|
-
const id = "
|
|
824
|
+
const address = "0xa0d8";
|
|
825
|
+
const id = "test_id";
|
|
701
826
|
const txs = [
|
|
702
827
|
{
|
|
703
|
-
hash: "
|
|
704
|
-
sender: "
|
|
828
|
+
hash: "0x0189",
|
|
829
|
+
sender: "0xa0d8",
|
|
705
830
|
gas_used: "200",
|
|
706
831
|
gas_unit_price: "100",
|
|
707
832
|
success: false,
|
|
708
833
|
payload: {
|
|
709
|
-
type: "entry_function_payload",
|
|
710
834
|
function: "0x1::coin::transfer",
|
|
711
|
-
type_arguments: [],
|
|
712
|
-
arguments: ["
|
|
835
|
+
type_arguments: ["0xd111::staked_coin::StakedAptos"],
|
|
836
|
+
arguments: ["0x4e5e", "50000000"],
|
|
837
|
+
type: "entry_function_payload",
|
|
713
838
|
},
|
|
714
839
|
events: [
|
|
715
840
|
{
|
|
716
|
-
type: "0x1::coin::WithdrawEvent",
|
|
717
841
|
guid: {
|
|
718
|
-
|
|
719
|
-
|
|
842
|
+
creation_number: "0",
|
|
843
|
+
account_address: "0x0",
|
|
720
844
|
},
|
|
845
|
+
sequence_number: "0",
|
|
846
|
+
type: "0x1::transaction_fee::FeeStatement",
|
|
721
847
|
data: {
|
|
722
|
-
|
|
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
|
+
},
|
|
723
886
|
},
|
|
887
|
+
type: "write_resource",
|
|
724
888
|
},
|
|
725
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";
|
|
1017
|
+
const txs = [
|
|
1018
|
+
{
|
|
1019
|
+
hash: "0x123",
|
|
1020
|
+
sender: address,
|
|
1021
|
+
gas_used: "200",
|
|
1022
|
+
gas_unit_price: "100",
|
|
1023
|
+
success: true,
|
|
1024
|
+
payload: {
|
|
1025
|
+
function: "0x1::aptos_account::transfer_coins",
|
|
1026
|
+
type_arguments: ["0xd111::staked_coin::StakedAptos"],
|
|
1027
|
+
arguments: ["0x4e5", "1500000"],
|
|
1028
|
+
type: "entry_function_payload",
|
|
1029
|
+
},
|
|
1030
|
+
events: [
|
|
1031
|
+
{
|
|
1032
|
+
guid: {
|
|
1033
|
+
creation_number: "11",
|
|
1034
|
+
account_address: "0xa0d",
|
|
1035
|
+
},
|
|
1036
|
+
sequence_number: "12",
|
|
1037
|
+
type: "0x1::coin::WithdrawEvent",
|
|
1038
|
+
data: {
|
|
1039
|
+
amount: "1500000",
|
|
1040
|
+
},
|
|
1041
|
+
},
|
|
1042
|
+
{
|
|
1043
|
+
guid: {
|
|
1044
|
+
creation_number: "4",
|
|
1045
|
+
account_address: "0x4e5",
|
|
1046
|
+
},
|
|
1047
|
+
sequence_number: "8",
|
|
726
1048
|
type: "0x1::coin::DepositEvent",
|
|
1049
|
+
data: {
|
|
1050
|
+
amount: "1500000",
|
|
1051
|
+
},
|
|
1052
|
+
},
|
|
1053
|
+
{
|
|
727
1054
|
guid: {
|
|
728
|
-
|
|
729
|
-
|
|
1055
|
+
creation_number: "0",
|
|
1056
|
+
account_address: "0x0",
|
|
730
1057
|
},
|
|
1058
|
+
sequence_number: "0",
|
|
1059
|
+
type: "0x1::transaction_fee::FeeStatement",
|
|
731
1060
|
data: {
|
|
732
|
-
|
|
1061
|
+
execution_gas_units: "6",
|
|
1062
|
+
io_gas_units: "6",
|
|
1063
|
+
storage_fee_octas: "0",
|
|
1064
|
+
storage_fee_refund_octas: "0",
|
|
1065
|
+
total_charge_gas_units: "12",
|
|
733
1066
|
},
|
|
734
1067
|
},
|
|
735
1068
|
],
|
|
736
1069
|
changes: [
|
|
737
1070
|
{
|
|
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
|
+
},
|
|
738
1100
|
type: "write_resource",
|
|
1101
|
+
},
|
|
1102
|
+
{
|
|
1103
|
+
address: "0xa0d",
|
|
1104
|
+
state_key_hash: "0x1709",
|
|
739
1105
|
data: {
|
|
740
|
-
type:
|
|
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
|
+
type: "write_resource",
|
|
1133
|
+
},
|
|
1134
|
+
{
|
|
1135
|
+
address: "0xa0d",
|
|
1136
|
+
state_key_hash: "0x5520",
|
|
1137
|
+
data: {
|
|
1138
|
+
type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
|
|
741
1139
|
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,
|
|
742
1153
|
withdraw_events: {
|
|
1154
|
+
counter: "13",
|
|
743
1155
|
guid: {
|
|
744
1156
|
id: {
|
|
745
|
-
addr: "
|
|
1157
|
+
addr: "0xa0d",
|
|
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",
|
|
746
1188
|
creation_num: "1",
|
|
747
1189
|
},
|
|
748
1190
|
},
|
|
749
1191
|
},
|
|
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
|
+
},
|
|
750
1410
|
deposit_events: {
|
|
1411
|
+
counter: "46",
|
|
751
1412
|
guid: {
|
|
752
1413
|
id: {
|
|
753
|
-
addr: "
|
|
1414
|
+
addr: "0xa0d8",
|
|
754
1415
|
creation_num: "2",
|
|
755
1416
|
},
|
|
756
1417
|
},
|
|
757
1418
|
},
|
|
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
|
+
},
|
|
758
1470
|
},
|
|
759
1471
|
},
|
|
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",
|
|
760
1518
|
},
|
|
761
1519
|
],
|
|
762
1520
|
block: { hash: "0xabc", height: 1 },
|
|
@@ -764,9 +1522,25 @@ describe("Aptos sync logic ", () => {
|
|
|
764
1522
|
sequence_number: "1",
|
|
765
1523
|
},
|
|
766
1524
|
];
|
|
767
|
-
const
|
|
768
|
-
expect(
|
|
769
|
-
expect(
|
|
1525
|
+
const [ops, tokenOps] = (0, logic_1.txsToOps)({ address: "0x6b8c" }, "test_id", txs);
|
|
1526
|
+
expect(ops).toHaveLength(0);
|
|
1527
|
+
expect(tokenOps).toHaveLength(1);
|
|
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
|
+
});
|
|
770
1544
|
});
|
|
771
1545
|
});
|
|
772
1546
|
});
|