@covalenthq/client-sdk 0.7.2 → 0.7.3
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 +2 -1
- package/dist/cjs/index.js +255 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/services/CovalentClient.d.ts +2 -2
- package/dist/cjs/services/TransactionService.d.ts +45 -0
- package/dist/cjs/util/Chains.d.ts +19 -1
- package/dist/cjs/util/types/TransactionServiceTypes.d.ts +18 -0
- package/dist/es/index.js +255 -3
- package/dist/es/index.js.map +1 -1
- package/dist/es/services/CovalentClient.d.ts +2 -2
- package/dist/es/services/TransactionService.d.ts +45 -0
- package/dist/es/util/Chains.d.ts +19 -1
- package/dist/es/util/types/TransactionServiceTypes.d.ts +18 -0
- package/dist/esm/index.js +255 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/services/CovalentClient.d.ts +2 -2
- package/dist/esm/services/TransactionService.d.ts +45 -0
- package/dist/esm/util/Chains.d.ts +19 -1
- package/dist/esm/util/types/TransactionServiceTypes.d.ts +18 -0
- package/dist/services/CovalentClient.d.ts +2 -2
- package/dist/services/CovalentClient.js +1 -1
- package/dist/services/TransactionService.d.ts +45 -0
- package/dist/services/TransactionService.js +236 -2
- package/dist/services/TransactionService.js.map +1 -1
- package/dist/util/Chains.d.ts +19 -1
- package/dist/util/Chains.js +18 -0
- package/dist/util/Chains.js.map +1 -1
- package/dist/util/types/TransactionServiceTypes.d.ts +18 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -181,8 +181,9 @@ The `TransactionService` class refers to the [transactions API endpoints](https:
|
|
|
181
181
|
- `getTransaction()`: Fetch and render a single transaction including its decoded log events. Additionally return semantically decoded information for DEX trades, lending and NFT sales.
|
|
182
182
|
- `getTransactionsForBlock()`: Fetch all transactions including their decoded log events in a block and further flag interesting wallets or transactions.
|
|
183
183
|
- `getTransactionSummary()`: 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.
|
|
184
|
+
- `getTimeBucketTransactionsForAddress()`: Fetch all transactions including their decoded log events in a 15-minute time bucket interval.
|
|
184
185
|
|
|
185
|
-
The functions `getAllTransactionsForAddressByPage()` and `
|
|
186
|
+
The functions `getAllTransactionsForAddressByPage()`, `getTransactionsForAddressV3()`, and `getTimeBucketTransactionsForAddress()` have been enhanced with the introduction of `next()` and `prev()` support functions. These functions facilitate a smoother transition for developers navigating through our links object, which includes `prev` and `next` fields. Instead of requiring developers to manually extract values from these fields and create JavaScript API fetch calls for the URL values, the new `next()` and `prev()` functions provide a streamlined approach, allowing developers to simulate this behavior more efficiently.
|
|
186
187
|
|
|
187
188
|
```ts
|
|
188
189
|
import { CovalentClient } from "@covalenthq/client-sdk";
|
package/dist/cjs/index.js
CHANGED
|
@@ -4789,6 +4789,155 @@ class TransactionsResponse {
|
|
|
4789
4789
|
}
|
|
4790
4790
|
}
|
|
4791
4791
|
}
|
|
4792
|
+
class TransactionsTimeBucketResponse {
|
|
4793
|
+
constructor(data, _debug, _apiKey, _threadCount, _urlParams) {
|
|
4794
|
+
this._debug = _debug;
|
|
4795
|
+
this._apiKey = _apiKey;
|
|
4796
|
+
this._threadCount = _threadCount;
|
|
4797
|
+
this._urlParams = _urlParams;
|
|
4798
|
+
this.address = data.address;
|
|
4799
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
|
|
4800
|
+
this.quote_currency = data.quote_currency;
|
|
4801
|
+
this.chain_id = data.chain_id;
|
|
4802
|
+
this.chain_name = data.chain_name;
|
|
4803
|
+
this.complete = data.complete;
|
|
4804
|
+
this.current_bucket = data.current_bucket;
|
|
4805
|
+
this.links = data.links && data.links !== null ? new PaginationLinks(data.links) : null;
|
|
4806
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new Transaction(itemData)) : null;
|
|
4807
|
+
}
|
|
4808
|
+
async prev() {
|
|
4809
|
+
let success = false;
|
|
4810
|
+
let data;
|
|
4811
|
+
let response;
|
|
4812
|
+
const backoff = new ExponentialBackoff(this._apiKey, this._debug);
|
|
4813
|
+
const LIMIT = pLimit$1(this._threadCount);
|
|
4814
|
+
while (!success) {
|
|
4815
|
+
try {
|
|
4816
|
+
let startTime;
|
|
4817
|
+
if (this._debug) {
|
|
4818
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
4819
|
+
}
|
|
4820
|
+
if (this.links.prev === null) {
|
|
4821
|
+
success = true;
|
|
4822
|
+
return {
|
|
4823
|
+
data: null,
|
|
4824
|
+
error: true,
|
|
4825
|
+
error_code: 400,
|
|
4826
|
+
error_message: "Invalid URL: URL link cannot be null"
|
|
4827
|
+
};
|
|
4828
|
+
}
|
|
4829
|
+
response = await LIMIT(() => fetch(`${this.links.prev}?${this._urlParams}`, {
|
|
4830
|
+
headers: {
|
|
4831
|
+
"Authorization": `Bearer ${this._apiKey}`,
|
|
4832
|
+
"X-Requested-With": userAgent
|
|
4833
|
+
}
|
|
4834
|
+
}));
|
|
4835
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
4836
|
+
if (response.status === null || response.status === 429) {
|
|
4837
|
+
try {
|
|
4838
|
+
data = await LIMIT(() => backoff.backOff(response.url));
|
|
4839
|
+
}
|
|
4840
|
+
catch (error) {
|
|
4841
|
+
success = true;
|
|
4842
|
+
return {
|
|
4843
|
+
data: null,
|
|
4844
|
+
error: true,
|
|
4845
|
+
error_code: response.status ?? 429,
|
|
4846
|
+
error_message: error.message
|
|
4847
|
+
};
|
|
4848
|
+
}
|
|
4849
|
+
}
|
|
4850
|
+
else {
|
|
4851
|
+
data = await response.json();
|
|
4852
|
+
}
|
|
4853
|
+
const dataClass = new TransactionsTimeBucketResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams);
|
|
4854
|
+
checkAndModifyResponse(dataClass);
|
|
4855
|
+
success = true;
|
|
4856
|
+
return {
|
|
4857
|
+
data: dataClass,
|
|
4858
|
+
error: data.error,
|
|
4859
|
+
error_code: data ? data.error_code : response.status,
|
|
4860
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4861
|
+
};
|
|
4862
|
+
}
|
|
4863
|
+
catch (error) {
|
|
4864
|
+
success = true;
|
|
4865
|
+
return {
|
|
4866
|
+
data: null,
|
|
4867
|
+
error: true,
|
|
4868
|
+
error_code: data ? data.error_code : response.status,
|
|
4869
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4870
|
+
};
|
|
4871
|
+
}
|
|
4872
|
+
}
|
|
4873
|
+
}
|
|
4874
|
+
async next() {
|
|
4875
|
+
let success = false;
|
|
4876
|
+
let data;
|
|
4877
|
+
let response;
|
|
4878
|
+
const backoff = new ExponentialBackoff(this._apiKey, this._debug);
|
|
4879
|
+
const LIMIT = pLimit$1(this._threadCount);
|
|
4880
|
+
while (!success) {
|
|
4881
|
+
try {
|
|
4882
|
+
let startTime;
|
|
4883
|
+
if (this._debug) {
|
|
4884
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
4885
|
+
}
|
|
4886
|
+
if (this.links.next === null) {
|
|
4887
|
+
success = true;
|
|
4888
|
+
return {
|
|
4889
|
+
data: null,
|
|
4890
|
+
error: true,
|
|
4891
|
+
error_code: 400,
|
|
4892
|
+
error_message: "Invalid URL: URL link cannot be null"
|
|
4893
|
+
};
|
|
4894
|
+
}
|
|
4895
|
+
response = await LIMIT(() => fetch(`${this.links.next}?${this._urlParams}`, {
|
|
4896
|
+
headers: {
|
|
4897
|
+
"Authorization": `Bearer ${this._apiKey}`,
|
|
4898
|
+
"X-Requested-With": userAgent
|
|
4899
|
+
}
|
|
4900
|
+
}));
|
|
4901
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
4902
|
+
if (response.status === null || response.status === 429) {
|
|
4903
|
+
try {
|
|
4904
|
+
data = await LIMIT(() => backoff.backOff(response.url));
|
|
4905
|
+
}
|
|
4906
|
+
catch (error) {
|
|
4907
|
+
success = true;
|
|
4908
|
+
return {
|
|
4909
|
+
data: null,
|
|
4910
|
+
error: true,
|
|
4911
|
+
error_code: response.status ?? 429,
|
|
4912
|
+
error_message: error.message
|
|
4913
|
+
};
|
|
4914
|
+
}
|
|
4915
|
+
}
|
|
4916
|
+
else {
|
|
4917
|
+
data = await response.json();
|
|
4918
|
+
}
|
|
4919
|
+
const dataClass = new TransactionsTimeBucketResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams);
|
|
4920
|
+
checkAndModifyResponse(dataClass);
|
|
4921
|
+
success = true;
|
|
4922
|
+
return {
|
|
4923
|
+
data: dataClass,
|
|
4924
|
+
error: data.error,
|
|
4925
|
+
error_code: data ? data.error_code : response.status,
|
|
4926
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4927
|
+
};
|
|
4928
|
+
}
|
|
4929
|
+
catch (error) {
|
|
4930
|
+
success = true;
|
|
4931
|
+
return {
|
|
4932
|
+
data: null,
|
|
4933
|
+
error: true,
|
|
4934
|
+
error_code: data ? data.error_code : response.status,
|
|
4935
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4936
|
+
};
|
|
4937
|
+
}
|
|
4938
|
+
}
|
|
4939
|
+
}
|
|
4940
|
+
}
|
|
4792
4941
|
/**
|
|
4793
4942
|
* Transactions APIs
|
|
4794
4943
|
*
|
|
@@ -5293,12 +5442,12 @@ class TransactionService {
|
|
|
5293
5442
|
if (this.debug) {
|
|
5294
5443
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
5295
5444
|
}
|
|
5296
|
-
response = await fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v3/page/${page}/?${urlParams}`, {
|
|
5445
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v3/page/${page}/?${urlParams}`, {
|
|
5297
5446
|
headers: {
|
|
5298
5447
|
"Authorization": `Bearer ${this.apiKey}`,
|
|
5299
5448
|
"X-Requested-With": userAgent
|
|
5300
5449
|
}
|
|
5301
|
-
});
|
|
5450
|
+
}));
|
|
5302
5451
|
debugOutput(response.url, response.status ?? 429, startTime);
|
|
5303
5452
|
if (response.status === null || response.status === 429) {
|
|
5304
5453
|
try {
|
|
@@ -5338,6 +5487,91 @@ class TransactionService {
|
|
|
5338
5487
|
}
|
|
5339
5488
|
}
|
|
5340
5489
|
}
|
|
5490
|
+
/**
|
|
5491
|
+
*
|
|
5492
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
5493
|
+
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
5494
|
+
* @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.
|
|
5495
|
+
* @param {GetTimeBucketTransactionsForAddressQueryParamOpts} queryParamOpts
|
|
5496
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
5497
|
+
* - `noLogs`: Omit log events.
|
|
5498
|
+
* - `withSafe`: Include safe details.
|
|
5499
|
+
*
|
|
5500
|
+
*/
|
|
5501
|
+
async getTimeBucketTransactionsForAddress(chainName, walletAddress, timeBucket, queryParamOpts) {
|
|
5502
|
+
let success = false;
|
|
5503
|
+
let data;
|
|
5504
|
+
let response;
|
|
5505
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
5506
|
+
while (!success) {
|
|
5507
|
+
try {
|
|
5508
|
+
const urlParams = new URLSearchParams();
|
|
5509
|
+
if (!this.is_key_valid) {
|
|
5510
|
+
return {
|
|
5511
|
+
data: null,
|
|
5512
|
+
error: true,
|
|
5513
|
+
error_code: 401,
|
|
5514
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
5515
|
+
};
|
|
5516
|
+
}
|
|
5517
|
+
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
5518
|
+
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
5519
|
+
}
|
|
5520
|
+
if (queryParamOpts?.noLogs !== undefined) {
|
|
5521
|
+
urlParams.append("no-logs", queryParamOpts?.noLogs.toString());
|
|
5522
|
+
}
|
|
5523
|
+
if (queryParamOpts?.withSafe !== undefined) {
|
|
5524
|
+
urlParams.append("with-safe", queryParamOpts?.withSafe.toString());
|
|
5525
|
+
}
|
|
5526
|
+
let startTime;
|
|
5527
|
+
if (this.debug) {
|
|
5528
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
5529
|
+
}
|
|
5530
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/bulk/transactions/${walletAddress}/${timeBucket}/?${urlParams}`, {
|
|
5531
|
+
headers: {
|
|
5532
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
5533
|
+
"X-Requested-With": userAgent
|
|
5534
|
+
}
|
|
5535
|
+
}));
|
|
5536
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
5537
|
+
if (response.status === null || response.status === 429) {
|
|
5538
|
+
try {
|
|
5539
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
5540
|
+
}
|
|
5541
|
+
catch (error) {
|
|
5542
|
+
success = true;
|
|
5543
|
+
return {
|
|
5544
|
+
data: null,
|
|
5545
|
+
error: true,
|
|
5546
|
+
error_code: response.status ?? 429,
|
|
5547
|
+
error_message: error.message
|
|
5548
|
+
};
|
|
5549
|
+
}
|
|
5550
|
+
}
|
|
5551
|
+
else {
|
|
5552
|
+
data = await response.json();
|
|
5553
|
+
}
|
|
5554
|
+
const dataClass = new TransactionsTimeBucketResponse(data.data, this.debug, this.apiKey, this.threadCount, urlParams);
|
|
5555
|
+
checkAndModifyResponse(dataClass);
|
|
5556
|
+
success = true;
|
|
5557
|
+
return {
|
|
5558
|
+
data: dataClass,
|
|
5559
|
+
error: data.error,
|
|
5560
|
+
error_code: data ? data.error_code : response.status,
|
|
5561
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
5562
|
+
};
|
|
5563
|
+
}
|
|
5564
|
+
catch (error) {
|
|
5565
|
+
success = true;
|
|
5566
|
+
return {
|
|
5567
|
+
data: null,
|
|
5568
|
+
error: true,
|
|
5569
|
+
error_code: data ? data.error_code : response.status,
|
|
5570
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
5571
|
+
};
|
|
5572
|
+
}
|
|
5573
|
+
}
|
|
5574
|
+
}
|
|
5341
5575
|
}
|
|
5342
5576
|
|
|
5343
5577
|
class PoolResponse {
|
|
@@ -6795,7 +7029,7 @@ class XykService {
|
|
|
6795
7029
|
}
|
|
6796
7030
|
}
|
|
6797
7031
|
|
|
6798
|
-
const userAgent = "com.covalenthq.sdk.typescript/0.7.
|
|
7032
|
+
const userAgent = "com.covalenthq.sdk.typescript/0.7.3";
|
|
6799
7033
|
/**
|
|
6800
7034
|
* CovalentClient Class
|
|
6801
7035
|
*/
|
|
@@ -7111,6 +7345,24 @@ exports.Chains = void 0;
|
|
|
7111
7345
|
Chains["BNB_OPBNB_MAINNET"] = "bnb-opbnb-mainnet";
|
|
7112
7346
|
Chains["TELOS_MAINNET"] = "telos-mainnet";
|
|
7113
7347
|
Chains["TELOS_TESTNET"] = "telos-testnet";
|
|
7348
|
+
Chains["AVALANCHE_HUBBLE_EXCHANGE_TESTNET"] = "avalanche-hubble-exchange-testnet";
|
|
7349
|
+
Chains["AVALANCHE_MIHO_TESTNET"] = "avalanche-miho-testnet";
|
|
7350
|
+
Chains["AVALANCHE_BULLETIN_TESTNET"] = "avalanche-bulletin-testnet";
|
|
7351
|
+
Chains["AVALANCHE_KIWI_TESTNET"] = "avalanche-kiwi-testnet";
|
|
7352
|
+
Chains["AVALANCHE_HERO_TESTNET"] = "avalanche-hero-testnet";
|
|
7353
|
+
Chains["AVALANCHE_AVACLOUD_TESTNET"] = "avalanche-avacloud-testnet";
|
|
7354
|
+
Chains["AVALANCHE_THIRDWEB_TESTNET"] = "avalanche-thirdweb-testnet";
|
|
7355
|
+
Chains["AVALANCHE_MONDRIAN_TESTNET"] = "avalanche-mondrian-testnet";
|
|
7356
|
+
Chains["AVALANCHE_CONDUIT_TESTNET"] = "avalanche-conduit-testnet";
|
|
7357
|
+
Chains["AVALANCHE_NMAC_TESTNET"] = "avalanche-nmac-testnet";
|
|
7358
|
+
Chains["AVALANCHE_ORDERLY_TESTNET"] = "avalanche-orderly-testnet";
|
|
7359
|
+
Chains["AVALANCHE_AMPLIFY_TESTNET"] = "avalanche-amplify-testnet";
|
|
7360
|
+
Chains["AVALANCHE_MIRAI_TESTNET"] = "avalanche-mirai-testnet";
|
|
7361
|
+
Chains["AVALANCHE_WAGMI_TESTNET"] = "avalanche-wagmi-testnet";
|
|
7362
|
+
Chains["AVALANCHE_PLAYA3ULL_TESTNET"] = "avalanche-playa3ull-testnet";
|
|
7363
|
+
Chains["AVALANCHE_BEAM_MAINNET"] = "avalanche-beam-mainnet";
|
|
7364
|
+
Chains["SCROLL_MAINNET"] = "scroll-mainnet";
|
|
7365
|
+
Chains["ETH_HOLESKY"] = "eth-holesky";
|
|
7114
7366
|
})(exports.Chains || (exports.Chains = {}));
|
|
7115
7367
|
|
|
7116
7368
|
exports.Client = Client;
|