@ledgerhq/coin-aptos 2.5.1 → 2.5.2-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 +5 -8
- package/CHANGELOG.md +18 -0
- package/lib/__tests__/bridge/deviceTransactionConfig.test.js +115 -30
- package/lib/__tests__/bridge/deviceTransactionConfig.test.js.map +1 -1
- package/lib/__tests__/bridge/getFeesForTransaction.test.js +10 -10
- package/lib/__tests__/bridge/getFeesForTransaction.test.js.map +1 -1
- package/lib/__tests__/bridge/getTransactionStatus.test.js +193 -2
- package/lib/__tests__/bridge/getTransactionStatus.test.js.map +1 -1
- package/lib/__tests__/bridge/index.test.js +4 -1
- package/lib/__tests__/bridge/index.test.js.map +1 -1
- package/lib/__tests__/bridge/logic.test.js +9 -9
- package/lib/__tests__/bridge/logic.test.js.map +1 -1
- package/lib/__tests__/bridge/prepareTransaction.test.js +1 -0
- package/lib/__tests__/bridge/prepareTransaction.test.js.map +1 -1
- package/lib/__tests__/bridge/serialization.d.ts +2 -0
- package/lib/__tests__/bridge/serialization.d.ts.map +1 -0
- package/lib/__tests__/bridge/serialization.js +91 -0
- package/lib/__tests__/bridge/serialization.js.map +1 -0
- package/lib/__tests__/bridge/synchronisation.test.js +763 -23
- package/lib/__tests__/bridge/synchronisation.test.js.map +1 -1
- package/lib/__tests__/logic/staking.test.d.ts +2 -0
- package/lib/__tests__/logic/staking.test.d.ts.map +1 -0
- package/lib/__tests__/logic/staking.test.js +202 -0
- package/lib/__tests__/logic/staking.test.js.map +1 -0
- package/lib/__tests__/network/client.test.js +3 -3
- package/lib/__tests__/network/validators.test.d.ts +2 -0
- package/lib/__tests__/network/validators.test.d.ts.map +1 -0
- package/lib/__tests__/network/validators.test.js +98 -0
- package/lib/__tests__/network/validators.test.js.map +1 -0
- package/lib/__tests__/utils/IconGenerator.test.d.ts +2 -0
- package/lib/__tests__/utils/IconGenerator.test.d.ts.map +1 -0
- package/lib/__tests__/utils/IconGenerator.test.js +14 -0
- package/lib/__tests__/utils/IconGenerator.test.js.map +1 -0
- package/lib/__tests__/utils/index.test.d.ts +2 -0
- package/lib/__tests__/utils/index.test.d.ts.map +1 -0
- package/lib/__tests__/utils/index.test.js +11 -0
- package/lib/__tests__/utils/index.test.js.map +1 -0
- package/lib/bridge/bridge.fixture.d.ts.map +1 -1
- package/lib/bridge/bridge.fixture.js +12 -0
- package/lib/bridge/bridge.fixture.js.map +1 -1
- package/lib/bridge/deviceTransactionConfig.d.ts +7 -8
- package/lib/bridge/deviceTransactionConfig.d.ts.map +1 -1
- package/lib/bridge/deviceTransactionConfig.js +83 -16
- package/lib/bridge/deviceTransactionConfig.js.map +1 -1
- package/lib/bridge/estimateMaxSpendable.d.ts +4 -4
- package/lib/bridge/estimateMaxSpendable.d.ts.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 +8 -4
- package/lib/bridge/getFeesForTransaction.js.map +1 -1
- package/lib/bridge/getTransactionStatus.d.ts +2 -3
- package/lib/bridge/getTransactionStatus.d.ts.map +1 -1
- package/lib/bridge/getTransactionStatus.js +139 -25
- package/lib/bridge/getTransactionStatus.js.map +1 -1
- package/lib/bridge/index.d.ts +3 -3
- package/lib/bridge/index.d.ts.map +1 -1
- package/lib/bridge/index.js +9 -2
- package/lib/bridge/index.js.map +1 -1
- package/lib/bridge/logic.d.ts +3 -3
- package/lib/bridge/logic.d.ts.map +1 -1
- package/lib/bridge/logic.js +23 -9
- package/lib/bridge/logic.js.map +1 -1
- package/lib/bridge/prepareTransaction.d.ts +2 -3
- package/lib/bridge/prepareTransaction.d.ts.map +1 -1
- package/lib/bridge/prepareTransaction.js +46 -10
- package/lib/bridge/prepareTransaction.js.map +1 -1
- package/lib/bridge/serialization.d.ts +7 -0
- package/lib/bridge/serialization.d.ts.map +1 -0
- package/lib/bridge/serialization.js +51 -0
- package/lib/bridge/serialization.js.map +1 -0
- package/lib/bridge/signOperation.d.ts.map +1 -1
- package/lib/bridge/signOperation.js +17 -5
- package/lib/bridge/signOperation.js.map +1 -1
- package/lib/bridge/synchronisation.d.ts +6 -4
- package/lib/bridge/synchronisation.d.ts.map +1 -1
- package/lib/bridge/synchronisation.js +51 -4
- package/lib/bridge/synchronisation.js.map +1 -1
- package/lib/constants.d.ts +25 -1
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +54 -8
- package/lib/constants.js.map +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -15
- package/lib/index.js.map +1 -1
- package/lib/logic/buildTransaction.d.ts.map +1 -1
- package/lib/logic/buildTransaction.js +42 -19
- package/lib/logic/buildTransaction.js.map +1 -1
- package/lib/logic/getCoinAndAmounts.d.ts +2 -0
- package/lib/logic/getCoinAndAmounts.d.ts.map +1 -1
- package/lib/logic/getCoinAndAmounts.js +65 -38
- package/lib/logic/getCoinAndAmounts.js.map +1 -1
- package/lib/logic/staking.d.ts +12 -0
- package/lib/logic/staking.d.ts.map +1 -0
- package/lib/logic/staking.js +81 -0
- package/lib/logic/staking.js.map +1 -0
- package/lib/logic/transactionsToOperations.js +3 -3
- package/lib/logic/transactionsToOperations.js.map +1 -1
- package/lib/network/client.d.ts +4 -1
- package/lib/network/client.d.ts.map +1 -1
- package/lib/network/client.js +32 -1
- package/lib/network/client.js.map +1 -1
- package/lib/network/graphql/queries.d.ts +2 -0
- package/lib/network/graphql/queries.d.ts.map +1 -1
- package/lib/network/graphql/queries.js +42 -2
- package/lib/network/graphql/queries.js.map +1 -1
- package/lib/network/graphql/types.d.ts +57 -6
- package/lib/network/graphql/types.d.ts.map +1 -1
- package/lib/network/index.d.ts.map +1 -1
- package/lib/network/index.js.map +1 -1
- package/lib/network/validators.d.ts +3 -0
- package/lib/network/validators.d.ts.map +1 -0
- package/lib/network/validators.js +42 -0
- package/lib/network/validators.js.map +1 -0
- package/lib/preload-data.d.ts +7 -0
- package/lib/preload-data.d.ts.map +1 -0
- package/lib/preload-data.js +42 -0
- package/lib/preload-data.js.map +1 -0
- package/lib/preload.d.ts +6 -0
- package/lib/preload.d.ts.map +1 -0
- package/lib/preload.js +21 -0
- package/lib/preload.js.map +1 -0
- package/lib/test/bridgeDatasetTest.d.ts.map +1 -1
- package/lib/test/bridgeDatasetTest.js +1 -0
- package/lib/test/bridgeDatasetTest.js.map +1 -1
- package/lib/types/index.d.ts +92 -8
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js.map +1 -1
- package/lib/utils/IconGenerator.d.ts +12 -0
- package/lib/utils/IconGenerator.d.ts.map +1 -0
- package/lib/utils/IconGenerator.js +138 -0
- package/lib/utils/IconGenerator.js.map +1 -0
- package/lib/utils/index.d.ts +3 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/index.js +31 -0
- package/lib/utils/index.js.map +1 -0
- package/lib-es/__tests__/bridge/deviceTransactionConfig.test.js +113 -8
- package/lib-es/__tests__/bridge/deviceTransactionConfig.test.js.map +1 -1
- package/lib-es/__tests__/bridge/getFeesForTransaction.test.js +10 -10
- package/lib-es/__tests__/bridge/getFeesForTransaction.test.js.map +1 -1
- package/lib-es/__tests__/bridge/getTransactionStatus.test.js +194 -3
- package/lib-es/__tests__/bridge/getTransactionStatus.test.js.map +1 -1
- package/lib-es/__tests__/bridge/index.test.js +4 -1
- package/lib-es/__tests__/bridge/index.test.js.map +1 -1
- package/lib-es/__tests__/bridge/logic.test.js +10 -10
- package/lib-es/__tests__/bridge/logic.test.js.map +1 -1
- package/lib-es/__tests__/bridge/prepareTransaction.test.js +1 -0
- package/lib-es/__tests__/bridge/prepareTransaction.test.js.map +1 -1
- package/lib-es/__tests__/bridge/serialization.d.ts +2 -0
- package/lib-es/__tests__/bridge/serialization.d.ts.map +1 -0
- package/lib-es/__tests__/bridge/serialization.js +86 -0
- package/lib-es/__tests__/bridge/serialization.js.map +1 -0
- package/lib-es/__tests__/bridge/synchronisation.test.js +763 -23
- package/lib-es/__tests__/bridge/synchronisation.test.js.map +1 -1
- package/lib-es/__tests__/logic/staking.test.d.ts +2 -0
- package/lib-es/__tests__/logic/staking.test.d.ts.map +1 -0
- package/lib-es/__tests__/logic/staking.test.js +197 -0
- package/lib-es/__tests__/logic/staking.test.js.map +1 -0
- package/lib-es/__tests__/network/client.test.js +3 -3
- package/lib-es/__tests__/network/validators.test.d.ts +2 -0
- package/lib-es/__tests__/network/validators.test.d.ts.map +1 -0
- package/lib-es/__tests__/network/validators.test.js +93 -0
- package/lib-es/__tests__/network/validators.test.js.map +1 -0
- package/lib-es/__tests__/utils/IconGenerator.test.d.ts +2 -0
- package/lib-es/__tests__/utils/IconGenerator.test.d.ts.map +1 -0
- package/lib-es/__tests__/utils/IconGenerator.test.js +12 -0
- package/lib-es/__tests__/utils/IconGenerator.test.js.map +1 -0
- package/lib-es/__tests__/utils/index.test.d.ts +2 -0
- package/lib-es/__tests__/utils/index.test.d.ts.map +1 -0
- package/lib-es/__tests__/utils/index.test.js +9 -0
- package/lib-es/__tests__/utils/index.test.js.map +1 -0
- package/lib-es/bridge/bridge.fixture.d.ts.map +1 -1
- package/lib-es/bridge/bridge.fixture.js +12 -0
- package/lib-es/bridge/bridge.fixture.js.map +1 -1
- package/lib-es/bridge/deviceTransactionConfig.d.ts +7 -8
- package/lib-es/bridge/deviceTransactionConfig.d.ts.map +1 -1
- package/lib-es/bridge/deviceTransactionConfig.js +83 -14
- package/lib-es/bridge/deviceTransactionConfig.js.map +1 -1
- package/lib-es/bridge/estimateMaxSpendable.d.ts +4 -4
- package/lib-es/bridge/estimateMaxSpendable.d.ts.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 +9 -5
- package/lib-es/bridge/getFeesForTransaction.js.map +1 -1
- package/lib-es/bridge/getTransactionStatus.d.ts +2 -3
- package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -1
- package/lib-es/bridge/getTransactionStatus.js +140 -26
- package/lib-es/bridge/getTransactionStatus.js.map +1 -1
- package/lib-es/bridge/index.d.ts +3 -3
- package/lib-es/bridge/index.d.ts.map +1 -1
- package/lib-es/bridge/index.js +9 -2
- package/lib-es/bridge/index.js.map +1 -1
- package/lib-es/bridge/logic.d.ts +3 -3
- package/lib-es/bridge/logic.d.ts.map +1 -1
- package/lib-es/bridge/logic.js +23 -9
- package/lib-es/bridge/logic.js.map +1 -1
- package/lib-es/bridge/prepareTransaction.d.ts +2 -3
- package/lib-es/bridge/prepareTransaction.d.ts.map +1 -1
- package/lib-es/bridge/prepareTransaction.js +46 -10
- package/lib-es/bridge/prepareTransaction.js.map +1 -1
- package/lib-es/bridge/serialization.d.ts +7 -0
- package/lib-es/bridge/serialization.d.ts.map +1 -0
- package/lib-es/bridge/serialization.js +41 -0
- package/lib-es/bridge/serialization.js.map +1 -0
- package/lib-es/bridge/signOperation.d.ts.map +1 -1
- package/lib-es/bridge/signOperation.js +17 -5
- package/lib-es/bridge/signOperation.js.map +1 -1
- package/lib-es/bridge/synchronisation.d.ts +6 -4
- package/lib-es/bridge/synchronisation.d.ts.map +1 -1
- package/lib-es/bridge/synchronisation.js +49 -3
- package/lib-es/bridge/synchronisation.js.map +1 -1
- package/lib-es/constants.d.ts +25 -1
- package/lib-es/constants.d.ts.map +1 -1
- package/lib-es/constants.js +53 -7
- package/lib-es/constants.js.map +1 -1
- package/lib-es/index.d.ts +0 -1
- package/lib-es/index.d.ts.map +1 -1
- package/lib-es/index.js +0 -1
- package/lib-es/index.js.map +1 -1
- package/lib-es/logic/buildTransaction.d.ts.map +1 -1
- package/lib-es/logic/buildTransaction.js +42 -19
- package/lib-es/logic/buildTransaction.js.map +1 -1
- package/lib-es/logic/getCoinAndAmounts.d.ts +2 -0
- package/lib-es/logic/getCoinAndAmounts.d.ts.map +1 -1
- package/lib-es/logic/getCoinAndAmounts.js +66 -39
- package/lib-es/logic/getCoinAndAmounts.js.map +1 -1
- package/lib-es/logic/staking.d.ts +12 -0
- package/lib-es/logic/staking.d.ts.map +1 -0
- package/lib-es/logic/staking.js +67 -0
- package/lib-es/logic/staking.js.map +1 -0
- package/lib-es/logic/transactionsToOperations.js +4 -4
- package/lib-es/logic/transactionsToOperations.js.map +1 -1
- package/lib-es/network/client.d.ts +4 -1
- package/lib-es/network/client.d.ts.map +1 -1
- package/lib-es/network/client.js +32 -1
- package/lib-es/network/client.js.map +1 -1
- package/lib-es/network/graphql/queries.d.ts +2 -0
- package/lib-es/network/graphql/queries.d.ts.map +1 -1
- package/lib-es/network/graphql/queries.js +41 -1
- package/lib-es/network/graphql/queries.js.map +1 -1
- package/lib-es/network/graphql/types.d.ts +57 -6
- package/lib-es/network/graphql/types.d.ts.map +1 -1
- package/lib-es/network/index.d.ts.map +1 -1
- package/lib-es/network/index.js.map +1 -1
- package/lib-es/network/validators.d.ts +3 -0
- package/lib-es/network/validators.d.ts.map +1 -0
- package/lib-es/network/validators.js +35 -0
- package/lib-es/network/validators.js.map +1 -0
- package/lib-es/preload-data.d.ts +7 -0
- package/lib-es/preload-data.d.ts.map +1 -0
- package/lib-es/preload-data.js +36 -0
- package/lib-es/preload-data.js.map +1 -0
- package/lib-es/preload.d.ts +6 -0
- package/lib-es/preload.d.ts.map +1 -0
- package/lib-es/preload.js +16 -0
- package/lib-es/preload.js.map +1 -0
- package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -1
- package/lib-es/test/bridgeDatasetTest.js +1 -0
- package/lib-es/test/bridgeDatasetTest.js.map +1 -1
- package/lib-es/types/index.d.ts +92 -8
- package/lib-es/types/index.d.ts.map +1 -1
- package/lib-es/types/index.js.map +1 -1
- package/lib-es/utils/IconGenerator.d.ts +12 -0
- package/lib-es/utils/IconGenerator.d.ts.map +1 -0
- package/lib-es/utils/IconGenerator.js +134 -0
- package/lib-es/utils/IconGenerator.js.map +1 -0
- package/lib-es/utils/index.d.ts +3 -0
- package/lib-es/utils/index.d.ts.map +1 -0
- package/lib-es/utils/index.js +13 -0
- package/lib-es/utils/index.js.map +1 -0
- package/package.json +14 -9
- package/src/__tests__/bridge/deviceTransactionConfig.test.ts +120 -8
- package/src/__tests__/bridge/getFeesForTransaction.test.ts +10 -10
- package/src/__tests__/bridge/getTransactionStatus.test.ts +247 -3
- package/src/__tests__/bridge/index.test.ts +5 -1
- package/src/__tests__/bridge/logic.test.ts +10 -10
- package/src/__tests__/bridge/prepareTransaction.test.ts +4 -4
- package/src/__tests__/bridge/serialization.ts +103 -0
- package/src/__tests__/bridge/synchronisation.test.ts +798 -32
- package/src/__tests__/logic/staking.test.ts +221 -0
- package/src/__tests__/network/client.test.ts +3 -3
- package/src/__tests__/network/validators.test.ts +105 -0
- package/src/__tests__/utils/IconGenerator.test.ts +13 -0
- package/src/__tests__/utils/index.test.ts +11 -0
- package/src/bridge/bridge.fixture.ts +12 -0
- package/src/bridge/deviceTransactionConfig.ts +90 -21
- package/src/bridge/estimateMaxSpendable.ts +5 -5
- package/src/bridge/getFeesForTransaction.ts +17 -5
- package/src/bridge/getTransactionStatus.ts +208 -32
- package/src/bridge/index.ts +14 -5
- package/src/bridge/logic.ts +28 -12
- package/src/bridge/prepareTransaction.ts +72 -24
- package/src/bridge/serialization.ts +52 -0
- package/src/bridge/signOperation.ts +20 -7
- package/src/bridge/synchronisation.ts +69 -12
- package/src/constants.ts +64 -2
- package/src/index.ts +0 -2
- package/src/logic/buildTransaction.ts +49 -24
- package/src/logic/getCoinAndAmounts.ts +91 -41
- package/src/logic/staking.ts +105 -0
- package/src/logic/transactionsToOperations.ts +5 -5
- package/src/network/client.ts +44 -4
- package/src/network/graphql/queries.ts +46 -1
- package/src/network/graphql/types.ts +63 -6
- package/src/network/index.ts +1 -0
- package/src/network/validators.ts +48 -0
- package/src/preload-data.ts +43 -0
- package/src/preload.ts +23 -0
- package/src/test/bridgeDatasetTest.ts +1 -0
- package/src/types/index.ts +106 -8
- package/src/utils/IconGenerator.ts +166 -0
- package/src/utils/index.ts +16 -0
|
@@ -12,6 +12,7 @@ const synchronisation_1 = require("../../bridge/synchronisation");
|
|
|
12
12
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
13
13
|
const bridge_fixture_1 = require("../../bridge/bridge.fixture");
|
|
14
14
|
const logic_1 = require("../../bridge/logic");
|
|
15
|
+
const live_env_1 = require("@ledgerhq/live-env");
|
|
15
16
|
jest.mock("@ledgerhq/coin-framework/account", () => {
|
|
16
17
|
const originalModule = jest.requireActual("@ledgerhq/coin-framework/account");
|
|
17
18
|
const partialMockedModule = Object.keys(originalModule).reduce((pre, methodName) => {
|
|
@@ -41,7 +42,7 @@ describe("getAccountShape", () => {
|
|
|
41
42
|
});
|
|
42
43
|
it("account with xpub", async () => {
|
|
43
44
|
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
44
|
-
balance:
|
|
45
|
+
balance: (0, bignumber_js_1.default)(0),
|
|
45
46
|
transactions: [],
|
|
46
47
|
blockHeight: 0,
|
|
47
48
|
}));
|
|
@@ -50,7 +51,7 @@ describe("getAccountShape", () => {
|
|
|
50
51
|
}));
|
|
51
52
|
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
52
53
|
jest.mocked(jsHelpers_1.mergeOps).mockReturnValue([]);
|
|
53
|
-
jest.mocked(logic_1.txsToOps).mockReturnValue([[], []]);
|
|
54
|
+
jest.mocked(logic_1.txsToOps).mockReturnValue([[], [], []]);
|
|
54
55
|
const account = await (0, synchronisation_1.getAccountShape)({
|
|
55
56
|
id: "1",
|
|
56
57
|
address: "address",
|
|
@@ -69,8 +70,8 @@ describe("getAccountShape", () => {
|
|
|
69
70
|
freshAddress: "address",
|
|
70
71
|
freshAddressPath: "",
|
|
71
72
|
used: true,
|
|
72
|
-
balance:
|
|
73
|
-
spendableBalance:
|
|
73
|
+
balance: (0, bignumber_js_1.default)(10),
|
|
74
|
+
spendableBalance: (0, bignumber_js_1.default)(10),
|
|
74
75
|
creationDate: new Date(),
|
|
75
76
|
blockHeight: 0,
|
|
76
77
|
currency: (0, index_1.getCryptoCurrencyById)("aptos"),
|
|
@@ -88,7 +89,7 @@ describe("getAccountShape", () => {
|
|
|
88
89
|
});
|
|
89
90
|
it("account without xpub", async () => {
|
|
90
91
|
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
91
|
-
balance:
|
|
92
|
+
balance: (0, bignumber_js_1.default)(0),
|
|
92
93
|
transactions: [],
|
|
93
94
|
blockHeight: 0,
|
|
94
95
|
}));
|
|
@@ -97,7 +98,7 @@ describe("getAccountShape", () => {
|
|
|
97
98
|
}));
|
|
98
99
|
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
99
100
|
jest.mocked(jsHelpers_1.mergeOps).mockReturnValue([]);
|
|
100
|
-
jest.mocked(logic_1.txsToOps).mockReturnValue([[], []]);
|
|
101
|
+
jest.mocked(logic_1.txsToOps).mockReturnValue([[], [], []]);
|
|
101
102
|
const account = await (0, synchronisation_1.getAccountShape)({
|
|
102
103
|
id: "1",
|
|
103
104
|
address: "address",
|
|
@@ -115,8 +116,8 @@ describe("getAccountShape", () => {
|
|
|
115
116
|
freshAddress: "address",
|
|
116
117
|
freshAddressPath: "",
|
|
117
118
|
used: true,
|
|
118
|
-
balance:
|
|
119
|
-
spendableBalance:
|
|
119
|
+
balance: (0, bignumber_js_1.default)(10),
|
|
120
|
+
spendableBalance: (0, bignumber_js_1.default)(10),
|
|
120
121
|
creationDate: new Date(),
|
|
121
122
|
blockHeight: 0,
|
|
122
123
|
currency: (0, index_1.getCryptoCurrencyById)("aptos"),
|
|
@@ -134,7 +135,7 @@ describe("getAccountShape", () => {
|
|
|
134
135
|
});
|
|
135
136
|
it("without initialAccount", async () => {
|
|
136
137
|
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
137
|
-
balance:
|
|
138
|
+
balance: (0, bignumber_js_1.default)(0),
|
|
138
139
|
transactions: [],
|
|
139
140
|
blockHeight: 0,
|
|
140
141
|
}));
|
|
@@ -143,7 +144,7 @@ describe("getAccountShape", () => {
|
|
|
143
144
|
}));
|
|
144
145
|
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
145
146
|
jest.mocked(jsHelpers_1.mergeOps).mockReturnValue([]);
|
|
146
|
-
jest.mocked(logic_1.txsToOps).mockReturnValue([[], []]);
|
|
147
|
+
jest.mocked(logic_1.txsToOps).mockReturnValue([[], [], []]);
|
|
147
148
|
const account = await (0, synchronisation_1.getAccountShape)({
|
|
148
149
|
id: "1",
|
|
149
150
|
address: "address",
|
|
@@ -160,7 +161,7 @@ describe("getAccountShape", () => {
|
|
|
160
161
|
});
|
|
161
162
|
it("initialAccount with operations", async () => {
|
|
162
163
|
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
163
|
-
balance:
|
|
164
|
+
balance: (0, bignumber_js_1.default)(0),
|
|
164
165
|
transactions: [],
|
|
165
166
|
blockHeight: 0,
|
|
166
167
|
}));
|
|
@@ -169,7 +170,7 @@ describe("getAccountShape", () => {
|
|
|
169
170
|
}));
|
|
170
171
|
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
171
172
|
jest.mocked(jsHelpers_1.mergeOps).mockReturnValue([]);
|
|
172
|
-
jest.mocked(logic_1.txsToOps).mockReturnValue([[], []]);
|
|
173
|
+
jest.mocked(logic_1.txsToOps).mockReturnValue([[], [], []]);
|
|
173
174
|
const account = await (0, synchronisation_1.getAccountShape)({
|
|
174
175
|
id: "1",
|
|
175
176
|
address: "address",
|
|
@@ -187,8 +188,8 @@ describe("getAccountShape", () => {
|
|
|
187
188
|
freshAddress: "address",
|
|
188
189
|
freshAddressPath: "",
|
|
189
190
|
used: true,
|
|
190
|
-
balance:
|
|
191
|
-
spendableBalance:
|
|
191
|
+
balance: (0, bignumber_js_1.default)(10),
|
|
192
|
+
spendableBalance: (0, bignumber_js_1.default)(10),
|
|
192
193
|
creationDate: new Date(),
|
|
193
194
|
blockHeight: 0,
|
|
194
195
|
currency: (0, index_1.getCryptoCurrencyById)("aptos"),
|
|
@@ -206,7 +207,7 @@ describe("getAccountShape", () => {
|
|
|
206
207
|
});
|
|
207
208
|
it("initialAccount with operations with extra", async () => {
|
|
208
209
|
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
209
|
-
balance:
|
|
210
|
+
balance: (0, bignumber_js_1.default)(0),
|
|
210
211
|
transactions: [],
|
|
211
212
|
blockHeight: 0,
|
|
212
213
|
}));
|
|
@@ -215,7 +216,7 @@ describe("getAccountShape", () => {
|
|
|
215
216
|
}));
|
|
216
217
|
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
217
218
|
jest.mocked(jsHelpers_1.mergeOps).mockReturnValue([]);
|
|
218
|
-
jest.mocked(logic_1.txsToOps).mockReturnValue([[], []]);
|
|
219
|
+
jest.mocked(logic_1.txsToOps).mockReturnValue([[], [], []]);
|
|
219
220
|
const account = await (0, synchronisation_1.getAccountShape)({
|
|
220
221
|
id: "1",
|
|
221
222
|
address: "address",
|
|
@@ -233,8 +234,8 @@ describe("getAccountShape", () => {
|
|
|
233
234
|
freshAddress: "address",
|
|
234
235
|
freshAddressPath: "",
|
|
235
236
|
used: true,
|
|
236
|
-
balance:
|
|
237
|
-
spendableBalance:
|
|
237
|
+
balance: (0, bignumber_js_1.default)(10),
|
|
238
|
+
spendableBalance: (0, bignumber_js_1.default)(10),
|
|
238
239
|
creationDate: new Date(),
|
|
239
240
|
blockHeight: 0,
|
|
240
241
|
currency: (0, index_1.getCryptoCurrencyById)("aptos"),
|
|
@@ -252,7 +253,7 @@ describe("getAccountShape", () => {
|
|
|
252
253
|
});
|
|
253
254
|
it("get publicKey from rest", async () => {
|
|
254
255
|
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
255
|
-
balance:
|
|
256
|
+
balance: (0, bignumber_js_1.default)(0),
|
|
256
257
|
transactions: [],
|
|
257
258
|
blockHeight: 0,
|
|
258
259
|
}));
|
|
@@ -261,7 +262,7 @@ describe("getAccountShape", () => {
|
|
|
261
262
|
}));
|
|
262
263
|
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
263
264
|
jest.mocked(jsHelpers_1.mergeOps).mockReturnValue([]);
|
|
264
|
-
jest.mocked(logic_1.txsToOps).mockReturnValue([[], []]);
|
|
265
|
+
jest.mocked(logic_1.txsToOps).mockReturnValue([[], [], []]);
|
|
265
266
|
const account = await (0, synchronisation_1.getAccountShape)({
|
|
266
267
|
id: "1",
|
|
267
268
|
address: "address",
|
|
@@ -279,8 +280,8 @@ describe("getAccountShape", () => {
|
|
|
279
280
|
freshAddress: "address",
|
|
280
281
|
freshAddressPath: "",
|
|
281
282
|
used: true,
|
|
282
|
-
balance:
|
|
283
|
-
spendableBalance:
|
|
283
|
+
balance: (0, bignumber_js_1.default)(10),
|
|
284
|
+
spendableBalance: (0, bignumber_js_1.default)(10),
|
|
284
285
|
creationDate: new Date(),
|
|
285
286
|
blockHeight: 0,
|
|
286
287
|
currency: (0, index_1.getCryptoCurrencyById)("aptos"),
|
|
@@ -871,8 +872,9 @@ describe("getAccountShape", () => {
|
|
|
871
872
|
hasFailed: false,
|
|
872
873
|
},
|
|
873
874
|
];
|
|
875
|
+
const stakingOperations = [];
|
|
874
876
|
jest.mocked(jsHelpers_1.mergeOps).mockReturnValue(operations);
|
|
875
|
-
jest.mocked(logic_1.txsToOps).mockReturnValue([operations, tokenOperations]);
|
|
877
|
+
jest.mocked(logic_1.txsToOps).mockReturnValue([operations, tokenOperations, stakingOperations]);
|
|
876
878
|
const info = {
|
|
877
879
|
currency: {
|
|
878
880
|
type: "CryptoCurrency",
|
|
@@ -1483,4 +1485,742 @@ describe("getSubAccounts", () => {
|
|
|
1483
1485
|
]);
|
|
1484
1486
|
});
|
|
1485
1487
|
});
|
|
1488
|
+
describe("getStake", () => {
|
|
1489
|
+
beforeEach(() => {
|
|
1490
|
+
mockedAptosAPI = jest.mocked(network_1.AptosAPI);
|
|
1491
|
+
});
|
|
1492
|
+
afterEach(() => {
|
|
1493
|
+
jest.clearAllMocks();
|
|
1494
|
+
});
|
|
1495
|
+
it("When AptosResource has StakingPositions should validate", async () => {
|
|
1496
|
+
const mockDelegatorBalance = [1000000, 500000, 200000];
|
|
1497
|
+
const validatorAddress = "0xvalidator1";
|
|
1498
|
+
const stakingOperations = [
|
|
1499
|
+
{
|
|
1500
|
+
id: "js:2:aptos:474d:aptos-0x3f35-OUT",
|
|
1501
|
+
hash: "0x3f35",
|
|
1502
|
+
type: "STAKE",
|
|
1503
|
+
value: (0, bignumber_js_1.default)(1200),
|
|
1504
|
+
fee: (0, bignumber_js_1.default)(1200),
|
|
1505
|
+
blockHash: "0x6d02",
|
|
1506
|
+
blockHeight: 311948147,
|
|
1507
|
+
senders: ["0xa0d8"],
|
|
1508
|
+
recipients: [validatorAddress],
|
|
1509
|
+
accountId: "js:2:aptos:474d:aptos",
|
|
1510
|
+
date: new Date("2025-03-28T15:56:00.481Z"),
|
|
1511
|
+
extra: {
|
|
1512
|
+
version: "2532591427",
|
|
1513
|
+
},
|
|
1514
|
+
transactionSequenceNumber: 121,
|
|
1515
|
+
hasFailed: false,
|
|
1516
|
+
},
|
|
1517
|
+
];
|
|
1518
|
+
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
1519
|
+
balance: (0, bignumber_js_1.default)(68254118),
|
|
1520
|
+
transactions: [
|
|
1521
|
+
{
|
|
1522
|
+
version: "2532591427",
|
|
1523
|
+
hash: "0x3f35",
|
|
1524
|
+
state_change_hash: "0xb480",
|
|
1525
|
+
event_root_hash: "0x3fa1",
|
|
1526
|
+
state_checkpoint_hash: null,
|
|
1527
|
+
gas_used: "12",
|
|
1528
|
+
success: true,
|
|
1529
|
+
vm_status: "Executed successfully",
|
|
1530
|
+
accumulator_root_hash: "0x319f",
|
|
1531
|
+
changes: [
|
|
1532
|
+
{
|
|
1533
|
+
address: "0x4e5e",
|
|
1534
|
+
state_key_hash: "0x3c0c",
|
|
1535
|
+
data: {
|
|
1536
|
+
type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
|
|
1537
|
+
data: {
|
|
1538
|
+
coin: {
|
|
1539
|
+
value: "4000000",
|
|
1540
|
+
},
|
|
1541
|
+
deposit_events: {
|
|
1542
|
+
counter: "9",
|
|
1543
|
+
guid: {
|
|
1544
|
+
id: {
|
|
1545
|
+
addr: "0x4e5e",
|
|
1546
|
+
creation_num: "4",
|
|
1547
|
+
},
|
|
1548
|
+
},
|
|
1549
|
+
},
|
|
1550
|
+
frozen: false,
|
|
1551
|
+
withdraw_events: {
|
|
1552
|
+
counter: "6",
|
|
1553
|
+
guid: {
|
|
1554
|
+
id: {
|
|
1555
|
+
addr: "0x4e5e",
|
|
1556
|
+
creation_num: "5",
|
|
1557
|
+
},
|
|
1558
|
+
},
|
|
1559
|
+
},
|
|
1560
|
+
},
|
|
1561
|
+
},
|
|
1562
|
+
type: "write_resource",
|
|
1563
|
+
},
|
|
1564
|
+
{
|
|
1565
|
+
address: "0xa0d8",
|
|
1566
|
+
state_key_hash: "0x1709",
|
|
1567
|
+
data: {
|
|
1568
|
+
type: "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
|
|
1569
|
+
data: {
|
|
1570
|
+
coin: {
|
|
1571
|
+
value: "68254118",
|
|
1572
|
+
},
|
|
1573
|
+
deposit_events: {
|
|
1574
|
+
counter: "46",
|
|
1575
|
+
guid: {
|
|
1576
|
+
id: {
|
|
1577
|
+
addr: "0xa0d8",
|
|
1578
|
+
creation_num: "2",
|
|
1579
|
+
},
|
|
1580
|
+
},
|
|
1581
|
+
},
|
|
1582
|
+
frozen: false,
|
|
1583
|
+
withdraw_events: {
|
|
1584
|
+
counter: "89",
|
|
1585
|
+
guid: {
|
|
1586
|
+
id: {
|
|
1587
|
+
addr: "0xa0d8",
|
|
1588
|
+
creation_num: "3",
|
|
1589
|
+
},
|
|
1590
|
+
},
|
|
1591
|
+
},
|
|
1592
|
+
},
|
|
1593
|
+
},
|
|
1594
|
+
type: "write_resource",
|
|
1595
|
+
},
|
|
1596
|
+
{
|
|
1597
|
+
address: "0xa0d8",
|
|
1598
|
+
state_key_hash: "0x5520",
|
|
1599
|
+
data: {
|
|
1600
|
+
type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
|
|
1601
|
+
data: {
|
|
1602
|
+
coin: {
|
|
1603
|
+
value: "1000000",
|
|
1604
|
+
},
|
|
1605
|
+
deposit_events: {
|
|
1606
|
+
counter: "7",
|
|
1607
|
+
guid: {
|
|
1608
|
+
id: {
|
|
1609
|
+
addr: "0xa0d8",
|
|
1610
|
+
creation_num: "10",
|
|
1611
|
+
},
|
|
1612
|
+
},
|
|
1613
|
+
},
|
|
1614
|
+
frozen: false,
|
|
1615
|
+
withdraw_events: {
|
|
1616
|
+
counter: "13",
|
|
1617
|
+
guid: {
|
|
1618
|
+
id: {
|
|
1619
|
+
addr: "0xa0d8",
|
|
1620
|
+
creation_num: "11",
|
|
1621
|
+
},
|
|
1622
|
+
},
|
|
1623
|
+
},
|
|
1624
|
+
},
|
|
1625
|
+
},
|
|
1626
|
+
type: "write_resource",
|
|
1627
|
+
},
|
|
1628
|
+
{
|
|
1629
|
+
address: "0xa0d8",
|
|
1630
|
+
state_key_hash: "0x6f1e",
|
|
1631
|
+
data: {
|
|
1632
|
+
type: "0x1::account::Account",
|
|
1633
|
+
data: {
|
|
1634
|
+
authentication_key: "0xa0d8",
|
|
1635
|
+
coin_register_events: {
|
|
1636
|
+
counter: "5",
|
|
1637
|
+
guid: {
|
|
1638
|
+
id: {
|
|
1639
|
+
addr: "0xa0d8",
|
|
1640
|
+
creation_num: "0",
|
|
1641
|
+
},
|
|
1642
|
+
},
|
|
1643
|
+
},
|
|
1644
|
+
guid_creation_num: "12",
|
|
1645
|
+
key_rotation_events: {
|
|
1646
|
+
counter: "0",
|
|
1647
|
+
guid: {
|
|
1648
|
+
id: {
|
|
1649
|
+
addr: "0xa0d8",
|
|
1650
|
+
creation_num: "1",
|
|
1651
|
+
},
|
|
1652
|
+
},
|
|
1653
|
+
},
|
|
1654
|
+
rotation_capability_offer: {
|
|
1655
|
+
for: {
|
|
1656
|
+
vec: [],
|
|
1657
|
+
},
|
|
1658
|
+
},
|
|
1659
|
+
sequence_number: "122",
|
|
1660
|
+
signer_capability_offer: {
|
|
1661
|
+
for: {
|
|
1662
|
+
vec: [],
|
|
1663
|
+
},
|
|
1664
|
+
},
|
|
1665
|
+
},
|
|
1666
|
+
},
|
|
1667
|
+
type: "write_resource",
|
|
1668
|
+
},
|
|
1669
|
+
{
|
|
1670
|
+
state_key_hash: "0x6e4b",
|
|
1671
|
+
handle: "0x1b85",
|
|
1672
|
+
key: "0x0619",
|
|
1673
|
+
value: "0x1ddaf8da3b1497010000000000000000",
|
|
1674
|
+
data: null,
|
|
1675
|
+
type: "write_table_item",
|
|
1676
|
+
},
|
|
1677
|
+
],
|
|
1678
|
+
sender: "0xa0d8",
|
|
1679
|
+
sequence_number: "121",
|
|
1680
|
+
max_gas_amount: "12",
|
|
1681
|
+
gas_unit_price: "100",
|
|
1682
|
+
expiration_timestamp_secs: "1743177404",
|
|
1683
|
+
payload: {
|
|
1684
|
+
function: "0x1::aptos_account::transfer_coins",
|
|
1685
|
+
type_arguments: ["0xd111::staked_coin::StakedAptos"],
|
|
1686
|
+
arguments: ["0x4e5e", "1500000"],
|
|
1687
|
+
type: "entry_function_payload",
|
|
1688
|
+
},
|
|
1689
|
+
signature: {
|
|
1690
|
+
public_key: "0x474d",
|
|
1691
|
+
signature: "0x0ad8",
|
|
1692
|
+
type: "ed25519_signature",
|
|
1693
|
+
},
|
|
1694
|
+
events: [
|
|
1695
|
+
{
|
|
1696
|
+
guid: {
|
|
1697
|
+
creation_number: "11",
|
|
1698
|
+
account_address: "0xa0d8",
|
|
1699
|
+
},
|
|
1700
|
+
sequence_number: "12",
|
|
1701
|
+
type: "0x1::coin::WithdrawEvent",
|
|
1702
|
+
data: {
|
|
1703
|
+
amount: "1500000",
|
|
1704
|
+
},
|
|
1705
|
+
},
|
|
1706
|
+
{
|
|
1707
|
+
guid: {
|
|
1708
|
+
creation_number: "4",
|
|
1709
|
+
account_address: "0x4e5e",
|
|
1710
|
+
},
|
|
1711
|
+
sequence_number: "8",
|
|
1712
|
+
type: "0x1::coin::DepositEvent",
|
|
1713
|
+
data: {
|
|
1714
|
+
amount: "1500000",
|
|
1715
|
+
},
|
|
1716
|
+
},
|
|
1717
|
+
{
|
|
1718
|
+
guid: {
|
|
1719
|
+
creation_number: "0",
|
|
1720
|
+
account_address: "0x0",
|
|
1721
|
+
},
|
|
1722
|
+
sequence_number: "0",
|
|
1723
|
+
type: "0x1::transaction_fee::FeeStatement",
|
|
1724
|
+
data: {
|
|
1725
|
+
execution_gas_units: "6",
|
|
1726
|
+
io_gas_units: "6",
|
|
1727
|
+
storage_fee_octas: "0",
|
|
1728
|
+
storage_fee_refund_octas: "0",
|
|
1729
|
+
total_charge_gas_units: "12",
|
|
1730
|
+
},
|
|
1731
|
+
},
|
|
1732
|
+
],
|
|
1733
|
+
timestamp: "1743177360481259",
|
|
1734
|
+
type: "user_transaction",
|
|
1735
|
+
block: {
|
|
1736
|
+
height: 311948147,
|
|
1737
|
+
hash: "0x6d02",
|
|
1738
|
+
},
|
|
1739
|
+
},
|
|
1740
|
+
{
|
|
1741
|
+
version: "2532549325",
|
|
1742
|
+
hash: "0x9a6b",
|
|
1743
|
+
state_change_hash: "0xa424",
|
|
1744
|
+
event_root_hash: "0x0321",
|
|
1745
|
+
state_checkpoint_hash: null,
|
|
1746
|
+
gas_used: "12",
|
|
1747
|
+
success: true,
|
|
1748
|
+
vm_status: "Executed successfully",
|
|
1749
|
+
accumulator_root_hash: "0xede9",
|
|
1750
|
+
changes: [
|
|
1751
|
+
{
|
|
1752
|
+
address: "0x4e5e",
|
|
1753
|
+
state_key_hash: "0x3c0c",
|
|
1754
|
+
data: {
|
|
1755
|
+
type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
|
|
1756
|
+
data: {
|
|
1757
|
+
coin: {
|
|
1758
|
+
value: "2500000",
|
|
1759
|
+
},
|
|
1760
|
+
deposit_events: {
|
|
1761
|
+
counter: "8",
|
|
1762
|
+
guid: {
|
|
1763
|
+
id: {
|
|
1764
|
+
addr: "0x4e5e",
|
|
1765
|
+
creation_num: "4",
|
|
1766
|
+
},
|
|
1767
|
+
},
|
|
1768
|
+
},
|
|
1769
|
+
frozen: false,
|
|
1770
|
+
withdraw_events: {
|
|
1771
|
+
counter: "6",
|
|
1772
|
+
guid: {
|
|
1773
|
+
id: {
|
|
1774
|
+
addr: "0x4e5e",
|
|
1775
|
+
creation_num: "5",
|
|
1776
|
+
},
|
|
1777
|
+
},
|
|
1778
|
+
},
|
|
1779
|
+
},
|
|
1780
|
+
},
|
|
1781
|
+
type: "write_resource",
|
|
1782
|
+
},
|
|
1783
|
+
{
|
|
1784
|
+
address: "0xa0d8",
|
|
1785
|
+
state_key_hash: "0x1709",
|
|
1786
|
+
data: {
|
|
1787
|
+
type: "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
|
|
1788
|
+
data: {
|
|
1789
|
+
coin: {
|
|
1790
|
+
value: "68255318",
|
|
1791
|
+
},
|
|
1792
|
+
deposit_events: {
|
|
1793
|
+
counter: "46",
|
|
1794
|
+
guid: {
|
|
1795
|
+
id: {
|
|
1796
|
+
addr: "0xa0d8",
|
|
1797
|
+
creation_num: "2",
|
|
1798
|
+
},
|
|
1799
|
+
},
|
|
1800
|
+
},
|
|
1801
|
+
frozen: false,
|
|
1802
|
+
withdraw_events: {
|
|
1803
|
+
counter: "89",
|
|
1804
|
+
guid: {
|
|
1805
|
+
id: {
|
|
1806
|
+
addr: "0xa0d8",
|
|
1807
|
+
creation_num: "3",
|
|
1808
|
+
},
|
|
1809
|
+
},
|
|
1810
|
+
},
|
|
1811
|
+
},
|
|
1812
|
+
},
|
|
1813
|
+
type: "write_resource",
|
|
1814
|
+
},
|
|
1815
|
+
{
|
|
1816
|
+
address: "0xa0d8",
|
|
1817
|
+
state_key_hash: "0x5520",
|
|
1818
|
+
data: {
|
|
1819
|
+
type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
|
|
1820
|
+
data: {
|
|
1821
|
+
coin: {
|
|
1822
|
+
value: "2500000",
|
|
1823
|
+
},
|
|
1824
|
+
deposit_events: {
|
|
1825
|
+
counter: "7",
|
|
1826
|
+
guid: {
|
|
1827
|
+
id: {
|
|
1828
|
+
addr: "0xa0d8",
|
|
1829
|
+
creation_num: "10",
|
|
1830
|
+
},
|
|
1831
|
+
},
|
|
1832
|
+
},
|
|
1833
|
+
frozen: false,
|
|
1834
|
+
withdraw_events: {
|
|
1835
|
+
counter: "12",
|
|
1836
|
+
guid: {
|
|
1837
|
+
id: {
|
|
1838
|
+
addr: "0xa0d8",
|
|
1839
|
+
creation_num: "11",
|
|
1840
|
+
},
|
|
1841
|
+
},
|
|
1842
|
+
},
|
|
1843
|
+
},
|
|
1844
|
+
},
|
|
1845
|
+
type: "write_resource",
|
|
1846
|
+
},
|
|
1847
|
+
{
|
|
1848
|
+
address: "0xa0d8",
|
|
1849
|
+
state_key_hash: "0x6f1e",
|
|
1850
|
+
data: {
|
|
1851
|
+
type: "0x1::account::Account",
|
|
1852
|
+
data: {
|
|
1853
|
+
authentication_key: "0xa0d8",
|
|
1854
|
+
coin_register_events: {
|
|
1855
|
+
counter: "5",
|
|
1856
|
+
guid: {
|
|
1857
|
+
id: {
|
|
1858
|
+
addr: "0xa0d8",
|
|
1859
|
+
creation_num: "0",
|
|
1860
|
+
},
|
|
1861
|
+
},
|
|
1862
|
+
},
|
|
1863
|
+
guid_creation_num: "12",
|
|
1864
|
+
key_rotation_events: {
|
|
1865
|
+
counter: "0",
|
|
1866
|
+
guid: {
|
|
1867
|
+
id: {
|
|
1868
|
+
addr: "0xa0d8",
|
|
1869
|
+
creation_num: "1",
|
|
1870
|
+
},
|
|
1871
|
+
},
|
|
1872
|
+
},
|
|
1873
|
+
rotation_capability_offer: {
|
|
1874
|
+
for: {
|
|
1875
|
+
vec: [],
|
|
1876
|
+
},
|
|
1877
|
+
},
|
|
1878
|
+
sequence_number: "121",
|
|
1879
|
+
signer_capability_offer: {
|
|
1880
|
+
for: {
|
|
1881
|
+
vec: [],
|
|
1882
|
+
},
|
|
1883
|
+
},
|
|
1884
|
+
},
|
|
1885
|
+
},
|
|
1886
|
+
type: "write_resource",
|
|
1887
|
+
},
|
|
1888
|
+
{
|
|
1889
|
+
state_key_hash: "0x6e4b",
|
|
1890
|
+
handle: "0x1b85",
|
|
1891
|
+
key: "0x0619",
|
|
1892
|
+
value: "0xe86e0039581497010000000000000000",
|
|
1893
|
+
data: null,
|
|
1894
|
+
type: "write_table_item",
|
|
1895
|
+
},
|
|
1896
|
+
],
|
|
1897
|
+
sender: "0xa0d8",
|
|
1898
|
+
sequence_number: "120",
|
|
1899
|
+
max_gas_amount: "12",
|
|
1900
|
+
gas_unit_price: "100",
|
|
1901
|
+
expiration_timestamp_secs: "1743176706",
|
|
1902
|
+
payload: {
|
|
1903
|
+
function: "0x1::aptos_account::transfer_coins",
|
|
1904
|
+
type_arguments: ["0xd111::staked_coin::StakedAptos"],
|
|
1905
|
+
arguments: ["0x4e5e", "2500000"],
|
|
1906
|
+
type: "entry_function_payload",
|
|
1907
|
+
},
|
|
1908
|
+
signature: {
|
|
1909
|
+
public_key: "0x474d",
|
|
1910
|
+
signature: "0xb70e",
|
|
1911
|
+
type: "ed25519_signature",
|
|
1912
|
+
},
|
|
1913
|
+
events: [
|
|
1914
|
+
{
|
|
1915
|
+
guid: {
|
|
1916
|
+
creation_number: "11",
|
|
1917
|
+
account_address: "0xa0d8",
|
|
1918
|
+
},
|
|
1919
|
+
sequence_number: "11",
|
|
1920
|
+
type: "0x1::coin::WithdrawEvent",
|
|
1921
|
+
data: {
|
|
1922
|
+
amount: "2500000",
|
|
1923
|
+
},
|
|
1924
|
+
},
|
|
1925
|
+
{
|
|
1926
|
+
guid: {
|
|
1927
|
+
creation_number: "4",
|
|
1928
|
+
account_address: "0x4e5e",
|
|
1929
|
+
},
|
|
1930
|
+
sequence_number: "7",
|
|
1931
|
+
type: "0x1::coin::DepositEvent",
|
|
1932
|
+
data: {
|
|
1933
|
+
amount: "2500000",
|
|
1934
|
+
},
|
|
1935
|
+
},
|
|
1936
|
+
{
|
|
1937
|
+
guid: {
|
|
1938
|
+
creation_number: "0",
|
|
1939
|
+
account_address: "0x0",
|
|
1940
|
+
},
|
|
1941
|
+
sequence_number: "0",
|
|
1942
|
+
type: "0x1::transaction_fee::FeeStatement",
|
|
1943
|
+
data: {
|
|
1944
|
+
execution_gas_units: "6",
|
|
1945
|
+
io_gas_units: "6",
|
|
1946
|
+
storage_fee_octas: "0",
|
|
1947
|
+
storage_fee_refund_octas: "0",
|
|
1948
|
+
total_charge_gas_units: "12",
|
|
1949
|
+
},
|
|
1950
|
+
},
|
|
1951
|
+
],
|
|
1952
|
+
timestamp: "1743176594693251",
|
|
1953
|
+
type: "user_transaction",
|
|
1954
|
+
block: {
|
|
1955
|
+
height: 311942427,
|
|
1956
|
+
hash: "0x8655",
|
|
1957
|
+
},
|
|
1958
|
+
},
|
|
1959
|
+
],
|
|
1960
|
+
blockHeight: 316278241,
|
|
1961
|
+
}));
|
|
1962
|
+
const mockGetBalance = jest.fn().mockImplementation(() => (0, bignumber_js_1.default)(5000000));
|
|
1963
|
+
mockedDecodeTokenAccountId.mockReturnValue({
|
|
1964
|
+
token: {
|
|
1965
|
+
type: "TokenCurrency",
|
|
1966
|
+
id: "aptos/coin/dstapt_0xd111::staked_coin::stakedaptos",
|
|
1967
|
+
contractAddress: "0xd111::staked_coin::StakedAptos",
|
|
1968
|
+
parentCurrency: {
|
|
1969
|
+
type: "CryptoCurrency",
|
|
1970
|
+
id: "aptos",
|
|
1971
|
+
coinType: 637,
|
|
1972
|
+
name: "Aptos",
|
|
1973
|
+
managerAppName: "Aptos",
|
|
1974
|
+
ticker: "APT",
|
|
1975
|
+
scheme: "aptos",
|
|
1976
|
+
color: "#231F20",
|
|
1977
|
+
family: "aptos",
|
|
1978
|
+
units: [
|
|
1979
|
+
{
|
|
1980
|
+
name: "APT",
|
|
1981
|
+
code: "APT",
|
|
1982
|
+
magnitude: 8,
|
|
1983
|
+
},
|
|
1984
|
+
],
|
|
1985
|
+
explorerViews: [
|
|
1986
|
+
{
|
|
1987
|
+
address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
|
|
1988
|
+
tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
|
|
1989
|
+
},
|
|
1990
|
+
],
|
|
1991
|
+
},
|
|
1992
|
+
name: "dstAPT",
|
|
1993
|
+
tokenType: "coin",
|
|
1994
|
+
ticker: "dstAPT",
|
|
1995
|
+
disableCountervalue: false,
|
|
1996
|
+
delisted: false,
|
|
1997
|
+
units: [
|
|
1998
|
+
{
|
|
1999
|
+
name: "dstAPT",
|
|
2000
|
+
code: "dstAPT",
|
|
2001
|
+
magnitude: 8,
|
|
2002
|
+
},
|
|
2003
|
+
],
|
|
2004
|
+
},
|
|
2005
|
+
accountId: "js:2:aptos:6415:aptos",
|
|
2006
|
+
});
|
|
2007
|
+
const operations = [
|
|
2008
|
+
{
|
|
2009
|
+
id: "js:2:aptos:474d:aptos-0x3f35-OUT",
|
|
2010
|
+
hash: "0x3f35",
|
|
2011
|
+
type: "FEES",
|
|
2012
|
+
value: (0, bignumber_js_1.default)(1200),
|
|
2013
|
+
fee: (0, bignumber_js_1.default)(1200),
|
|
2014
|
+
blockHash: "0x6d02",
|
|
2015
|
+
blockHeight: 311948147,
|
|
2016
|
+
senders: ["0xa0d8"],
|
|
2017
|
+
recipients: ["0x4e5e"],
|
|
2018
|
+
accountId: "js:2:aptos:474d:aptos",
|
|
2019
|
+
date: new Date("2025-03-28T15:56:00.481Z"),
|
|
2020
|
+
extra: {
|
|
2021
|
+
version: "2532591427",
|
|
2022
|
+
},
|
|
2023
|
+
transactionSequenceNumber: 121,
|
|
2024
|
+
hasFailed: false,
|
|
2025
|
+
},
|
|
2026
|
+
{
|
|
2027
|
+
id: "js:2:aptos:474d:aptos-0x9a6b-OUT",
|
|
2028
|
+
hash: "0x9a6b",
|
|
2029
|
+
type: "FEES",
|
|
2030
|
+
value: (0, bignumber_js_1.default)(1200),
|
|
2031
|
+
fee: (0, bignumber_js_1.default)(1200),
|
|
2032
|
+
blockHash: "0x8655",
|
|
2033
|
+
blockHeight: 311942427,
|
|
2034
|
+
senders: ["0xa0d8"],
|
|
2035
|
+
recipients: ["0x4e5e"],
|
|
2036
|
+
accountId: "js:2:aptos:474d:aptos",
|
|
2037
|
+
date: new Date("2025-03-28T15:43:14.693Z"),
|
|
2038
|
+
extra: {
|
|
2039
|
+
version: "2532549325",
|
|
2040
|
+
},
|
|
2041
|
+
transactionSequenceNumber: 120,
|
|
2042
|
+
hasFailed: false,
|
|
2043
|
+
},
|
|
2044
|
+
];
|
|
2045
|
+
const tokenOperations = [
|
|
2046
|
+
{
|
|
2047
|
+
id: "js:2:aptos:474d:aptos-0x3f35-OUT",
|
|
2048
|
+
hash: "0x3f35",
|
|
2049
|
+
type: "OUT",
|
|
2050
|
+
value: (0, bignumber_js_1.default)(1500000),
|
|
2051
|
+
fee: (0, bignumber_js_1.default)(1200),
|
|
2052
|
+
blockHash: "0x6d02",
|
|
2053
|
+
blockHeight: 311948147,
|
|
2054
|
+
senders: ["0xa0d8"],
|
|
2055
|
+
recipients: ["0x4e5e"],
|
|
2056
|
+
accountId: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
|
|
2057
|
+
date: new Date("2025-03-28T15:56:00.481Z"),
|
|
2058
|
+
extra: {
|
|
2059
|
+
version: "2532591427",
|
|
2060
|
+
},
|
|
2061
|
+
transactionSequenceNumber: 121,
|
|
2062
|
+
hasFailed: false,
|
|
2063
|
+
},
|
|
2064
|
+
{
|
|
2065
|
+
id: "js:2:aptos:474d:aptos-0x9a6b-OUT",
|
|
2066
|
+
hash: "0x9a6b",
|
|
2067
|
+
type: "OUT",
|
|
2068
|
+
value: (0, bignumber_js_1.default)(2500000),
|
|
2069
|
+
fee: (0, bignumber_js_1.default)(1200),
|
|
2070
|
+
blockHash: "0x8655",
|
|
2071
|
+
blockHeight: 311942427,
|
|
2072
|
+
senders: ["0xa0d8"],
|
|
2073
|
+
recipients: ["0x4e5e"],
|
|
2074
|
+
accountId: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
|
|
2075
|
+
date: new Date("2025-03-28T15:43:14.693Z"),
|
|
2076
|
+
extra: {
|
|
2077
|
+
version: "2532549325",
|
|
2078
|
+
},
|
|
2079
|
+
transactionSequenceNumber: 120,
|
|
2080
|
+
hasFailed: false,
|
|
2081
|
+
},
|
|
2082
|
+
];
|
|
2083
|
+
const mockedGetDelegatorBalanceInPool = jest.fn().mockResolvedValue([
|
|
2084
|
+
(0, bignumber_js_1.default)(mockDelegatorBalance[0]), // active
|
|
2085
|
+
(0, bignumber_js_1.default)(mockDelegatorBalance[1]), // inactive
|
|
2086
|
+
(0, bignumber_js_1.default)(mockDelegatorBalance[2]), // pending_inactive
|
|
2087
|
+
]);
|
|
2088
|
+
mockedAptosAPI.mockImplementation(() => ({
|
|
2089
|
+
getAccountInfo: mockGetAccountInfo,
|
|
2090
|
+
getDelegatorBalanceInPool: mockedGetDelegatorBalanceInPool,
|
|
2091
|
+
getBalances: mockGetBalance,
|
|
2092
|
+
}));
|
|
2093
|
+
jest.mocked(jsHelpers_1.mergeOps).mockReturnValue(operations);
|
|
2094
|
+
jest.mocked(logic_1.txsToOps).mockReturnValue([operations, tokenOperations, stakingOperations]);
|
|
2095
|
+
const info = {
|
|
2096
|
+
currency: {
|
|
2097
|
+
type: "CryptoCurrency",
|
|
2098
|
+
id: "aptos",
|
|
2099
|
+
coinType: 637,
|
|
2100
|
+
name: "Aptos",
|
|
2101
|
+
managerAppName: "Aptos",
|
|
2102
|
+
ticker: "APT",
|
|
2103
|
+
scheme: "aptos",
|
|
2104
|
+
color: "#231F20",
|
|
2105
|
+
family: "aptos",
|
|
2106
|
+
units: [
|
|
2107
|
+
{
|
|
2108
|
+
name: "APT",
|
|
2109
|
+
code: "APT",
|
|
2110
|
+
magnitude: 8,
|
|
2111
|
+
},
|
|
2112
|
+
],
|
|
2113
|
+
},
|
|
2114
|
+
index: 0,
|
|
2115
|
+
address: "0xa0d8",
|
|
2116
|
+
derivationPath: "44'/637'/0'",
|
|
2117
|
+
derivationMode: "aptos",
|
|
2118
|
+
initialAccount: {
|
|
2119
|
+
type: "Account",
|
|
2120
|
+
id: "js:2:aptos:474d:aptos",
|
|
2121
|
+
used: true,
|
|
2122
|
+
seedIdentifier: "3086",
|
|
2123
|
+
derivationMode: "aptos",
|
|
2124
|
+
index: 0,
|
|
2125
|
+
freshAddress: "0xa0d8",
|
|
2126
|
+
freshAddressPath: "44'/637'/0'/0'/0'",
|
|
2127
|
+
blockHeight: 316272224,
|
|
2128
|
+
creationDate: "2025-01-16T14:17:41.076Z",
|
|
2129
|
+
balance: (0, bignumber_js_1.default)(68254118),
|
|
2130
|
+
spendableBalance: (0, bignumber_js_1.default)(68254118),
|
|
2131
|
+
operations: [],
|
|
2132
|
+
operationsCount: 0,
|
|
2133
|
+
pendingOperations: [],
|
|
2134
|
+
currency: {
|
|
2135
|
+
type: "CryptoCurrency",
|
|
2136
|
+
id: "aptos",
|
|
2137
|
+
coinType: 637,
|
|
2138
|
+
name: "Aptos",
|
|
2139
|
+
managerAppName: "Aptos",
|
|
2140
|
+
ticker: "APT",
|
|
2141
|
+
scheme: "aptos",
|
|
2142
|
+
color: "#231F20",
|
|
2143
|
+
family: "aptos",
|
|
2144
|
+
units: [
|
|
2145
|
+
{
|
|
2146
|
+
name: "APT",
|
|
2147
|
+
code: "APT",
|
|
2148
|
+
magnitude: 8,
|
|
2149
|
+
},
|
|
2150
|
+
],
|
|
2151
|
+
},
|
|
2152
|
+
lastSyncDate: new Date(),
|
|
2153
|
+
swapHistory: [],
|
|
2154
|
+
balanceHistoryCache: index_2.emptyHistoryCache,
|
|
2155
|
+
xpub: "474d",
|
|
2156
|
+
subAccounts: [
|
|
2157
|
+
{
|
|
2158
|
+
type: "TokenAccount",
|
|
2159
|
+
id: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
|
|
2160
|
+
parentId: "js:2:aptos:474d:aptos",
|
|
2161
|
+
token: {
|
|
2162
|
+
type: "TokenCurrency",
|
|
2163
|
+
id: "aptos/coin/dstapt_0xd111::staked_coin::stakedaptos",
|
|
2164
|
+
contractAddress: "0xd111::staked_coin::StakedAptos",
|
|
2165
|
+
parentCurrency: {
|
|
2166
|
+
type: "CryptoCurrency",
|
|
2167
|
+
id: "aptos",
|
|
2168
|
+
coinType: 637,
|
|
2169
|
+
name: "Aptos",
|
|
2170
|
+
managerAppName: "Aptos",
|
|
2171
|
+
ticker: "APT",
|
|
2172
|
+
scheme: "aptos",
|
|
2173
|
+
color: "#231F20",
|
|
2174
|
+
family: "aptos",
|
|
2175
|
+
units: [
|
|
2176
|
+
{
|
|
2177
|
+
name: "APT",
|
|
2178
|
+
code: "APT",
|
|
2179
|
+
magnitude: 8,
|
|
2180
|
+
},
|
|
2181
|
+
],
|
|
2182
|
+
},
|
|
2183
|
+
name: "dstAPT",
|
|
2184
|
+
tokenType: "coin",
|
|
2185
|
+
ticker: "dstAPT",
|
|
2186
|
+
disableCountervalue: false,
|
|
2187
|
+
delisted: false,
|
|
2188
|
+
units: [
|
|
2189
|
+
{
|
|
2190
|
+
name: "dstAPT",
|
|
2191
|
+
code: "dstAPT",
|
|
2192
|
+
magnitude: 8,
|
|
2193
|
+
},
|
|
2194
|
+
],
|
|
2195
|
+
},
|
|
2196
|
+
balance: (0, bignumber_js_1.default)(5000000),
|
|
2197
|
+
spendableBalance: (0, bignumber_js_1.default)(5000000),
|
|
2198
|
+
creationDate: "2025-03-11T09:33:46.840Z",
|
|
2199
|
+
operations: [],
|
|
2200
|
+
operationsCount: 0,
|
|
2201
|
+
pendingOperations: [],
|
|
2202
|
+
swapHistory: [],
|
|
2203
|
+
balanceHistoryCache: index_2.emptyHistoryCache,
|
|
2204
|
+
},
|
|
2205
|
+
],
|
|
2206
|
+
},
|
|
2207
|
+
};
|
|
2208
|
+
const result = await (0, synchronisation_1.getAccountShape)(info, {});
|
|
2209
|
+
expect(result.aptosResources).toBeDefined();
|
|
2210
|
+
const stakingEnabled = (0, live_env_1.getEnv)("APTOS_ENABLE_STAKING") === true;
|
|
2211
|
+
if (stakingEnabled) {
|
|
2212
|
+
expect(result.aptosResources?.stakingPositions).toHaveLength(1);
|
|
2213
|
+
const position = result.aptosResources?.stakingPositions?.[0];
|
|
2214
|
+
expect(position).toEqual({
|
|
2215
|
+
active: (0, bignumber_js_1.default)(mockDelegatorBalance[0]),
|
|
2216
|
+
inactive: (0, bignumber_js_1.default)(mockDelegatorBalance[1]),
|
|
2217
|
+
pendingInactive: (0, bignumber_js_1.default)(mockDelegatorBalance[2]),
|
|
2218
|
+
validatorId: stakingOperations[0].recipients[0],
|
|
2219
|
+
});
|
|
2220
|
+
expect(result.aptosResources?.activeBalance).toEqual((0, bignumber_js_1.default)(mockDelegatorBalance[0]));
|
|
2221
|
+
expect(result.aptosResources?.inactiveBalance).toEqual((0, bignumber_js_1.default)(mockDelegatorBalance[1]));
|
|
2222
|
+
expect(result.aptosResources?.pendingInactiveBalance).toEqual((0, bignumber_js_1.default)(mockDelegatorBalance[2]));
|
|
2223
|
+
}
|
|
2224
|
+
});
|
|
2225
|
+
});
|
|
1486
2226
|
//# sourceMappingURL=synchronisation.test.js.map
|