@covalenthq/client-sdk 2.2.4 → 2.2.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/README.md +6 -6
- package/dist/cjs/index.js +183 -61
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/src/services/BalanceService.d.ts +2 -2
- package/dist/cjs/src/services/TransactionService.d.ts +49 -20
- package/dist/cjs/src/utils/types/BalanceService.types.d.ts +1 -1
- package/dist/cjs/src/utils/types/TransactionService.types.d.ts +47 -2
- package/dist/esm/index.js +183 -61
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/src/services/BalanceService.d.ts +2 -2
- package/dist/esm/src/services/TransactionService.d.ts +49 -20
- package/dist/esm/src/utils/types/BalanceService.types.d.ts +1 -1
- package/dist/esm/src/utils/types/TransactionService.types.d.ts +47 -2
- package/package.json +4 -3
|
@@ -50,7 +50,7 @@ export declare class BalanceService {
|
|
|
50
50
|
* - `pageNumber`: 0-indexed page number to begin pagination.
|
|
51
51
|
*
|
|
52
52
|
*/
|
|
53
|
-
getErc20TransfersForWalletAddress(chainName: Chain, walletAddress: string, queryParamOpts
|
|
53
|
+
getErc20TransfersForWalletAddress(chainName: Chain, walletAddress: string, queryParamOpts: GetErc20TransfersForWalletAddressQueryParamOpts): AsyncIterable<GoldRushResponse<Erc20TransfersResponse>>;
|
|
54
54
|
/**
|
|
55
55
|
*
|
|
56
56
|
* Commonly used to render the transfer-in and transfer-out of a token along with historical prices from an address.
|
|
@@ -66,7 +66,7 @@ export declare class BalanceService {
|
|
|
66
66
|
* - `pageNumber`: 0-indexed page number to begin pagination.
|
|
67
67
|
*
|
|
68
68
|
*/
|
|
69
|
-
getErc20TransfersForWalletAddressByPage(chainName: Chain, walletAddress: string, queryParamOpts
|
|
69
|
+
getErc20TransfersForWalletAddressByPage(chainName: Chain, walletAddress: string, queryParamOpts: GetErc20TransfersForWalletAddressQueryParamOpts): Promise<GoldRushResponse<Erc20TransfersResponse>>;
|
|
70
70
|
/**
|
|
71
71
|
*
|
|
72
72
|
* Commonly used to get a list of all the token holders for a specified ERC20 or ERC721 token. Returns historic token holders when block-height is set (defaults to `latest`). Useful for building pie charts of token holders.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Execution } from "../utils/functions/execution";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { Chain, GoldRushResponse } from "../utils/types/Generic.types";
|
|
3
|
+
import type { EarliestTransactionsForAddressResponse, GetAllTransactionsForAddressQueryParamOpts, GetEarliestTransactionsForAddressQueryParamOpts, getPaginatedTransactionsForAddressQueryParamOpts, GetTimeBucketTransactionsForAddressQueryParamOpts, GetTransactionQueryParamOpts, getTransactionsForBlockByPageQueryParamOpts, GetTransactionSummaryQueryParamOpts, RecentTransactionsResponse, TransactionResponse, TransactionsBlockResponse, TransactionsForBlockResponse, TransactionsResponse, TransactionsSummaryResponse, TransactionsTimeBucketResponse } from "../utils/types/TransactionService.types";
|
|
4
4
|
/**
|
|
5
5
|
* Transactions API
|
|
6
6
|
*
|
|
@@ -23,6 +23,30 @@ export declare class TransactionService {
|
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
25
|
getTransaction(chainName: Chain, txHash: string, queryParamOpts?: GetTransactionQueryParamOpts): Promise<GoldRushResponse<TransactionResponse>>;
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* Commonly used to fetch the earliest and latest transactions, and the transaction count for a wallet. Calculate the age of the wallet and the time it has been idle and quickly gain insights into their engagement with web3.
|
|
29
|
+
*
|
|
30
|
+
* @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
|
|
31
|
+
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
32
|
+
* @param {GetTransactionSummaryQueryParamOpts} queryParamOpts
|
|
33
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
34
|
+
* - `withGas`: Include gas summary details. Additional charge of 1 credit when true. Response times may be impacted for wallets with millions of transactions.
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
getTransactionSummary(chainName: Chain, walletAddress: string, queryParamOpts?: GetTransactionSummaryQueryParamOpts): Promise<GoldRushResponse<TransactionsSummaryResponse>>;
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* Commonly used to fetch and render the earliest transactions involving an address. Frequently seen in wallet applications.
|
|
41
|
+
*
|
|
42
|
+
* @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
|
|
43
|
+
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
44
|
+
* @param {GetEarliestTransactionsForAddressQueryParamOpts} queryParamOpts
|
|
45
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
46
|
+
* - `noLogs`: Omit log events.
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
49
|
+
getEarliestTransactionsForAddress(chainName: Chain, walletAddress: string, queryParamOpts?: GetEarliestTransactionsForAddressQueryParamOpts): Promise<GoldRushResponse<EarliestTransactionsForAddressResponse>>;
|
|
26
50
|
/**
|
|
27
51
|
*
|
|
28
52
|
* Commonly used to fetch and render the most recent transactions involving an address. Frequently seen in wallet applications.
|
|
@@ -56,50 +80,55 @@ export declare class TransactionService {
|
|
|
56
80
|
*/
|
|
57
81
|
getAllTransactionsForAddressByPage(chainName: Chain, walletAddress: string, queryParamOpts?: GetAllTransactionsForAddressQueryParamOpts): Promise<GoldRushResponse<RecentTransactionsResponse>>;
|
|
58
82
|
/**
|
|
59
|
-
*
|
|
60
|
-
* Commonly used to fetch all transactions including their decoded log events in a block and further flag interesting wallets or transactions.
|
|
61
83
|
*
|
|
62
84
|
* @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
|
|
63
|
-
* @param {
|
|
64
|
-
* @param {
|
|
85
|
+
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
86
|
+
* @param {number} page - The requested page, 0-indexed.
|
|
87
|
+
* @param {getPaginatedTransactionsForAddressQueryParamOpts} queryParamOpts
|
|
65
88
|
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
66
89
|
* - `noLogs`: Omit log events.
|
|
90
|
+
* - `blockSignedAtAsc`: Sort the transactions in ascending chronological order. By default, it's set to `false` and returns transactions in descending chronological order.
|
|
67
91
|
*
|
|
68
92
|
*/
|
|
69
|
-
|
|
93
|
+
getPaginatedTransactionsForAddress(chainName: Chain, walletAddress: string, page: number, queryParamOpts?: getPaginatedTransactionsForAddressQueryParamOpts): Promise<GoldRushResponse<TransactionsResponse>>;
|
|
70
94
|
/**
|
|
71
|
-
*
|
|
72
|
-
* Commonly used to fetch the earliest and latest transactions, and the transaction count for a wallet. Calculate the age of the wallet and the time it has been idle and quickly gain insights into their engagement with web3.
|
|
73
95
|
*
|
|
74
96
|
* @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
|
|
75
97
|
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
76
|
-
* @param {
|
|
98
|
+
* @param {number} timeBucket - The 0-indexed 15-minute time bucket. E.g. 27 Feb 2023 05:23 GMT = 1677475383 (Unix time). 1677475383/900=1863861 timeBucket.
|
|
99
|
+
* @param {GetTimeBucketTransactionsForAddressQueryParamOpts} queryParamOpts
|
|
77
100
|
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
78
|
-
* - `
|
|
101
|
+
* - `noLogs`: Omit log events.
|
|
79
102
|
*
|
|
80
103
|
*/
|
|
81
|
-
|
|
104
|
+
getTimeBucketTransactionsForAddress(chainName: Chain, walletAddress: string, timeBucket: number, queryParamOpts?: GetTimeBucketTransactionsForAddressQueryParamOpts): Promise<GoldRushResponse<TransactionsTimeBucketResponse>>;
|
|
82
105
|
/**
|
|
106
|
+
*
|
|
107
|
+
* Commonly used to fetch all transactions including their decoded log events in a block and further flag interesting wallets or transactions.
|
|
83
108
|
*
|
|
84
109
|
* @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
|
|
85
|
-
* @param {
|
|
110
|
+
* @param {number} blockHeight - The requested block height.
|
|
86
111
|
* @param {number} page - The requested page, 0-indexed.
|
|
87
|
-
* @param {
|
|
112
|
+
* @param {getTransactionsForBlockByPageQueryParamOpts} queryParamOpts
|
|
88
113
|
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
89
114
|
* - `noLogs`: Omit log events.
|
|
90
|
-
* - `blockSignedAtAsc`: Sort the transactions in ascending chronological order. By default, it's set to `false` and returns transactions in descending chronological order.
|
|
91
115
|
*
|
|
92
116
|
*/
|
|
93
|
-
|
|
117
|
+
getTransactionsForBlockByPage(chainName: Chain, blockHeight: number | string | "latest", page: number, queryParamOpts?: getTransactionsForBlockByPageQueryParamOpts): Promise<GoldRushResponse<TransactionsBlockResponse>>;
|
|
94
118
|
/**
|
|
119
|
+
*
|
|
120
|
+
* Commonly used to fetch all transactions including their decoded log events in a block and further flag interesting wallets or transactions.
|
|
95
121
|
*
|
|
96
122
|
* @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
|
|
97
|
-
* @param {string}
|
|
98
|
-
* @param {
|
|
99
|
-
* @param {GetTimeBucketTransactionsForAddressQueryParamOpts} queryParamOpts
|
|
123
|
+
* @param {string} blockHash - The requested block hash.
|
|
124
|
+
* @param {getTransactionsForBlockByPageQueryParamOpts} queryParamOpts
|
|
100
125
|
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
101
126
|
* - `noLogs`: Omit log events.
|
|
102
127
|
*
|
|
103
128
|
*/
|
|
104
|
-
|
|
129
|
+
getTransactionsForBlock(chainName: Chain, blockHash: string, queryParamOpts?: getTransactionsForBlockByPageQueryParamOpts): Promise<GoldRushResponse<TransactionsForBlockResponse>>;
|
|
130
|
+
/**
|
|
131
|
+
* @deprecated This method has been deprecated and will be removed in future releases. Use `getPaginatedTransactionsForAddress` instead.
|
|
132
|
+
*/
|
|
133
|
+
getTransactionsForAddressV3(chainName: Chain, walletAddress: string, page: number, queryParamOpts?: getPaginatedTransactionsForAddressQueryParamOpts): Promise<GoldRushResponse<TransactionsResponse>>;
|
|
105
134
|
}
|
|
@@ -398,7 +398,7 @@ export type GetErc20TransfersForWalletAddressQueryParamOpts = Nullable<{
|
|
|
398
398
|
/** * The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`. */
|
|
399
399
|
quoteCurrency?: Quote;
|
|
400
400
|
/** * The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically. */
|
|
401
|
-
contractAddress
|
|
401
|
+
contractAddress: string;
|
|
402
402
|
/** * The block height to start from, defaults to `0`. */
|
|
403
403
|
startingBlock?: number;
|
|
404
404
|
/** * The block height to end at, defaults to current block height. */
|
|
@@ -172,6 +172,12 @@ export type TransactionsBlockResponse = Nullable<{
|
|
|
172
172
|
chain_name: ChainName;
|
|
173
173
|
/** * List of response items. */
|
|
174
174
|
items: Transaction[];
|
|
175
|
+
/** * URL link to the next and prev pages. */
|
|
176
|
+
links: PaginationLinks;
|
|
177
|
+
/** * An executable async function for the next page. */
|
|
178
|
+
next: (() => Promise<GoldRushResponse<TransactionsBlockResponse>>) | null;
|
|
179
|
+
/** * An executable async function for the prev page. */
|
|
180
|
+
prev: (() => Promise<GoldRushResponse<TransactionsBlockResponse>>) | null;
|
|
175
181
|
}>;
|
|
176
182
|
export type TransactionsSummaryResponse = Nullable<{
|
|
177
183
|
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
|
|
@@ -283,13 +289,13 @@ export type GetAllTransactionsForAddressQueryParamOpts = Nullable<{
|
|
|
283
289
|
/** * Whether to include the transaction's input data such as the Method ID. */
|
|
284
290
|
withInputData?: boolean;
|
|
285
291
|
}>;
|
|
286
|
-
export type
|
|
292
|
+
export type getTransactionsForBlockByPageQueryParamOpts = Nullable<{
|
|
287
293
|
/** * The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`. */
|
|
288
294
|
quoteCurrency?: Quote;
|
|
289
295
|
/** * Omit log events. */
|
|
290
296
|
noLogs?: boolean;
|
|
291
297
|
}>;
|
|
292
|
-
export type
|
|
298
|
+
export type getPaginatedTransactionsForAddressQueryParamOpts = Nullable<{
|
|
293
299
|
/** * The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`. */
|
|
294
300
|
quoteCurrency?: Quote;
|
|
295
301
|
/** * Omit log events. */
|
|
@@ -345,3 +351,42 @@ export type InputData = Nullable<{
|
|
|
345
351
|
/** * The first 4 bytes of the invoked smart contract function signature. Used to identify the function being called in the contract. */
|
|
346
352
|
method_id: string;
|
|
347
353
|
}>;
|
|
354
|
+
export type GetEarliestTransactionsForAddressQueryParamOpts = Nullable<{
|
|
355
|
+
/** * The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`. */
|
|
356
|
+
quoteCurrency?: Quote;
|
|
357
|
+
/** * Omit log events. */
|
|
358
|
+
noLogs?: boolean;
|
|
359
|
+
}>;
|
|
360
|
+
export type EarliestTransactionsForAddressResponse = Nullable<{
|
|
361
|
+
/** * The requested address. */
|
|
362
|
+
address: string;
|
|
363
|
+
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
|
|
364
|
+
updated_at: Date;
|
|
365
|
+
/** * The requested quote currency eg: `USD`. */
|
|
366
|
+
quote_currency: Quote;
|
|
367
|
+
/** * The requested chain ID eg: `1`. */
|
|
368
|
+
chain_id: ChainID;
|
|
369
|
+
/** * The requested chain name eg: `eth-mainnet`. */
|
|
370
|
+
chain_name: ChainName;
|
|
371
|
+
complete: boolean;
|
|
372
|
+
/** * The current bucket of the response. */
|
|
373
|
+
current_bucket: number;
|
|
374
|
+
/** * URL link to the next and prev pages. */
|
|
375
|
+
links: PaginationLinks;
|
|
376
|
+
/** * List of response items. */
|
|
377
|
+
items: Transaction[];
|
|
378
|
+
/** * An executable async function for the prev page. */
|
|
379
|
+
prev: (() => Promise<GoldRushResponse<EarliestTransactionsForAddressResponse>>) | null;
|
|
380
|
+
/** * An executable async function for the next page. */
|
|
381
|
+
next: (() => Promise<GoldRushResponse<EarliestTransactionsForAddressResponse>>) | null;
|
|
382
|
+
}>;
|
|
383
|
+
export type TransactionsForBlockResponse = Nullable<{
|
|
384
|
+
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
|
|
385
|
+
updated_at: Date;
|
|
386
|
+
/** * The requested chain ID eg: `1`. */
|
|
387
|
+
chain_id: ChainID;
|
|
388
|
+
/** * The requested chain name eg: `eth-mainnet`. */
|
|
389
|
+
chain_name: ChainName;
|
|
390
|
+
/** * List of response items. */
|
|
391
|
+
items: Transaction[];
|
|
392
|
+
}>;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var version = "2.2.
|
|
1
|
+
var version = "2.2.5";
|
|
2
2
|
|
|
3
3
|
const bigIntParser = (val) => {
|
|
4
4
|
if (val === null || val === undefined) {
|
|
@@ -2452,6 +2452,119 @@ class TransactionService {
|
|
|
2452
2452
|
};
|
|
2453
2453
|
return await this.execution.execute(endpoint, parseData);
|
|
2454
2454
|
}
|
|
2455
|
+
/**
|
|
2456
|
+
*
|
|
2457
|
+
* Commonly used to fetch the earliest and latest transactions, and the transaction count for a wallet. Calculate the age of the wallet and the time it has been idle and quickly gain insights into their engagement with web3.
|
|
2458
|
+
*
|
|
2459
|
+
* @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
|
|
2460
|
+
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2461
|
+
* @param {GetTransactionSummaryQueryParamOpts} queryParamOpts
|
|
2462
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
2463
|
+
* - `withGas`: Include gas summary details. Additional charge of 1 credit when true. Response times may be impacted for wallets with millions of transactions.
|
|
2464
|
+
*
|
|
2465
|
+
*/
|
|
2466
|
+
async getTransactionSummary(chainName, walletAddress, queryParamOpts) {
|
|
2467
|
+
const endpoint = endpointGenerator(`${chainName}/address/${walletAddress}/transactions_summary`, [
|
|
2468
|
+
{
|
|
2469
|
+
key: "quote-currency",
|
|
2470
|
+
value: queryParamOpts?.quoteCurrency,
|
|
2471
|
+
},
|
|
2472
|
+
{
|
|
2473
|
+
key: "with-gas",
|
|
2474
|
+
value: queryParamOpts?.withGas,
|
|
2475
|
+
},
|
|
2476
|
+
]);
|
|
2477
|
+
const parseData = (data) => {
|
|
2478
|
+
if (data.data) {
|
|
2479
|
+
data.data.updated_at = data.data.updated_at
|
|
2480
|
+
? new Date(data.data.updated_at)
|
|
2481
|
+
: null;
|
|
2482
|
+
data.data.items = data.data.items
|
|
2483
|
+
? data.data.items.map((txsItem) => ({
|
|
2484
|
+
...txsItem,
|
|
2485
|
+
earliest_transaction: {
|
|
2486
|
+
...txsItem.earliest_transaction,
|
|
2487
|
+
block_signed_at: txsItem?.earliest_transaction?.block_signed_at
|
|
2488
|
+
? new Date(txsItem.earliest_transaction.block_signed_at)
|
|
2489
|
+
: null,
|
|
2490
|
+
},
|
|
2491
|
+
latest_transaction: {
|
|
2492
|
+
...txsItem.latest_transaction,
|
|
2493
|
+
block_signed_at: txsItem?.latest_transaction?.block_signed_at
|
|
2494
|
+
? new Date(txsItem?.latest_transaction?.block_signed_at)
|
|
2495
|
+
: null,
|
|
2496
|
+
},
|
|
2497
|
+
// ? API vs docs non-consistent
|
|
2498
|
+
// gas_summary: {
|
|
2499
|
+
// ...txsItem.gas_summary,
|
|
2500
|
+
// total_fees_paid: bigIntParser(
|
|
2501
|
+
// txsItem.gas_summary.total_fees_paid
|
|
2502
|
+
// ),
|
|
2503
|
+
// },
|
|
2504
|
+
}))
|
|
2505
|
+
: null;
|
|
2506
|
+
}
|
|
2507
|
+
return data;
|
|
2508
|
+
};
|
|
2509
|
+
return await this.execution.execute(endpoint, parseData);
|
|
2510
|
+
}
|
|
2511
|
+
/**
|
|
2512
|
+
*
|
|
2513
|
+
* Commonly used to fetch and render the earliest transactions involving an address. Frequently seen in wallet applications.
|
|
2514
|
+
*
|
|
2515
|
+
* @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
|
|
2516
|
+
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2517
|
+
* @param {GetEarliestTransactionsForAddressQueryParamOpts} queryParamOpts
|
|
2518
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
2519
|
+
* - `noLogs`: Omit log events.
|
|
2520
|
+
*
|
|
2521
|
+
*/
|
|
2522
|
+
async getEarliestTransactionsForAddress(chainName, walletAddress, queryParamOpts) {
|
|
2523
|
+
const searchParams = [
|
|
2524
|
+
{
|
|
2525
|
+
key: "quote-currency",
|
|
2526
|
+
value: queryParamOpts?.quoteCurrency,
|
|
2527
|
+
},
|
|
2528
|
+
{
|
|
2529
|
+
key: "no-logs",
|
|
2530
|
+
value: queryParamOpts?.noLogs,
|
|
2531
|
+
},
|
|
2532
|
+
];
|
|
2533
|
+
const endpoint = endpointGenerator(`${chainName}/bulk/transactions/${walletAddress}`, searchParams);
|
|
2534
|
+
const parseData = (data) => {
|
|
2535
|
+
if (data.data) {
|
|
2536
|
+
data.data.prev = data.data?.links?.prev
|
|
2537
|
+
? async () => this.execution.execute(endpointGenerator(data.data?.links?.prev, searchParams), parseData)
|
|
2538
|
+
: null;
|
|
2539
|
+
data.data.next = data.data?.links?.next
|
|
2540
|
+
? async () => this.execution.execute(endpointGenerator(data.data?.links?.next, searchParams), parseData)
|
|
2541
|
+
: null;
|
|
2542
|
+
data.data.updated_at = data.data.updated_at
|
|
2543
|
+
? new Date(data.data.updated_at)
|
|
2544
|
+
: null;
|
|
2545
|
+
data.data.items = data.data.items
|
|
2546
|
+
? data.data.items.map((txItem) => ({
|
|
2547
|
+
...txItem,
|
|
2548
|
+
value: bigIntParser(txItem.value),
|
|
2549
|
+
fees_paid: bigIntParser(txItem.fees_paid),
|
|
2550
|
+
block_signed_at: txItem.block_signed_at
|
|
2551
|
+
? new Date(txItem.block_signed_at)
|
|
2552
|
+
: null,
|
|
2553
|
+
log_events: txItem.log_events
|
|
2554
|
+
? txItem.log_events.map((logItem) => ({
|
|
2555
|
+
...logItem,
|
|
2556
|
+
block_signed_at: logItem.block_signed_at
|
|
2557
|
+
? new Date(logItem.block_signed_at)
|
|
2558
|
+
: null,
|
|
2559
|
+
}))
|
|
2560
|
+
: null,
|
|
2561
|
+
}))
|
|
2562
|
+
: null;
|
|
2563
|
+
}
|
|
2564
|
+
return data;
|
|
2565
|
+
};
|
|
2566
|
+
return await this.execution.execute(endpoint, parseData);
|
|
2567
|
+
}
|
|
2455
2568
|
/**
|
|
2456
2569
|
*
|
|
2457
2570
|
* Commonly used to fetch and render the most recent transactions involving an address. Frequently seen in wallet applications.
|
|
@@ -2602,18 +2715,18 @@ class TransactionService {
|
|
|
2602
2715
|
return await this.execution.execute(endpoint, parseData);
|
|
2603
2716
|
}
|
|
2604
2717
|
/**
|
|
2605
|
-
*
|
|
2606
|
-
* Commonly used to fetch all transactions including their decoded log events in a block and further flag interesting wallets or transactions.
|
|
2607
2718
|
*
|
|
2608
2719
|
* @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
|
|
2609
|
-
* @param {
|
|
2610
|
-
* @param {
|
|
2720
|
+
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2721
|
+
* @param {number} page - The requested page, 0-indexed.
|
|
2722
|
+
* @param {getPaginatedTransactionsForAddressQueryParamOpts} queryParamOpts
|
|
2611
2723
|
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
2612
2724
|
* - `noLogs`: Omit log events.
|
|
2725
|
+
* - `blockSignedAtAsc`: Sort the transactions in ascending chronological order. By default, it's set to `false` and returns transactions in descending chronological order.
|
|
2613
2726
|
*
|
|
2614
2727
|
*/
|
|
2615
|
-
async
|
|
2616
|
-
const
|
|
2728
|
+
async getPaginatedTransactionsForAddress(chainName, walletAddress, page, queryParamOpts) {
|
|
2729
|
+
const searchParams = [
|
|
2617
2730
|
{
|
|
2618
2731
|
key: "quote-currency",
|
|
2619
2732
|
value: queryParamOpts?.quoteCurrency,
|
|
@@ -2622,9 +2735,20 @@ class TransactionService {
|
|
|
2622
2735
|
key: "no-logs",
|
|
2623
2736
|
value: queryParamOpts?.noLogs,
|
|
2624
2737
|
},
|
|
2625
|
-
|
|
2738
|
+
{
|
|
2739
|
+
key: "block-signed-at-asc",
|
|
2740
|
+
value: queryParamOpts?.blockSignedAtAsc,
|
|
2741
|
+
},
|
|
2742
|
+
];
|
|
2743
|
+
const endpoint = endpointGenerator(`${chainName}/address/${walletAddress}/transactions_v3/page/${page}`, searchParams);
|
|
2626
2744
|
const parseData = (data) => {
|
|
2627
2745
|
if (data.data) {
|
|
2746
|
+
data.data.prev = data.data?.links?.prev
|
|
2747
|
+
? async () => this.execution.execute(endpointGenerator(data.data?.links?.prev, searchParams), parseData)
|
|
2748
|
+
: null;
|
|
2749
|
+
data.data.next = data.data?.links?.next
|
|
2750
|
+
? async () => this.execution.execute(endpointGenerator(data.data?.links?.next, searchParams), parseData)
|
|
2751
|
+
: null;
|
|
2628
2752
|
data.data.updated_at = data.data.updated_at
|
|
2629
2753
|
? new Date(data.data.updated_at)
|
|
2630
2754
|
: null;
|
|
@@ -2652,54 +2776,54 @@ class TransactionService {
|
|
|
2652
2776
|
return await this.execution.execute(endpoint, parseData);
|
|
2653
2777
|
}
|
|
2654
2778
|
/**
|
|
2655
|
-
*
|
|
2656
|
-
* Commonly used to fetch the earliest and latest transactions, and the transaction count for a wallet. Calculate the age of the wallet and the time it has been idle and quickly gain insights into their engagement with web3.
|
|
2657
2779
|
*
|
|
2658
2780
|
* @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
|
|
2659
2781
|
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2660
|
-
* @param {
|
|
2782
|
+
* @param {number} timeBucket - The 0-indexed 15-minute time bucket. E.g. 27 Feb 2023 05:23 GMT = 1677475383 (Unix time). 1677475383/900=1863861 timeBucket.
|
|
2783
|
+
* @param {GetTimeBucketTransactionsForAddressQueryParamOpts} queryParamOpts
|
|
2661
2784
|
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
2662
|
-
* - `
|
|
2785
|
+
* - `noLogs`: Omit log events.
|
|
2663
2786
|
*
|
|
2664
2787
|
*/
|
|
2665
|
-
async
|
|
2666
|
-
const
|
|
2788
|
+
async getTimeBucketTransactionsForAddress(chainName, walletAddress, timeBucket, queryParamOpts) {
|
|
2789
|
+
const searchParams = [
|
|
2667
2790
|
{
|
|
2668
2791
|
key: "quote-currency",
|
|
2669
2792
|
value: queryParamOpts?.quoteCurrency,
|
|
2670
2793
|
},
|
|
2671
2794
|
{
|
|
2672
|
-
key: "
|
|
2673
|
-
value: queryParamOpts?.
|
|
2795
|
+
key: "no-logs",
|
|
2796
|
+
value: queryParamOpts?.noLogs,
|
|
2674
2797
|
},
|
|
2675
|
-
]
|
|
2798
|
+
];
|
|
2799
|
+
const endpoint = endpointGenerator(`${chainName}/bulk/transactions/${walletAddress}/${timeBucket}`, searchParams);
|
|
2676
2800
|
const parseData = (data) => {
|
|
2677
2801
|
if (data.data) {
|
|
2802
|
+
data.data.prev = data.data?.links?.prev
|
|
2803
|
+
? async () => this.execution.execute(endpointGenerator(data.data?.links?.prev, searchParams), parseData)
|
|
2804
|
+
: null;
|
|
2805
|
+
data.data.next = data.data?.links?.next
|
|
2806
|
+
? async () => this.execution.execute(endpointGenerator(data.data?.links?.next, searchParams), parseData)
|
|
2807
|
+
: null;
|
|
2678
2808
|
data.data.updated_at = data.data.updated_at
|
|
2679
2809
|
? new Date(data.data.updated_at)
|
|
2680
2810
|
: null;
|
|
2681
2811
|
data.data.items = data.data.items
|
|
2682
|
-
? data.data.items.map((
|
|
2683
|
-
...
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
// gas_summary: {
|
|
2698
|
-
// ...txsItem.gas_summary,
|
|
2699
|
-
// total_fees_paid: bigIntParser(
|
|
2700
|
-
// txsItem.gas_summary.total_fees_paid
|
|
2701
|
-
// ),
|
|
2702
|
-
// },
|
|
2812
|
+
? data.data.items.map((txItem) => ({
|
|
2813
|
+
...txItem,
|
|
2814
|
+
value: bigIntParser(txItem.value),
|
|
2815
|
+
fees_paid: bigIntParser(txItem.fees_paid),
|
|
2816
|
+
block_signed_at: txItem.block_signed_at
|
|
2817
|
+
? new Date(txItem.block_signed_at)
|
|
2818
|
+
: null,
|
|
2819
|
+
log_events: txItem.log_events
|
|
2820
|
+
? txItem.log_events.map((logItem) => ({
|
|
2821
|
+
...logItem,
|
|
2822
|
+
block_signed_at: logItem.block_signed_at
|
|
2823
|
+
? new Date(logItem.block_signed_at)
|
|
2824
|
+
: null,
|
|
2825
|
+
}))
|
|
2826
|
+
: null,
|
|
2703
2827
|
}))
|
|
2704
2828
|
: null;
|
|
2705
2829
|
}
|
|
@@ -2708,17 +2832,18 @@ class TransactionService {
|
|
|
2708
2832
|
return await this.execution.execute(endpoint, parseData);
|
|
2709
2833
|
}
|
|
2710
2834
|
/**
|
|
2835
|
+
*
|
|
2836
|
+
* Commonly used to fetch all transactions including their decoded log events in a block and further flag interesting wallets or transactions.
|
|
2711
2837
|
*
|
|
2712
2838
|
* @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
|
|
2713
|
-
* @param {
|
|
2839
|
+
* @param {number} blockHeight - The requested block height.
|
|
2714
2840
|
* @param {number} page - The requested page, 0-indexed.
|
|
2715
|
-
* @param {
|
|
2841
|
+
* @param {getTransactionsForBlockByPageQueryParamOpts} queryParamOpts
|
|
2716
2842
|
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
2717
2843
|
* - `noLogs`: Omit log events.
|
|
2718
|
-
* - `blockSignedAtAsc`: Sort the transactions in ascending chronological order. By default, it's set to `false` and returns transactions in descending chronological order.
|
|
2719
2844
|
*
|
|
2720
2845
|
*/
|
|
2721
|
-
async
|
|
2846
|
+
async getTransactionsForBlockByPage(chainName, blockHeight, page, queryParamOpts) {
|
|
2722
2847
|
const searchParams = [
|
|
2723
2848
|
{
|
|
2724
2849
|
key: "quote-currency",
|
|
@@ -2728,23 +2853,19 @@ class TransactionService {
|
|
|
2728
2853
|
key: "no-logs",
|
|
2729
2854
|
value: queryParamOpts?.noLogs,
|
|
2730
2855
|
},
|
|
2731
|
-
{
|
|
2732
|
-
key: "block-signed-at-asc",
|
|
2733
|
-
value: queryParamOpts?.blockSignedAtAsc,
|
|
2734
|
-
},
|
|
2735
2856
|
];
|
|
2736
|
-
const endpoint = endpointGenerator(`${chainName}/
|
|
2857
|
+
const endpoint = endpointGenerator(`${chainName}/block/${blockHeight}/transactions_v3/page/${page}`, searchParams);
|
|
2737
2858
|
const parseData = (data) => {
|
|
2738
2859
|
if (data.data) {
|
|
2860
|
+
data.data.updated_at = data.data.updated_at
|
|
2861
|
+
? new Date(data.data.updated_at)
|
|
2862
|
+
: null;
|
|
2739
2863
|
data.data.prev = data.data?.links?.prev
|
|
2740
2864
|
? async () => this.execution.execute(endpointGenerator(data.data?.links?.prev, searchParams), parseData)
|
|
2741
2865
|
: null;
|
|
2742
2866
|
data.data.next = data.data?.links?.next
|
|
2743
2867
|
? async () => this.execution.execute(endpointGenerator(data.data?.links?.next, searchParams), parseData)
|
|
2744
2868
|
: null;
|
|
2745
|
-
data.data.updated_at = data.data.updated_at
|
|
2746
|
-
? new Date(data.data.updated_at)
|
|
2747
|
-
: null;
|
|
2748
2869
|
data.data.items = data.data.items
|
|
2749
2870
|
? data.data.items.map((txItem) => ({
|
|
2750
2871
|
...txItem,
|
|
@@ -2769,16 +2890,17 @@ class TransactionService {
|
|
|
2769
2890
|
return await this.execution.execute(endpoint, parseData);
|
|
2770
2891
|
}
|
|
2771
2892
|
/**
|
|
2893
|
+
*
|
|
2894
|
+
* Commonly used to fetch all transactions including their decoded log events in a block and further flag interesting wallets or transactions.
|
|
2772
2895
|
*
|
|
2773
2896
|
* @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
|
|
2774
|
-
* @param {string}
|
|
2775
|
-
* @param {
|
|
2776
|
-
* @param {GetTimeBucketTransactionsForAddressQueryParamOpts} queryParamOpts
|
|
2897
|
+
* @param {string} blockHash - The requested block hash.
|
|
2898
|
+
* @param {getTransactionsForBlockByPageQueryParamOpts} queryParamOpts
|
|
2777
2899
|
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
2778
2900
|
* - `noLogs`: Omit log events.
|
|
2779
2901
|
*
|
|
2780
2902
|
*/
|
|
2781
|
-
async
|
|
2903
|
+
async getTransactionsForBlock(chainName, blockHash, queryParamOpts) {
|
|
2782
2904
|
const searchParams = [
|
|
2783
2905
|
{
|
|
2784
2906
|
key: "quote-currency",
|
|
@@ -2789,15 +2911,9 @@ class TransactionService {
|
|
|
2789
2911
|
value: queryParamOpts?.noLogs,
|
|
2790
2912
|
},
|
|
2791
2913
|
];
|
|
2792
|
-
const endpoint = endpointGenerator(`${chainName}/
|
|
2914
|
+
const endpoint = endpointGenerator(`${chainName}/block_hash/${blockHash}/transactions_v3`, searchParams);
|
|
2793
2915
|
const parseData = (data) => {
|
|
2794
2916
|
if (data.data) {
|
|
2795
|
-
data.data.prev = data.data?.links?.prev
|
|
2796
|
-
? async () => this.execution.execute(endpointGenerator(data.data?.links?.prev, searchParams), parseData)
|
|
2797
|
-
: null;
|
|
2798
|
-
data.data.next = data.data?.links?.next
|
|
2799
|
-
? async () => this.execution.execute(endpointGenerator(data.data?.links?.next, searchParams), parseData)
|
|
2800
|
-
: null;
|
|
2801
2917
|
data.data.updated_at = data.data.updated_at
|
|
2802
2918
|
? new Date(data.data.updated_at)
|
|
2803
2919
|
: null;
|
|
@@ -2824,6 +2940,12 @@ class TransactionService {
|
|
|
2824
2940
|
};
|
|
2825
2941
|
return await this.execution.execute(endpoint, parseData);
|
|
2826
2942
|
}
|
|
2943
|
+
/**
|
|
2944
|
+
* @deprecated This method has been deprecated and will be removed in future releases. Use `getPaginatedTransactionsForAddress` instead.
|
|
2945
|
+
*/
|
|
2946
|
+
async getTransactionsForAddressV3(chainName, walletAddress, page, queryParamOpts) {
|
|
2947
|
+
return this.getPaginatedTransactionsForAddress(chainName, walletAddress, page, queryParamOpts);
|
|
2948
|
+
}
|
|
2827
2949
|
}
|
|
2828
2950
|
|
|
2829
2951
|
async function debugOutput(settings, ...content) {
|