@covalenthq/client-sdk 2.1.2 → 2.2.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/README.md +22 -6
- package/dist/cjs/index.js +90 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/src/GoldRushClient.d.ts +3 -1
- package/dist/cjs/src/services/AllChainsService.d.ts +26 -0
- package/dist/cjs/src/utils/functions/endpointGenerator.d.ts +1 -1
- package/dist/cjs/src/utils/functions/timestamp-parser.d.ts +1 -1
- package/dist/cjs/src/utils/types/AllChainService.types.d.ts +32 -0
- package/dist/cjs/src/utils/types/BaseService.types.d.ts +2 -0
- package/dist/cjs/src/utils/types/Generic.types.d.ts +8 -0
- package/dist/cjs/src/utils/types/PricingService.types.d.ts +3 -2
- package/dist/cjs/src/utils/types/TransactionService.types.d.ts +1 -0
- package/dist/esm/index.js +90 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/src/GoldRushClient.d.ts +3 -1
- package/dist/esm/src/services/AllChainsService.d.ts +26 -0
- package/dist/esm/src/utils/functions/endpointGenerator.d.ts +1 -1
- package/dist/esm/src/utils/functions/timestamp-parser.d.ts +1 -1
- package/dist/esm/src/utils/types/AllChainService.types.d.ts +32 -0
- package/dist/esm/src/utils/types/BaseService.types.d.ts +2 -0
- package/dist/esm/src/utils/types/Generic.types.d.ts +8 -0
- package/dist/esm/src/utils/types/PricingService.types.d.ts +3 -2
- package/dist/esm/src/utils/types/TransactionService.types.d.ts +1 -0
- package/package.json +2 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AllChainsService } from "./services/AllChainsService";
|
|
1
2
|
import { BalanceService } from "./services/BalanceService";
|
|
2
3
|
import { BaseService } from "./services/BaseService";
|
|
3
4
|
import { NftService } from "./services/NftService";
|
|
@@ -10,11 +11,12 @@ import { type GoldRushClientSettings } from "./utils/types/Generic.types";
|
|
|
10
11
|
*/
|
|
11
12
|
export declare class GoldRushClient {
|
|
12
13
|
private readonly userAgent;
|
|
13
|
-
|
|
14
|
+
AllChainsService: AllChainsService;
|
|
14
15
|
BalanceService: BalanceService;
|
|
15
16
|
BaseService: BaseService;
|
|
16
17
|
NftService: NftService;
|
|
17
18
|
PricingService: PricingService;
|
|
19
|
+
SecurityService: SecurityService;
|
|
18
20
|
TransactionService: TransactionService;
|
|
19
21
|
constructor(apiKey: string, settings?: GoldRushClientSettings);
|
|
20
22
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type Execution } from "../utils/functions/execution";
|
|
2
|
+
import { type GetMultiChainAndMultiAddressTransactionsParamOtps, type MultiChainMultiAddressTransactionsResponse } from "../utils/types/AllChainService.types";
|
|
3
|
+
import { type GoldRushResponse } from "../utils/types/Generic.types";
|
|
4
|
+
/**
|
|
5
|
+
* Cross Chain API
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export declare class AllChainsService {
|
|
9
|
+
private execution;
|
|
10
|
+
constructor(execution: Execution);
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* Commonly used to get transactions cross chains and addresses.
|
|
14
|
+
*
|
|
15
|
+
* @param {Chain[]} chains - An array of the chain names or IDs to retrieve transactions from. Defaults to all foundational chains.
|
|
16
|
+
* @param {string[]} addresses - An array of addresses for which transactions are fetched. Does not support name resolution.
|
|
17
|
+
* @param {number} limit - Number of transactions to return per page, up to the default max of 100 items.
|
|
18
|
+
* @param {string} before - Pagination cursor pointing to fetch transactions before a certain point.
|
|
19
|
+
* @param {string} after - Pagination cursor pointing to fetch transactions after a certain point.
|
|
20
|
+
* @param {boolean} withLogs - Whether to include raw logs in the response.
|
|
21
|
+
* @param {boolean} withDecodedLogs - Whether to include decoded logs in the response.
|
|
22
|
+
* @param {Quote | "BTC" | "ETH"} quoteCurrency - The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, `GBP`, "BTC" and "ETH".
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
getMultiChainAndMultiAddressTransactions(queryParamOpts?: GetMultiChainAndMultiAddressTransactionsParamOtps): Promise<GoldRushResponse<MultiChainMultiAddressTransactionsResponse>>;
|
|
26
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const timestampParser: (timestamp: string | Date, type: "descriptive" | "DD MMM YY" | "relative" | "YYYY
|
|
1
|
+
export declare const timestampParser: (timestamp: string | Date, type: "descriptive" | "DD MMM YY" | "relative" | "YYYY-MM-DD") => string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type Chain, type Nullable, type Quote } from "./Generic.types";
|
|
2
|
+
import { type Transaction } from "./TransactionService.types";
|
|
3
|
+
export type MultiChainMultiAddressTransactionsResponse = Nullable<{
|
|
4
|
+
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
|
|
5
|
+
updated_at: Date;
|
|
6
|
+
/** * The the pagination cursor to get the previous page of results */
|
|
7
|
+
cursor_before: string;
|
|
8
|
+
/** * The the pagination cursor to get the next page of results */
|
|
9
|
+
cursor_after: string;
|
|
10
|
+
/** * The requested quote currency eg: `USD`. */
|
|
11
|
+
quote_currency: Quote | "ETH" | "BTC";
|
|
12
|
+
/** * List of response items. */
|
|
13
|
+
items: Transaction[];
|
|
14
|
+
}>;
|
|
15
|
+
export type GetMultiChainAndMultiAddressTransactionsParamOtps = Nullable<{
|
|
16
|
+
/** * An array of the chain names or IDs to retrieve transactions from. Defaults to all foundational chains. */
|
|
17
|
+
chains?: Chain[];
|
|
18
|
+
/** * An array of addresses for which transactions are fetched. Does not support name resolution. */
|
|
19
|
+
addresses?: string[];
|
|
20
|
+
/** * Number of transactions to return per page, up to the default max of 100 items. */
|
|
21
|
+
limit?: number;
|
|
22
|
+
/** * Pagination cursor pointing to fetch transactions before a certain point. */
|
|
23
|
+
before?: string;
|
|
24
|
+
/** * Pagination cursor pointing to fetch transactions after a certain point. */
|
|
25
|
+
after?: string;
|
|
26
|
+
/** * Whether to include raw logs in the response. */
|
|
27
|
+
withLogs?: boolean;
|
|
28
|
+
/** * Whether to include decoded logs in the response. */
|
|
29
|
+
withDecodedLogs?: boolean;
|
|
30
|
+
/** * The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, `GBP`, "BTC" and "ETH". */
|
|
31
|
+
quoteCurrency?: Quote | "BTC" | "ETH";
|
|
32
|
+
}>;
|
|
@@ -181,6 +181,8 @@ export type ChainItem = Nullable<{
|
|
|
181
181
|
is_appchain: boolean;
|
|
182
182
|
/** * The ChainItem the appchain is a part of. */
|
|
183
183
|
appchain_of: ChainItem;
|
|
184
|
+
/** * A classification of the chain */
|
|
185
|
+
priority_label: "Foundational" | "Frontier" | "Community";
|
|
184
186
|
}>;
|
|
185
187
|
export type ColorTheme = Nullable<{
|
|
186
188
|
/** * The red color code. */
|
|
@@ -381,6 +381,14 @@ export interface NftExternalData {
|
|
|
381
381
|
animation_url: string;
|
|
382
382
|
external_url: string;
|
|
383
383
|
attributes: NftCollectionAttribute[];
|
|
384
|
+
thumbnails: NFTThumbnails;
|
|
385
|
+
}
|
|
386
|
+
export interface NFTThumbnails {
|
|
387
|
+
image256: string;
|
|
388
|
+
image512: string;
|
|
389
|
+
image1024: string;
|
|
390
|
+
image_opengraph_url: string;
|
|
391
|
+
thumbhash: string;
|
|
384
392
|
}
|
|
385
393
|
export interface DecodedItem {
|
|
386
394
|
name: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ContractMetadata, type LogoUrls, type Nullable } from "./Generic.types";
|
|
1
|
+
import { type ContractMetadata, type LogoUrls, type Nullable, type Quote } from "./Generic.types";
|
|
2
2
|
export type TokenPricesResponse = Nullable<{
|
|
3
3
|
/** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
|
|
4
4
|
contract_decimals: number;
|
|
@@ -12,9 +12,10 @@ export type TokenPricesResponse = Nullable<{
|
|
|
12
12
|
supports_erc: string[];
|
|
13
13
|
/** * The contract logo URL. */
|
|
14
14
|
logo_url: string;
|
|
15
|
+
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
|
|
15
16
|
update_at: Date;
|
|
16
17
|
/** * The requested quote currency eg: `USD`. */
|
|
17
|
-
quote_currency:
|
|
18
|
+
quote_currency: Quote;
|
|
18
19
|
/** * The contract logo URLs. */
|
|
19
20
|
logo_urls: LogoUrls;
|
|
20
21
|
/** * List of response items. */
|
|
@@ -40,6 +40,7 @@ export type Transaction = Nullable<{
|
|
|
40
40
|
pretty_value_quote: string;
|
|
41
41
|
/** * The requested chain native gas token metadata. */
|
|
42
42
|
gas_metadata: ContractMetadata;
|
|
43
|
+
/** * The gas offered for this tx. */
|
|
43
44
|
gas_offered: number;
|
|
44
45
|
/** * The gas spent for this tx. */
|
|
45
46
|
gas_spent: number;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var version = "2.
|
|
1
|
+
var version = "2.2.0";
|
|
2
2
|
|
|
3
3
|
const bigIntParser = (val) => {
|
|
4
4
|
if (val === null || val === undefined) {
|
|
@@ -25,6 +25,93 @@ const endpointGenerator = (extension = "", params = []) => {
|
|
|
25
25
|
return new URL(`${baseUrl}/${extension}?${urlParams}`);
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Cross Chain API
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
class AllChainsService {
|
|
33
|
+
constructor(execution) {
|
|
34
|
+
this.execution = execution;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* Commonly used to get transactions cross chains and addresses.
|
|
39
|
+
*
|
|
40
|
+
* @param {Chain[]} chains - An array of the chain names or IDs to retrieve transactions from. Defaults to all foundational chains.
|
|
41
|
+
* @param {string[]} addresses - An array of addresses for which transactions are fetched. Does not support name resolution.
|
|
42
|
+
* @param {number} limit - Number of transactions to return per page, up to the default max of 100 items.
|
|
43
|
+
* @param {string} before - Pagination cursor pointing to fetch transactions before a certain point.
|
|
44
|
+
* @param {string} after - Pagination cursor pointing to fetch transactions after a certain point.
|
|
45
|
+
* @param {boolean} withLogs - Whether to include raw logs in the response.
|
|
46
|
+
* @param {boolean} withDecodedLogs - Whether to include decoded logs in the response.
|
|
47
|
+
* @param {Quote | "BTC" | "ETH"} quoteCurrency - The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, `GBP`, "BTC" and "ETH".
|
|
48
|
+
*
|
|
49
|
+
*/
|
|
50
|
+
async getMultiChainAndMultiAddressTransactions(queryParamOpts) {
|
|
51
|
+
const endpoint = endpointGenerator(`allchains/transactions`, [
|
|
52
|
+
{
|
|
53
|
+
key: "chains",
|
|
54
|
+
value: queryParamOpts?.chains,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
key: "addresses",
|
|
58
|
+
value: queryParamOpts?.addresses,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
key: "limit",
|
|
62
|
+
value: queryParamOpts?.limit,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
key: "before",
|
|
66
|
+
value: queryParamOpts?.before,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
key: "after",
|
|
70
|
+
value: queryParamOpts?.after,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
key: "with-logs",
|
|
74
|
+
value: queryParamOpts?.withLogs,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
key: "with-decoded-logs",
|
|
78
|
+
value: queryParamOpts?.withDecodedLogs,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
key: "quote-currency",
|
|
82
|
+
value: queryParamOpts?.quoteCurrency,
|
|
83
|
+
},
|
|
84
|
+
]);
|
|
85
|
+
const parseData = (data) => {
|
|
86
|
+
if (data.data) {
|
|
87
|
+
data.data.updated_at = data.data.updated_at
|
|
88
|
+
? new Date(data.data.updated_at)
|
|
89
|
+
: null;
|
|
90
|
+
data.data.items = data.data.items
|
|
91
|
+
? data.data.items.map((txItem) => ({
|
|
92
|
+
...txItem,
|
|
93
|
+
value: bigIntParser(txItem.value),
|
|
94
|
+
fees_paid: bigIntParser(txItem.fees_paid),
|
|
95
|
+
block_signed_at: txItem.block_signed_at
|
|
96
|
+
? new Date(txItem.block_signed_at)
|
|
97
|
+
: null,
|
|
98
|
+
log_events: txItem.log_events
|
|
99
|
+
? txItem.log_events.map((logItem) => ({
|
|
100
|
+
...logItem,
|
|
101
|
+
block_signed_at: logItem.block_signed_at
|
|
102
|
+
? new Date(logItem.block_signed_at)
|
|
103
|
+
: null,
|
|
104
|
+
}))
|
|
105
|
+
: null,
|
|
106
|
+
}))
|
|
107
|
+
: null;
|
|
108
|
+
}
|
|
109
|
+
return data;
|
|
110
|
+
};
|
|
111
|
+
return await this.execution.execute(endpoint, parseData);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
28
115
|
async function* paginateEndpoint(endpoint, execution, parseData, implementation) {
|
|
29
116
|
let _endpoint = new URL(endpoint);
|
|
30
117
|
let hasMore = true;
|
|
@@ -2516,6 +2603,7 @@ class GoldRushClient {
|
|
|
2516
2603
|
? `${settings.source} (${this.userAgent})`
|
|
2517
2604
|
: this.userAgent,
|
|
2518
2605
|
});
|
|
2606
|
+
this.AllChainsService = new AllChainsService(execution);
|
|
2519
2607
|
this.BalanceService = new BalanceService(execution);
|
|
2520
2608
|
this.BaseService = new BaseService(execution);
|
|
2521
2609
|
this.NftService = new NftService(execution);
|
|
@@ -3684,7 +3772,7 @@ const timestampParser = (timestamp, type) => {
|
|
|
3684
3772
|
return `just now`;
|
|
3685
3773
|
}
|
|
3686
3774
|
}
|
|
3687
|
-
case "YYYY
|
|
3775
|
+
case "YYYY-MM-DD": {
|
|
3688
3776
|
const offsetMinutes = _unix.getTimezoneOffset();
|
|
3689
3777
|
const offsetMilliseconds = offsetMinutes * 60 * 1000;
|
|
3690
3778
|
const utcTime = _unix.getTime() + offsetMilliseconds;
|