@defillama/sdk 5.0.235 → 5.0.236

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.
Files changed (60) hide show
  1. package/build/ChainApi.d.ts +23 -1
  2. package/build/chains/algorand.d.ts +277 -0
  3. package/build/chains/algorand.js +618 -0
  4. package/build/chains/aptos.d.ts +230 -0
  5. package/build/chains/aptos.js +612 -0
  6. package/build/chains/cardano.d.ts +242 -0
  7. package/build/chains/cardano.js +407 -0
  8. package/build/chains/cosmos.d.ts +252 -0
  9. package/build/chains/cosmos.js +618 -0
  10. package/build/chains/icp.d.ts +235 -0
  11. package/build/chains/icp.js +1040 -0
  12. package/build/chains/index.d.ts +23 -0
  13. package/build/chains/index.js +59 -0
  14. package/build/chains/near.d.ts +192 -0
  15. package/build/chains/near.js +446 -0
  16. package/build/chains/rpc.d.ts +125 -0
  17. package/build/chains/rpc.js +326 -0
  18. package/build/chains/starknet.d.ts +205 -0
  19. package/build/chains/starknet.js +884 -0
  20. package/build/chains/stellar.d.ts +410 -0
  21. package/build/chains/stellar.js +1082 -0
  22. package/build/chains/substrate.d.ts +333 -0
  23. package/build/chains/substrate.js +1042 -0
  24. package/build/chains/sui.d.ts +365 -0
  25. package/build/chains/sui.js +1135 -0
  26. package/build/chains/svm.d.ts +340 -0
  27. package/build/chains/svm.js +760 -0
  28. package/build/chains/tezos.d.ts +225 -0
  29. package/build/chains/tezos.js +412 -0
  30. package/build/chains/ton.d.ts +353 -0
  31. package/build/chains/ton.js +788 -0
  32. package/build/chains/tron.d.ts +45 -0
  33. package/build/chains/tron.js +110 -0
  34. package/build/chains/utxo.d.ts +202 -0
  35. package/build/chains/utxo.js +592 -0
  36. package/build/chains/xrpl.d.ts +179 -0
  37. package/build/chains/xrpl.js +467 -0
  38. package/build/index.d.ts +2 -1
  39. package/build/index.js +3 -1
  40. package/build/providers.json +1 -1
  41. package/build/util/chainUtils/data.json +11 -0
  42. package/build/util/chainUtils/index.d.ts +1 -0
  43. package/build/util/chainUtils/index.js +23 -0
  44. package/build/util/common.js +2 -3
  45. package/build/util/cosmos.d.ts +1 -11
  46. package/build/util/cosmos.js +6 -66
  47. package/build/util/env.js +1 -0
  48. package/build/util/indexer.compatibility.d.ts +6 -0
  49. package/build/util/indexer.compatibility.js +64 -0
  50. package/build/util/indexer.d.ts +24 -2
  51. package/build/util/indexer.js +215 -282
  52. package/build/util/indexerSql.d.ts +8 -1
  53. package/build/util/indexerSql.js +53 -22
  54. package/build/util/logs.decode.shared.js +5 -4
  55. package/build/util/transactions.d.ts +23 -1
  56. package/build/util/updateChainLabels.d.ts +1 -0
  57. package/build/util/updateChainLabels.js +5 -0
  58. package/build/util/updateProviderList.js +38 -17
  59. package/package.json +20 -7
  60. package/README.md +0 -41
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Non-EVM chain clients. One module per chain family, all resolving endpoints
3
+ * through `rpc.getEndpoints` so `<CHAIN>_RPC` env vars override built-in defaults.
4
+ *
5
+ * Usage: `sdk.chains.svm.getAccounts({ chain: 'solana', accounts })`
6
+ */
7
+ export * as rpc from "./rpc";
8
+ export * as svm from "./svm";
9
+ export * as cosmos from "./cosmos";
10
+ export * as starknet from "./starknet";
11
+ export * as aptos from "./aptos";
12
+ export * as sui from "./sui";
13
+ export * as near from "./near";
14
+ export * as ton from "./ton";
15
+ export * as algorand from "./algorand";
16
+ export * as stellar from "./stellar";
17
+ export * as xrpl from "./xrpl";
18
+ export * as cardano from "./cardano";
19
+ export * as tezos from "./tezos";
20
+ export * as icp from "./icp";
21
+ export * as substrate from "./substrate";
22
+ export * as utxo from "./utxo";
23
+ export * as tron from "./tron";
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.tron = exports.utxo = exports.substrate = exports.icp = exports.tezos = exports.cardano = exports.xrpl = exports.stellar = exports.algorand = exports.ton = exports.near = exports.sui = exports.aptos = exports.starknet = exports.cosmos = exports.svm = exports.rpc = void 0;
37
+ /**
38
+ * Non-EVM chain clients. One module per chain family, all resolving endpoints
39
+ * through `rpc.getEndpoints` so `<CHAIN>_RPC` env vars override built-in defaults.
40
+ *
41
+ * Usage: `sdk.chains.svm.getAccounts({ chain: 'solana', accounts })`
42
+ */
43
+ exports.rpc = __importStar(require("./rpc"));
44
+ exports.svm = __importStar(require("./svm"));
45
+ exports.cosmos = __importStar(require("./cosmos"));
46
+ exports.starknet = __importStar(require("./starknet"));
47
+ exports.aptos = __importStar(require("./aptos"));
48
+ exports.sui = __importStar(require("./sui"));
49
+ exports.near = __importStar(require("./near"));
50
+ exports.ton = __importStar(require("./ton"));
51
+ exports.algorand = __importStar(require("./algorand"));
52
+ exports.stellar = __importStar(require("./stellar"));
53
+ exports.xrpl = __importStar(require("./xrpl"));
54
+ exports.cardano = __importStar(require("./cardano"));
55
+ exports.tezos = __importStar(require("./tezos"));
56
+ exports.icp = __importStar(require("./icp"));
57
+ exports.substrate = __importStar(require("./substrate"));
58
+ exports.utxo = __importStar(require("./utxo"));
59
+ exports.tron = __importStar(require("./tron"));
@@ -0,0 +1,192 @@
1
+ import { JsonRpcError, Endpoints, RetryOptions } from "./rpc";
2
+ export declare const CHAIN = "near";
3
+ export declare const DEFAULT_ENDPOINTS: string[];
4
+ export type BlockId = number | string;
5
+ export interface RpcOptions extends RetryOptions {
6
+ /** explicit endpoint(s); overrides `NEAR_RPC` and the defaults */
7
+ endpoints?: Endpoints;
8
+ /** axios timeout in ms, default 30s */
9
+ timeout?: number;
10
+ /** skip the shared concurrency limiter */
11
+ skipLimiter?: boolean;
12
+ }
13
+ export interface QueryParams {
14
+ request_type: 'view_account' | 'view_code' | 'view_state' | 'view_access_key' | 'view_access_key_list' | 'call_function' | string;
15
+ account_id?: string;
16
+ /** block height or hash; when set `finality` is not sent */
17
+ block_id?: BlockId;
18
+ /** convenience alias for `block_id` */
19
+ blockId?: BlockId;
20
+ finality?: 'final' | 'optimistic' | 'near-final';
21
+ [key: string]: any;
22
+ }
23
+ export interface AccountView {
24
+ amount: string;
25
+ locked: string;
26
+ code_hash: string;
27
+ storage_usage: number;
28
+ storage_paid_at: number;
29
+ block_height: number;
30
+ block_hash: string;
31
+ [key: string]: any;
32
+ }
33
+ export interface TokenMetadata {
34
+ spec?: string;
35
+ name: string;
36
+ symbol: string;
37
+ icon?: string | null;
38
+ reference?: string | null;
39
+ reference_hash?: string | null;
40
+ decimals: number;
41
+ [key: string]: any;
42
+ }
43
+ export interface Block {
44
+ number: number;
45
+ /** unix seconds */
46
+ timestamp: number;
47
+ /** raw nanosecond timestamp as string */
48
+ timestampNs: string;
49
+ hash: string;
50
+ prevHash: string;
51
+ header: any;
52
+ chunks: any[];
53
+ author: string;
54
+ }
55
+ export interface AccessKey {
56
+ public_key: string;
57
+ access_key: {
58
+ nonce: number;
59
+ permission: any;
60
+ };
61
+ }
62
+ export interface StateEntry {
63
+ /** utf8 decoded key (lossy for binary keys) */
64
+ key: string;
65
+ /** utf8 decoded value (lossy for binary/borsh values) */
66
+ value: string;
67
+ keyBase64: string;
68
+ valueBase64: string;
69
+ }
70
+ /**
71
+ * Error returned by a NEAR node (`error` member of the JSON-RPC response, or the
72
+ * `result.error` string of a failed `call_function`). Extends `JsonRpcError` so the
73
+ * shared retry helper keeps it intact. `nodeError` is the raw error object, `cause`
74
+ * mirrors NEAR's structured `error.cause.name` (e.g. `UNKNOWN_ACCOUNT`, `CONTRACT_EXECUTION_ERROR`).
75
+ */
76
+ export declare class NearRpcError extends JsonRpcError {
77
+ nodeError: any;
78
+ errorName?: string;
79
+ cause?: string;
80
+ endpoint?: string;
81
+ constructor(method: string, error: any, endpoint?: string, label?: string);
82
+ }
83
+ /**
84
+ * Encode `call_function` arguments to base64. Objects are JSON serialised, a
85
+ * `Buffer`/`Uint8Array` is taken as raw bytes, a string is assumed to be base64 already
86
+ * (pass `''` for methods without arguments), `undefined`/`null` become `{}`.
87
+ */
88
+ export declare function encodeArgs(args?: any): string;
89
+ /**
90
+ * Decode the `result` byte array of a `call_function` response. Returns the parsed JSON
91
+ * when the payload is JSON, otherwise the utf8 string (empty payload -> `''`).
92
+ */
93
+ export declare function decodeResult(bytes: number[] | Uint8Array | Buffer | undefined | null): any;
94
+ /** True for a syntactically valid NEAR account id (named accounts and 64-hex implicit accounts) */
95
+ export declare function isNearAccountId(str: any): boolean;
96
+ /** True for a 64 char hex implicit account id */
97
+ export declare function isImplicitAccountId(str: any): boolean;
98
+ /** yoctoNEAR (string/bigint) -> NEAR as a number (loses precision below 1e-15 NEAR, fine for reporting) */
99
+ export declare function yoctoToNear(amount: string | bigint | number): number;
100
+ /** Endpoint list: `NEAR_RPC` env (comma separated) or `DEFAULT_ENDPOINTS` */
101
+ export declare function getEndpoints(): string[];
102
+ /**
103
+ * Decide whether a failed attempt should be retried. Transport/HTTP level failures
104
+ * (network errors, timeouts, 4xx/5xx from a gateway - e.g. the 410 of a discontinued
105
+ * provider, 429 rate limits) always rotate to the next endpoint; node errors only when
106
+ * another node might have the data (missing/garbage collected block, node not synced,
107
+ * internal error). Contract level errors (unknown account, method not found, execution
108
+ * failure) are deterministic and fail fast.
109
+ */
110
+ export declare function shouldRetry(e: any): boolean;
111
+ /**
112
+ * Raw NEAR JSON-RPC call. Returns `result`, throws `NearRpcError` when the node answers with
113
+ * an `error`. Rotates endpoints (round-robin), retries with exponential backoff and runs
114
+ * under the shared concurrency limiter.
115
+ */
116
+ export declare function rpc(method: string, params?: any, options?: RpcOptions): Promise<any>;
117
+ /**
118
+ * The `query` RPC method. Defaults to `finality: 'final'`; when `block_id`/`blockId` is
119
+ * given the finality is omitted (the node rejects requests carrying both).
120
+ */
121
+ export declare function query<T = any>(params: QueryParams, options?: RpcOptions): Promise<T>;
122
+ /** `view_account`: raw account view (`amount` and `locked` are yoctoNEAR strings) */
123
+ export declare function viewAccount({ account, blockId }: {
124
+ account: string;
125
+ blockId?: BlockId;
126
+ }, options?: RpcOptions): Promise<AccountView>;
127
+ /** Native balance (`amount`, yoctoNEAR string, excludes `locked` stake) */
128
+ export declare function getBalance({ account, blockId }: {
129
+ account: string;
130
+ blockId?: BlockId;
131
+ }, options?: RpcOptions): Promise<string>;
132
+ /**
133
+ * View call (`call_function`). `args` are JSON serialised and base64 encoded, the returned
134
+ * byte array is decoded to JSON (or a string). Throws `NearRpcError` carrying the node
135
+ * error message on failure (unknown account/method, execution error, ...).
136
+ */
137
+ export declare function call<T = any>({ contract, method, args, blockId }: {
138
+ contract: string;
139
+ method: string;
140
+ args?: any;
141
+ blockId?: BlockId;
142
+ }, options?: RpcOptions): Promise<T>;
143
+ /** Alias of `call` */
144
+ export declare const viewFunction: typeof call;
145
+ /**
146
+ * `ft_balance_of` raw balance string. Mirrors the adapters helper: when the token
147
+ * contract does not exist the balance is `'0'` instead of an error.
148
+ */
149
+ export declare function getTokenBalance({ token, account, blockId }: {
150
+ token: string;
151
+ account: string;
152
+ blockId?: BlockId;
153
+ }, options?: RpcOptions): Promise<string>;
154
+ /** `ft_metadata` (NEP-148) */
155
+ export declare function getTokenMetadata({ token, blockId }: {
156
+ token: string;
157
+ blockId?: BlockId;
158
+ }, options?: RpcOptions): Promise<TokenMetadata>;
159
+ /** `ft_total_supply` raw string */
160
+ export declare function getTokenTotalSupply({ token, blockId }: {
161
+ token: string;
162
+ blockId?: BlockId;
163
+ }, options?: RpcOptions): Promise<string>;
164
+ /** `block` RPC: by height/hash (`blockId`) or by finality (default `final`) */
165
+ export declare function getBlock({ blockId, finality }?: {
166
+ blockId?: BlockId;
167
+ finality?: 'final' | 'optimistic' | 'near-final';
168
+ }, options?: RpcOptions): Promise<Block>;
169
+ export declare function getLatestBlock(options?: RpcOptions): Promise<Block>;
170
+ /**
171
+ * Last block produced at or before `timestamp` (unix seconds). Binary search on heights;
172
+ * missing heights are skipped by stepping forward. Non archival nodes only keep ~5 epochs
173
+ * (a few days) of history, older timestamps need an archival `NEAR_RPC`.
174
+ */
175
+ export declare function getBlockAtTimestamp({ timestamp }: {
176
+ timestamp: number;
177
+ }, options?: RpcOptions): Promise<Block>;
178
+ /** `view_access_key_list`: all access keys of an account */
179
+ export declare function getAccessKeys({ account, blockId }: {
180
+ account: string;
181
+ blockId?: BlockId;
182
+ }, options?: RpcOptions): Promise<AccessKey[]>;
183
+ /**
184
+ * `view_state`: contract storage entries whose key starts with `prefix` (utf8 string, or
185
+ * raw bytes / base64 via `prefixBase64`). Keys and values are returned base64 and utf8 decoded.
186
+ */
187
+ export declare function viewState({ contract, prefix, prefixBase64, blockId }: {
188
+ contract: string;
189
+ prefix?: string;
190
+ prefixBase64?: string;
191
+ blockId?: BlockId;
192
+ }, options?: RpcOptions): Promise<StateEntry[]>;