@ledgerhq/coin-aptos 2.0.0-nightly.5 → 2.0.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/.turbo/turbo-build.log +1 -1
- package/.unimportedrc.json +18 -6
- package/CHANGELOG.md +152 -34
- package/jest.config.js +2 -1
- package/jest.integ.config.js +8 -0
- package/lib/__tests__/api/index.integ.test.d.ts +2 -0
- package/lib/__tests__/api/index.integ.test.d.ts.map +1 -0
- package/lib/__tests__/api/index.integ.test.js +52 -0
- package/lib/__tests__/api/index.integ.test.js.map +1 -0
- package/lib/__tests__/api/index.test.js +48 -404
- package/lib/__tests__/api/index.test.js.map +1 -1
- package/lib/__tests__/bridge/broadcast.test.js +5 -5
- package/lib/__tests__/bridge/broadcast.test.js.map +1 -1
- package/lib/__tests__/bridge/buildTransaction.test.js +60 -5
- package/lib/__tests__/bridge/buildTransaction.test.js.map +1 -1
- package/lib/__tests__/bridge/createTransaction.test.js +1 -1
- package/lib/__tests__/bridge/createTransaction.test.js.map +1 -1
- package/lib/__tests__/bridge/getFeesForTransaction.test.js +115 -14
- package/lib/__tests__/bridge/getFeesForTransaction.test.js.map +1 -1
- package/lib/__tests__/bridge/getTransactionStatus.test.js +175 -37
- package/lib/__tests__/bridge/getTransactionStatus.test.js.map +1 -1
- package/lib/__tests__/bridge/logic.test.js +889 -115
- package/lib/__tests__/bridge/logic.test.js.map +1 -1
- package/lib/__tests__/bridge/prepareTransaction.test.js +3 -3
- package/lib/__tests__/bridge/prepareTransaction.test.js.map +1 -1
- package/lib/__tests__/bridge/signOperation.test.js +131 -4
- package/lib/__tests__/bridge/signOperation.test.js.map +1 -1
- package/lib/__tests__/bridge/synchronisation.test.js +1215 -68
- package/lib/__tests__/bridge/synchronisation.test.js.map +1 -1
- package/lib/__tests__/network/client.test.d.ts +2 -0
- package/lib/__tests__/network/client.test.d.ts.map +1 -0
- package/lib/__tests__/network/client.test.js +520 -0
- package/lib/__tests__/network/client.test.js.map +1 -0
- package/lib/api/index.d.ts +4 -30
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +24 -170
- package/lib/api/index.js.map +1 -1
- package/lib/bridge/bridge.fixture.d.ts +2 -0
- package/lib/bridge/bridge.fixture.d.ts.map +1 -1
- package/lib/bridge/bridge.fixture.js +85 -13
- package/lib/bridge/bridge.fixture.js.map +1 -1
- package/lib/bridge/broadcast.d.ts +3 -2
- package/lib/bridge/broadcast.d.ts.map +1 -1
- package/lib/bridge/broadcast.js +4 -3
- package/lib/bridge/broadcast.js.map +1 -1
- package/lib/bridge/buildTransaction.d.ts +1 -1
- package/lib/bridge/buildTransaction.d.ts.map +1 -1
- package/lib/bridge/buildTransaction.js +29 -3
- package/lib/bridge/buildTransaction.js.map +1 -1
- package/lib/bridge/createTransaction.js +3 -3
- package/lib/bridge/createTransaction.js.map +1 -1
- package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -1
- package/lib/bridge/estimateMaxSpendable.js +6 -5
- package/lib/bridge/estimateMaxSpendable.js.map +1 -1
- package/lib/bridge/getFeesForTransaction.d.ts +1 -1
- package/lib/bridge/getFeesForTransaction.d.ts.map +1 -1
- package/lib/bridge/getFeesForTransaction.js +19 -13
- package/lib/bridge/getFeesForTransaction.js.map +1 -1
- package/lib/bridge/getTransactionStatus.d.ts.map +1 -1
- package/lib/bridge/getTransactionStatus.js +28 -14
- package/lib/bridge/getTransactionStatus.js.map +1 -1
- package/lib/bridge/index.d.ts +1 -1
- package/lib/bridge/index.d.ts.map +1 -1
- package/lib/bridge/logic.d.ts +13 -11
- package/lib/bridge/logic.d.ts.map +1 -1
- package/lib/bridge/logic.js +152 -57
- package/lib/bridge/logic.js.map +1 -1
- package/lib/bridge/prepareTransaction.d.ts.map +1 -1
- package/lib/bridge/prepareTransaction.js +5 -4
- package/lib/bridge/prepareTransaction.js.map +1 -1
- package/lib/bridge/signOperation.d.ts.map +1 -1
- package/lib/bridge/signOperation.js +20 -6
- package/lib/bridge/signOperation.js.map +1 -1
- package/lib/bridge/synchronisation.d.ts +15 -0
- package/lib/bridge/synchronisation.d.ts.map +1 -1
- package/lib/bridge/synchronisation.js +129 -6
- package/lib/bridge/synchronisation.js.map +1 -1
- package/lib/config.d.ts +13 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +9 -0
- package/lib/config.js.map +1 -0
- package/lib/constants.d.ts +9 -1
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +13 -2
- package/lib/constants.js.map +1 -1
- package/lib/network/client.d.ts +36 -0
- package/lib/network/client.d.ts.map +1 -0
- package/lib/network/client.js +247 -0
- package/lib/network/client.js.map +1 -0
- package/lib/network/graphql/queries.d.ts.map +1 -0
- package/lib/{api → network}/graphql/queries.js +6 -6
- package/lib/network/graphql/queries.js.map +1 -0
- package/lib/{api → network}/graphql/types.d.ts +9 -9
- package/lib/network/graphql/types.d.ts.map +1 -0
- package/lib/{api → network}/graphql/types.js.map +1 -1
- package/lib/network/index.d.ts +2 -1
- package/lib/network/index.d.ts.map +1 -1
- package/lib/network/index.js +15 -0
- package/lib/network/index.js.map +1 -1
- package/lib/test/bot-specs.d.ts.map +1 -1
- package/lib/test/bot-specs.js +40 -1
- package/lib/test/bot-specs.js.map +1 -1
- package/lib/test/bridgeDatasetTest.d.ts.map +1 -1
- package/lib/test/bridgeDatasetTest.js +44 -62
- package/lib/test/bridgeDatasetTest.js.map +1 -1
- package/lib/test/speculos-deviceActions.d.ts +1 -0
- package/lib/test/speculos-deviceActions.d.ts.map +1 -1
- package/lib/test/speculos-deviceActions.js +37 -5
- package/lib/test/speculos-deviceActions.js.map +1 -1
- package/lib/types/assets.d.ts +12 -0
- package/lib/types/assets.d.ts.map +1 -0
- package/lib/types/assets.js +3 -0
- package/lib/types/assets.js.map +1 -0
- package/lib/types/index.d.ts +18 -7
- package/lib/types/index.d.ts.map +1 -1
- package/lib-es/__tests__/api/index.integ.test.d.ts +2 -0
- package/lib-es/__tests__/api/index.integ.test.d.ts.map +1 -0
- package/lib-es/__tests__/api/index.integ.test.js +50 -0
- package/lib-es/__tests__/api/index.integ.test.js.map +1 -0
- package/lib-es/__tests__/api/index.test.js +52 -408
- package/lib-es/__tests__/api/index.test.js.map +1 -1
- package/lib-es/__tests__/bridge/broadcast.test.js +2 -2
- package/lib-es/__tests__/bridge/broadcast.test.js.map +1 -1
- package/lib-es/__tests__/bridge/buildTransaction.test.js +60 -5
- package/lib-es/__tests__/bridge/buildTransaction.test.js.map +1 -1
- package/lib-es/__tests__/bridge/createTransaction.test.js +1 -1
- package/lib-es/__tests__/bridge/createTransaction.test.js.map +1 -1
- package/lib-es/__tests__/bridge/getFeesForTransaction.test.js +112 -11
- package/lib-es/__tests__/bridge/getFeesForTransaction.test.js.map +1 -1
- package/lib-es/__tests__/bridge/getTransactionStatus.test.js +177 -39
- package/lib-es/__tests__/bridge/getTransactionStatus.test.js.map +1 -1
- package/lib-es/__tests__/bridge/logic.test.js +891 -117
- package/lib-es/__tests__/bridge/logic.test.js.map +1 -1
- package/lib-es/__tests__/bridge/prepareTransaction.test.js +2 -2
- package/lib-es/__tests__/bridge/prepareTransaction.test.js.map +1 -1
- package/lib-es/__tests__/bridge/signOperation.test.js +131 -4
- package/lib-es/__tests__/bridge/signOperation.test.js.map +1 -1
- package/lib-es/__tests__/bridge/synchronisation.test.js +1213 -69
- package/lib-es/__tests__/bridge/synchronisation.test.js.map +1 -1
- package/lib-es/__tests__/network/client.test.d.ts +2 -0
- package/lib-es/__tests__/network/client.test.d.ts.map +1 -0
- package/lib-es/__tests__/network/client.test.js +515 -0
- package/lib-es/__tests__/network/client.test.js.map +1 -0
- package/lib-es/api/index.d.ts +4 -30
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +22 -168
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/bridge/bridge.fixture.d.ts +2 -0
- package/lib-es/bridge/bridge.fixture.d.ts.map +1 -1
- package/lib-es/bridge/bridge.fixture.js +82 -12
- package/lib-es/bridge/bridge.fixture.js.map +1 -1
- package/lib-es/bridge/broadcast.d.ts +3 -2
- package/lib-es/bridge/broadcast.d.ts.map +1 -1
- package/lib-es/bridge/broadcast.js +4 -3
- package/lib-es/bridge/broadcast.js.map +1 -1
- package/lib-es/bridge/buildTransaction.d.ts +1 -1
- package/lib-es/bridge/buildTransaction.d.ts.map +1 -1
- package/lib-es/bridge/buildTransaction.js +30 -4
- package/lib-es/bridge/buildTransaction.js.map +1 -1
- package/lib-es/bridge/createTransaction.js +1 -1
- package/lib-es/bridge/createTransaction.js.map +1 -1
- package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -1
- package/lib-es/bridge/estimateMaxSpendable.js +4 -3
- package/lib-es/bridge/estimateMaxSpendable.js.map +1 -1
- package/lib-es/bridge/getFeesForTransaction.d.ts +1 -1
- package/lib-es/bridge/getFeesForTransaction.d.ts.map +1 -1
- package/lib-es/bridge/getFeesForTransaction.js +14 -8
- package/lib-es/bridge/getFeesForTransaction.js.map +1 -1
- package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -1
- package/lib-es/bridge/getTransactionStatus.js +28 -14
- package/lib-es/bridge/getTransactionStatus.js.map +1 -1
- package/lib-es/bridge/index.d.ts +1 -1
- package/lib-es/bridge/index.d.ts.map +1 -1
- package/lib-es/bridge/logic.d.ts +13 -11
- package/lib-es/bridge/logic.d.ts.map +1 -1
- package/lib-es/bridge/logic.js +146 -55
- package/lib-es/bridge/logic.js.map +1 -1
- package/lib-es/bridge/prepareTransaction.d.ts.map +1 -1
- package/lib-es/bridge/prepareTransaction.js +5 -4
- package/lib-es/bridge/prepareTransaction.js.map +1 -1
- package/lib-es/bridge/signOperation.d.ts.map +1 -1
- package/lib-es/bridge/signOperation.js +18 -4
- package/lib-es/bridge/signOperation.js.map +1 -1
- package/lib-es/bridge/synchronisation.d.ts +15 -0
- package/lib-es/bridge/synchronisation.d.ts.map +1 -1
- package/lib-es/bridge/synchronisation.js +124 -4
- package/lib-es/bridge/synchronisation.js.map +1 -1
- package/lib-es/config.d.ts +13 -0
- package/lib-es/config.d.ts.map +1 -0
- package/lib-es/config.js +4 -0
- package/lib-es/config.js.map +1 -0
- package/lib-es/constants.d.ts +9 -1
- package/lib-es/constants.d.ts.map +1 -1
- package/lib-es/constants.js +9 -1
- package/lib-es/constants.js.map +1 -1
- package/lib-es/network/client.d.ts +36 -0
- package/lib-es/network/client.d.ts.map +1 -0
- package/lib-es/network/client.js +240 -0
- package/lib-es/network/client.js.map +1 -0
- package/lib-es/network/graphql/queries.d.ts.map +1 -0
- package/lib-es/{api → network}/graphql/queries.js +6 -6
- package/lib-es/network/graphql/queries.js.map +1 -0
- package/lib-es/{api → network}/graphql/types.d.ts +9 -9
- package/lib-es/network/graphql/types.d.ts.map +1 -0
- package/lib-es/{api → network}/graphql/types.js.map +1 -1
- package/lib-es/network/index.d.ts +2 -1
- package/lib-es/network/index.d.ts.map +1 -1
- package/lib-es/network/index.js +1 -0
- package/lib-es/network/index.js.map +1 -1
- package/lib-es/test/bot-specs.d.ts.map +1 -1
- package/lib-es/test/bot-specs.js +41 -2
- package/lib-es/test/bot-specs.js.map +1 -1
- package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -1
- package/lib-es/test/bridgeDatasetTest.js +44 -59
- package/lib-es/test/bridgeDatasetTest.js.map +1 -1
- package/lib-es/test/speculos-deviceActions.d.ts +1 -0
- package/lib-es/test/speculos-deviceActions.d.ts.map +1 -1
- package/lib-es/test/speculos-deviceActions.js +36 -4
- package/lib-es/test/speculos-deviceActions.js.map +1 -1
- package/lib-es/types/assets.d.ts +12 -0
- package/lib-es/types/assets.d.ts.map +1 -0
- package/lib-es/types/assets.js +2 -0
- package/lib-es/types/assets.js.map +1 -0
- package/lib-es/types/index.d.ts +18 -7
- package/lib-es/types/index.d.ts.map +1 -1
- package/package.json +12 -9
- package/src/__tests__/api/index.integ.test.ts +58 -0
- package/src/__tests__/api/index.test.ts +60 -477
- package/src/__tests__/bridge/broadcast.test.ts +2 -2
- package/src/__tests__/bridge/buildTransaction.test.ts +87 -5
- package/src/__tests__/bridge/createTransaction.test.ts +1 -1
- package/src/__tests__/bridge/getFeesForTransaction.test.ts +146 -11
- package/src/__tests__/bridge/getTransactionStatus.test.ts +217 -38
- package/src/__tests__/bridge/logic.test.ts +922 -118
- package/src/__tests__/bridge/prepareTransaction.test.ts +2 -2
- package/src/__tests__/bridge/signOperation.test.ts +147 -5
- package/src/__tests__/bridge/synchronisation.test.ts +1265 -71
- package/src/__tests__/network/client.test.ts +618 -0
- package/src/api/index.ts +31 -223
- package/src/bridge/bridge.fixture.ts +91 -12
- package/src/bridge/broadcast.ts +7 -7
- package/src/bridge/buildTransaction.ts +40 -7
- package/src/bridge/createTransaction.ts +1 -1
- package/src/bridge/estimateMaxSpendable.ts +4 -3
- package/src/bridge/getFeesForTransaction.ts +16 -10
- package/src/bridge/getTransactionStatus.ts +35 -13
- package/src/bridge/index.ts +1 -1
- package/src/bridge/logic.ts +202 -67
- package/src/bridge/prepareTransaction.ts +7 -4
- package/src/bridge/signOperation.ts +20 -4
- package/src/bridge/synchronisation.ts +171 -4
- package/src/config.ts +19 -0
- package/src/constants.ts +17 -1
- package/src/network/client.ts +315 -0
- package/src/{api → network}/graphql/queries.ts +6 -6
- package/src/{api → network}/graphql/types.ts +9 -9
- package/src/network/index.ts +2 -1
- package/src/test/bot-specs.ts +63 -3
- package/src/test/bridgeDatasetTest.ts +46 -59
- package/src/test/speculos-deviceActions.ts +40 -4
- package/src/types/assets.ts +15 -0
- package/src/types/index.ts +15 -1
- package/lib/api/graphql/queries.d.ts.map +0 -1
- package/lib/api/graphql/queries.js.map +0 -1
- package/lib/api/graphql/types.d.ts.map +0 -1
- package/lib-es/api/graphql/queries.d.ts.map +0 -1
- package/lib-es/api/graphql/queries.js.map +0 -1
- package/lib-es/api/graphql/types.d.ts.map +0 -1
- /package/lib/{api → network}/graphql/queries.d.ts +0 -0
- /package/lib/{api → network}/graphql/types.js +0 -0
- /package/lib-es/{api → network}/graphql/queries.d.ts +0 -0
- /package/lib-es/{api → network}/graphql/types.js +0 -0
package/src/constants.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { MoveStructId } from "@aptos-labs/ts-sdk";
|
|
2
|
+
import BigNumber from "bignumber.js";
|
|
3
|
+
|
|
4
|
+
export const DEFAULT_GAS = new BigNumber(200);
|
|
5
|
+
export const DEFAULT_GAS_PRICE = new BigNumber(100);
|
|
6
|
+
export const ESTIMATE_GAS_MUL = new BigNumber(1.0); // define buffer for gas estimation change here, if needed
|
|
2
7
|
|
|
3
8
|
export const LOAD_LIMIT = 10;
|
|
4
9
|
|
|
@@ -10,25 +15,36 @@ export enum TX_STATUS {
|
|
|
10
15
|
|
|
11
16
|
export const WRITE_RESOURCE = "write_resource";
|
|
12
17
|
|
|
13
|
-
export const
|
|
18
|
+
export const COIN_TRANSFER_TYPES: MoveStructId[] = [
|
|
14
19
|
"0x1::aptos_account::transfer",
|
|
15
20
|
"0x1::aptos_account::transfer_coins",
|
|
16
21
|
"0x1::coin::transfer",
|
|
17
22
|
];
|
|
23
|
+
|
|
24
|
+
export const FA_TRANSFER_TYPES: MoveStructId[] = ["0x1::primary_fungible_store::transfer"];
|
|
25
|
+
|
|
18
26
|
export const BATCH_TRANSFER_TYPES: MoveStructId[] = [
|
|
19
27
|
"0x1::aptos_account::batch_transfer",
|
|
20
28
|
"0x1::aptos_account::batch_transfer_coins",
|
|
21
29
|
];
|
|
30
|
+
|
|
22
31
|
export const DELEGATION_POOL_TYPES: MoveStructId[] = [
|
|
23
32
|
"0x1::delegation_pool::add_stake",
|
|
24
33
|
"0x1::delegation_pool::withdraw",
|
|
25
34
|
];
|
|
26
35
|
|
|
27
36
|
export const APTOS_ASSET_ID: MoveStructId = "0x1::aptos_coin::AptosCoin";
|
|
37
|
+
|
|
28
38
|
export const APTOS_COIN_CHANGE: MoveStructId = `0x1::coin::CoinStore<${APTOS_ASSET_ID}>`;
|
|
29
39
|
|
|
40
|
+
export const APTOS_FUNGIBLE_STORE: MoveStructId = "0x1::fungible_asset::FungibleStore";
|
|
41
|
+
|
|
42
|
+
export const APTOS_OBJECT_CORE: MoveStructId = "0x1::object::ObjectCore";
|
|
43
|
+
|
|
30
44
|
export enum DIRECTION {
|
|
31
45
|
IN = "IN",
|
|
32
46
|
OUT = "OUT",
|
|
33
47
|
UNKNOWN = "UNKNOWN",
|
|
34
48
|
}
|
|
49
|
+
|
|
50
|
+
export const SUPPORTED_TOKEN_TYPES = ["coin", "fungible_asset"];
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { ApolloClient, InMemoryCache } from "@apollo/client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
AccountData,
|
|
5
|
+
Aptos,
|
|
6
|
+
AptosApiType,
|
|
7
|
+
AptosConfig,
|
|
8
|
+
Ed25519PublicKey,
|
|
9
|
+
GasEstimation,
|
|
10
|
+
InputEntryFunctionData,
|
|
11
|
+
InputGenerateTransactionOptions,
|
|
12
|
+
MimeType,
|
|
13
|
+
post,
|
|
14
|
+
RawTransaction,
|
|
15
|
+
SimpleTransaction,
|
|
16
|
+
TransactionResponse,
|
|
17
|
+
UserTransactionResponse,
|
|
18
|
+
PostRequestOptions,
|
|
19
|
+
Block,
|
|
20
|
+
AptosSettings,
|
|
21
|
+
MoveFunctionId,
|
|
22
|
+
} from "@aptos-labs/ts-sdk";
|
|
23
|
+
import { getEnv } from "@ledgerhq/live-env";
|
|
24
|
+
import network from "@ledgerhq/live-network";
|
|
25
|
+
import BigNumber from "bignumber.js";
|
|
26
|
+
import isUndefined from "lodash/isUndefined";
|
|
27
|
+
import { APTOS_ASSET_ID, DEFAULT_GAS, DEFAULT_GAS_PRICE, ESTIMATE_GAS_MUL } from "../constants";
|
|
28
|
+
import { isTestnet } from "../bridge/logic";
|
|
29
|
+
import type { AptosTransaction, TransactionOptions } from "../types";
|
|
30
|
+
import { GetAccountTransactionsData, GetAccountTransactionsDataGt } from "./graphql/queries";
|
|
31
|
+
import {
|
|
32
|
+
GetAccountTransactionsDataQuery,
|
|
33
|
+
GetAccountTransactionsDataGtQueryVariables,
|
|
34
|
+
} from "./graphql/types";
|
|
35
|
+
import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
36
|
+
import { BlockInfo, FeeEstimation, TransactionIntent } from "@ledgerhq/coin-framework/api/types";
|
|
37
|
+
import { AptosAsset, AptosExtra, AptosFeeParameters, AptosSender } from "../types/assets";
|
|
38
|
+
import { log } from "@ledgerhq/logs";
|
|
39
|
+
|
|
40
|
+
const getApiEndpoint = (currencyId: string) =>
|
|
41
|
+
isTestnet(currencyId) ? getEnv("APTOS_TESTNET_API_ENDPOINT") : getEnv("APTOS_API_ENDPOINT");
|
|
42
|
+
const getIndexerEndpoint = (currencyId: string) =>
|
|
43
|
+
isTestnet(currencyId)
|
|
44
|
+
? getEnv("APTOS_TESTNET_INDEXER_ENDPOINT")
|
|
45
|
+
: getEnv("APTOS_INDEXER_ENDPOINT");
|
|
46
|
+
|
|
47
|
+
export class AptosAPI {
|
|
48
|
+
private readonly aptosConfig: AptosConfig;
|
|
49
|
+
private readonly aptosClient: Aptos;
|
|
50
|
+
private readonly apolloClient: ApolloClient<object>;
|
|
51
|
+
|
|
52
|
+
constructor(currencyIdOrSettings: AptosSettings | string) {
|
|
53
|
+
if (typeof currencyIdOrSettings === "string") {
|
|
54
|
+
this.aptosConfig = new AptosConfig({
|
|
55
|
+
fullnode: getApiEndpoint(currencyIdOrSettings),
|
|
56
|
+
indexer: getIndexerEndpoint(currencyIdOrSettings),
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
this.aptosConfig = new AptosConfig(currencyIdOrSettings);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
this.aptosClient = new Aptos(this.aptosConfig);
|
|
63
|
+
this.apolloClient = new ApolloClient({
|
|
64
|
+
uri: this.aptosConfig.indexer ?? "",
|
|
65
|
+
cache: new InMemoryCache(),
|
|
66
|
+
headers: {
|
|
67
|
+
"x-client": "ledger-live",
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async getAccount(address: string): Promise<AccountData> {
|
|
73
|
+
return this.aptosClient.getAccountInfo({ accountAddress: address });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async getAccountInfo(address: string, startAt?: string) {
|
|
77
|
+
const [balance, transactions, blockHeight] = await Promise.all([
|
|
78
|
+
this.getCoinBalance(address, APTOS_ASSET_ID),
|
|
79
|
+
this.fetchTransactions(address, startAt),
|
|
80
|
+
this.getHeight(),
|
|
81
|
+
]);
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
balance,
|
|
85
|
+
transactions,
|
|
86
|
+
blockHeight,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async estimateGasPrice(): Promise<GasEstimation> {
|
|
91
|
+
return this.aptosClient.getGasPriceEstimation();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async generateTransaction(
|
|
95
|
+
address: string,
|
|
96
|
+
payload: InputEntryFunctionData,
|
|
97
|
+
options: TransactionOptions,
|
|
98
|
+
): Promise<RawTransaction> {
|
|
99
|
+
const opts: Partial<InputGenerateTransactionOptions> = {};
|
|
100
|
+
if (!isUndefined(options.maxGasAmount)) {
|
|
101
|
+
opts.maxGasAmount = Number(options.maxGasAmount);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (!isUndefined(options.gasUnitPrice)) {
|
|
105
|
+
opts.gasUnitPrice = Number(options.gasUnitPrice);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
try {
|
|
109
|
+
const { ledger_timestamp } = await this.aptosClient.getLedgerInfo();
|
|
110
|
+
opts.expireTimestamp = Number(Math.ceil(+ledger_timestamp / 1_000_000 + 2 * 60)); // in milliseconds
|
|
111
|
+
} catch {
|
|
112
|
+
// skip
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return this.aptosClient.transaction.build
|
|
116
|
+
.simple({
|
|
117
|
+
sender: address,
|
|
118
|
+
data: payload,
|
|
119
|
+
options: opts,
|
|
120
|
+
})
|
|
121
|
+
.then(t => t.rawTransaction)
|
|
122
|
+
.catch(error => {
|
|
123
|
+
throw error;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async simulateTransaction(
|
|
128
|
+
address: Ed25519PublicKey,
|
|
129
|
+
tx: RawTransaction,
|
|
130
|
+
options = {
|
|
131
|
+
estimateGasUnitPrice: true,
|
|
132
|
+
estimateMaxGasAmount: true,
|
|
133
|
+
estimatePrioritizedGasUnitPrice: false,
|
|
134
|
+
},
|
|
135
|
+
): Promise<UserTransactionResponse[]> {
|
|
136
|
+
return this.aptosClient.transaction.simulate.simple({
|
|
137
|
+
signerPublicKey: address,
|
|
138
|
+
transaction: { rawTransaction: tx } as SimpleTransaction,
|
|
139
|
+
options,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async broadcast(signature: string): Promise<string> {
|
|
144
|
+
const txBytes = Uint8Array.from(Buffer.from(signature, "hex"));
|
|
145
|
+
const pendingTx = await post<PostRequestOptions, TransactionResponse>({
|
|
146
|
+
contentType: MimeType.BCS_SIGNED_TRANSACTION,
|
|
147
|
+
aptosConfig: this.aptosClient.config,
|
|
148
|
+
body: txBytes,
|
|
149
|
+
path: "transactions",
|
|
150
|
+
type: AptosApiType.FULLNODE,
|
|
151
|
+
originMethod: "",
|
|
152
|
+
});
|
|
153
|
+
return pendingTx.data.hash;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
async getBalance(address: string, token: TokenCurrency): Promise<BigNumber> {
|
|
157
|
+
if (token.tokenType === "coin") {
|
|
158
|
+
return await this.getCoinBalance(address, token.contractAddress);
|
|
159
|
+
} else {
|
|
160
|
+
return await this.getFABalance(address, token.contractAddress);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async getLastBlock(): Promise<BlockInfo> {
|
|
165
|
+
const { block_height } = await this.aptosClient.getLedgerInfo();
|
|
166
|
+
const block = await this.aptosClient.getBlockByHeight({ blockHeight: Number(block_height) });
|
|
167
|
+
return {
|
|
168
|
+
height: Number(block.block_height),
|
|
169
|
+
hash: block.block_hash,
|
|
170
|
+
time: new Date(Number(block.block_timestamp)),
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async getCoinBalance(address: string, contract_address: string): Promise<BigNumber> {
|
|
175
|
+
try {
|
|
176
|
+
const [balanceStr] = await this.aptosClient.view<[string]>({
|
|
177
|
+
payload: {
|
|
178
|
+
function: "0x1::coin::balance",
|
|
179
|
+
typeArguments: [contract_address],
|
|
180
|
+
functionArguments: [address],
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
const balance = parseInt(balanceStr, 10);
|
|
184
|
+
return new BigNumber(balance);
|
|
185
|
+
} catch (error) {
|
|
186
|
+
log("error", "getCoinBalance", {
|
|
187
|
+
error,
|
|
188
|
+
});
|
|
189
|
+
return new BigNumber(0);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
async getFABalance(address: string, contract_address: string): Promise<BigNumber> {
|
|
194
|
+
try {
|
|
195
|
+
const [balanceStr] = await this.aptosClient.view<[string]>({
|
|
196
|
+
payload: {
|
|
197
|
+
function: "0x1::primary_fungible_store::balance",
|
|
198
|
+
typeArguments: ["0x1::object::ObjectCore"],
|
|
199
|
+
functionArguments: [address, contract_address],
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
const balance = parseInt(balanceStr, 10);
|
|
203
|
+
return new BigNumber(balance);
|
|
204
|
+
} catch (error) {
|
|
205
|
+
log("error", "getFABalance", {
|
|
206
|
+
error,
|
|
207
|
+
});
|
|
208
|
+
return new BigNumber(0);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
async estimateFees(
|
|
213
|
+
transactionIntent: TransactionIntent<AptosAsset, AptosExtra, AptosSender>,
|
|
214
|
+
): Promise<FeeEstimation<AptosFeeParameters>> {
|
|
215
|
+
const publicKeyEd = new Ed25519PublicKey(transactionIntent.sender.xpub);
|
|
216
|
+
const fn: MoveFunctionId = "0x1::aptos_account::transfer_coins";
|
|
217
|
+
|
|
218
|
+
const txPayload: InputEntryFunctionData = {
|
|
219
|
+
function: fn,
|
|
220
|
+
typeArguments: [APTOS_ASSET_ID],
|
|
221
|
+
functionArguments: [transactionIntent.recipient, transactionIntent.amount],
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
const txOptions: TransactionOptions = {
|
|
225
|
+
maxGasAmount: DEFAULT_GAS.toString(),
|
|
226
|
+
gasUnitPrice: DEFAULT_GAS_PRICE.toString(),
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const tx = await this.generateTransaction(
|
|
230
|
+
transactionIntent.sender.freshAddress,
|
|
231
|
+
txPayload,
|
|
232
|
+
txOptions,
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
const simulation = await this.simulateTransaction(publicKeyEd, tx);
|
|
236
|
+
const completedTx = simulation[0];
|
|
237
|
+
|
|
238
|
+
const gasLimit = new BigNumber(completedTx.gas_used).multipliedBy(ESTIMATE_GAS_MUL);
|
|
239
|
+
const gasPrice = new BigNumber(completedTx.gas_unit_price);
|
|
240
|
+
|
|
241
|
+
const expectedGas = gasPrice.multipliedBy(gasLimit);
|
|
242
|
+
|
|
243
|
+
return {
|
|
244
|
+
value: BigInt(expectedGas.toString()),
|
|
245
|
+
parameters: {
|
|
246
|
+
gasLimit: BigInt(gasLimit.toString()),
|
|
247
|
+
gasPrice: BigInt(gasPrice.toString()),
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
private async fetchTransactions(address: string, gt?: string) {
|
|
253
|
+
if (!address) {
|
|
254
|
+
return [];
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
let query = GetAccountTransactionsData;
|
|
258
|
+
if (gt) {
|
|
259
|
+
query = GetAccountTransactionsDataGt;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const queryResponse = await this.apolloClient.query<
|
|
263
|
+
GetAccountTransactionsDataQuery,
|
|
264
|
+
GetAccountTransactionsDataGtQueryVariables
|
|
265
|
+
>({
|
|
266
|
+
query,
|
|
267
|
+
variables: {
|
|
268
|
+
address,
|
|
269
|
+
limit: 1000,
|
|
270
|
+
gt,
|
|
271
|
+
},
|
|
272
|
+
fetchPolicy: "network-only",
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
return Promise.all(
|
|
276
|
+
queryResponse.data.account_transactions.map(({ transaction_version }) => {
|
|
277
|
+
return this.richItemByVersion(transaction_version);
|
|
278
|
+
}),
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
private async richItemByVersion(version: number): Promise<AptosTransaction | null> {
|
|
283
|
+
try {
|
|
284
|
+
const tx: TransactionResponse = await this.aptosClient.getTransactionByVersion({
|
|
285
|
+
ledgerVersion: version,
|
|
286
|
+
});
|
|
287
|
+
const block = await this.getBlock(version);
|
|
288
|
+
return {
|
|
289
|
+
...tx,
|
|
290
|
+
block,
|
|
291
|
+
} as AptosTransaction;
|
|
292
|
+
} catch (error) {
|
|
293
|
+
log("error", "richItemByVersion", {
|
|
294
|
+
error,
|
|
295
|
+
});
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
private async getHeight(): Promise<number> {
|
|
301
|
+
const { data } = await network<Block>({
|
|
302
|
+
method: "GET",
|
|
303
|
+
url: this.aptosConfig.fullnode ?? "",
|
|
304
|
+
});
|
|
305
|
+
return parseInt(data.block_height);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
private async getBlock(version: number) {
|
|
309
|
+
const block = await this.aptosClient.getBlockByVersion({ ledgerVersion: version });
|
|
310
|
+
return {
|
|
311
|
+
height: parseInt(block.block_height),
|
|
312
|
+
hash: block.block_hash,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
}
|
|
@@ -18,8 +18,8 @@ export const GetDelegatedStakingActivities = gql`
|
|
|
18
18
|
`;
|
|
19
19
|
export const GetAccountTransactionsData = gql`
|
|
20
20
|
query GetAccountTransactionsData($address: String, $limit: Int) {
|
|
21
|
-
|
|
22
|
-
where: {
|
|
21
|
+
account_transactions(
|
|
22
|
+
where: { account_address: { _eq: $address } }
|
|
23
23
|
order_by: { transaction_version: desc }
|
|
24
24
|
limit: $limit
|
|
25
25
|
) {
|
|
@@ -30,8 +30,8 @@ export const GetAccountTransactionsData = gql`
|
|
|
30
30
|
`;
|
|
31
31
|
export const GetAccountTransactionsDataGt = gql`
|
|
32
32
|
query GetAccountTransactionsDataGt($address: String, $limit: Int, $gt: bigint) {
|
|
33
|
-
|
|
34
|
-
where: {
|
|
33
|
+
account_transactions(
|
|
34
|
+
where: { account_address: { _eq: $address }, transaction_version: { _gt: $gt } }
|
|
35
35
|
order_by: { transaction_version: desc }
|
|
36
36
|
limit: $limit
|
|
37
37
|
) {
|
|
@@ -42,8 +42,8 @@ export const GetAccountTransactionsDataGt = gql`
|
|
|
42
42
|
`;
|
|
43
43
|
export const GetAccountTransactionsDataLt = gql`
|
|
44
44
|
query GetAccountTransactionsDataLt($address: String, $limit: Int, $lt: bigint) {
|
|
45
|
-
|
|
46
|
-
where: {
|
|
45
|
+
account_transactions(
|
|
46
|
+
where: { account_address: { _eq: $address }, transaction_version: { _lt: $lt } }
|
|
47
47
|
order_by: { transaction_version: desc }
|
|
48
48
|
limit: $limit
|
|
49
49
|
) {
|
|
@@ -22,9 +22,9 @@ export type GetAccountTransactionsDataQueryVariables = Exact<{
|
|
|
22
22
|
|
|
23
23
|
export type GetAccountTransactionsDataQuery = {
|
|
24
24
|
__typename?: "query_root";
|
|
25
|
-
|
|
26
|
-
__typename
|
|
27
|
-
transaction_version
|
|
25
|
+
account_transactions: Array<{
|
|
26
|
+
__typename?: "account_transactions";
|
|
27
|
+
transaction_version: number;
|
|
28
28
|
}>;
|
|
29
29
|
};
|
|
30
30
|
|
|
@@ -36,9 +36,9 @@ export type GetAccountTransactionsDataGtQueryVariables = Exact<{
|
|
|
36
36
|
|
|
37
37
|
export type GetAccountTransactionsDataGtQuery = {
|
|
38
38
|
__typename?: "query_root";
|
|
39
|
-
|
|
40
|
-
__typename
|
|
41
|
-
transaction_version
|
|
39
|
+
account_transactions: Array<{
|
|
40
|
+
__typename?: "account_transactions";
|
|
41
|
+
transaction_version: number;
|
|
42
42
|
}>;
|
|
43
43
|
};
|
|
44
44
|
|
|
@@ -50,9 +50,9 @@ export type GetAccountTransactionsDataLtQueryVariables = Exact<{
|
|
|
50
50
|
|
|
51
51
|
export type GetAccountTransactionsDataLtQuery = {
|
|
52
52
|
__typename?: "query_root";
|
|
53
|
-
|
|
54
|
-
__typename
|
|
55
|
-
transaction_version
|
|
53
|
+
account_transactions: Array<{
|
|
54
|
+
__typename?: "account_transactions";
|
|
55
|
+
transaction_version: number;
|
|
56
56
|
}>;
|
|
57
57
|
};
|
|
58
58
|
|
package/src/network/index.ts
CHANGED
|
@@ -9,10 +9,11 @@ import {
|
|
|
9
9
|
RawTransaction,
|
|
10
10
|
SimpleTransaction,
|
|
11
11
|
} from "@aptos-labs/ts-sdk";
|
|
12
|
-
import { SignerContext } from "@ledgerhq/coin-framework/
|
|
12
|
+
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
13
13
|
import { Account } from "@ledgerhq/types-live";
|
|
14
14
|
import { AptosSigner } from "../types";
|
|
15
15
|
import { sha3_256 as sha3Hash } from "@noble/hashes/sha3";
|
|
16
|
+
export * from "./client";
|
|
16
17
|
|
|
17
18
|
export async function signTransaction(
|
|
18
19
|
signerContext: SignerContext<AptosSigner>,
|
package/src/test/bot-specs.ts
CHANGED
|
@@ -5,8 +5,9 @@ import BigNumber from "bignumber.js";
|
|
|
5
5
|
import type { Transaction } from "../types";
|
|
6
6
|
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
|
|
7
7
|
import { genericTestDestination, pickSiblings, botTest } from "@ledgerhq/coin-framework/bot/specs";
|
|
8
|
-
import type { AppSpec } from "@ledgerhq/coin-framework/bot/types";
|
|
9
|
-
import { acceptTransaction } from "./speculos-deviceActions";
|
|
8
|
+
import type { AppSpec, TransactionTestInput } from "@ledgerhq/coin-framework/bot/types";
|
|
9
|
+
import { acceptTokenTransaction, acceptTransaction } from "./speculos-deviceActions";
|
|
10
|
+
import { Account, TokenAccount } from "@ledgerhq/types-live";
|
|
10
11
|
|
|
11
12
|
const MIN_SAFE = new BigNumber(0.0001);
|
|
12
13
|
const maxAccount = 6;
|
|
@@ -19,7 +20,7 @@ const aptosSpecs: AppSpec<Transaction> = {
|
|
|
19
20
|
appName: "Aptos",
|
|
20
21
|
},
|
|
21
22
|
genericDeviceAction: acceptTransaction,
|
|
22
|
-
testTimeout:
|
|
23
|
+
testTimeout: 2 * 60 * 1000,
|
|
23
24
|
minViableAmount: MIN_SAFE,
|
|
24
25
|
transactionCheck: ({ maxSpendable }) => {
|
|
25
26
|
invariant(maxSpendable.gt(MIN_SAFE), "balance is too low");
|
|
@@ -84,9 +85,68 @@ const aptosSpecs: AppSpec<Transaction> = {
|
|
|
84
85
|
);
|
|
85
86
|
},
|
|
86
87
|
},
|
|
88
|
+
{
|
|
89
|
+
name: "Send ~50% of token amount",
|
|
90
|
+
feature: "tokens",
|
|
91
|
+
maxRun: 1,
|
|
92
|
+
deviceAction: acceptTokenTransaction,
|
|
93
|
+
transaction: ({ account, bridge, siblings, maxSpendable }) => {
|
|
94
|
+
invariant(maxSpendable.gt(MIN_SAFE), "Balance is too low");
|
|
95
|
+
|
|
96
|
+
const senderTokenAcc = findTokenSubAccountWithBalance(account);
|
|
97
|
+
invariant(senderTokenAcc, "Sender token account with available balance not found");
|
|
98
|
+
|
|
99
|
+
const sibling = pickSiblings(siblings, maxAccount);
|
|
100
|
+
|
|
101
|
+
const recipientTokenAcc = findTokenSubAccountWithBalance(sibling);
|
|
102
|
+
invariant(recipientTokenAcc, "Receiver token account with available balance not found");
|
|
103
|
+
|
|
104
|
+
const amount = senderTokenAcc.spendableBalance.div(2).integerValue();
|
|
105
|
+
const recipient = sibling.freshAddress;
|
|
106
|
+
const transaction = bridge.createTransaction(account);
|
|
107
|
+
const subAccountId = senderTokenAcc.id;
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
transaction,
|
|
111
|
+
updates: [{ subAccountId }, { recipient }, { amount }],
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
test: input => {
|
|
115
|
+
expectTokenAccountCorrectBalanceChange(input);
|
|
116
|
+
},
|
|
117
|
+
},
|
|
87
118
|
],
|
|
88
119
|
};
|
|
89
120
|
|
|
121
|
+
function findTokenSubAccountWithBalance(account: Account) {
|
|
122
|
+
return account.subAccounts?.find(acc => acc.type === "TokenAccount" && acc.balance.gt(0)) as
|
|
123
|
+
| TokenAccount
|
|
124
|
+
| undefined;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function expectTokenAccountCorrectBalanceChange({
|
|
128
|
+
account,
|
|
129
|
+
accountBeforeTransaction,
|
|
130
|
+
status,
|
|
131
|
+
transaction,
|
|
132
|
+
}: TransactionTestInput<Transaction>) {
|
|
133
|
+
const tokenAccId = transaction.subAccountId;
|
|
134
|
+
if (!tokenAccId) throw new Error("Wrong subAccountId");
|
|
135
|
+
|
|
136
|
+
const tokenAccAfterTx = account.subAccounts?.find(acc => acc.id === tokenAccId);
|
|
137
|
+
const tokenAccBeforeTx = accountBeforeTransaction.subAccounts?.find(acc => acc.id === tokenAccId);
|
|
138
|
+
|
|
139
|
+
if (!tokenAccAfterTx || !tokenAccBeforeTx) {
|
|
140
|
+
throw new Error("Token sub accounts not found!");
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
botTest("Token balance decreased with operation", () =>
|
|
144
|
+
expect(tokenAccAfterTx.balance.toString()).toBe(
|
|
145
|
+
tokenAccBeforeTx.balance.minus(status.amount).toString(),
|
|
146
|
+
),
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
90
150
|
export default {
|
|
91
151
|
aptosSpecs,
|
|
92
152
|
};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { CurrenciesData, DatasetTest } from "@ledgerhq/types-live";
|
|
2
|
-
import BigNumber from "bignumber.js";
|
|
3
|
-
import { fromTransactionRaw } from "../bridge/transaction";
|
|
4
2
|
import { Transaction } from "../types";
|
|
5
3
|
|
|
6
4
|
const aptos: CurrenciesData<Transaction> = {
|
|
@@ -21,86 +19,75 @@ const aptos: CurrenciesData<Transaction> = {
|
|
|
21
19
|
],
|
|
22
20
|
accounts: [
|
|
23
21
|
{
|
|
22
|
+
FIXME_tests: ["balance is sum of ops"],
|
|
24
23
|
raw: {
|
|
25
|
-
id: "js:2:aptos:d1a8c6a1cdd52dd40c7ea61ee4571fb51fcae440a594c1eca18636928f1d3956:",
|
|
24
|
+
id: "js:2:aptos:d1a8c6a1cdd52dd40c7ea61ee4571fb51fcae440a594c1eca18636928f1d3956:aptos",
|
|
26
25
|
seedIdentifier: "d6816f4f22f867b56cf9304b776f452a16d107835d73ee8a33c4ced210300583",
|
|
27
26
|
used: true,
|
|
28
|
-
derivationMode: "",
|
|
27
|
+
derivationMode: "aptos",
|
|
29
28
|
index: 0,
|
|
30
29
|
freshAddress: "0x445fa0013887abd1a0c14acdec6e48090e0ad3fed3e08202aac15ca14f3be26b",
|
|
31
30
|
freshAddressPath: "44'/637'/0'/0'/0'",
|
|
32
|
-
blockHeight:
|
|
31
|
+
blockHeight: 302459501,
|
|
33
32
|
creationDate: "2024-12-18T12:26:31.070Z",
|
|
34
|
-
operationsCount:
|
|
33
|
+
operationsCount: 6,
|
|
35
34
|
operations: [],
|
|
36
35
|
pendingOperations: [],
|
|
37
36
|
currencyId: "aptos",
|
|
38
|
-
lastSyncDate: "2025-
|
|
39
|
-
balance: "
|
|
40
|
-
spendableBalance: "
|
|
37
|
+
lastSyncDate: "2025-03-12T10:42:53.570Z",
|
|
38
|
+
balance: "19949100",
|
|
39
|
+
spendableBalance: "19949100",
|
|
41
40
|
balanceHistoryCache: {
|
|
42
41
|
HOUR: {
|
|
43
42
|
balances: [
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
|
|
54
|
-
30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
|
|
55
|
-
30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
|
|
56
|
-
30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
|
|
57
|
-
30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
|
|
58
|
-
30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
|
|
59
|
-
30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
|
|
60
|
-
30100,
|
|
43
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
44
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
45
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
46
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
47
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
48
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
49
|
+
0, 19949100, 19949100, 19949100, 19949100, 19949100, 19949100, 19949100, 19949100,
|
|
50
|
+
19949100, 19949100, 19949100, 19949100, 19949100, 19949100, 19949100, 19949100,
|
|
51
|
+
19949100, 19949100,
|
|
61
52
|
],
|
|
62
|
-
latestDate:
|
|
53
|
+
latestDate: 1741773600000,
|
|
63
54
|
},
|
|
64
55
|
DAY: {
|
|
65
56
|
balances: [
|
|
66
|
-
0,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
57
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
58
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
59
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
60
|
+
19949100,
|
|
70
61
|
],
|
|
71
|
-
latestDate:
|
|
72
|
-
},
|
|
73
|
-
WEEK: {
|
|
74
|
-
balances: [0, 30100, 30100, 30100, 30100, 30100, 30100, 30100],
|
|
75
|
-
latestDate: 1738454400000,
|
|
62
|
+
latestDate: 1741737600000,
|
|
76
63
|
},
|
|
64
|
+
WEEK: { balances: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], latestDate: 1741478400000 },
|
|
77
65
|
},
|
|
78
66
|
xpub: "d1a8c6a1cdd52dd40c7ea61ee4571fb51fcae440a594c1eca18636928f1d3956",
|
|
67
|
+
subAccounts: [
|
|
68
|
+
{
|
|
69
|
+
type: "TokenAccountRaw",
|
|
70
|
+
id: "js:2:aptos:d1a8c6a1cdd52dd40c7ea61ee4571fb51fcae440a594c1eca18636928f1d3956:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd11107bdf0d6d7040c6c0bfbdecb6545191fdf13e8d8d259952f53e1713f61b5%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
|
|
71
|
+
parentId:
|
|
72
|
+
"js:2:aptos:d1a8c6a1cdd52dd40c7ea61ee4571fb51fcae440a594c1eca18636928f1d3956:aptos",
|
|
73
|
+
tokenId:
|
|
74
|
+
"aptos/coin/dstapt_0xd11107bdf0d6d7040c6c0bfbdecb6545191fdf13e8d8d259952f53e1713f61b5::staked_coin::stakedaptos",
|
|
75
|
+
balance: "30000000",
|
|
76
|
+
spendableBalance: "30000000",
|
|
77
|
+
balanceHistoryCache: {
|
|
78
|
+
HOUR: { latestDate: null, balances: [] },
|
|
79
|
+
DAY: { latestDate: null, balances: [] },
|
|
80
|
+
WEEK: { latestDate: null, balances: [] },
|
|
81
|
+
},
|
|
82
|
+
creationDate: "2025-03-12T10:42:53.570Z",
|
|
83
|
+
operationsCount: 2,
|
|
84
|
+
operations: [],
|
|
85
|
+
pendingOperations: [],
|
|
86
|
+
swapHistory: [],
|
|
87
|
+
},
|
|
88
|
+
],
|
|
79
89
|
swapHistory: [],
|
|
80
90
|
},
|
|
81
|
-
transactions: [
|
|
82
|
-
{
|
|
83
|
-
name: "NO_NAME",
|
|
84
|
-
transaction: fromTransactionRaw({
|
|
85
|
-
amount: "1000",
|
|
86
|
-
recipient: "0xd20fa44192f94ba086ab16bfdf57e43ff118ada69b4c66fa9b9a9223cbc068c1",
|
|
87
|
-
useAllAmount: false,
|
|
88
|
-
subAccountId: null,
|
|
89
|
-
family: "aptos",
|
|
90
|
-
mode: "send",
|
|
91
|
-
fees: "900",
|
|
92
|
-
options: '{"maxGasAmount":"9","gasUnitPrice":"100"}',
|
|
93
|
-
errors: "{}",
|
|
94
|
-
}),
|
|
95
|
-
expectedStatus: () =>
|
|
96
|
-
// you can use account and transaction for smart logic. drop the =>fn otherwise
|
|
97
|
-
({
|
|
98
|
-
errors: {},
|
|
99
|
-
warnings: {},
|
|
100
|
-
amount: BigNumber("1000"),
|
|
101
|
-
}),
|
|
102
|
-
},
|
|
103
|
-
],
|
|
104
91
|
},
|
|
105
92
|
],
|
|
106
93
|
};
|