@aptos-labs/ts-sdk 0.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/LICENSE +201 -0
- package/README.md +144 -0
- package/dist/browser/index.global.js +410 -0
- package/dist/browser/index.global.js.map +1 -0
- package/dist/cjs/index.d.ts +4965 -0
- package/dist/cjs/index.js +4762 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/index.d.ts +4965 -0
- package/dist/esm/index.mjs +4645 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/types/index.d.ts +1247 -0
- package/dist/types/index.js +151 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +79 -0
- package/src/api/account.ts +360 -0
- package/src/api/aptos.ts +103 -0
- package/src/api/aptosConfig.ts +77 -0
- package/src/api/coin.ts +39 -0
- package/src/api/digitalAsset.ts +192 -0
- package/src/api/event.ts +78 -0
- package/src/api/faucet.ts +30 -0
- package/src/api/fungibleAsset.ts +82 -0
- package/src/api/general.ts +188 -0
- package/src/api/index.ts +5 -0
- package/src/api/staking.ts +58 -0
- package/src/api/transaction.ts +135 -0
- package/src/api/transactionSubmission.ts +168 -0
- package/src/bcs/consts.ts +12 -0
- package/src/bcs/deserializer.ts +248 -0
- package/src/bcs/index.ts +9 -0
- package/src/bcs/serializable/entryFunctionBytes.ts +61 -0
- package/src/bcs/serializable/fixedBytes.ts +65 -0
- package/src/bcs/serializable/movePrimitives.ts +211 -0
- package/src/bcs/serializable/moveStructs.ts +462 -0
- package/src/bcs/serializer.ts +353 -0
- package/src/client/core.ts +106 -0
- package/src/client/get.ts +109 -0
- package/src/client/index.ts +7 -0
- package/src/client/post.ts +90 -0
- package/src/client/types.ts +58 -0
- package/src/core/account.ts +180 -0
- package/src/core/accountAddress.ts +407 -0
- package/src/core/authenticationKey.ts +102 -0
- package/src/core/common.ts +40 -0
- package/src/core/crypto/asymmetricCrypto.ts +77 -0
- package/src/core/crypto/ed25519.ts +224 -0
- package/src/core/crypto/index.ts +7 -0
- package/src/core/crypto/multiEd25519.ts +251 -0
- package/src/core/crypto/secp256k1.ts +227 -0
- package/src/core/hex.ts +177 -0
- package/src/core/index.ts +9 -0
- package/src/index.ts +12 -0
- package/src/internal/account.ts +484 -0
- package/src/internal/coin.ts +32 -0
- package/src/internal/digitalAsset.ts +302 -0
- package/src/internal/event.ts +88 -0
- package/src/internal/faucet.ts +41 -0
- package/src/internal/fungibleAsset.ts +114 -0
- package/src/internal/general.ts +160 -0
- package/src/internal/queries/TokenActivitiesFieldsFragment.graphql +17 -0
- package/src/internal/queries/currentTokenOwnershipFieldsFragment.graphql +45 -0
- package/src/internal/queries/getAccountCoinCount.graphql +7 -0
- package/src/internal/queries/getAccountCoinsData.graphql +32 -0
- package/src/internal/queries/getAccountCollectionsWithOwnedTokens.graphql +33 -0
- package/src/internal/queries/getAccountOwnedObjects.graphql +16 -0
- package/src/internal/queries/getAccountOwnedTokens.graphql +11 -0
- package/src/internal/queries/getAccountOwnedTokensByTokenData.graphql +11 -0
- package/src/internal/queries/getAccountOwnedTokensFromCollectionAddress.graphql +11 -0
- package/src/internal/queries/getAccountTokensCount.graphql +7 -0
- package/src/internal/queries/getAccountTransactionsCount.graphql +7 -0
- package/src/internal/queries/getChainTopUserTransactions.graphql +5 -0
- package/src/internal/queries/getCollectionData.graphql +20 -0
- package/src/internal/queries/getCurrentFungibleAssetBalances.graphql +17 -0
- package/src/internal/queries/getDelegatedStakingActivities.graphql +12 -0
- package/src/internal/queries/getEvents.graphql +12 -0
- package/src/internal/queries/getFungibleAssetActivities.graphql +20 -0
- package/src/internal/queries/getFungibleAssetMetadata.graphql +16 -0
- package/src/internal/queries/getNumberOfDelegatorsQuery.graphql +9 -0
- package/src/internal/queries/getProcessorStatus.graphql +7 -0
- package/src/internal/queries/getTokenActivity.graphql +11 -0
- package/src/internal/queries/getTokenCurrentOwner.graphql +11 -0
- package/src/internal/queries/getTokenData.graphql +38 -0
- package/src/internal/staking.ts +68 -0
- package/src/internal/transaction.ts +245 -0
- package/src/internal/transactionSubmission.ts +162 -0
- package/src/transactions/authenticator/account.ts +121 -0
- package/src/transactions/authenticator/transaction.ts +222 -0
- package/src/transactions/instances/chainId.ts +26 -0
- package/src/transactions/instances/identifier.ts +28 -0
- package/src/transactions/instances/index.ts +9 -0
- package/src/transactions/instances/moduleId.ts +53 -0
- package/src/transactions/instances/rawTransaction.ts +199 -0
- package/src/transactions/instances/signedTransaction.ts +43 -0
- package/src/transactions/instances/transactionArgument.ts +37 -0
- package/src/transactions/instances/transactionPayload.ts +407 -0
- package/src/transactions/transaction_builder/transaction_builder.ts +541 -0
- package/src/transactions/typeTag/typeTag.ts +487 -0
- package/src/transactions/types.ts +262 -0
- package/src/types/codegen.yaml +33 -0
- package/src/types/generated/operations.ts +623 -0
- package/src/types/generated/queries.ts +737 -0
- package/src/types/generated/types.ts +10387 -0
- package/src/types/index.ts +944 -0
- package/src/types/indexer.ts +93 -0
- package/src/utils/apiEndpoints.ts +36 -0
- package/src/utils/const.ts +51 -0
- package/src/utils/hdKey.ts +113 -0
- package/src/utils/helpers.ts +12 -0
- package/src/utils/memoize.ts +68 -0
- package/src/version.ts +9 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
fragment TokenActivitiesFields on token_activities_v2 {
|
|
2
|
+
after_value
|
|
3
|
+
before_value
|
|
4
|
+
entry_function_id_str
|
|
5
|
+
event_account_address
|
|
6
|
+
event_index
|
|
7
|
+
from_address
|
|
8
|
+
is_fungible_v2
|
|
9
|
+
property_version_v1
|
|
10
|
+
to_address
|
|
11
|
+
token_amount
|
|
12
|
+
token_data_id
|
|
13
|
+
token_standard
|
|
14
|
+
transaction_timestamp
|
|
15
|
+
transaction_version
|
|
16
|
+
type
|
|
17
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
fragment CurrentTokenOwnershipFields on current_token_ownerships_v2 {
|
|
2
|
+
token_standard
|
|
3
|
+
token_properties_mutated_v1
|
|
4
|
+
token_data_id
|
|
5
|
+
table_type_v1
|
|
6
|
+
storage_id
|
|
7
|
+
property_version_v1
|
|
8
|
+
owner_address
|
|
9
|
+
last_transaction_version
|
|
10
|
+
last_transaction_timestamp
|
|
11
|
+
is_soulbound_v2
|
|
12
|
+
is_fungible_v2
|
|
13
|
+
amount
|
|
14
|
+
current_token_data {
|
|
15
|
+
collection_id
|
|
16
|
+
description
|
|
17
|
+
is_fungible_v2
|
|
18
|
+
largest_property_version_v1
|
|
19
|
+
last_transaction_timestamp
|
|
20
|
+
last_transaction_version
|
|
21
|
+
maximum
|
|
22
|
+
supply
|
|
23
|
+
token_data_id
|
|
24
|
+
token_name
|
|
25
|
+
token_properties
|
|
26
|
+
token_standard
|
|
27
|
+
token_uri
|
|
28
|
+
current_collection {
|
|
29
|
+
collection_id
|
|
30
|
+
collection_name
|
|
31
|
+
creator_address
|
|
32
|
+
current_supply
|
|
33
|
+
description
|
|
34
|
+
last_transaction_timestamp
|
|
35
|
+
last_transaction_version
|
|
36
|
+
max_supply
|
|
37
|
+
mutable_description
|
|
38
|
+
mutable_uri
|
|
39
|
+
table_handle_v1
|
|
40
|
+
token_standard
|
|
41
|
+
total_minted_v2
|
|
42
|
+
uri
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
query getAccountCoinsData(
|
|
2
|
+
$where_condition: current_fungible_asset_balances_bool_exp!
|
|
3
|
+
$offset: Int
|
|
4
|
+
$limit: Int
|
|
5
|
+
$order_by: [current_fungible_asset_balances_order_by!]
|
|
6
|
+
) {
|
|
7
|
+
current_fungible_asset_balances(where: $where_condition, offset: $offset, limit: $limit, order_by: $order_by) {
|
|
8
|
+
amount
|
|
9
|
+
asset_type
|
|
10
|
+
is_frozen
|
|
11
|
+
is_primary
|
|
12
|
+
last_transaction_timestamp
|
|
13
|
+
last_transaction_version
|
|
14
|
+
owner_address
|
|
15
|
+
storage_id
|
|
16
|
+
token_standard
|
|
17
|
+
metadata {
|
|
18
|
+
token_standard
|
|
19
|
+
symbol
|
|
20
|
+
supply_aggregator_table_key_v1
|
|
21
|
+
supply_aggregator_table_handle_v1
|
|
22
|
+
project_uri
|
|
23
|
+
name
|
|
24
|
+
last_transaction_version
|
|
25
|
+
last_transaction_timestamp
|
|
26
|
+
icon_uri
|
|
27
|
+
decimals
|
|
28
|
+
creator_address
|
|
29
|
+
asset_type
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
query getAccountCollectionsWithOwnedTokens(
|
|
2
|
+
$where_condition: current_collection_ownership_v2_view_bool_exp!
|
|
3
|
+
$offset: Int
|
|
4
|
+
$limit: Int
|
|
5
|
+
$order_by: [current_collection_ownership_v2_view_order_by!]
|
|
6
|
+
) {
|
|
7
|
+
current_collection_ownership_v2_view(where: $where_condition, offset: $offset, limit: $limit, order_by: $order_by) {
|
|
8
|
+
current_collection {
|
|
9
|
+
collection_id
|
|
10
|
+
collection_name
|
|
11
|
+
creator_address
|
|
12
|
+
current_supply
|
|
13
|
+
description
|
|
14
|
+
last_transaction_timestamp
|
|
15
|
+
last_transaction_version
|
|
16
|
+
mutable_description
|
|
17
|
+
max_supply
|
|
18
|
+
mutable_uri
|
|
19
|
+
table_handle_v1
|
|
20
|
+
token_standard
|
|
21
|
+
total_minted_v2
|
|
22
|
+
uri
|
|
23
|
+
}
|
|
24
|
+
collection_id
|
|
25
|
+
collection_name
|
|
26
|
+
collection_uri
|
|
27
|
+
creator_address
|
|
28
|
+
distinct_tokens
|
|
29
|
+
last_transaction_version
|
|
30
|
+
owner_address
|
|
31
|
+
single_token_uri
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
query getAccountOwnedObjects(
|
|
2
|
+
$where_condition: current_objects_bool_exp
|
|
3
|
+
$offset: Int
|
|
4
|
+
$limit: Int
|
|
5
|
+
$order_by: [current_objects_order_by!]
|
|
6
|
+
) {
|
|
7
|
+
current_objects(where: $where_condition, offset: $offset, limit: $limit, order_by: $order_by) {
|
|
8
|
+
allow_ungated_transfer
|
|
9
|
+
state_key_hash
|
|
10
|
+
owner_address
|
|
11
|
+
object_address
|
|
12
|
+
last_transaction_version
|
|
13
|
+
last_guid_creation_num
|
|
14
|
+
is_deleted
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#import "./CurrentTokenOwnershipFieldsFragment";
|
|
2
|
+
query getAccountOwnedTokens(
|
|
3
|
+
$where_condition: current_token_ownerships_v2_bool_exp!
|
|
4
|
+
$offset: Int
|
|
5
|
+
$limit: Int
|
|
6
|
+
$order_by: [current_token_ownerships_v2_order_by!]
|
|
7
|
+
) {
|
|
8
|
+
current_token_ownerships_v2(where: $where_condition, offset: $offset, limit: $limit, order_by: $order_by) {
|
|
9
|
+
...CurrentTokenOwnershipFields
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#import "./CurrentTokenOwnershipFieldsFragment";
|
|
2
|
+
query getAccountOwnedTokensByTokenData(
|
|
3
|
+
$where_condition: current_token_ownerships_v2_bool_exp!
|
|
4
|
+
$offset: Int
|
|
5
|
+
$limit: Int
|
|
6
|
+
$order_by: [current_token_ownerships_v2_order_by!]
|
|
7
|
+
) {
|
|
8
|
+
current_token_ownerships_v2(where: $where_condition, offset: $offset, limit: $limit, order_by: $order_by) {
|
|
9
|
+
...CurrentTokenOwnershipFields
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#import "./CurrentTokenOwnershipFieldsFragment";
|
|
2
|
+
query getAccountOwnedTokensFromCollection(
|
|
3
|
+
$where_condition: current_token_ownerships_v2_bool_exp!
|
|
4
|
+
$offset: Int
|
|
5
|
+
$limit: Int
|
|
6
|
+
$order_by: [current_token_ownerships_v2_order_by!]
|
|
7
|
+
) {
|
|
8
|
+
current_token_ownerships_v2(where: $where_condition, offset: $offset, limit: $limit, order_by: $order_by) {
|
|
9
|
+
...CurrentTokenOwnershipFields
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
query getCollectionData(
|
|
2
|
+
$where_condition: current_collections_v2_bool_exp!
|
|
3
|
+
) {
|
|
4
|
+
current_collections_v2(where: $where_condition) {
|
|
5
|
+
collection_id
|
|
6
|
+
collection_name
|
|
7
|
+
creator_address
|
|
8
|
+
current_supply
|
|
9
|
+
description
|
|
10
|
+
last_transaction_timestamp
|
|
11
|
+
last_transaction_version
|
|
12
|
+
max_supply
|
|
13
|
+
mutable_description
|
|
14
|
+
mutable_uri
|
|
15
|
+
table_handle_v1
|
|
16
|
+
token_standard
|
|
17
|
+
total_minted_v2
|
|
18
|
+
uri
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
query getCurrentFungibleAssetBalances(
|
|
2
|
+
$where_condition: current_fungible_asset_balances_bool_exp
|
|
3
|
+
$offset: Int
|
|
4
|
+
$limit: Int
|
|
5
|
+
) {
|
|
6
|
+
current_fungible_asset_balances(where: $where_condition, offset: $offset, limit: $limit) {
|
|
7
|
+
amount
|
|
8
|
+
asset_type
|
|
9
|
+
is_frozen
|
|
10
|
+
is_primary
|
|
11
|
+
last_transaction_timestamp
|
|
12
|
+
last_transaction_version
|
|
13
|
+
owner_address
|
|
14
|
+
storage_id
|
|
15
|
+
token_standard
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
query getDelegatedStakingActivities($delegatorAddress: String, $poolAddress: String) {
|
|
2
|
+
delegated_staking_activities(
|
|
3
|
+
where: { delegator_address: { _eq: $delegatorAddress }, pool_address: { _eq: $poolAddress } }
|
|
4
|
+
) {
|
|
5
|
+
amount
|
|
6
|
+
delegator_address
|
|
7
|
+
event_index
|
|
8
|
+
event_type
|
|
9
|
+
pool_address
|
|
10
|
+
transaction_version
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
query getEvents($where_condition: events_bool_exp, $offset: Int, $limit: Int, $order_by: [events_order_by!]) {
|
|
2
|
+
events(where: $where_condition, offset: $offset, limit: $limit, order_by: $order_by) {
|
|
3
|
+
account_address
|
|
4
|
+
creation_number
|
|
5
|
+
data
|
|
6
|
+
event_index
|
|
7
|
+
sequence_number
|
|
8
|
+
transaction_block_height
|
|
9
|
+
transaction_version
|
|
10
|
+
type
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
query getFungibleAssetActivities($where_condition: fungible_asset_activities_bool_exp, $offset: Int, $limit: Int) {
|
|
2
|
+
fungible_asset_activities(where: $where_condition, offset: $offset, limit: $limit) {
|
|
3
|
+
amount
|
|
4
|
+
asset_type
|
|
5
|
+
block_height
|
|
6
|
+
entry_function_id_str
|
|
7
|
+
event_index
|
|
8
|
+
gas_fee_payer_address
|
|
9
|
+
is_frozen
|
|
10
|
+
is_gas_fee
|
|
11
|
+
is_transaction_success
|
|
12
|
+
owner_address
|
|
13
|
+
storage_id
|
|
14
|
+
storage_refund_amount
|
|
15
|
+
token_standard
|
|
16
|
+
transaction_timestamp
|
|
17
|
+
transaction_version
|
|
18
|
+
type
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
query getFungibleAssetMetadata($where_condition: fungible_asset_metadata_bool_exp, $offset: Int, $limit: Int) {
|
|
2
|
+
fungible_asset_metadata(where: $where_condition, offset: $offset, limit: $limit) {
|
|
3
|
+
icon_uri
|
|
4
|
+
project_uri
|
|
5
|
+
supply_aggregator_table_handle_v1
|
|
6
|
+
supply_aggregator_table_key_v1
|
|
7
|
+
creator_address
|
|
8
|
+
asset_type
|
|
9
|
+
decimals
|
|
10
|
+
last_transaction_timestamp
|
|
11
|
+
last_transaction_version
|
|
12
|
+
name
|
|
13
|
+
symbol
|
|
14
|
+
token_standard
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
query getNumberOfDelegators($where_condition: num_active_delegator_per_pool_bool_exp!, $order_by: [num_active_delegator_per_pool_order_by!]) {
|
|
2
|
+
num_active_delegator_per_pool(
|
|
3
|
+
where: $where_condition,
|
|
4
|
+
order_by: $order_by
|
|
5
|
+
) {
|
|
6
|
+
num_active_delegator
|
|
7
|
+
pool_address
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#import "./TokenActivitiesFieldsFragment";
|
|
2
|
+
query getTokenActivity(
|
|
3
|
+
$where_condition: token_activities_v2_bool_exp!
|
|
4
|
+
$offset: Int
|
|
5
|
+
$limit: Int
|
|
6
|
+
$order_by: [token_activities_v2_order_by!]
|
|
7
|
+
) {
|
|
8
|
+
token_activities_v2(where: $where_condition, order_by: $order_by, offset: $offset, limit: $limit) {
|
|
9
|
+
...TokenActivitiesFields
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#import "./CurrentTokenOwnershipFieldsFragment";
|
|
2
|
+
query getCurrentTokenOwnership(
|
|
3
|
+
$where_condition: current_token_ownerships_v2_bool_exp!
|
|
4
|
+
$offset: Int
|
|
5
|
+
$limit: Int
|
|
6
|
+
$order_by: [current_token_ownerships_v2_order_by!]
|
|
7
|
+
) {
|
|
8
|
+
current_token_ownerships_v2(where: $where_condition, offset: $offset, limit: $limit, order_by: $order_by) {
|
|
9
|
+
...CurrentTokenOwnershipFields
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
query getTokenData(
|
|
2
|
+
$where_condition: current_token_datas_v2_bool_exp
|
|
3
|
+
$offset: Int
|
|
4
|
+
$limit: Int
|
|
5
|
+
$order_by: [current_token_datas_v2_order_by!]
|
|
6
|
+
) {
|
|
7
|
+
current_token_datas_v2(where: $where_condition, offset: $offset, limit: $limit, order_by: $order_by) {
|
|
8
|
+
collection_id
|
|
9
|
+
description
|
|
10
|
+
is_fungible_v2
|
|
11
|
+
largest_property_version_v1
|
|
12
|
+
last_transaction_timestamp
|
|
13
|
+
last_transaction_version
|
|
14
|
+
maximum
|
|
15
|
+
supply
|
|
16
|
+
token_data_id
|
|
17
|
+
token_name
|
|
18
|
+
token_properties
|
|
19
|
+
token_standard
|
|
20
|
+
token_uri
|
|
21
|
+
current_collection {
|
|
22
|
+
collection_id
|
|
23
|
+
collection_name
|
|
24
|
+
creator_address
|
|
25
|
+
current_supply
|
|
26
|
+
description
|
|
27
|
+
last_transaction_timestamp
|
|
28
|
+
last_transaction_version
|
|
29
|
+
max_supply
|
|
30
|
+
mutable_description
|
|
31
|
+
mutable_uri
|
|
32
|
+
table_handle_v1
|
|
33
|
+
token_standard
|
|
34
|
+
total_minted_v2
|
|
35
|
+
uri
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Copyright © Aptos Foundation
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This file contains the underlying implementations for exposed API surface in
|
|
6
|
+
* the {@link api/staking}. By moving the methods out into a separate file,
|
|
7
|
+
* other namespaces and processes can access these methods without depending on the entire
|
|
8
|
+
* faucet namespace and without having a dependency cycle error.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { AptosConfig } from "../api/aptosConfig";
|
|
12
|
+
import { Hex } from "../core";
|
|
13
|
+
import { GetDelegatedStakingActivitiesResponse, GetNumberOfDelegatorsResponse, HexInput, OrderBy } from "../types";
|
|
14
|
+
import { GetDelegatedStakingActivitiesQuery, GetNumberOfDelegatorsQuery } from "../types/generated/operations";
|
|
15
|
+
import { GetDelegatedStakingActivities, GetNumberOfDelegators } from "../types/generated/queries";
|
|
16
|
+
import { queryIndexer } from "./general";
|
|
17
|
+
|
|
18
|
+
export async function getNumberOfDelegators(args: {
|
|
19
|
+
aptosConfig: AptosConfig;
|
|
20
|
+
poolAddress: HexInput;
|
|
21
|
+
}): Promise<number> {
|
|
22
|
+
const { aptosConfig, poolAddress } = args;
|
|
23
|
+
const address = Hex.fromHexInput(poolAddress).toString();
|
|
24
|
+
const query = {
|
|
25
|
+
query: GetNumberOfDelegators,
|
|
26
|
+
variables: { where_condition: { pool_address: { _eq: address } } },
|
|
27
|
+
};
|
|
28
|
+
const data: GetNumberOfDelegatorsQuery = await queryIndexer<GetNumberOfDelegatorsQuery>({ aptosConfig, query });
|
|
29
|
+
if (data.num_active_delegator_per_pool.length === 0) {
|
|
30
|
+
throw Error("Delegator pool not found");
|
|
31
|
+
}
|
|
32
|
+
return data.num_active_delegator_per_pool[0].num_active_delegator;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function getNumberOfDelegatorsForAllPools(args: {
|
|
36
|
+
aptosConfig: AptosConfig;
|
|
37
|
+
options?: {
|
|
38
|
+
orderBy?: OrderBy<GetNumberOfDelegatorsResponse[0]>;
|
|
39
|
+
};
|
|
40
|
+
}): Promise<GetNumberOfDelegatorsResponse> {
|
|
41
|
+
const { aptosConfig, options } = args;
|
|
42
|
+
const query = {
|
|
43
|
+
query: GetNumberOfDelegators,
|
|
44
|
+
variables: { where_condition: {}, order_by: options?.orderBy },
|
|
45
|
+
};
|
|
46
|
+
const data: GetNumberOfDelegatorsQuery = await queryIndexer<GetNumberOfDelegatorsQuery>({
|
|
47
|
+
aptosConfig,
|
|
48
|
+
query,
|
|
49
|
+
});
|
|
50
|
+
return data.num_active_delegator_per_pool;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export async function getDelegatedStakingActivities(args: {
|
|
54
|
+
aptosConfig: AptosConfig;
|
|
55
|
+
delegatorAddress: HexInput;
|
|
56
|
+
poolAddress: HexInput;
|
|
57
|
+
}): Promise<GetDelegatedStakingActivitiesResponse> {
|
|
58
|
+
const { aptosConfig, delegatorAddress, poolAddress } = args;
|
|
59
|
+
const query = {
|
|
60
|
+
query: GetDelegatedStakingActivities,
|
|
61
|
+
variables: {
|
|
62
|
+
delegatorAddress: Hex.fromHexInput(delegatorAddress).toString(),
|
|
63
|
+
poolAddress: Hex.fromHexInput(poolAddress).toString(),
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
const data = await queryIndexer<GetDelegatedStakingActivitiesQuery>({ aptosConfig, query });
|
|
67
|
+
return data.delegated_staking_activities;
|
|
68
|
+
}
|