@aptos-labs/js-pro 0.1.4 → 0.1.5
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/CHANGELOG.md +6 -0
- package/dist/client.d.ts +1 -4
- package/dist/client.d.ts.map +1 -1
- package/dist/index.js +34 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -51
- package/dist/index.mjs.map +1 -1
- package/dist/operations/generated/operations.d.ts +0 -27
- package/dist/operations/generated/operations.d.ts.map +1 -1
- package/dist/operations/generated/sdk.d.ts +0 -4
- package/dist/operations/generated/sdk.d.ts.map +1 -1
- package/dist/operations/generated/types.d.ts +37 -3645
- package/dist/operations/generated/types.d.ts.map +1 -1
- package/dist/operations/index.d.ts +0 -2
- package/dist/operations/index.d.ts.map +1 -1
- package/dist/queries/index.d.ts +0 -1
- package/dist/queries/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +0 -3
- package/src/index.ts +1 -1
- package/src/mutations/buildTransaction.ts +3 -3
- package/src/mutations/signAndSubmitTransaction.ts +1 -1
- package/src/mutations/signTransaction.ts +1 -1
- package/src/mutations/simulateTransaction.ts +3 -3
- package/src/mutations/submitTransaction.ts +1 -1
- package/src/mutations/waitForTransaction.ts +1 -1
- package/src/operations/generated/operations.ts +0 -14
- package/src/operations/generated/sdk.ts +0 -25
- package/src/operations/generated/types.ts +5007 -9064
- package/src/operations/index.ts +1 -1
- package/src/operations/schemas/account.gql +0 -19
- package/src/queries/fetchAccountCoins.ts +2 -2
- package/src/queries/fetchAccountCollections.ts +2 -2
- package/src/queries/fetchAccountTokens.ts +1 -1
- package/src/queries/fetchAccountTransactions.ts +2 -2
- package/src/queries/fetchAddressFromName.ts +2 -2
- package/src/queries/fetchAptBalance.ts +1 -1
- package/src/queries/fetchBalance.ts +1 -1
- package/src/queries/fetchEstimatedGasPrice.ts +1 -1
- package/src/queries/fetchFungibleAssetMetadata.ts +1 -1
- package/src/queries/fetchLedgerInfo.ts +1 -1
- package/src/queries/fetchNameFromAddress.ts +2 -2
- package/src/queries/fetchProcessorStatus.ts +1 -1
- package/src/queries/fetchResourceType.ts +1 -1
- package/src/queries/fetchResources.ts +2 -2
- package/src/queries/fetchTokenData.ts +1 -1
- package/src/queries/fetchTransaction.ts +1 -1
- package/src/queries/fetchUserTransactions.ts +1 -1
- package/src/queries/fetchViewModule.ts +1 -1
- package/src/queries/getClients.ts +1 -1
- package/src/queries/index.ts +0 -1
- package/src/types/signers.ts +2 -2
- package/src/utils/convert.ts +3 -3
- package/src/utils/fungibleAssets.ts +2 -2
- package/src/utils/index.ts +1 -1
- package/src/utils/lib.ts +2 -2
- package/src/utils/normalize.ts +16 -16
- package/src/utils/objects.ts +1 -1
- package/src/utils/tokens.ts +1 -1
- package/src/utils/transactions/TransactionParser.ts +6 -6
- package/src/utils/transactions/parsers/CoinEventParser.ts +2 -2
- package/src/utils/transactions/parsers/CoinStoreWritesetParser.ts +4 -4
- package/src/utils/transactions/parsers/FungibleAssetEventParser.ts +4 -4
- package/src/utils/transactions/parsers/FungibleAssetStoreWritesetParser.ts +2 -2
- package/src/utils/transactions/parsers/ObjectOwnersWritesetParser.ts +1 -1
- package/src/utils/transactions/shared.ts +2 -2
- package/dist/queries/fetchAccountTotalTransactions.d.ts +0 -9
- package/dist/queries/fetchAccountTotalTransactions.d.ts.map +0 -1
- package/src/queries/fetchAccountTotalTransactions.ts +0 -27
package/src/operations/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { getSdk } from "./generated/sdk.js";
|
|
|
5
5
|
|
|
6
6
|
export function createIndexerClient(
|
|
7
7
|
endpoint: string,
|
|
8
|
-
options?: ConstructorParameters<typeof GraphQLClient>[1]
|
|
8
|
+
options?: ConstructorParameters<typeof GraphQLClient>[1],
|
|
9
9
|
) {
|
|
10
10
|
const graphqlClient = new GraphQLClient(endpoint, options);
|
|
11
11
|
return getSdk(graphqlClient);
|
|
@@ -128,17 +128,6 @@ query getTokenData($address: String!) {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
query getActivitiesAggregate($account_address: String!) {
|
|
132
|
-
address_events_summary(
|
|
133
|
-
where: { account_address: { _eq: $account_address } }
|
|
134
|
-
) {
|
|
135
|
-
block_metadata {
|
|
136
|
-
timestamp
|
|
137
|
-
}
|
|
138
|
-
num_distinct_versions
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
131
|
query getTokenActivities($tokenId: String!, $offset: Int, $limit: Int) {
|
|
143
132
|
token_activities_v2(
|
|
144
133
|
where: { token_data_id: { _eq: $tokenId } }
|
|
@@ -346,14 +335,6 @@ query getUserTransactions(
|
|
|
346
335
|
}
|
|
347
336
|
}
|
|
348
337
|
|
|
349
|
-
query getAccountTotalTransactions($address: String!) {
|
|
350
|
-
move_resources_aggregate(where: {address: {_eq: $address}}) {
|
|
351
|
-
aggregate {
|
|
352
|
-
count
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
338
|
query getFungibleAssetMetadata($type: String!) {
|
|
358
339
|
fungible_asset_metadata(where: { asset_type: { _eq: $type } }) {
|
|
359
340
|
asset_type
|
|
@@ -48,7 +48,7 @@ export async function fetchAccountCoins(
|
|
|
48
48
|
offset = 0,
|
|
49
49
|
orderBy,
|
|
50
50
|
where,
|
|
51
|
-
}: FetchAccountCoinsParameters
|
|
51
|
+
}: FetchAccountCoinsParameters,
|
|
52
52
|
): Promise<FetchAccountCoinsResult> {
|
|
53
53
|
const { indexer } = this.getClients({ network });
|
|
54
54
|
|
|
@@ -76,7 +76,7 @@ export async function fetchAccountCoins(
|
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
const balances = response.current_fungible_asset_balances.filter(
|
|
79
|
-
(e) => e.metadata !== undefined && e.metadata !== null
|
|
79
|
+
(e) => e.metadata !== undefined && e.metadata !== null,
|
|
80
80
|
) as (FungibleAssetBalanceFieldsFragment & {
|
|
81
81
|
metadata: FungibleAssetMetadataFieldsFragment;
|
|
82
82
|
})[];
|
|
@@ -47,7 +47,7 @@ export async function fetchAccountCollections(
|
|
|
47
47
|
orderBy = [],
|
|
48
48
|
where = [],
|
|
49
49
|
...params
|
|
50
|
-
}: FetchAccountCollectionsParameters
|
|
50
|
+
}: FetchAccountCollectionsParameters,
|
|
51
51
|
): Promise<FetchAccountCollectionsResult> {
|
|
52
52
|
const { indexer } = this.getClients({ network });
|
|
53
53
|
if (!indexer) throw new IndexerNotInitializedError();
|
|
@@ -76,7 +76,7 @@ export async function fetchAccountCollections(
|
|
|
76
76
|
if (!collection.current_collection) return;
|
|
77
77
|
|
|
78
78
|
collections.push(
|
|
79
|
-
normalizeCollectionData(collection.current_collection)
|
|
79
|
+
normalizeCollectionData(collection.current_collection),
|
|
80
80
|
);
|
|
81
81
|
});
|
|
82
82
|
|
|
@@ -49,7 +49,7 @@ export async function fetchAccountTokens(
|
|
|
49
49
|
offset = 0,
|
|
50
50
|
orderBy = [],
|
|
51
51
|
where = [],
|
|
52
|
-
}: FetchAccountTokensParameters
|
|
52
|
+
}: FetchAccountTokensParameters,
|
|
53
53
|
): Promise<FetchAccountTokensResult> {
|
|
54
54
|
const { indexer } = this.getClients({ network });
|
|
55
55
|
if (!indexer) throw new IndexerNotInitializedError();
|
|
@@ -67,7 +67,7 @@ export async function fetchAccountTransactions(
|
|
|
67
67
|
tokenActivitiesWhere = [],
|
|
68
68
|
fungibleAssetActivitiesOrderBy = [],
|
|
69
69
|
tokenActivitiesOrderBy = [],
|
|
70
|
-
}: FetchAccountTransactionsParameters
|
|
70
|
+
}: FetchAccountTransactionsParameters,
|
|
71
71
|
): Promise<FetchAccountTransactionsResult> {
|
|
72
72
|
const { indexer } = this.getClients({ network });
|
|
73
73
|
if (!indexer) throw new IndexerNotInitializedError();
|
|
@@ -96,7 +96,7 @@ export async function fetchAccountTransactions(
|
|
|
96
96
|
return {
|
|
97
97
|
hasNextPage: response.account_transactions.length === limit,
|
|
98
98
|
transactions: response.account_transactions.map(
|
|
99
|
-
normalizeAccountTransaction
|
|
99
|
+
normalizeAccountTransaction,
|
|
100
100
|
),
|
|
101
101
|
};
|
|
102
102
|
},
|
|
@@ -18,13 +18,13 @@ export type FetchAddressFromNameResult = AccountAddress | null;
|
|
|
18
18
|
|
|
19
19
|
export async function fetchAddressFromName(
|
|
20
20
|
this: AptosJSProClient,
|
|
21
|
-
{ network, name }: FetchAddressFromNameParameters
|
|
21
|
+
{ network, name }: FetchAddressFromNameParameters,
|
|
22
22
|
): Promise<FetchAddressFromNameResult> {
|
|
23
23
|
const { aptos } = this.getClients({ network });
|
|
24
24
|
|
|
25
25
|
const address = await asyncTryOrDefault(
|
|
26
26
|
() => aptos.getTargetAddress({ name: name.toString() }),
|
|
27
|
-
undefined
|
|
27
|
+
undefined,
|
|
28
28
|
);
|
|
29
29
|
|
|
30
30
|
return address ? AccountAddress.from(address) : null;
|
|
@@ -16,7 +16,7 @@ export type FetchAptBalanceResult = bigint;
|
|
|
16
16
|
|
|
17
17
|
export async function fetchAptBalance(
|
|
18
18
|
this: AptosJSProClient,
|
|
19
|
-
{ address, network }: FetchAptBalanceParameters
|
|
19
|
+
{ address, network }: FetchAptBalanceParameters,
|
|
20
20
|
): Promise<FetchAptBalanceResult> {
|
|
21
21
|
const { aptos } = this.getClients({ network });
|
|
22
22
|
|
|
@@ -20,7 +20,7 @@ export type FetchBalanceResult = bigint;
|
|
|
20
20
|
|
|
21
21
|
export async function fetchBalance(
|
|
22
22
|
this: AptosJSProClient,
|
|
23
|
-
{ address, asset, network }: FetchBalanceParameters
|
|
23
|
+
{ address, asset, network }: FetchBalanceParameters,
|
|
24
24
|
): Promise<FetchBalanceResult> {
|
|
25
25
|
const { aptos } = this.getClients({ network });
|
|
26
26
|
|
|
@@ -14,7 +14,7 @@ export type FetchEstimatedGasPriceResult = {
|
|
|
14
14
|
|
|
15
15
|
export async function fetchEstimatedGasPrice(
|
|
16
16
|
this: AptosJSProClient,
|
|
17
|
-
{ network }: FetchEstimatedGasPriceParameters = {}
|
|
17
|
+
{ network }: FetchEstimatedGasPriceParameters = {},
|
|
18
18
|
): Promise<FetchEstimatedGasPriceResult> {
|
|
19
19
|
const { aptos } = this.getClients({ network });
|
|
20
20
|
|
|
@@ -15,7 +15,7 @@ export type FetchFungibleAssetMetadataResult = FungibleAssetMetadata | null;
|
|
|
15
15
|
|
|
16
16
|
export async function fetchFungibleAssetMetadata(
|
|
17
17
|
this: AptosJSProClient,
|
|
18
|
-
{ network, ...params }: FetchFungibleAssetMetadataParameters
|
|
18
|
+
{ network, ...params }: FetchFungibleAssetMetadataParameters,
|
|
19
19
|
): Promise<FetchFungibleAssetMetadataResult> {
|
|
20
20
|
const { aptos } = this.getClients({ network });
|
|
21
21
|
|
|
@@ -21,7 +21,7 @@ export type FetchLedgerInfoResult = {
|
|
|
21
21
|
|
|
22
22
|
export async function fetchLedgerInfo(
|
|
23
23
|
this: AptosJSProClient,
|
|
24
|
-
{ network }: FetchLedgerInfoParameters = {}
|
|
24
|
+
{ network }: FetchLedgerInfoParameters = {},
|
|
25
25
|
): Promise<FetchLedgerInfoResult> {
|
|
26
26
|
const { aptos } = this.getClients({ network });
|
|
27
27
|
|
|
@@ -18,13 +18,13 @@ export type FetchNameFromAddressResult = AptosName | null;
|
|
|
18
18
|
|
|
19
19
|
export async function fetchNameFromAddress(
|
|
20
20
|
this: AptosJSProClient,
|
|
21
|
-
{ network, address }: FetchNameFromAddressParameters
|
|
21
|
+
{ network, address }: FetchNameFromAddressParameters,
|
|
22
22
|
): Promise<FetchNameFromAddressResult> {
|
|
23
23
|
const { aptos } = this.getClients({ network });
|
|
24
24
|
|
|
25
25
|
const name = await asyncTryOrDefault(
|
|
26
26
|
() => aptos.getPrimaryName({ address }),
|
|
27
|
-
undefined
|
|
27
|
+
undefined,
|
|
28
28
|
);
|
|
29
29
|
|
|
30
30
|
return name ? new AptosName(name) : null;
|
|
@@ -16,7 +16,7 @@ export type FetchProcessorStatusResult = {
|
|
|
16
16
|
|
|
17
17
|
export async function fetchProcessorStatus(
|
|
18
18
|
this: AptosJSProClient,
|
|
19
|
-
{ network, processor }: FetchProcessorStatusParameters
|
|
19
|
+
{ network, processor }: FetchProcessorStatusParameters,
|
|
20
20
|
): Promise<FetchProcessorStatusResult> {
|
|
21
21
|
const { aptos } = this.getClients({ network });
|
|
22
22
|
|
|
@@ -62,7 +62,7 @@ export async function fetchResourceType<T extends string | object>(
|
|
|
62
62
|
network,
|
|
63
63
|
accountAddress,
|
|
64
64
|
...params
|
|
65
|
-
}: FetchResourceTypeParameters<T extends object ? string : T & string
|
|
65
|
+
}: FetchResourceTypeParameters<T extends object ? string : T & string>,
|
|
66
66
|
): Promise<
|
|
67
67
|
FetchResourceTypeResult<ExtractResourceData<T>, GetResourceTypeString<T>>
|
|
68
68
|
> {
|
|
@@ -14,13 +14,13 @@ export type FetchResourcesResult = MoveResource[];
|
|
|
14
14
|
|
|
15
15
|
export async function fetchResources(
|
|
16
16
|
this: AptosJSProClient,
|
|
17
|
-
{ network, ...params }: FetchResourcesParameters
|
|
17
|
+
{ network, ...params }: FetchResourcesParameters,
|
|
18
18
|
): Promise<FetchResourcesResult> {
|
|
19
19
|
const { aptos } = this.getClients({ network });
|
|
20
20
|
|
|
21
21
|
const result = await asyncTryOrDefault(
|
|
22
22
|
() => aptos.getAccountResources(params),
|
|
23
|
-
[]
|
|
23
|
+
[],
|
|
24
24
|
);
|
|
25
25
|
|
|
26
26
|
return result;
|
|
@@ -21,7 +21,7 @@ export type FetchTokenDataResult = TokenData | null;
|
|
|
21
21
|
|
|
22
22
|
export async function fetchTokenData(
|
|
23
23
|
this: AptosJSProClient,
|
|
24
|
-
params: FetchTokenDataParameters
|
|
24
|
+
params: FetchTokenDataParameters,
|
|
25
25
|
): Promise<FetchTokenDataResult> {
|
|
26
26
|
const { indexer } = this.getClients({ network: params.network });
|
|
27
27
|
|
|
@@ -18,7 +18,7 @@ export type FetchTransactionResult = TransactionResponse;
|
|
|
18
18
|
|
|
19
19
|
export async function fetchTransaction(
|
|
20
20
|
this: AptosJSProClient,
|
|
21
|
-
{ network, ...params }: FetchTransactionParameters
|
|
21
|
+
{ network, ...params }: FetchTransactionParameters,
|
|
22
22
|
): Promise<FetchTransactionResult> {
|
|
23
23
|
const { aptos } = this.getClients({ network });
|
|
24
24
|
|
|
@@ -32,7 +32,7 @@ export async function fetchUserTransactions(
|
|
|
32
32
|
offset = 0,
|
|
33
33
|
orderBy = [],
|
|
34
34
|
where = {},
|
|
35
|
-
}: FetchUserTransactionsParameters = {}
|
|
35
|
+
}: FetchUserTransactionsParameters = {},
|
|
36
36
|
): Promise<FetchUserTransactionsResult> {
|
|
37
37
|
const { indexer } = this.getClients({ network });
|
|
38
38
|
if (!indexer) throw new IndexerNotInitializedError();
|
|
@@ -13,7 +13,7 @@ export type FetchViewModuleResult<T extends Array<MoveValue>> = T;
|
|
|
13
13
|
|
|
14
14
|
export async function fetchViewModule<T extends Array<MoveValue>>(
|
|
15
15
|
this: AptosJSProClient,
|
|
16
|
-
params: FetchViewModuleParameters
|
|
16
|
+
params: FetchViewModuleParameters,
|
|
17
17
|
): Promise<FetchViewModuleResult<T>> {
|
|
18
18
|
const { aptos } = this.getClients({ network: params.network });
|
|
19
19
|
|
|
@@ -18,7 +18,7 @@ export type GetClientsResult = {
|
|
|
18
18
|
|
|
19
19
|
export function getClients(
|
|
20
20
|
this: AptosJSProClient,
|
|
21
|
-
{ network: selectedNetwork }: GetClientsParameters = {}
|
|
21
|
+
{ network: selectedNetwork }: GetClientsParameters = {},
|
|
22
22
|
): GetClientsResult {
|
|
23
23
|
let aptos: Aptos = this.aptos;
|
|
24
24
|
let indexer: Sdk | undefined = this.indexer;
|
package/src/queries/index.ts
CHANGED
package/src/types/signers.ts
CHANGED
|
@@ -29,7 +29,7 @@ export type CustomSignerClient = {
|
|
|
29
29
|
aptos: Aptos;
|
|
30
30
|
transaction: AnyRawTransaction;
|
|
31
31
|
signer?: Account;
|
|
32
|
-
} & FeePayerOrFeePayerAuthenticatorOrNeither
|
|
32
|
+
} & FeePayerOrFeePayerAuthenticatorOrNeither,
|
|
33
33
|
): Promise<TransactionResponse>;
|
|
34
34
|
};
|
|
35
35
|
|
|
@@ -58,7 +58,7 @@ export type AdapterSignerClient = {
|
|
|
58
58
|
};
|
|
59
59
|
};
|
|
60
60
|
signer?: Account;
|
|
61
|
-
} & FeePayerOrFeePayerAuthenticatorOrNeither
|
|
61
|
+
} & FeePayerOrFeePayerAuthenticatorOrNeither,
|
|
62
62
|
): Promise<TransactionResponse>;
|
|
63
63
|
};
|
|
64
64
|
|
package/src/utils/convert.ts
CHANGED
|
@@ -5,14 +5,14 @@ import { Account } from "@aptos-labs/ts-sdk";
|
|
|
5
5
|
import { AccountInfo, SignerClient } from "../types";
|
|
6
6
|
|
|
7
7
|
export const convertAptosAccountToAccountInfo = (
|
|
8
|
-
account: Account | undefined
|
|
8
|
+
account: Account | undefined,
|
|
9
9
|
): AccountInfo | undefined =>
|
|
10
10
|
account
|
|
11
11
|
? { address: account.accountAddress, publicKey: account.publicKey }
|
|
12
12
|
: undefined;
|
|
13
13
|
|
|
14
14
|
export const convertAptosAccountToSigner = (
|
|
15
|
-
account: Account | undefined
|
|
15
|
+
account: Account | undefined,
|
|
16
16
|
): SignerClient | undefined =>
|
|
17
17
|
account
|
|
18
18
|
? {
|
|
@@ -25,7 +25,7 @@ export const convertAptosAccountToSigner = (
|
|
|
25
25
|
signTransaction: async ({ signer, transaction }) => ({
|
|
26
26
|
rawTransaction: transaction.rawTransaction.bcsToBytes(),
|
|
27
27
|
authenticator: (signer ?? account).signTransactionWithAuthenticator(
|
|
28
|
-
transaction
|
|
28
|
+
transaction,
|
|
29
29
|
),
|
|
30
30
|
}),
|
|
31
31
|
}
|
|
@@ -24,9 +24,9 @@ export const getPairedMetadata = (coinType: string) =>
|
|
|
24
24
|
*/
|
|
25
25
|
export const getPrimaryFungibleStore = (
|
|
26
26
|
accountAddress: string,
|
|
27
|
-
metadata: string
|
|
27
|
+
metadata: string,
|
|
28
28
|
) =>
|
|
29
29
|
createUserDerivedObjectAddress(
|
|
30
30
|
AccountAddress.fromString(accountAddress),
|
|
31
|
-
metadata
|
|
31
|
+
metadata,
|
|
32
32
|
).toStringLong();
|
package/src/utils/index.ts
CHANGED
package/src/utils/lib.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export const asyncTryOrDefault = async <T, U>(
|
|
9
9
|
fn: () => T,
|
|
10
|
-
defaultValue: U
|
|
10
|
+
defaultValue: U,
|
|
11
11
|
): Promise<T | U> => {
|
|
12
12
|
try {
|
|
13
13
|
const res = await fn();
|
|
@@ -18,7 +18,7 @@ export const asyncTryOrDefault = async <T, U>(
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export function shareRequests<TParam extends string | number, TResult>(
|
|
21
|
-
query: (param: TParam) => Promise<TResult
|
|
21
|
+
query: (param: TParam) => Promise<TResult>,
|
|
22
22
|
) {
|
|
23
23
|
const pendingRequests: { [key: string]: Promise<TResult> } = {};
|
|
24
24
|
return async (param: TParam) => {
|
package/src/utils/normalize.ts
CHANGED
|
@@ -33,7 +33,7 @@ import { fixBadAptosUri } from "./tokens.js";
|
|
|
33
33
|
// normalizePrimaryAptosName
|
|
34
34
|
|
|
35
35
|
export const normalizePrimaryAptosName = (
|
|
36
|
-
aptosName: PrimaryAptosNameFragment
|
|
36
|
+
aptosName: PrimaryAptosNameFragment,
|
|
37
37
|
): AptosName | undefined =>
|
|
38
38
|
aptosName.domain
|
|
39
39
|
? new AptosName(aptosName.domain, aptosName.subdomain)
|
|
@@ -42,7 +42,7 @@ export const normalizePrimaryAptosName = (
|
|
|
42
42
|
// normalizeFungibleAssetMetadata
|
|
43
43
|
|
|
44
44
|
export const normalizeFungibleAssetMetadata = (
|
|
45
|
-
metadata: FungibleAssetMetadataFieldsFragment
|
|
45
|
+
metadata: FungibleAssetMetadataFieldsFragment,
|
|
46
46
|
): FungibleAssetMetadata => ({
|
|
47
47
|
assetType: metadata.asset_type,
|
|
48
48
|
creatorAddress: metadata.creator_address,
|
|
@@ -59,7 +59,7 @@ export const normalizeFungibleAssetMetadata = (
|
|
|
59
59
|
export const normalizeFungibleAssetBalances = (
|
|
60
60
|
balances: (FungibleAssetBalanceFieldsFragment & {
|
|
61
61
|
metadata: FungibleAssetMetadataFieldsFragment;
|
|
62
|
-
})[]
|
|
62
|
+
})[],
|
|
63
63
|
): FungibleAssetBalance[] =>
|
|
64
64
|
balances.map(
|
|
65
65
|
(balance) =>
|
|
@@ -77,13 +77,13 @@ export const normalizeFungibleAssetBalances = (
|
|
|
77
77
|
metadata: normalizeFungibleAssetMetadata(balance.metadata),
|
|
78
78
|
ownerAddress: balance.owner_address,
|
|
79
79
|
tokenStandard: balance.token_standard,
|
|
80
|
-
}) satisfies FungibleAssetBalance
|
|
80
|
+
}) satisfies FungibleAssetBalance,
|
|
81
81
|
);
|
|
82
82
|
|
|
83
83
|
// normalizeCollectionData
|
|
84
84
|
|
|
85
85
|
export const normalizeCollectionData = (
|
|
86
|
-
collectionData: CollectionDataFieldsFragment
|
|
86
|
+
collectionData: CollectionDataFieldsFragment,
|
|
87
87
|
): CollectionData => ({
|
|
88
88
|
cdnImageUri: collectionData.cdn_asset_uris?.cdn_image_uri,
|
|
89
89
|
collectionId: collectionData.collection_id,
|
|
@@ -100,7 +100,7 @@ export const normalizeCollectionData = (
|
|
|
100
100
|
export const normalizeCollectionOwnership = (
|
|
101
101
|
collectionOwnership: CollectionOwnershipFragment & {
|
|
102
102
|
current_collection: CollectionDataFieldsFragment;
|
|
103
|
-
}
|
|
103
|
+
},
|
|
104
104
|
): CollectionData => ({
|
|
105
105
|
...normalizeCollectionData(collectionOwnership.current_collection),
|
|
106
106
|
distinctTokens: collectionOwnership.distinct_tokens,
|
|
@@ -110,7 +110,7 @@ export const normalizeCollectionOwnership = (
|
|
|
110
110
|
// normalizeTokenData
|
|
111
111
|
|
|
112
112
|
export const normalizeTokenData = (
|
|
113
|
-
tokenData: TokenDataFieldsFragment
|
|
113
|
+
tokenData: TokenDataFieldsFragment,
|
|
114
114
|
): TokenData => {
|
|
115
115
|
const fixedUri = fixBadAptosUri(tokenData.token_uri);
|
|
116
116
|
return {
|
|
@@ -137,7 +137,7 @@ export const normalizeTokenData = (
|
|
|
137
137
|
// normalizeBaseTokenActivity
|
|
138
138
|
|
|
139
139
|
export const normalizeBaseTokenActivity = (
|
|
140
|
-
activity: BaseTokenActivityFragment
|
|
140
|
+
activity: BaseTokenActivityFragment,
|
|
141
141
|
): BaseTokenActivity => ({
|
|
142
142
|
fromAddress: activity.from_address,
|
|
143
143
|
toAddress: activity.to_address,
|
|
@@ -151,7 +151,7 @@ export const normalizeBaseTokenActivity = (
|
|
|
151
151
|
// normalizeAccountTransaction
|
|
152
152
|
|
|
153
153
|
export const normalizeAccountTransaction = (
|
|
154
|
-
transaction: AccountTransactionFragment
|
|
154
|
+
transaction: AccountTransactionFragment,
|
|
155
155
|
): AccountTransaction => {
|
|
156
156
|
const fungibleAssetActivities: FungibleAssetActivity[] = [];
|
|
157
157
|
const tokenActivities: TokenActivity[] = [];
|
|
@@ -164,7 +164,7 @@ export const normalizeAccountTransaction = (
|
|
|
164
164
|
...e,
|
|
165
165
|
asset_type: e.asset_type,
|
|
166
166
|
metadata: e.metadata,
|
|
167
|
-
})
|
|
167
|
+
}),
|
|
168
168
|
);
|
|
169
169
|
});
|
|
170
170
|
|
|
@@ -174,12 +174,12 @@ export const normalizeAccountTransaction = (
|
|
|
174
174
|
normalizeTokenActivity({
|
|
175
175
|
...e,
|
|
176
176
|
current_token_data: e.current_token_data,
|
|
177
|
-
})
|
|
177
|
+
}),
|
|
178
178
|
);
|
|
179
179
|
});
|
|
180
180
|
|
|
181
181
|
transaction.delegated_staking_activities.forEach((e) =>
|
|
182
|
-
delegatedStakingActivities.push(normalizeDelegatedStakingActivity(e))
|
|
182
|
+
delegatedStakingActivities.push(normalizeDelegatedStakingActivity(e)),
|
|
183
183
|
);
|
|
184
184
|
|
|
185
185
|
return {
|
|
@@ -204,7 +204,7 @@ export const normalizeFungibleAssetActivity = (
|
|
|
204
204
|
activity: FungibleAssetActivityFragment & {
|
|
205
205
|
asset_type: string;
|
|
206
206
|
metadata: FungibleAssetMetadataFieldsFragment;
|
|
207
|
-
}
|
|
207
|
+
},
|
|
208
208
|
): FungibleAssetActivity => ({
|
|
209
209
|
ownerAddress: activity.owner_address,
|
|
210
210
|
ownerPrimaryAptosName: activity.owner_primary_aptos_name.at(0)
|
|
@@ -229,7 +229,7 @@ export const normalizeFungibleAssetActivity = (
|
|
|
229
229
|
export const normalizeTokenActivity = (
|
|
230
230
|
activity: TokenActivityFragment & {
|
|
231
231
|
current_token_data: TokenDataFieldsFragment;
|
|
232
|
-
}
|
|
232
|
+
},
|
|
233
233
|
): TokenActivity => ({
|
|
234
234
|
...normalizeBaseTokenActivity(activity),
|
|
235
235
|
primaryAptosNameFrom: activity.primary_aptos_name_from.at(0)
|
|
@@ -247,7 +247,7 @@ export const normalizeTokenActivity = (
|
|
|
247
247
|
// normalizeDelegatedStakingActivity
|
|
248
248
|
|
|
249
249
|
export const normalizeDelegatedStakingActivity = (
|
|
250
|
-
activity: DelegatedStakingActivityFragment
|
|
250
|
+
activity: DelegatedStakingActivityFragment,
|
|
251
251
|
): DelegatedStakingActivity => ({
|
|
252
252
|
delegatorAddress: activity.delegator_address,
|
|
253
253
|
eventIndex: activity.event_index,
|
|
@@ -260,7 +260,7 @@ export const normalizeDelegatedStakingActivity = (
|
|
|
260
260
|
// normalizeUserTransaction
|
|
261
261
|
|
|
262
262
|
export const normalizeUserTransaction = (
|
|
263
|
-
transaction: UserTransactionFragment
|
|
263
|
+
transaction: UserTransactionFragment,
|
|
264
264
|
): UserTransaction => ({
|
|
265
265
|
entryFunction: transaction.entry_function_id_str,
|
|
266
266
|
expirationTimestampSecs: transaction.expiration_timestamp_secs,
|
package/src/utils/objects.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { sha3_256 } from "@noble/hashes/sha3";
|
|
|
19
19
|
*/
|
|
20
20
|
export const createUserDerivedObjectAddress = (
|
|
21
21
|
source: AccountAddressInput,
|
|
22
|
-
object: AccountAddressInput
|
|
22
|
+
object: AccountAddressInput,
|
|
23
23
|
): AccountAddress => {
|
|
24
24
|
const sourceBytes = AccountAddress.from(source).bcsToBytes();
|
|
25
25
|
|
package/src/utils/tokens.ts
CHANGED
|
@@ -7,7 +7,7 @@ export function fixBadAptosUri(uri: string) {
|
|
|
7
7
|
const match =
|
|
8
8
|
uri.match(/^https:\/\/aptosnames.com\/name\/([^/]+)$/) ??
|
|
9
9
|
uri.match(
|
|
10
|
-
/^https:\/\/aptosnames.com\/api(?:\/[^/]+)?\/v\d+\/metadata\/([^/]+)
|
|
10
|
+
/^https:\/\/aptosnames.com\/api(?:\/[^/]+)?\/v\d+\/metadata\/([^/]+)/,
|
|
11
11
|
);
|
|
12
12
|
return match ? `${APTOS_NAMES_ENDPOINT}/v1/metadata/${match[1]}` : uri;
|
|
13
13
|
}
|
|
@@ -44,7 +44,7 @@ export default class TransactionParser<
|
|
|
44
44
|
*/
|
|
45
45
|
constructor(
|
|
46
46
|
public parsers: ValidateParsers<Parsers> & Parsers,
|
|
47
|
-
initial: ContextOfParsers<Parsers
|
|
47
|
+
initial: ContextOfParsers<Parsers>,
|
|
48
48
|
) {
|
|
49
49
|
this.defaultContext = initial;
|
|
50
50
|
}
|
|
@@ -99,7 +99,7 @@ export default class TransactionParser<
|
|
|
99
99
|
fungibleAssetBalanceChanges: {},
|
|
100
100
|
fungibleAssetStoreMetadata: {},
|
|
101
101
|
objectOwners: {},
|
|
102
|
-
}
|
|
102
|
+
},
|
|
103
103
|
);
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -109,7 +109,7 @@ export default class TransactionParser<
|
|
|
109
109
|
* asset store.
|
|
110
110
|
*/
|
|
111
111
|
static getBalanceChanges(
|
|
112
|
-
ctx: FungibleAssetEventParserProvides & CoinEventParserProvides
|
|
112
|
+
ctx: FungibleAssetEventParserProvides & CoinEventParserProvides,
|
|
113
113
|
) {
|
|
114
114
|
const balanceChanges: {
|
|
115
115
|
[address: string]: {
|
|
@@ -129,7 +129,7 @@ export default class TransactionParser<
|
|
|
129
129
|
coinType,
|
|
130
130
|
faAddress: getPairedMetadata(coinType),
|
|
131
131
|
};
|
|
132
|
-
})
|
|
132
|
+
}),
|
|
133
133
|
);
|
|
134
134
|
|
|
135
135
|
Object.entries(ctx.fungibleAssetBalanceChanges).forEach(
|
|
@@ -148,7 +148,7 @@ export default class TransactionParser<
|
|
|
148
148
|
|
|
149
149
|
// If the address already has a balance change for this fungible asset, add the delta to it.
|
|
150
150
|
const pairedCoinBalanceChange = Object.entries(
|
|
151
|
-
balanceChanges[address]
|
|
151
|
+
balanceChanges[address],
|
|
152
152
|
).find(([, change]) => change.faAddress === faAddress);
|
|
153
153
|
|
|
154
154
|
if (pairedCoinBalanceChange) {
|
|
@@ -164,7 +164,7 @@ export default class TransactionParser<
|
|
|
164
164
|
coinType: undefined,
|
|
165
165
|
};
|
|
166
166
|
}
|
|
167
|
-
})
|
|
167
|
+
}),
|
|
168
168
|
);
|
|
169
169
|
|
|
170
170
|
return balanceChanges;
|
|
@@ -27,7 +27,7 @@ export class CoinEventParser extends EventParser<
|
|
|
27
27
|
},
|
|
28
28
|
accountAddress: string,
|
|
29
29
|
amount: bigint,
|
|
30
|
-
opts: { creationNum: string } | { coinType: string }
|
|
30
|
+
opts: { creationNum: string } | { coinType: string },
|
|
31
31
|
) {
|
|
32
32
|
let coinType: string;
|
|
33
33
|
if ("creationNum" in opts) {
|
|
@@ -56,7 +56,7 @@ export class CoinEventParser extends EventParser<
|
|
|
56
56
|
[accountAddress: string]: { [coinType: string]: bigint };
|
|
57
57
|
};
|
|
58
58
|
},
|
|
59
|
-
event: Event
|
|
59
|
+
event: Event,
|
|
60
60
|
) {
|
|
61
61
|
switch (event.type) {
|
|
62
62
|
case "0x1::coin::DepositEvent": {
|
|
@@ -22,14 +22,14 @@ export class CoinStoreWritesetParser extends WritesetParser<
|
|
|
22
22
|
ctx: object & {
|
|
23
23
|
coinEventGuidToCoinType: { [eventGuid: string]: string };
|
|
24
24
|
},
|
|
25
|
-
change: WriteSetChange
|
|
25
|
+
change: WriteSetChange,
|
|
26
26
|
): void {
|
|
27
27
|
if (!isWriteResourceChange(change)) return;
|
|
28
28
|
|
|
29
29
|
const resource = change.data;
|
|
30
30
|
|
|
31
31
|
const coinType = resource.type.match(
|
|
32
|
-
new RegExp(`^0x1::coin::CoinStore<(.+)>$`)
|
|
32
|
+
new RegExp(`^0x1::coin::CoinStore<(.+)>$`),
|
|
33
33
|
)?.[1];
|
|
34
34
|
|
|
35
35
|
if (!coinType) return;
|
|
@@ -49,11 +49,11 @@ export class CoinStoreWritesetParser extends WritesetParser<
|
|
|
49
49
|
|
|
50
50
|
const depositEventGuid = serializeEventGuid(
|
|
51
51
|
coinResourceData.deposit_events.guid.id.addr,
|
|
52
|
-
coinResourceData.deposit_events.guid.id.creation_num
|
|
52
|
+
coinResourceData.deposit_events.guid.id.creation_num,
|
|
53
53
|
);
|
|
54
54
|
const withdrawEventGuid = serializeEventGuid(
|
|
55
55
|
coinResourceData.withdraw_events.guid.id.addr,
|
|
56
|
-
coinResourceData.withdraw_events.guid.id.creation_num
|
|
56
|
+
coinResourceData.withdraw_events.guid.id.creation_num,
|
|
57
57
|
);
|
|
58
58
|
|
|
59
59
|
ctx.coinEventGuidToCoinType[depositEventGuid] = coinType;
|