@avalabs/core-covalent-sdk 2.8.0-alpha.197

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ Copyright (C) 2021, Ava Labs, Inc. All rights reserved.
2
+
3
+ Subject to the limited license below (**”License””), you may not, and you may not permit anyone else to, copy, reproduce, aggregate, republish, download, post, distribute, license, sublicense, reverse engineer, modify, or create derivative works based on this software (collectively, **“Software”**).
4
+
5
+ You are hereby granted a limited, non-exclusive, non-sublicensable and non-transferable license to download and use the Software as-is solely (i) for use in connection with the Avalanche Public Blockchain platform, having a NetworkID of 1 (Mainnet) or 5 (Fuji), and associated blockchains, comprised exclusively of the Avalanche X-Chain, C-Chain, P-Chain and any subnets linked to the P-Chain (**“Avalanche Authorized Platform”**) or (ii) for non-production, testing or research purposes without any commercial application within the Avalanche ecosystem (**“Non-Commercial Use”**); provided that, in each case, you may not use or allow use of the Software (a) in connection with any forks of the Avalanche Authorized Platform, (b) in any manner not operationally connected to the Avalanche Authorized Platform other than for Non-Commercial Use, or (c) to the extent the number of monthly active users or the number of total installs of any software that uses the Software across all versions thereof exceeds 10,000 at any time. You may not modify or alter the Software in any way.
6
+
7
+ You hereby acknowledge and agree to the terms set forth at www.avalabs.org/important-notice.
8
+
9
+ **TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED ON AN “AS IS” BASIS, AND AVA LABS EXPRESSLY DISCLAIMS AND EXCLUDES ALL REPRESENTATIONS, WARRANTIES AND OTHER TERMS AND CONDITIONS, WHETHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION BY OPERATION OF LAW OR BY CUSTOM, STATUTE OR OTHERWISE, AND INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED WARRANTY, TERM, OR CONDITION OF NON-INFRINGEMENT, MERCHANTABILITY, TITLE, OR FITNESS FOR PARTICULAR PURPOSE. YOU USE THE SOFTWARE AT YOUR OWN RISK. AVA LABS EXPRESSLY DISCLAIMS ALL LIABILITY (INCLUDING FOR ALL DIRECT, CONSEQUENTIAL OR OTHER DAMAGES OR LOSSES) RELATED TO ANY USE OF THE SOFTWARE.**
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # `covalent-sdk`
2
+
3
+ > TODO: description
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ const covalentSdk = require('covalent-sdk');
9
+
10
+ // TODO: DEMONSTRATE API
11
+ ```
@@ -0,0 +1,170 @@
1
+ import { HttpOptions } from '@avalabs/core-utils-sdk';
2
+
3
+ interface GetAddressBalancesV2Response {
4
+ data: {
5
+ address: string;
6
+ updated_at: string;
7
+ next_update_at: string;
8
+ quote_currency: string;
9
+ chain_id: number;
10
+ items: GetAddressBalanceV2Item[];
11
+ pagination: null | PaginationResponse;
12
+ };
13
+ error: boolean;
14
+ error_message: null | string;
15
+ error_code: null | string;
16
+ }
17
+ interface PaginationQuery {
18
+ pageSize: number;
19
+ pageNumber: number;
20
+ }
21
+ interface PaginationResponse {
22
+ has_more: boolean;
23
+ page_number: number;
24
+ page_size: number;
25
+ total_count: null | number;
26
+ }
27
+ interface GetAddressBalanceV2Item {
28
+ contract_decimals: number;
29
+ contract_name: string;
30
+ contract_ticker_symbol: string;
31
+ contract_address: string;
32
+ supports_erc: null | string[];
33
+ logo_url: string;
34
+ last_transferred_at: null | string;
35
+ type: 'cryptocurrency' | 'dust' | 'nft';
36
+ balance: string;
37
+ balance_24h: null | string;
38
+ quote_rate: number;
39
+ quote_rate_24h: null | number;
40
+ quote: number;
41
+ quote_24h: null | number;
42
+ nft_data: null | NFTData[];
43
+ }
44
+ interface NFTAttribute {
45
+ trait_type: string;
46
+ value: string;
47
+ }
48
+ interface NFTData {
49
+ token_id: string;
50
+ token_balance: null | string;
51
+ token_url: null | string;
52
+ supports_erc: string[];
53
+ token_price_wei: null;
54
+ token_quote_rate_eth: null;
55
+ original_owner: string;
56
+ external_data: {
57
+ name: string;
58
+ description: string;
59
+ image: string;
60
+ image_256: string;
61
+ image_512: string;
62
+ image_1024: string;
63
+ animation_url: string | null;
64
+ external_url: string | null;
65
+ attributes: NFTAttribute[];
66
+ owner: string | null;
67
+ };
68
+ owner: string;
69
+ owner_address: null;
70
+ burned: null;
71
+ }
72
+ interface GetTxsForAddressResponse {
73
+ data: {
74
+ address: string;
75
+ updated_at: string;
76
+ next_update_at: string;
77
+ quote_currency: string;
78
+ chain_id: number;
79
+ items: AddressTxsItem[];
80
+ pagination: null | PaginationResponse;
81
+ };
82
+ error: boolean;
83
+ error_message: null | string;
84
+ error_code: null | string;
85
+ }
86
+ interface AddressTxsItem {
87
+ block_signed_at: string;
88
+ block_height: number;
89
+ tx_hash: string;
90
+ tx_offset: number;
91
+ successful: boolean;
92
+ from_address: string;
93
+ from_address_label: null | string;
94
+ to_address: string;
95
+ to_address_label: null | string;
96
+ value: string;
97
+ value_quote: number;
98
+ gas_offered: number;
99
+ gas_spent: number;
100
+ gas_price: number;
101
+ gas_quote: number;
102
+ gas_quote_rate: number;
103
+ logEvents?: TxsLogEvent[];
104
+ }
105
+ interface TxsLogEvent {
106
+ block_signed_at: string;
107
+ block_height: number;
108
+ tx_offset: number;
109
+ log_offset: number;
110
+ tx_hash: string;
111
+ raw_log_topics: string[];
112
+ sender_contract_decimals: number;
113
+ sender_name: null | string;
114
+ sender_contract_ticker_symbol: null | string;
115
+ sender_address: string;
116
+ sender_address_label: null | string;
117
+ sender_logo_url: null | string;
118
+ raw_log_data: string;
119
+ decoded: any;
120
+ }
121
+
122
+ declare class Covalent {
123
+ private chainID;
124
+ private apiKey;
125
+ private httpClient;
126
+ constructor(chainID: number, apiKey?: string);
127
+ /**
128
+ * Set the API key used by this instance.
129
+ * @param key
130
+ */
131
+ setApiKey(key: string | undefined): void;
132
+ /**
133
+ * Connect to a different chain.
134
+ * @param chainID
135
+ */
136
+ setChainID(chainID: number): void;
137
+ /**
138
+ * Return current token balances along with their spot prices. This endpoint supports a variety of
139
+ * token standards like ERC20, ERC721 and ERC1155. As a special case, network native tokens like ETH
140
+ * on Ethereum are also returned even though it's not a token contract.
141
+ * @param address The address to check the balance of.
142
+ * @param nft True if you want NFT data returned.
143
+ * @param currency The currency to get price data on.
144
+ * @param pagination
145
+ */
146
+ getAddressBalancesV2(address: string, nft?: boolean, currency?: string, pagination?: PaginationQuery, httpOptions?: {
147
+ params?: Record<string, string>;
148
+ customOptions?: HttpOptions;
149
+ }): Promise<GetAddressBalancesV2Response>;
150
+ /**
151
+ * Return all transactions along with their decoded log events. This endpoint does a
152
+ * deep-crawl of the blockchain to retrieve all kinds of transactions that references the address
153
+ * including indexed topics within the event logs.
154
+ * @param address Address to get history of.
155
+ * @param currency
156
+ * @param ascending Order by ascending.
157
+ * @param logs Set to `true` if you want event logs.
158
+ * @param pagination
159
+ */
160
+ getTransactionsForAddress(address: string, currency?: string, ascending?: boolean, logs?: boolean, pagination?: PaginationQuery, httpOptions?: {
161
+ params?: Record<string, string>;
162
+ customOptions?: HttpOptions;
163
+ }): Promise<GetTxsForAddressResponse>;
164
+ }
165
+
166
+ declare const BASE_URL = "https://api.covalenthq.com";
167
+
168
+ declare function createApiUrl(chainID: number, version?: number): string;
169
+
170
+ export { AddressTxsItem, BASE_URL, Covalent, GetAddressBalanceV2Item, GetAddressBalancesV2Response, GetTxsForAddressResponse, NFTAttribute, NFTData, PaginationQuery, PaginationResponse, TxsLogEvent, createApiUrl };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var t=require("@avalabs/core-utils-sdk");const e="https://api.covalenthq.com";function a(t,a=1){return`${e}/v${a}/${t}`}exports.BASE_URL=e,exports.Covalent=class{chainID;apiKey;httpClient;constructor(e,s){this.chainID=e,this.apiKey=s,this.httpClient=new t.HttpClient(a(e))}setApiKey(t){this.apiKey=t}setChainID(e){this.chainID=e,this.httpClient=new t.HttpClient(a(e))}async getAddressBalancesV2(t,e=!1,a="USD",s,n){const i=new URLSearchParams({...n?.params,nft:e.toString(),"quote-currency":a});this.apiKey&&i.append("key",this.apiKey),s&&i.append("page-size",s.pageSize.toString()),s&&i.append("page-number",s.pageNumber.toString());const r=`/address/${t}/balances_v2/`;return await this.httpClient.get(r,Object.fromEntries(i),n?.customOptions)}async getTransactionsForAddress(t,e="USD",a=!1,s=!1,n,i){const r=new URLSearchParams({...i?.params,"block-signed-at-asc":a?"true":"false","quote-currency":e,"no-logs":s?"false":"true"});this.apiKey&&r.append("key",this.apiKey),n&&r.append("page-size",n.pageSize.toString()),n&&r.append("page-number",n.pageNumber.toString());const p=`/address/${t}/transactions_v2/`;return await this.httpClient.get(p,Object.fromEntries(r),i?.customOptions)}},exports.createApiUrl=a;
@@ -0,0 +1,48 @@
1
+ import { HttpOptions } from '@avalabs/core-utils-sdk';
2
+ import { PaginationQuery, GetAddressBalancesV2Response, GetTxsForAddressResponse } from './models.js';
3
+
4
+ declare class Covalent {
5
+ private chainID;
6
+ private apiKey;
7
+ private httpClient;
8
+ constructor(chainID: number, apiKey?: string);
9
+ /**
10
+ * Set the API key used by this instance.
11
+ * @param key
12
+ */
13
+ setApiKey(key: string | undefined): void;
14
+ /**
15
+ * Connect to a different chain.
16
+ * @param chainID
17
+ */
18
+ setChainID(chainID: number): void;
19
+ /**
20
+ * Return current token balances along with their spot prices. This endpoint supports a variety of
21
+ * token standards like ERC20, ERC721 and ERC1155. As a special case, network native tokens like ETH
22
+ * on Ethereum are also returned even though it's not a token contract.
23
+ * @param address The address to check the balance of.
24
+ * @param nft True if you want NFT data returned.
25
+ * @param currency The currency to get price data on.
26
+ * @param pagination
27
+ */
28
+ getAddressBalancesV2(address: string, nft?: boolean, currency?: string, pagination?: PaginationQuery, httpOptions?: {
29
+ params?: Record<string, string>;
30
+ customOptions?: HttpOptions;
31
+ }): Promise<GetAddressBalancesV2Response>;
32
+ /**
33
+ * Return all transactions along with their decoded log events. This endpoint does a
34
+ * deep-crawl of the blockchain to retrieve all kinds of transactions that references the address
35
+ * including indexed topics within the event logs.
36
+ * @param address Address to get history of.
37
+ * @param currency
38
+ * @param ascending Order by ascending.
39
+ * @param logs Set to `true` if you want event logs.
40
+ * @param pagination
41
+ */
42
+ getTransactionsForAddress(address: string, currency?: string, ascending?: boolean, logs?: boolean, pagination?: PaginationQuery, httpOptions?: {
43
+ params?: Record<string, string>;
44
+ customOptions?: HttpOptions;
45
+ }): Promise<GetTxsForAddressResponse>;
46
+ }
47
+
48
+ export { Covalent };
@@ -0,0 +1 @@
1
+ import{HttpClient as t}from"@avalabs/core-utils-sdk";import{createApiUrl as e}from"./createApiUrl.js";class a{chainID;apiKey;httpClient;constructor(a,s){this.chainID=a,this.apiKey=s,this.httpClient=new t(e(a))}setApiKey(t){this.apiKey=t}setChainID(a){this.chainID=a,this.httpClient=new t(e(a))}async getAddressBalancesV2(t,e=!1,a="USD",s,i){const n=new URLSearchParams({...i?.params,nft:e.toString(),"quote-currency":a});this.apiKey&&n.append("key",this.apiKey),s&&n.append("page-size",s.pageSize.toString()),s&&n.append("page-number",s.pageNumber.toString());const r=`/address/${t}/balances_v2/`;return await this.httpClient.get(r,Object.fromEntries(n),i?.customOptions)}async getTransactionsForAddress(t,e="USD",a=!1,s=!1,i,n){const r=new URLSearchParams({...n?.params,"block-signed-at-asc":a?"true":"false","quote-currency":e,"no-logs":s?"false":"true"});this.apiKey&&r.append("key",this.apiKey),i&&r.append("page-size",i.pageSize.toString()),i&&r.append("page-number",i.pageNumber.toString());const p=`/address/${t}/transactions_v2/`;return await this.httpClient.get(p,Object.fromEntries(r),n?.customOptions)}}export{a as Covalent};
@@ -0,0 +1,3 @@
1
+ declare const BASE_URL = "https://api.covalenthq.com";
2
+
3
+ export { BASE_URL };
@@ -0,0 +1 @@
1
+ const t="https://api.covalenthq.com";export{t as BASE_URL};
@@ -0,0 +1,3 @@
1
+ declare function createApiUrl(chainID: number, version?: number): string;
2
+
3
+ export { createApiUrl };
@@ -0,0 +1 @@
1
+ import{BASE_URL as t}from"./constants.js";function n(n,o=1){return`${t}/v${o}/${n}`}export{n as createApiUrl};
package/esm/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export { Covalent } from './Covalent.js';
2
+ export { BASE_URL } from './constants.js';
3
+ export { createApiUrl } from './createApiUrl.js';
4
+ export { AddressTxsItem, GetAddressBalanceV2Item, GetAddressBalancesV2Response, GetTxsForAddressResponse, NFTAttribute, NFTData, PaginationQuery, PaginationResponse, TxsLogEvent } from './models.js';
package/esm/index.js ADDED
@@ -0,0 +1 @@
1
+ export{Covalent}from"./Covalent.js";export{BASE_URL}from"./constants.js";export{createApiUrl}from"./createApiUrl.js";
@@ -0,0 +1,120 @@
1
+ interface GetAddressBalancesV2Response {
2
+ data: {
3
+ address: string;
4
+ updated_at: string;
5
+ next_update_at: string;
6
+ quote_currency: string;
7
+ chain_id: number;
8
+ items: GetAddressBalanceV2Item[];
9
+ pagination: null | PaginationResponse;
10
+ };
11
+ error: boolean;
12
+ error_message: null | string;
13
+ error_code: null | string;
14
+ }
15
+ interface PaginationQuery {
16
+ pageSize: number;
17
+ pageNumber: number;
18
+ }
19
+ interface PaginationResponse {
20
+ has_more: boolean;
21
+ page_number: number;
22
+ page_size: number;
23
+ total_count: null | number;
24
+ }
25
+ interface GetAddressBalanceV2Item {
26
+ contract_decimals: number;
27
+ contract_name: string;
28
+ contract_ticker_symbol: string;
29
+ contract_address: string;
30
+ supports_erc: null | string[];
31
+ logo_url: string;
32
+ last_transferred_at: null | string;
33
+ type: 'cryptocurrency' | 'dust' | 'nft';
34
+ balance: string;
35
+ balance_24h: null | string;
36
+ quote_rate: number;
37
+ quote_rate_24h: null | number;
38
+ quote: number;
39
+ quote_24h: null | number;
40
+ nft_data: null | NFTData[];
41
+ }
42
+ interface NFTAttribute {
43
+ trait_type: string;
44
+ value: string;
45
+ }
46
+ interface NFTData {
47
+ token_id: string;
48
+ token_balance: null | string;
49
+ token_url: null | string;
50
+ supports_erc: string[];
51
+ token_price_wei: null;
52
+ token_quote_rate_eth: null;
53
+ original_owner: string;
54
+ external_data: {
55
+ name: string;
56
+ description: string;
57
+ image: string;
58
+ image_256: string;
59
+ image_512: string;
60
+ image_1024: string;
61
+ animation_url: string | null;
62
+ external_url: string | null;
63
+ attributes: NFTAttribute[];
64
+ owner: string | null;
65
+ };
66
+ owner: string;
67
+ owner_address: null;
68
+ burned: null;
69
+ }
70
+ interface GetTxsForAddressResponse {
71
+ data: {
72
+ address: string;
73
+ updated_at: string;
74
+ next_update_at: string;
75
+ quote_currency: string;
76
+ chain_id: number;
77
+ items: AddressTxsItem[];
78
+ pagination: null | PaginationResponse;
79
+ };
80
+ error: boolean;
81
+ error_message: null | string;
82
+ error_code: null | string;
83
+ }
84
+ interface AddressTxsItem {
85
+ block_signed_at: string;
86
+ block_height: number;
87
+ tx_hash: string;
88
+ tx_offset: number;
89
+ successful: boolean;
90
+ from_address: string;
91
+ from_address_label: null | string;
92
+ to_address: string;
93
+ to_address_label: null | string;
94
+ value: string;
95
+ value_quote: number;
96
+ gas_offered: number;
97
+ gas_spent: number;
98
+ gas_price: number;
99
+ gas_quote: number;
100
+ gas_quote_rate: number;
101
+ logEvents?: TxsLogEvent[];
102
+ }
103
+ interface TxsLogEvent {
104
+ block_signed_at: string;
105
+ block_height: number;
106
+ tx_offset: number;
107
+ log_offset: number;
108
+ tx_hash: string;
109
+ raw_log_topics: string[];
110
+ sender_contract_decimals: number;
111
+ sender_name: null | string;
112
+ sender_contract_ticker_symbol: null | string;
113
+ sender_address: string;
114
+ sender_address_label: null | string;
115
+ sender_logo_url: null | string;
116
+ raw_log_data: string;
117
+ decoded: any;
118
+ }
119
+
120
+ export { AddressTxsItem, GetAddressBalanceV2Item, GetAddressBalancesV2Response, GetTxsForAddressResponse, NFTAttribute, NFTData, PaginationQuery, PaginationResponse, TxsLogEvent };
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@avalabs/core-covalent-sdk",
3
+ "version": "2.8.0-alpha.197",
4
+ "license": "Limited Ecosystem License",
5
+ "private": false,
6
+ "main": "dist/index.js",
7
+ "module": "esm/index.js",
8
+ "typings": "dist/index.d.ts",
9
+ "files": [
10
+ "dist",
11
+ "esm"
12
+ ],
13
+ "sideEffects": false,
14
+ "publishConfig": {
15
+ "access": "restricted"
16
+ },
17
+ "description": "Typescript SDK for the Covalent API.",
18
+ "author": "Emre Kanatli",
19
+ "homepage": "https://github.com/ava-labs/avalanche-sdks#readme",
20
+ "scripts": {
21
+ "start": "rollup -c --watch",
22
+ "build": "rollup -c",
23
+ "lint": "eslint --fix -c ./.eslintrc.js \"src/**/*.ts*\""
24
+ },
25
+ "dependencies": {
26
+ "@avalabs/core-utils-sdk": "2.8.0-alpha.197"
27
+ }
28
+ }