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