@ledgerhq/coin-aptos 2.7.0 → 2.8.0-nightly.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +21 -0
- package/lib/__tests__/api/craftTransaction.unit.test.js +4 -4
- package/lib/__tests__/api/craftTransaction.unit.test.js.map +1 -1
- package/lib/__tests__/api/getBalance.unit.test.js +3 -4
- package/lib/__tests__/api/getBalance.unit.test.js.map +1 -1
- package/lib/__tests__/api/index.integ.test.js +23 -32
- package/lib/__tests__/api/index.integ.test.js.map +1 -1
- package/lib/__tests__/api/index.test.js.map +1 -1
- package/lib/__tests__/logic/getBalances.test.js +3 -4
- package/lib/__tests__/logic/getBalances.test.js.map +1 -1
- package/lib/__tests__/network/client.test.js +4 -6
- package/lib/__tests__/network/client.test.js.map +1 -1
- package/lib/__tests__/network/validators.test.js +12 -8
- package/lib/__tests__/network/validators.test.js.map +1 -1
- package/lib/api/index.d.ts +1 -2
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js.map +1 -1
- package/lib/logic/buildTransaction.d.ts.map +1 -1
- package/lib/logic/buildTransaction.js +1 -0
- package/lib/logic/buildTransaction.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts +1 -2
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.js +6 -4
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/logic/getBalances.d.ts +1 -2
- package/lib/logic/getBalances.d.ts.map +1 -1
- package/lib/logic/getBalances.js +2 -2
- package/lib/logic/getBalances.js.map +1 -1
- package/lib/logic/processRecipients.d.ts +1 -2
- package/lib/logic/processRecipients.d.ts.map +1 -1
- package/lib/logic/processRecipients.js.map +1 -1
- package/lib/logic/transactionsToOperations.d.ts +1 -2
- package/lib/logic/transactionsToOperations.d.ts.map +1 -1
- package/lib/logic/transactionsToOperations.js +3 -4
- package/lib/logic/transactionsToOperations.js.map +1 -1
- package/lib/network/client.d.ts +2 -3
- package/lib/network/client.d.ts.map +1 -1
- package/lib/network/client.js +11 -7
- package/lib/network/client.js.map +1 -1
- package/lib/network/graphql/queries.d.ts +0 -3
- package/lib/network/graphql/queries.d.ts.map +1 -1
- package/lib/network/graphql/queries.js +2 -50
- package/lib/network/graphql/queries.js.map +1 -1
- package/lib/network/graphql/types.d.ts +0 -47
- package/lib/network/graphql/types.d.ts.map +1 -1
- package/lib/network/validators.d.ts.map +1 -1
- package/lib/network/validators.js +10 -5
- package/lib/network/validators.js.map +1 -1
- package/lib/types/assets.d.ts +0 -6
- package/lib/types/assets.d.ts.map +1 -1
- package/lib-es/__tests__/api/craftTransaction.unit.test.js +4 -4
- package/lib-es/__tests__/api/craftTransaction.unit.test.js.map +1 -1
- package/lib-es/__tests__/api/getBalance.unit.test.js +3 -4
- package/lib-es/__tests__/api/getBalance.unit.test.js.map +1 -1
- package/lib-es/__tests__/api/index.integ.test.js +23 -32
- package/lib-es/__tests__/api/index.integ.test.js.map +1 -1
- package/lib-es/__tests__/api/index.test.js.map +1 -1
- package/lib-es/__tests__/logic/getBalances.test.js +3 -4
- package/lib-es/__tests__/logic/getBalances.test.js.map +1 -1
- package/lib-es/__tests__/network/client.test.js +4 -6
- package/lib-es/__tests__/network/client.test.js.map +1 -1
- package/lib-es/__tests__/network/validators.test.js +12 -8
- package/lib-es/__tests__/network/validators.test.js.map +1 -1
- package/lib-es/api/index.d.ts +1 -2
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/logic/buildTransaction.d.ts.map +1 -1
- package/lib-es/logic/buildTransaction.js +1 -0
- package/lib-es/logic/buildTransaction.js.map +1 -1
- package/lib-es/logic/craftTransaction.d.ts +1 -2
- package/lib-es/logic/craftTransaction.d.ts.map +1 -1
- package/lib-es/logic/craftTransaction.js +6 -4
- package/lib-es/logic/craftTransaction.js.map +1 -1
- package/lib-es/logic/getBalances.d.ts +1 -2
- package/lib-es/logic/getBalances.d.ts.map +1 -1
- package/lib-es/logic/getBalances.js +2 -2
- package/lib-es/logic/getBalances.js.map +1 -1
- package/lib-es/logic/processRecipients.d.ts +1 -2
- package/lib-es/logic/processRecipients.d.ts.map +1 -1
- package/lib-es/logic/processRecipients.js.map +1 -1
- package/lib-es/logic/transactionsToOperations.d.ts +1 -2
- package/lib-es/logic/transactionsToOperations.d.ts.map +1 -1
- package/lib-es/logic/transactionsToOperations.js +3 -4
- package/lib-es/logic/transactionsToOperations.js.map +1 -1
- package/lib-es/network/client.d.ts +2 -3
- package/lib-es/network/client.d.ts.map +1 -1
- package/lib-es/network/client.js +11 -7
- package/lib-es/network/client.js.map +1 -1
- package/lib-es/network/graphql/queries.d.ts +0 -3
- package/lib-es/network/graphql/queries.d.ts.map +1 -1
- package/lib-es/network/graphql/queries.js +1 -49
- package/lib-es/network/graphql/queries.js.map +1 -1
- package/lib-es/network/graphql/types.d.ts +0 -47
- package/lib-es/network/graphql/types.d.ts.map +1 -1
- package/lib-es/network/validators.d.ts.map +1 -1
- package/lib-es/network/validators.js +10 -5
- package/lib-es/network/validators.js.map +1 -1
- package/lib-es/types/assets.d.ts +0 -6
- package/lib-es/types/assets.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/__tests__/api/craftTransaction.unit.test.ts +9 -10
- package/src/__tests__/api/getBalance.unit.test.ts +3 -4
- package/src/__tests__/api/index.integ.test.ts +23 -32
- package/src/__tests__/api/index.test.ts +2 -3
- package/src/__tests__/logic/getBalances.test.ts +3 -4
- package/src/__tests__/network/client.test.ts +7 -10
- package/src/__tests__/network/validators.test.ts +12 -8
- package/src/api/index.ts +4 -6
- package/src/logic/buildTransaction.ts +1 -0
- package/src/logic/craftTransaction.ts +10 -7
- package/src/logic/getBalances.ts +3 -4
- package/src/logic/processRecipients.ts +4 -8
- package/src/logic/transactionsToOperations.ts +6 -8
- package/src/network/client.ts +15 -15
- package/src/network/graphql/queries.ts +1 -52
- package/src/network/graphql/types.ts +0 -56
- package/src/network/validators.ts +16 -6
- package/src/types/assets.ts +0 -9
|
@@ -1,26 +1,8 @@
|
|
|
1
1
|
import { gql } from "@apollo/client";
|
|
2
2
|
|
|
3
|
-
export const GetDelegatedStakingActivities = gql`
|
|
4
|
-
query getDelegatedStakingActivities($delegatorAddress: String) {
|
|
5
|
-
delegated_staking_activities(
|
|
6
|
-
where: { delegator_address: { _eq: $delegatorAddress } }
|
|
7
|
-
order_by: { transaction_version: asc }
|
|
8
|
-
) {
|
|
9
|
-
amount
|
|
10
|
-
delegator_address
|
|
11
|
-
pool_address
|
|
12
|
-
transaction_version
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
3
|
export const GetAccountTransactionsData = gql`
|
|
18
4
|
query GetAccountTransactionsData($address: String, $limit: Int) {
|
|
19
|
-
account_transactions(
|
|
20
|
-
where: { account_address: { _eq: $address } }
|
|
21
|
-
order_by: { transaction_version: desc }
|
|
22
|
-
limit: $limit
|
|
23
|
-
) {
|
|
5
|
+
account_transactions(where: { account_address: { _eq: $address } }, limit: $limit) {
|
|
24
6
|
transaction_version
|
|
25
7
|
__typename
|
|
26
8
|
}
|
|
@@ -31,20 +13,6 @@ export const GetAccountTransactionsDataGt = gql`
|
|
|
31
13
|
query GetAccountTransactionsDataGt($address: String, $limit: Int, $gt: bigint) {
|
|
32
14
|
account_transactions(
|
|
33
15
|
where: { account_address: { _eq: $address }, transaction_version: { _gt: $gt } }
|
|
34
|
-
order_by: { transaction_version: desc }
|
|
35
|
-
limit: $limit
|
|
36
|
-
) {
|
|
37
|
-
transaction_version
|
|
38
|
-
__typename
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
`;
|
|
42
|
-
|
|
43
|
-
export const GetAccountTransactionsDataLt = gql`
|
|
44
|
-
query GetAccountTransactionsDataLt($address: String, $limit: Int, $lt: bigint) {
|
|
45
|
-
account_transactions(
|
|
46
|
-
where: { account_address: { _eq: $address }, transaction_version: { _lt: $lt } }
|
|
47
|
-
order_by: { transaction_version: desc }
|
|
48
16
|
limit: $limit
|
|
49
17
|
) {
|
|
50
18
|
transaction_version
|
|
@@ -53,25 +21,6 @@ export const GetAccountTransactionsDataLt = gql`
|
|
|
53
21
|
}
|
|
54
22
|
`;
|
|
55
23
|
|
|
56
|
-
export const GetNumActiveDelegatorPerPoolData = gql`
|
|
57
|
-
query GetNumActiveDelegatorPerPoolData {
|
|
58
|
-
num_active_delegator_per_pool {
|
|
59
|
-
num_active_delegator
|
|
60
|
-
pool_address
|
|
61
|
-
}
|
|
62
|
-
delegated_staking_pools {
|
|
63
|
-
staking_pool_address
|
|
64
|
-
current_staking_pool {
|
|
65
|
-
operator_address
|
|
66
|
-
operator_aptos_name(where: { is_active: { _eq: true } }) {
|
|
67
|
-
domain
|
|
68
|
-
is_primary
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
`;
|
|
74
|
-
|
|
75
24
|
export const GetCurrentDelegatorBalancesData = gql`
|
|
76
25
|
query GetCurrentDelegatorBalances {
|
|
77
26
|
current_delegator_balances(distinct_on: pool_address) {
|
|
@@ -15,11 +15,6 @@ export type Scalars = {
|
|
|
15
15
|
timestamptz: any;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
export type GetAccountTransactionsDataQueryVariables = Exact<{
|
|
19
|
-
address?: InputMaybe<Scalars["String"]>;
|
|
20
|
-
limit?: InputMaybe<Scalars["Int"]>;
|
|
21
|
-
}>;
|
|
22
|
-
|
|
23
18
|
export type GetAccountTransactionsDataQuery = {
|
|
24
19
|
account_transactions: Array<{
|
|
25
20
|
transaction_version: number;
|
|
@@ -38,36 +33,6 @@ export type GetAccountTransactionsDataGtQuery = {
|
|
|
38
33
|
}>;
|
|
39
34
|
};
|
|
40
35
|
|
|
41
|
-
export type GetAccountTransactionsDataLtQueryVariables = Exact<{
|
|
42
|
-
address?: InputMaybe<Scalars["String"]>;
|
|
43
|
-
limit?: InputMaybe<Scalars["Int"]>;
|
|
44
|
-
lt?: InputMaybe<Scalars["bigint"]>;
|
|
45
|
-
}>;
|
|
46
|
-
|
|
47
|
-
export type GetAccountTransactionsDataLtQuery = {
|
|
48
|
-
account_transactions: Array<{
|
|
49
|
-
transaction_version: number;
|
|
50
|
-
}>;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export type DelegatedStakingActivity = {
|
|
54
|
-
amount: number;
|
|
55
|
-
delegator_address: string;
|
|
56
|
-
pool_address: string;
|
|
57
|
-
transaction_version: bigint;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export type GetDelegatedStakingActivitiesQuery = {
|
|
61
|
-
delegated_staking_activities: Array<DelegatedStakingActivity>;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export type PartitionedDelegatedStakingActivities = Record<string, DelegatedStakingActivity[]>;
|
|
65
|
-
|
|
66
|
-
export type StakePrincipals = {
|
|
67
|
-
activePrincipals: number;
|
|
68
|
-
pendingInactivePrincipals: number;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
36
|
export type StakeDetails = {
|
|
72
37
|
active: number;
|
|
73
38
|
inactive: number;
|
|
@@ -76,23 +41,6 @@ export type StakeDetails = {
|
|
|
76
41
|
poolAddress: string;
|
|
77
42
|
};
|
|
78
43
|
|
|
79
|
-
export type GetNumActiveDelegatorPerPoolQuery = {
|
|
80
|
-
num_active_delegator_per_pool: Array<{
|
|
81
|
-
pool_address: string;
|
|
82
|
-
num_active_delegator: number;
|
|
83
|
-
}>;
|
|
84
|
-
delegated_staking_pools: Array<{
|
|
85
|
-
staking_pool_address: string;
|
|
86
|
-
current_staking_pool: {
|
|
87
|
-
operator_address: string;
|
|
88
|
-
operator_aptos_name: Array<{
|
|
89
|
-
domain: string;
|
|
90
|
-
is_primary: boolean;
|
|
91
|
-
}>;
|
|
92
|
-
};
|
|
93
|
-
}>;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
44
|
export type GetCurrentDelegatorBalancesQuery = {
|
|
97
45
|
current_delegator_balances: Array<{
|
|
98
46
|
current_pool_balance: {
|
|
@@ -112,10 +60,6 @@ export type GetCurrentDelegatorBalancesQuery = {
|
|
|
112
60
|
}>;
|
|
113
61
|
};
|
|
114
62
|
|
|
115
|
-
export interface DelegationPoolAddress {
|
|
116
|
-
staking_pool_address: string;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
63
|
interface CurrentPoolBalance {
|
|
120
64
|
total_coins: string;
|
|
121
65
|
operator_commission_percentage: string;
|
|
@@ -6,15 +6,11 @@ import { AptosValidator } from "../types";
|
|
|
6
6
|
import { isTestnet } from "../logic/isTestnet";
|
|
7
7
|
import { APTOS_EXPLORER_ACCOUNT_URL } from "../constants";
|
|
8
8
|
import { formatUnlockTime } from "../logic/staking";
|
|
9
|
+
import { makeLRUCache, minutes } from "@ledgerhq/live-network/cache";
|
|
9
10
|
|
|
10
11
|
export async function getValidators(currencyId: string): Promise<AptosValidator[]> {
|
|
11
12
|
const api = new AptosAPI(currencyId);
|
|
12
|
-
const
|
|
13
|
-
const queryResponse = await api.apolloClient.query<GetCurrentDelegatorBalancesQuery, object>({
|
|
14
|
-
query: query,
|
|
15
|
-
fetchPolicy: "network-only",
|
|
16
|
-
});
|
|
17
|
-
|
|
13
|
+
const queryResponse = await cachedValidators(api, currencyId);
|
|
18
14
|
const stakingData: CurrentDelegatorBalance[] = queryResponse.data.current_delegator_balances;
|
|
19
15
|
|
|
20
16
|
const list: AptosValidator[] = await Promise.all(
|
|
@@ -46,3 +42,17 @@ export async function getValidators(currencyId: string): Promise<AptosValidator[
|
|
|
46
42
|
|
|
47
43
|
return list.sort((a, b) => b.activeStake.toNumber() - a.activeStake.toNumber());
|
|
48
44
|
}
|
|
45
|
+
|
|
46
|
+
const fetchValidatorsData = async (api: AptosAPI, _currencyId: string) => {
|
|
47
|
+
const query = GetCurrentDelegatorBalancesData;
|
|
48
|
+
return await api.apolloClient.query<GetCurrentDelegatorBalancesQuery, object>({
|
|
49
|
+
query: query,
|
|
50
|
+
fetchPolicy: "network-only",
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const cachedValidators = makeLRUCache(
|
|
55
|
+
fetchValidatorsData,
|
|
56
|
+
(_api: AptosAPI, currencyId: string) => currencyId,
|
|
57
|
+
minutes(30),
|
|
58
|
+
);
|
package/src/types/assets.ts
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
import type { Asset } from "@ledgerhq/coin-framework/api/types";
|
|
2
|
-
|
|
3
|
-
export type AptosAsset = Asset<AptosTokenInformation>;
|
|
4
|
-
|
|
5
|
-
export type AptosTokenInformation = {
|
|
6
|
-
standard: string;
|
|
7
|
-
contractAddress: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
1
|
export type AptosExtra = Record<string, unknown>;
|
|
11
2
|
|
|
12
3
|
export type AptosFeeParameters = {
|