@ledgerhq/coin-aptos 2.5.1 → 2.5.2-nightly.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.unimportedrc.json +5 -8
- package/CHANGELOG.md +8 -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 +12 -7
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AccountShapeInfo, mergeOps } from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
2
2
|
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/index";
|
|
3
|
-
import {
|
|
3
|
+
import { Operation, SyncConfig, TokenAccount } from "@ledgerhq/types-live";
|
|
4
4
|
import { decodeTokenAccountId } from "@ledgerhq/coin-framework/account";
|
|
5
5
|
import { emptyHistoryCache } from "@ledgerhq/coin-framework/account/index";
|
|
6
6
|
import { AptosAPI } from "../../network";
|
|
@@ -14,6 +14,8 @@ import BigNumber from "bignumber.js";
|
|
|
14
14
|
import { createFixtureAccount } from "../../bridge/bridge.fixture";
|
|
15
15
|
import { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
16
16
|
import { txsToOps } from "../../bridge/logic";
|
|
17
|
+
import { AptosAccount } from "../../types";
|
|
18
|
+
import { getEnv } from "@ledgerhq/live-env";
|
|
17
19
|
|
|
18
20
|
jest.mock("@ledgerhq/coin-framework/account", () => {
|
|
19
21
|
const originalModule = jest.requireActual("@ledgerhq/coin-framework/account");
|
|
@@ -54,7 +56,7 @@ describe("getAccountShape", () => {
|
|
|
54
56
|
|
|
55
57
|
it("account with xpub", async () => {
|
|
56
58
|
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
57
|
-
balance:
|
|
59
|
+
balance: BigNumber(0),
|
|
58
60
|
transactions: [],
|
|
59
61
|
blockHeight: 0,
|
|
60
62
|
}));
|
|
@@ -64,7 +66,7 @@ describe("getAccountShape", () => {
|
|
|
64
66
|
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
65
67
|
|
|
66
68
|
jest.mocked(mergeOps).mockReturnValue([]);
|
|
67
|
-
jest.mocked(txsToOps).mockReturnValue([[], []]);
|
|
69
|
+
jest.mocked(txsToOps).mockReturnValue([[], [], []]);
|
|
68
70
|
|
|
69
71
|
const account = await getAccountShape(
|
|
70
72
|
{
|
|
@@ -85,8 +87,8 @@ describe("getAccountShape", () => {
|
|
|
85
87
|
freshAddress: "address",
|
|
86
88
|
freshAddressPath: "",
|
|
87
89
|
used: true,
|
|
88
|
-
balance:
|
|
89
|
-
spendableBalance:
|
|
90
|
+
balance: BigNumber(10),
|
|
91
|
+
spendableBalance: BigNumber(10),
|
|
90
92
|
creationDate: new Date(),
|
|
91
93
|
blockHeight: 0,
|
|
92
94
|
currency: getCryptoCurrencyById("aptos"),
|
|
@@ -97,7 +99,7 @@ describe("getAccountShape", () => {
|
|
|
97
99
|
balanceHistoryCache: {},
|
|
98
100
|
swapHistory: [],
|
|
99
101
|
},
|
|
100
|
-
} as unknown as AccountShapeInfo<
|
|
102
|
+
} as unknown as AccountShapeInfo<AptosAccount>,
|
|
101
103
|
{} as SyncConfig,
|
|
102
104
|
);
|
|
103
105
|
|
|
@@ -108,7 +110,7 @@ describe("getAccountShape", () => {
|
|
|
108
110
|
|
|
109
111
|
it("account without xpub", async () => {
|
|
110
112
|
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
111
|
-
balance:
|
|
113
|
+
balance: BigNumber(0),
|
|
112
114
|
transactions: [],
|
|
113
115
|
blockHeight: 0,
|
|
114
116
|
}));
|
|
@@ -118,7 +120,7 @@ describe("getAccountShape", () => {
|
|
|
118
120
|
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
119
121
|
|
|
120
122
|
jest.mocked(mergeOps).mockReturnValue([]);
|
|
121
|
-
jest.mocked(txsToOps).mockReturnValue([[], []]);
|
|
123
|
+
jest.mocked(txsToOps).mockReturnValue([[], [], []]);
|
|
122
124
|
|
|
123
125
|
const account = await getAccountShape(
|
|
124
126
|
{
|
|
@@ -138,8 +140,8 @@ describe("getAccountShape", () => {
|
|
|
138
140
|
freshAddress: "address",
|
|
139
141
|
freshAddressPath: "",
|
|
140
142
|
used: true,
|
|
141
|
-
balance:
|
|
142
|
-
spendableBalance:
|
|
143
|
+
balance: BigNumber(10),
|
|
144
|
+
spendableBalance: BigNumber(10),
|
|
143
145
|
creationDate: new Date(),
|
|
144
146
|
blockHeight: 0,
|
|
145
147
|
currency: getCryptoCurrencyById("aptos"),
|
|
@@ -150,7 +152,7 @@ describe("getAccountShape", () => {
|
|
|
150
152
|
balanceHistoryCache: {},
|
|
151
153
|
swapHistory: [],
|
|
152
154
|
},
|
|
153
|
-
} as unknown as AccountShapeInfo<
|
|
155
|
+
} as unknown as AccountShapeInfo<AptosAccount>,
|
|
154
156
|
{} as SyncConfig,
|
|
155
157
|
);
|
|
156
158
|
|
|
@@ -161,7 +163,7 @@ describe("getAccountShape", () => {
|
|
|
161
163
|
|
|
162
164
|
it("without initialAccount", async () => {
|
|
163
165
|
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
164
|
-
balance:
|
|
166
|
+
balance: BigNumber(0),
|
|
165
167
|
transactions: [],
|
|
166
168
|
blockHeight: 0,
|
|
167
169
|
}));
|
|
@@ -171,7 +173,7 @@ describe("getAccountShape", () => {
|
|
|
171
173
|
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
172
174
|
|
|
173
175
|
jest.mocked(mergeOps).mockReturnValue([]);
|
|
174
|
-
jest.mocked(txsToOps).mockReturnValue([[], []]);
|
|
176
|
+
jest.mocked(txsToOps).mockReturnValue([[], [], []]);
|
|
175
177
|
|
|
176
178
|
const account = await getAccountShape(
|
|
177
179
|
{
|
|
@@ -183,7 +185,7 @@ describe("getAccountShape", () => {
|
|
|
183
185
|
xpub: "address",
|
|
184
186
|
derivationPath: "",
|
|
185
187
|
deviceId: "1",
|
|
186
|
-
} as unknown as AccountShapeInfo<
|
|
188
|
+
} as unknown as AccountShapeInfo<AptosAccount>,
|
|
187
189
|
{} as SyncConfig,
|
|
188
190
|
);
|
|
189
191
|
|
|
@@ -194,7 +196,7 @@ describe("getAccountShape", () => {
|
|
|
194
196
|
|
|
195
197
|
it("initialAccount with operations", async () => {
|
|
196
198
|
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
197
|
-
balance:
|
|
199
|
+
balance: BigNumber(0),
|
|
198
200
|
transactions: [],
|
|
199
201
|
blockHeight: 0,
|
|
200
202
|
}));
|
|
@@ -204,7 +206,7 @@ describe("getAccountShape", () => {
|
|
|
204
206
|
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
205
207
|
|
|
206
208
|
jest.mocked(mergeOps).mockReturnValue([]);
|
|
207
|
-
jest.mocked(txsToOps).mockReturnValue([[], []]);
|
|
209
|
+
jest.mocked(txsToOps).mockReturnValue([[], [], []]);
|
|
208
210
|
|
|
209
211
|
const account = await getAccountShape(
|
|
210
212
|
{
|
|
@@ -224,8 +226,8 @@ describe("getAccountShape", () => {
|
|
|
224
226
|
freshAddress: "address",
|
|
225
227
|
freshAddressPath: "",
|
|
226
228
|
used: true,
|
|
227
|
-
balance:
|
|
228
|
-
spendableBalance:
|
|
229
|
+
balance: BigNumber(10),
|
|
230
|
+
spendableBalance: BigNumber(10),
|
|
229
231
|
creationDate: new Date(),
|
|
230
232
|
blockHeight: 0,
|
|
231
233
|
currency: getCryptoCurrencyById("aptos"),
|
|
@@ -236,7 +238,7 @@ describe("getAccountShape", () => {
|
|
|
236
238
|
balanceHistoryCache: {},
|
|
237
239
|
swapHistory: [],
|
|
238
240
|
},
|
|
239
|
-
} as unknown as AccountShapeInfo<
|
|
241
|
+
} as unknown as AccountShapeInfo<AptosAccount>,
|
|
240
242
|
{} as SyncConfig,
|
|
241
243
|
);
|
|
242
244
|
|
|
@@ -247,7 +249,7 @@ describe("getAccountShape", () => {
|
|
|
247
249
|
|
|
248
250
|
it("initialAccount with operations with extra", async () => {
|
|
249
251
|
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
250
|
-
balance:
|
|
252
|
+
balance: BigNumber(0),
|
|
251
253
|
transactions: [],
|
|
252
254
|
blockHeight: 0,
|
|
253
255
|
}));
|
|
@@ -257,7 +259,7 @@ describe("getAccountShape", () => {
|
|
|
257
259
|
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
258
260
|
|
|
259
261
|
jest.mocked(mergeOps).mockReturnValue([]);
|
|
260
|
-
jest.mocked(txsToOps).mockReturnValue([[], []]);
|
|
262
|
+
jest.mocked(txsToOps).mockReturnValue([[], [], []]);
|
|
261
263
|
|
|
262
264
|
const account = await getAccountShape(
|
|
263
265
|
{
|
|
@@ -277,8 +279,8 @@ describe("getAccountShape", () => {
|
|
|
277
279
|
freshAddress: "address",
|
|
278
280
|
freshAddressPath: "",
|
|
279
281
|
used: true,
|
|
280
|
-
balance:
|
|
281
|
-
spendableBalance:
|
|
282
|
+
balance: BigNumber(10),
|
|
283
|
+
spendableBalance: BigNumber(10),
|
|
282
284
|
creationDate: new Date(),
|
|
283
285
|
blockHeight: 0,
|
|
284
286
|
currency: getCryptoCurrencyById("aptos"),
|
|
@@ -289,7 +291,7 @@ describe("getAccountShape", () => {
|
|
|
289
291
|
balanceHistoryCache: {},
|
|
290
292
|
swapHistory: [],
|
|
291
293
|
},
|
|
292
|
-
} as unknown as AccountShapeInfo<
|
|
294
|
+
} as unknown as AccountShapeInfo<AptosAccount>,
|
|
293
295
|
{} as SyncConfig,
|
|
294
296
|
);
|
|
295
297
|
|
|
@@ -300,7 +302,7 @@ describe("getAccountShape", () => {
|
|
|
300
302
|
|
|
301
303
|
it("get publicKey from rest", async () => {
|
|
302
304
|
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
303
|
-
balance:
|
|
305
|
+
balance: BigNumber(0),
|
|
304
306
|
transactions: [],
|
|
305
307
|
blockHeight: 0,
|
|
306
308
|
}));
|
|
@@ -310,7 +312,7 @@ describe("getAccountShape", () => {
|
|
|
310
312
|
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
311
313
|
|
|
312
314
|
jest.mocked(mergeOps).mockReturnValue([]);
|
|
313
|
-
jest.mocked(txsToOps).mockReturnValue([[], []]);
|
|
315
|
+
jest.mocked(txsToOps).mockReturnValue([[], [], []]);
|
|
314
316
|
|
|
315
317
|
const account = await getAccountShape(
|
|
316
318
|
{
|
|
@@ -330,8 +332,8 @@ describe("getAccountShape", () => {
|
|
|
330
332
|
freshAddress: "address",
|
|
331
333
|
freshAddressPath: "",
|
|
332
334
|
used: true,
|
|
333
|
-
balance:
|
|
334
|
-
spendableBalance:
|
|
335
|
+
balance: BigNumber(10),
|
|
336
|
+
spendableBalance: BigNumber(10),
|
|
335
337
|
creationDate: new Date(),
|
|
336
338
|
blockHeight: 0,
|
|
337
339
|
currency: getCryptoCurrencyById("aptos"),
|
|
@@ -343,7 +345,7 @@ describe("getAccountShape", () => {
|
|
|
343
345
|
swapHistory: [],
|
|
344
346
|
},
|
|
345
347
|
rest: { publicKey: "restPublicKey" },
|
|
346
|
-
} as unknown as AccountShapeInfo<
|
|
348
|
+
} as unknown as AccountShapeInfo<AptosAccount>,
|
|
347
349
|
{} as SyncConfig,
|
|
348
350
|
);
|
|
349
351
|
|
|
@@ -894,6 +896,7 @@ describe("getAccountShape", () => {
|
|
|
894
896
|
hasFailed: false,
|
|
895
897
|
},
|
|
896
898
|
] as Operation[];
|
|
899
|
+
|
|
897
900
|
const tokenOperations = [
|
|
898
901
|
{
|
|
899
902
|
id: "js:2:aptos:474d:aptos-0x3f35-OUT",
|
|
@@ -934,8 +937,11 @@ describe("getAccountShape", () => {
|
|
|
934
937
|
hasFailed: false,
|
|
935
938
|
},
|
|
936
939
|
] as Operation[];
|
|
940
|
+
|
|
941
|
+
const stakingOperations = [] as Operation[];
|
|
942
|
+
|
|
937
943
|
jest.mocked(mergeOps).mockReturnValue(operations);
|
|
938
|
-
jest.mocked(txsToOps).mockReturnValue([operations, tokenOperations]);
|
|
944
|
+
jest.mocked(txsToOps).mockReturnValue([operations, tokenOperations, stakingOperations]);
|
|
939
945
|
|
|
940
946
|
const info = {
|
|
941
947
|
currency: {
|
|
@@ -1049,7 +1055,7 @@ describe("getAccountShape", () => {
|
|
|
1049
1055
|
},
|
|
1050
1056
|
],
|
|
1051
1057
|
},
|
|
1052
|
-
} as unknown as AccountShapeInfo<
|
|
1058
|
+
} as unknown as AccountShapeInfo<AptosAccount>;
|
|
1053
1059
|
|
|
1054
1060
|
const result = await getAccountShape(info, {} as SyncConfig);
|
|
1055
1061
|
|
|
@@ -1387,7 +1393,7 @@ describe("getSubAccounts", () => {
|
|
|
1387
1393
|
index: 1,
|
|
1388
1394
|
derivationPath: "44'/637'/0'",
|
|
1389
1395
|
derivationMode: "aptos",
|
|
1390
|
-
} as AccountShapeInfo<
|
|
1396
|
+
} as AccountShapeInfo<AptosAccount>;
|
|
1391
1397
|
const accountId = "js:2:aptos:3282:aptos";
|
|
1392
1398
|
const lastTokenOperations = [
|
|
1393
1399
|
{
|
|
@@ -1581,3 +1587,763 @@ describe("getSubAccounts", () => {
|
|
|
1581
1587
|
]);
|
|
1582
1588
|
});
|
|
1583
1589
|
});
|
|
1590
|
+
|
|
1591
|
+
describe("getStake", () => {
|
|
1592
|
+
beforeEach(() => {
|
|
1593
|
+
mockedAptosAPI = jest.mocked(AptosAPI);
|
|
1594
|
+
});
|
|
1595
|
+
|
|
1596
|
+
afterEach(() => {
|
|
1597
|
+
jest.clearAllMocks();
|
|
1598
|
+
});
|
|
1599
|
+
|
|
1600
|
+
it("When AptosResource has StakingPositions should validate", async () => {
|
|
1601
|
+
const mockDelegatorBalance = [1000000, 500000, 200000];
|
|
1602
|
+
|
|
1603
|
+
const validatorAddress = "0xvalidator1";
|
|
1604
|
+
const stakingOperations = [
|
|
1605
|
+
{
|
|
1606
|
+
id: "js:2:aptos:474d:aptos-0x3f35-OUT",
|
|
1607
|
+
hash: "0x3f35",
|
|
1608
|
+
type: "STAKE",
|
|
1609
|
+
value: BigNumber(1200),
|
|
1610
|
+
fee: BigNumber(1200),
|
|
1611
|
+
blockHash: "0x6d02",
|
|
1612
|
+
blockHeight: 311948147,
|
|
1613
|
+
senders: ["0xa0d8"],
|
|
1614
|
+
recipients: [validatorAddress],
|
|
1615
|
+
accountId: "js:2:aptos:474d:aptos",
|
|
1616
|
+
date: new Date("2025-03-28T15:56:00.481Z"),
|
|
1617
|
+
extra: {
|
|
1618
|
+
version: "2532591427",
|
|
1619
|
+
},
|
|
1620
|
+
transactionSequenceNumber: 121,
|
|
1621
|
+
hasFailed: false,
|
|
1622
|
+
},
|
|
1623
|
+
] as Operation[];
|
|
1624
|
+
|
|
1625
|
+
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
1626
|
+
balance: BigNumber(68254118),
|
|
1627
|
+
transactions: [
|
|
1628
|
+
{
|
|
1629
|
+
version: "2532591427",
|
|
1630
|
+
hash: "0x3f35",
|
|
1631
|
+
state_change_hash: "0xb480",
|
|
1632
|
+
event_root_hash: "0x3fa1",
|
|
1633
|
+
state_checkpoint_hash: null,
|
|
1634
|
+
gas_used: "12",
|
|
1635
|
+
success: true,
|
|
1636
|
+
vm_status: "Executed successfully",
|
|
1637
|
+
accumulator_root_hash: "0x319f",
|
|
1638
|
+
changes: [
|
|
1639
|
+
{
|
|
1640
|
+
address: "0x4e5e",
|
|
1641
|
+
state_key_hash: "0x3c0c",
|
|
1642
|
+
data: {
|
|
1643
|
+
type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
|
|
1644
|
+
data: {
|
|
1645
|
+
coin: {
|
|
1646
|
+
value: "4000000",
|
|
1647
|
+
},
|
|
1648
|
+
deposit_events: {
|
|
1649
|
+
counter: "9",
|
|
1650
|
+
guid: {
|
|
1651
|
+
id: {
|
|
1652
|
+
addr: "0x4e5e",
|
|
1653
|
+
creation_num: "4",
|
|
1654
|
+
},
|
|
1655
|
+
},
|
|
1656
|
+
},
|
|
1657
|
+
frozen: false,
|
|
1658
|
+
withdraw_events: {
|
|
1659
|
+
counter: "6",
|
|
1660
|
+
guid: {
|
|
1661
|
+
id: {
|
|
1662
|
+
addr: "0x4e5e",
|
|
1663
|
+
creation_num: "5",
|
|
1664
|
+
},
|
|
1665
|
+
},
|
|
1666
|
+
},
|
|
1667
|
+
},
|
|
1668
|
+
},
|
|
1669
|
+
type: "write_resource",
|
|
1670
|
+
},
|
|
1671
|
+
{
|
|
1672
|
+
address: "0xa0d8",
|
|
1673
|
+
state_key_hash: "0x1709",
|
|
1674
|
+
data: {
|
|
1675
|
+
type: "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
|
|
1676
|
+
data: {
|
|
1677
|
+
coin: {
|
|
1678
|
+
value: "68254118",
|
|
1679
|
+
},
|
|
1680
|
+
deposit_events: {
|
|
1681
|
+
counter: "46",
|
|
1682
|
+
guid: {
|
|
1683
|
+
id: {
|
|
1684
|
+
addr: "0xa0d8",
|
|
1685
|
+
creation_num: "2",
|
|
1686
|
+
},
|
|
1687
|
+
},
|
|
1688
|
+
},
|
|
1689
|
+
frozen: false,
|
|
1690
|
+
withdraw_events: {
|
|
1691
|
+
counter: "89",
|
|
1692
|
+
guid: {
|
|
1693
|
+
id: {
|
|
1694
|
+
addr: "0xa0d8",
|
|
1695
|
+
creation_num: "3",
|
|
1696
|
+
},
|
|
1697
|
+
},
|
|
1698
|
+
},
|
|
1699
|
+
},
|
|
1700
|
+
},
|
|
1701
|
+
type: "write_resource",
|
|
1702
|
+
},
|
|
1703
|
+
{
|
|
1704
|
+
address: "0xa0d8",
|
|
1705
|
+
state_key_hash: "0x5520",
|
|
1706
|
+
data: {
|
|
1707
|
+
type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
|
|
1708
|
+
data: {
|
|
1709
|
+
coin: {
|
|
1710
|
+
value: "1000000",
|
|
1711
|
+
},
|
|
1712
|
+
deposit_events: {
|
|
1713
|
+
counter: "7",
|
|
1714
|
+
guid: {
|
|
1715
|
+
id: {
|
|
1716
|
+
addr: "0xa0d8",
|
|
1717
|
+
creation_num: "10",
|
|
1718
|
+
},
|
|
1719
|
+
},
|
|
1720
|
+
},
|
|
1721
|
+
frozen: false,
|
|
1722
|
+
withdraw_events: {
|
|
1723
|
+
counter: "13",
|
|
1724
|
+
guid: {
|
|
1725
|
+
id: {
|
|
1726
|
+
addr: "0xa0d8",
|
|
1727
|
+
creation_num: "11",
|
|
1728
|
+
},
|
|
1729
|
+
},
|
|
1730
|
+
},
|
|
1731
|
+
},
|
|
1732
|
+
},
|
|
1733
|
+
type: "write_resource",
|
|
1734
|
+
},
|
|
1735
|
+
{
|
|
1736
|
+
address: "0xa0d8",
|
|
1737
|
+
state_key_hash: "0x6f1e",
|
|
1738
|
+
data: {
|
|
1739
|
+
type: "0x1::account::Account",
|
|
1740
|
+
data: {
|
|
1741
|
+
authentication_key: "0xa0d8",
|
|
1742
|
+
coin_register_events: {
|
|
1743
|
+
counter: "5",
|
|
1744
|
+
guid: {
|
|
1745
|
+
id: {
|
|
1746
|
+
addr: "0xa0d8",
|
|
1747
|
+
creation_num: "0",
|
|
1748
|
+
},
|
|
1749
|
+
},
|
|
1750
|
+
},
|
|
1751
|
+
guid_creation_num: "12",
|
|
1752
|
+
key_rotation_events: {
|
|
1753
|
+
counter: "0",
|
|
1754
|
+
guid: {
|
|
1755
|
+
id: {
|
|
1756
|
+
addr: "0xa0d8",
|
|
1757
|
+
creation_num: "1",
|
|
1758
|
+
},
|
|
1759
|
+
},
|
|
1760
|
+
},
|
|
1761
|
+
rotation_capability_offer: {
|
|
1762
|
+
for: {
|
|
1763
|
+
vec: [],
|
|
1764
|
+
},
|
|
1765
|
+
},
|
|
1766
|
+
sequence_number: "122",
|
|
1767
|
+
signer_capability_offer: {
|
|
1768
|
+
for: {
|
|
1769
|
+
vec: [],
|
|
1770
|
+
},
|
|
1771
|
+
},
|
|
1772
|
+
},
|
|
1773
|
+
},
|
|
1774
|
+
type: "write_resource",
|
|
1775
|
+
},
|
|
1776
|
+
{
|
|
1777
|
+
state_key_hash: "0x6e4b",
|
|
1778
|
+
handle: "0x1b85",
|
|
1779
|
+
key: "0x0619",
|
|
1780
|
+
value: "0x1ddaf8da3b1497010000000000000000",
|
|
1781
|
+
data: null,
|
|
1782
|
+
type: "write_table_item",
|
|
1783
|
+
},
|
|
1784
|
+
],
|
|
1785
|
+
sender: "0xa0d8",
|
|
1786
|
+
sequence_number: "121",
|
|
1787
|
+
max_gas_amount: "12",
|
|
1788
|
+
gas_unit_price: "100",
|
|
1789
|
+
expiration_timestamp_secs: "1743177404",
|
|
1790
|
+
payload: {
|
|
1791
|
+
function: "0x1::aptos_account::transfer_coins",
|
|
1792
|
+
type_arguments: ["0xd111::staked_coin::StakedAptos"],
|
|
1793
|
+
arguments: ["0x4e5e", "1500000"],
|
|
1794
|
+
type: "entry_function_payload",
|
|
1795
|
+
},
|
|
1796
|
+
signature: {
|
|
1797
|
+
public_key: "0x474d",
|
|
1798
|
+
signature: "0x0ad8",
|
|
1799
|
+
type: "ed25519_signature",
|
|
1800
|
+
},
|
|
1801
|
+
events: [
|
|
1802
|
+
{
|
|
1803
|
+
guid: {
|
|
1804
|
+
creation_number: "11",
|
|
1805
|
+
account_address: "0xa0d8",
|
|
1806
|
+
},
|
|
1807
|
+
sequence_number: "12",
|
|
1808
|
+
type: "0x1::coin::WithdrawEvent",
|
|
1809
|
+
data: {
|
|
1810
|
+
amount: "1500000",
|
|
1811
|
+
},
|
|
1812
|
+
},
|
|
1813
|
+
{
|
|
1814
|
+
guid: {
|
|
1815
|
+
creation_number: "4",
|
|
1816
|
+
account_address: "0x4e5e",
|
|
1817
|
+
},
|
|
1818
|
+
sequence_number: "8",
|
|
1819
|
+
type: "0x1::coin::DepositEvent",
|
|
1820
|
+
data: {
|
|
1821
|
+
amount: "1500000",
|
|
1822
|
+
},
|
|
1823
|
+
},
|
|
1824
|
+
{
|
|
1825
|
+
guid: {
|
|
1826
|
+
creation_number: "0",
|
|
1827
|
+
account_address: "0x0",
|
|
1828
|
+
},
|
|
1829
|
+
sequence_number: "0",
|
|
1830
|
+
type: "0x1::transaction_fee::FeeStatement",
|
|
1831
|
+
data: {
|
|
1832
|
+
execution_gas_units: "6",
|
|
1833
|
+
io_gas_units: "6",
|
|
1834
|
+
storage_fee_octas: "0",
|
|
1835
|
+
storage_fee_refund_octas: "0",
|
|
1836
|
+
total_charge_gas_units: "12",
|
|
1837
|
+
},
|
|
1838
|
+
},
|
|
1839
|
+
],
|
|
1840
|
+
timestamp: "1743177360481259",
|
|
1841
|
+
type: "user_transaction",
|
|
1842
|
+
block: {
|
|
1843
|
+
height: 311948147,
|
|
1844
|
+
hash: "0x6d02",
|
|
1845
|
+
},
|
|
1846
|
+
},
|
|
1847
|
+
{
|
|
1848
|
+
version: "2532549325",
|
|
1849
|
+
hash: "0x9a6b",
|
|
1850
|
+
state_change_hash: "0xa424",
|
|
1851
|
+
event_root_hash: "0x0321",
|
|
1852
|
+
state_checkpoint_hash: null,
|
|
1853
|
+
gas_used: "12",
|
|
1854
|
+
success: true,
|
|
1855
|
+
vm_status: "Executed successfully",
|
|
1856
|
+
accumulator_root_hash: "0xede9",
|
|
1857
|
+
changes: [
|
|
1858
|
+
{
|
|
1859
|
+
address: "0x4e5e",
|
|
1860
|
+
state_key_hash: "0x3c0c",
|
|
1861
|
+
data: {
|
|
1862
|
+
type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
|
|
1863
|
+
data: {
|
|
1864
|
+
coin: {
|
|
1865
|
+
value: "2500000",
|
|
1866
|
+
},
|
|
1867
|
+
deposit_events: {
|
|
1868
|
+
counter: "8",
|
|
1869
|
+
guid: {
|
|
1870
|
+
id: {
|
|
1871
|
+
addr: "0x4e5e",
|
|
1872
|
+
creation_num: "4",
|
|
1873
|
+
},
|
|
1874
|
+
},
|
|
1875
|
+
},
|
|
1876
|
+
frozen: false,
|
|
1877
|
+
withdraw_events: {
|
|
1878
|
+
counter: "6",
|
|
1879
|
+
guid: {
|
|
1880
|
+
id: {
|
|
1881
|
+
addr: "0x4e5e",
|
|
1882
|
+
creation_num: "5",
|
|
1883
|
+
},
|
|
1884
|
+
},
|
|
1885
|
+
},
|
|
1886
|
+
},
|
|
1887
|
+
},
|
|
1888
|
+
type: "write_resource",
|
|
1889
|
+
},
|
|
1890
|
+
{
|
|
1891
|
+
address: "0xa0d8",
|
|
1892
|
+
state_key_hash: "0x1709",
|
|
1893
|
+
data: {
|
|
1894
|
+
type: "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
|
|
1895
|
+
data: {
|
|
1896
|
+
coin: {
|
|
1897
|
+
value: "68255318",
|
|
1898
|
+
},
|
|
1899
|
+
deposit_events: {
|
|
1900
|
+
counter: "46",
|
|
1901
|
+
guid: {
|
|
1902
|
+
id: {
|
|
1903
|
+
addr: "0xa0d8",
|
|
1904
|
+
creation_num: "2",
|
|
1905
|
+
},
|
|
1906
|
+
},
|
|
1907
|
+
},
|
|
1908
|
+
frozen: false,
|
|
1909
|
+
withdraw_events: {
|
|
1910
|
+
counter: "89",
|
|
1911
|
+
guid: {
|
|
1912
|
+
id: {
|
|
1913
|
+
addr: "0xa0d8",
|
|
1914
|
+
creation_num: "3",
|
|
1915
|
+
},
|
|
1916
|
+
},
|
|
1917
|
+
},
|
|
1918
|
+
},
|
|
1919
|
+
},
|
|
1920
|
+
type: "write_resource",
|
|
1921
|
+
},
|
|
1922
|
+
{
|
|
1923
|
+
address: "0xa0d8",
|
|
1924
|
+
state_key_hash: "0x5520",
|
|
1925
|
+
data: {
|
|
1926
|
+
type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
|
|
1927
|
+
data: {
|
|
1928
|
+
coin: {
|
|
1929
|
+
value: "2500000",
|
|
1930
|
+
},
|
|
1931
|
+
deposit_events: {
|
|
1932
|
+
counter: "7",
|
|
1933
|
+
guid: {
|
|
1934
|
+
id: {
|
|
1935
|
+
addr: "0xa0d8",
|
|
1936
|
+
creation_num: "10",
|
|
1937
|
+
},
|
|
1938
|
+
},
|
|
1939
|
+
},
|
|
1940
|
+
frozen: false,
|
|
1941
|
+
withdraw_events: {
|
|
1942
|
+
counter: "12",
|
|
1943
|
+
guid: {
|
|
1944
|
+
id: {
|
|
1945
|
+
addr: "0xa0d8",
|
|
1946
|
+
creation_num: "11",
|
|
1947
|
+
},
|
|
1948
|
+
},
|
|
1949
|
+
},
|
|
1950
|
+
},
|
|
1951
|
+
},
|
|
1952
|
+
type: "write_resource",
|
|
1953
|
+
},
|
|
1954
|
+
{
|
|
1955
|
+
address: "0xa0d8",
|
|
1956
|
+
state_key_hash: "0x6f1e",
|
|
1957
|
+
data: {
|
|
1958
|
+
type: "0x1::account::Account",
|
|
1959
|
+
data: {
|
|
1960
|
+
authentication_key: "0xa0d8",
|
|
1961
|
+
coin_register_events: {
|
|
1962
|
+
counter: "5",
|
|
1963
|
+
guid: {
|
|
1964
|
+
id: {
|
|
1965
|
+
addr: "0xa0d8",
|
|
1966
|
+
creation_num: "0",
|
|
1967
|
+
},
|
|
1968
|
+
},
|
|
1969
|
+
},
|
|
1970
|
+
guid_creation_num: "12",
|
|
1971
|
+
key_rotation_events: {
|
|
1972
|
+
counter: "0",
|
|
1973
|
+
guid: {
|
|
1974
|
+
id: {
|
|
1975
|
+
addr: "0xa0d8",
|
|
1976
|
+
creation_num: "1",
|
|
1977
|
+
},
|
|
1978
|
+
},
|
|
1979
|
+
},
|
|
1980
|
+
rotation_capability_offer: {
|
|
1981
|
+
for: {
|
|
1982
|
+
vec: [],
|
|
1983
|
+
},
|
|
1984
|
+
},
|
|
1985
|
+
sequence_number: "121",
|
|
1986
|
+
signer_capability_offer: {
|
|
1987
|
+
for: {
|
|
1988
|
+
vec: [],
|
|
1989
|
+
},
|
|
1990
|
+
},
|
|
1991
|
+
},
|
|
1992
|
+
},
|
|
1993
|
+
type: "write_resource",
|
|
1994
|
+
},
|
|
1995
|
+
{
|
|
1996
|
+
state_key_hash: "0x6e4b",
|
|
1997
|
+
handle: "0x1b85",
|
|
1998
|
+
key: "0x0619",
|
|
1999
|
+
value: "0xe86e0039581497010000000000000000",
|
|
2000
|
+
data: null,
|
|
2001
|
+
type: "write_table_item",
|
|
2002
|
+
},
|
|
2003
|
+
],
|
|
2004
|
+
sender: "0xa0d8",
|
|
2005
|
+
sequence_number: "120",
|
|
2006
|
+
max_gas_amount: "12",
|
|
2007
|
+
gas_unit_price: "100",
|
|
2008
|
+
expiration_timestamp_secs: "1743176706",
|
|
2009
|
+
payload: {
|
|
2010
|
+
function: "0x1::aptos_account::transfer_coins",
|
|
2011
|
+
type_arguments: ["0xd111::staked_coin::StakedAptos"],
|
|
2012
|
+
arguments: ["0x4e5e", "2500000"],
|
|
2013
|
+
type: "entry_function_payload",
|
|
2014
|
+
},
|
|
2015
|
+
signature: {
|
|
2016
|
+
public_key: "0x474d",
|
|
2017
|
+
signature: "0xb70e",
|
|
2018
|
+
type: "ed25519_signature",
|
|
2019
|
+
},
|
|
2020
|
+
events: [
|
|
2021
|
+
{
|
|
2022
|
+
guid: {
|
|
2023
|
+
creation_number: "11",
|
|
2024
|
+
account_address: "0xa0d8",
|
|
2025
|
+
},
|
|
2026
|
+
sequence_number: "11",
|
|
2027
|
+
type: "0x1::coin::WithdrawEvent",
|
|
2028
|
+
data: {
|
|
2029
|
+
amount: "2500000",
|
|
2030
|
+
},
|
|
2031
|
+
},
|
|
2032
|
+
{
|
|
2033
|
+
guid: {
|
|
2034
|
+
creation_number: "4",
|
|
2035
|
+
account_address: "0x4e5e",
|
|
2036
|
+
},
|
|
2037
|
+
sequence_number: "7",
|
|
2038
|
+
type: "0x1::coin::DepositEvent",
|
|
2039
|
+
data: {
|
|
2040
|
+
amount: "2500000",
|
|
2041
|
+
},
|
|
2042
|
+
},
|
|
2043
|
+
{
|
|
2044
|
+
guid: {
|
|
2045
|
+
creation_number: "0",
|
|
2046
|
+
account_address: "0x0",
|
|
2047
|
+
},
|
|
2048
|
+
sequence_number: "0",
|
|
2049
|
+
type: "0x1::transaction_fee::FeeStatement",
|
|
2050
|
+
data: {
|
|
2051
|
+
execution_gas_units: "6",
|
|
2052
|
+
io_gas_units: "6",
|
|
2053
|
+
storage_fee_octas: "0",
|
|
2054
|
+
storage_fee_refund_octas: "0",
|
|
2055
|
+
total_charge_gas_units: "12",
|
|
2056
|
+
},
|
|
2057
|
+
},
|
|
2058
|
+
],
|
|
2059
|
+
timestamp: "1743176594693251",
|
|
2060
|
+
type: "user_transaction",
|
|
2061
|
+
block: {
|
|
2062
|
+
height: 311942427,
|
|
2063
|
+
hash: "0x8655",
|
|
2064
|
+
},
|
|
2065
|
+
},
|
|
2066
|
+
],
|
|
2067
|
+
blockHeight: 316278241,
|
|
2068
|
+
}));
|
|
2069
|
+
|
|
2070
|
+
const mockGetBalance = jest.fn().mockImplementation(() => BigNumber(5000000));
|
|
2071
|
+
|
|
2072
|
+
mockedDecodeTokenAccountId.mockReturnValue({
|
|
2073
|
+
token: {
|
|
2074
|
+
type: "TokenCurrency",
|
|
2075
|
+
id: "aptos/coin/dstapt_0xd111::staked_coin::stakedaptos",
|
|
2076
|
+
contractAddress: "0xd111::staked_coin::StakedAptos",
|
|
2077
|
+
parentCurrency: {
|
|
2078
|
+
type: "CryptoCurrency",
|
|
2079
|
+
id: "aptos",
|
|
2080
|
+
coinType: 637,
|
|
2081
|
+
name: "Aptos",
|
|
2082
|
+
managerAppName: "Aptos",
|
|
2083
|
+
ticker: "APT",
|
|
2084
|
+
scheme: "aptos",
|
|
2085
|
+
color: "#231F20",
|
|
2086
|
+
family: "aptos",
|
|
2087
|
+
units: [
|
|
2088
|
+
{
|
|
2089
|
+
name: "APT",
|
|
2090
|
+
code: "APT",
|
|
2091
|
+
magnitude: 8,
|
|
2092
|
+
},
|
|
2093
|
+
],
|
|
2094
|
+
explorerViews: [
|
|
2095
|
+
{
|
|
2096
|
+
address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
|
|
2097
|
+
tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
|
|
2098
|
+
},
|
|
2099
|
+
],
|
|
2100
|
+
},
|
|
2101
|
+
name: "dstAPT",
|
|
2102
|
+
tokenType: "coin",
|
|
2103
|
+
ticker: "dstAPT",
|
|
2104
|
+
disableCountervalue: false,
|
|
2105
|
+
delisted: false,
|
|
2106
|
+
units: [
|
|
2107
|
+
{
|
|
2108
|
+
name: "dstAPT",
|
|
2109
|
+
code: "dstAPT",
|
|
2110
|
+
magnitude: 8,
|
|
2111
|
+
},
|
|
2112
|
+
],
|
|
2113
|
+
},
|
|
2114
|
+
accountId: "js:2:aptos:6415:aptos",
|
|
2115
|
+
});
|
|
2116
|
+
|
|
2117
|
+
const operations = [
|
|
2118
|
+
{
|
|
2119
|
+
id: "js:2:aptos:474d:aptos-0x3f35-OUT",
|
|
2120
|
+
hash: "0x3f35",
|
|
2121
|
+
type: "FEES",
|
|
2122
|
+
value: BigNumber(1200),
|
|
2123
|
+
fee: BigNumber(1200),
|
|
2124
|
+
blockHash: "0x6d02",
|
|
2125
|
+
blockHeight: 311948147,
|
|
2126
|
+
senders: ["0xa0d8"],
|
|
2127
|
+
recipients: ["0x4e5e"],
|
|
2128
|
+
accountId: "js:2:aptos:474d:aptos",
|
|
2129
|
+
date: new Date("2025-03-28T15:56:00.481Z"),
|
|
2130
|
+
extra: {
|
|
2131
|
+
version: "2532591427",
|
|
2132
|
+
},
|
|
2133
|
+
transactionSequenceNumber: 121,
|
|
2134
|
+
hasFailed: false,
|
|
2135
|
+
},
|
|
2136
|
+
{
|
|
2137
|
+
id: "js:2:aptos:474d:aptos-0x9a6b-OUT",
|
|
2138
|
+
hash: "0x9a6b",
|
|
2139
|
+
type: "FEES",
|
|
2140
|
+
value: BigNumber(1200),
|
|
2141
|
+
fee: BigNumber(1200),
|
|
2142
|
+
blockHash: "0x8655",
|
|
2143
|
+
blockHeight: 311942427,
|
|
2144
|
+
senders: ["0xa0d8"],
|
|
2145
|
+
recipients: ["0x4e5e"],
|
|
2146
|
+
accountId: "js:2:aptos:474d:aptos",
|
|
2147
|
+
date: new Date("2025-03-28T15:43:14.693Z"),
|
|
2148
|
+
extra: {
|
|
2149
|
+
version: "2532549325",
|
|
2150
|
+
},
|
|
2151
|
+
transactionSequenceNumber: 120,
|
|
2152
|
+
hasFailed: false,
|
|
2153
|
+
},
|
|
2154
|
+
] as Operation[];
|
|
2155
|
+
|
|
2156
|
+
const tokenOperations = [
|
|
2157
|
+
{
|
|
2158
|
+
id: "js:2:aptos:474d:aptos-0x3f35-OUT",
|
|
2159
|
+
hash: "0x3f35",
|
|
2160
|
+
type: "OUT",
|
|
2161
|
+
value: BigNumber(1500000),
|
|
2162
|
+
fee: BigNumber(1200),
|
|
2163
|
+
blockHash: "0x6d02",
|
|
2164
|
+
blockHeight: 311948147,
|
|
2165
|
+
senders: ["0xa0d8"],
|
|
2166
|
+
recipients: ["0x4e5e"],
|
|
2167
|
+
accountId:
|
|
2168
|
+
"js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
|
|
2169
|
+
date: new Date("2025-03-28T15:56:00.481Z"),
|
|
2170
|
+
extra: {
|
|
2171
|
+
version: "2532591427",
|
|
2172
|
+
},
|
|
2173
|
+
transactionSequenceNumber: 121,
|
|
2174
|
+
hasFailed: false,
|
|
2175
|
+
},
|
|
2176
|
+
{
|
|
2177
|
+
id: "js:2:aptos:474d:aptos-0x9a6b-OUT",
|
|
2178
|
+
hash: "0x9a6b",
|
|
2179
|
+
type: "OUT",
|
|
2180
|
+
value: BigNumber(2500000),
|
|
2181
|
+
fee: BigNumber(1200),
|
|
2182
|
+
blockHash: "0x8655",
|
|
2183
|
+
blockHeight: 311942427,
|
|
2184
|
+
senders: ["0xa0d8"],
|
|
2185
|
+
recipients: ["0x4e5e"],
|
|
2186
|
+
accountId:
|
|
2187
|
+
"js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
|
|
2188
|
+
date: new Date("2025-03-28T15:43:14.693Z"),
|
|
2189
|
+
extra: {
|
|
2190
|
+
version: "2532549325",
|
|
2191
|
+
},
|
|
2192
|
+
transactionSequenceNumber: 120,
|
|
2193
|
+
hasFailed: false,
|
|
2194
|
+
},
|
|
2195
|
+
] as Operation[];
|
|
2196
|
+
|
|
2197
|
+
const mockedGetDelegatorBalanceInPool = jest.fn().mockResolvedValue([
|
|
2198
|
+
BigNumber(mockDelegatorBalance[0]), // active
|
|
2199
|
+
BigNumber(mockDelegatorBalance[1]), // inactive
|
|
2200
|
+
BigNumber(mockDelegatorBalance[2]), // pending_inactive
|
|
2201
|
+
]);
|
|
2202
|
+
|
|
2203
|
+
mockedAptosAPI.mockImplementation(() => ({
|
|
2204
|
+
getAccountInfo: mockGetAccountInfo,
|
|
2205
|
+
getDelegatorBalanceInPool: mockedGetDelegatorBalanceInPool,
|
|
2206
|
+
getBalances: mockGetBalance,
|
|
2207
|
+
}));
|
|
2208
|
+
|
|
2209
|
+
jest.mocked(mergeOps).mockReturnValue(operations);
|
|
2210
|
+
jest.mocked(txsToOps).mockReturnValue([operations, tokenOperations, stakingOperations]);
|
|
2211
|
+
|
|
2212
|
+
const info = {
|
|
2213
|
+
currency: {
|
|
2214
|
+
type: "CryptoCurrency",
|
|
2215
|
+
id: "aptos",
|
|
2216
|
+
coinType: 637,
|
|
2217
|
+
name: "Aptos",
|
|
2218
|
+
managerAppName: "Aptos",
|
|
2219
|
+
ticker: "APT",
|
|
2220
|
+
scheme: "aptos",
|
|
2221
|
+
color: "#231F20",
|
|
2222
|
+
family: "aptos",
|
|
2223
|
+
units: [
|
|
2224
|
+
{
|
|
2225
|
+
name: "APT",
|
|
2226
|
+
code: "APT",
|
|
2227
|
+
magnitude: 8,
|
|
2228
|
+
},
|
|
2229
|
+
],
|
|
2230
|
+
},
|
|
2231
|
+
index: 0,
|
|
2232
|
+
address: "0xa0d8",
|
|
2233
|
+
derivationPath: "44'/637'/0'",
|
|
2234
|
+
derivationMode: "aptos",
|
|
2235
|
+
initialAccount: {
|
|
2236
|
+
type: "Account",
|
|
2237
|
+
id: "js:2:aptos:474d:aptos",
|
|
2238
|
+
used: true,
|
|
2239
|
+
seedIdentifier: "3086",
|
|
2240
|
+
derivationMode: "aptos",
|
|
2241
|
+
index: 0,
|
|
2242
|
+
freshAddress: "0xa0d8",
|
|
2243
|
+
freshAddressPath: "44'/637'/0'/0'/0'",
|
|
2244
|
+
blockHeight: 316272224,
|
|
2245
|
+
creationDate: "2025-01-16T14:17:41.076Z",
|
|
2246
|
+
balance: BigNumber(68254118),
|
|
2247
|
+
spendableBalance: BigNumber(68254118),
|
|
2248
|
+
operations: [],
|
|
2249
|
+
operationsCount: 0,
|
|
2250
|
+
pendingOperations: [],
|
|
2251
|
+
currency: {
|
|
2252
|
+
type: "CryptoCurrency",
|
|
2253
|
+
id: "aptos",
|
|
2254
|
+
coinType: 637,
|
|
2255
|
+
name: "Aptos",
|
|
2256
|
+
managerAppName: "Aptos",
|
|
2257
|
+
ticker: "APT",
|
|
2258
|
+
scheme: "aptos",
|
|
2259
|
+
color: "#231F20",
|
|
2260
|
+
family: "aptos",
|
|
2261
|
+
units: [
|
|
2262
|
+
{
|
|
2263
|
+
name: "APT",
|
|
2264
|
+
code: "APT",
|
|
2265
|
+
magnitude: 8,
|
|
2266
|
+
},
|
|
2267
|
+
],
|
|
2268
|
+
},
|
|
2269
|
+
lastSyncDate: new Date(),
|
|
2270
|
+
swapHistory: [],
|
|
2271
|
+
balanceHistoryCache: emptyHistoryCache,
|
|
2272
|
+
xpub: "474d",
|
|
2273
|
+
subAccounts: [
|
|
2274
|
+
{
|
|
2275
|
+
type: "TokenAccount",
|
|
2276
|
+
id: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
|
|
2277
|
+
parentId: "js:2:aptos:474d:aptos",
|
|
2278
|
+
token: {
|
|
2279
|
+
type: "TokenCurrency",
|
|
2280
|
+
id: "aptos/coin/dstapt_0xd111::staked_coin::stakedaptos",
|
|
2281
|
+
contractAddress: "0xd111::staked_coin::StakedAptos",
|
|
2282
|
+
parentCurrency: {
|
|
2283
|
+
type: "CryptoCurrency",
|
|
2284
|
+
id: "aptos",
|
|
2285
|
+
coinType: 637,
|
|
2286
|
+
name: "Aptos",
|
|
2287
|
+
managerAppName: "Aptos",
|
|
2288
|
+
ticker: "APT",
|
|
2289
|
+
scheme: "aptos",
|
|
2290
|
+
color: "#231F20",
|
|
2291
|
+
family: "aptos",
|
|
2292
|
+
units: [
|
|
2293
|
+
{
|
|
2294
|
+
name: "APT",
|
|
2295
|
+
code: "APT",
|
|
2296
|
+
magnitude: 8,
|
|
2297
|
+
},
|
|
2298
|
+
],
|
|
2299
|
+
},
|
|
2300
|
+
name: "dstAPT",
|
|
2301
|
+
tokenType: "coin",
|
|
2302
|
+
ticker: "dstAPT",
|
|
2303
|
+
disableCountervalue: false,
|
|
2304
|
+
delisted: false,
|
|
2305
|
+
units: [
|
|
2306
|
+
{
|
|
2307
|
+
name: "dstAPT",
|
|
2308
|
+
code: "dstAPT",
|
|
2309
|
+
magnitude: 8,
|
|
2310
|
+
},
|
|
2311
|
+
],
|
|
2312
|
+
},
|
|
2313
|
+
balance: BigNumber(5000000),
|
|
2314
|
+
spendableBalance: BigNumber(5000000),
|
|
2315
|
+
creationDate: "2025-03-11T09:33:46.840Z",
|
|
2316
|
+
operations: [],
|
|
2317
|
+
operationsCount: 0,
|
|
2318
|
+
pendingOperations: [],
|
|
2319
|
+
swapHistory: [],
|
|
2320
|
+
balanceHistoryCache: emptyHistoryCache,
|
|
2321
|
+
},
|
|
2322
|
+
],
|
|
2323
|
+
},
|
|
2324
|
+
} as unknown as AccountShapeInfo<AptosAccount>;
|
|
2325
|
+
|
|
2326
|
+
const result = await getAccountShape(info, {} as SyncConfig);
|
|
2327
|
+
|
|
2328
|
+
expect(result.aptosResources).toBeDefined();
|
|
2329
|
+
|
|
2330
|
+
const stakingEnabled = getEnv("APTOS_ENABLE_STAKING") === true;
|
|
2331
|
+
if (stakingEnabled) {
|
|
2332
|
+
expect(result.aptosResources?.stakingPositions).toHaveLength(1);
|
|
2333
|
+
|
|
2334
|
+
const position = result.aptosResources?.stakingPositions?.[0];
|
|
2335
|
+
expect(position).toEqual({
|
|
2336
|
+
active: BigNumber(mockDelegatorBalance[0]),
|
|
2337
|
+
inactive: BigNumber(mockDelegatorBalance[1]),
|
|
2338
|
+
pendingInactive: BigNumber(mockDelegatorBalance[2]),
|
|
2339
|
+
validatorId: stakingOperations[0].recipients[0],
|
|
2340
|
+
});
|
|
2341
|
+
|
|
2342
|
+
expect(result.aptosResources?.activeBalance).toEqual(BigNumber(mockDelegatorBalance[0]));
|
|
2343
|
+
expect(result.aptosResources?.inactiveBalance).toEqual(BigNumber(mockDelegatorBalance[1]));
|
|
2344
|
+
expect(result.aptosResources?.pendingInactiveBalance).toEqual(
|
|
2345
|
+
BigNumber(mockDelegatorBalance[2]),
|
|
2346
|
+
);
|
|
2347
|
+
}
|
|
2348
|
+
});
|
|
2349
|
+
});
|