@defillama/sdk 5.0.236 → 5.0.240
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/package.json +3 -3
- package/build/Balances.d.ts +0 -139
- package/build/Balances.js +0 -363
- package/build/ChainApi.d.ts +0 -142
- package/build/ChainApi.js +0 -297
- package/build/abi/abi2.d.ts +0 -5
- package/build/abi/abi2.js +0 -215
- package/build/abi/cachedABIs.d.ts +0 -4
- package/build/abi/cachedABIs.js +0 -8
- package/build/abi/convertResults.d.ts +0 -5
- package/build/abi/convertResults.js +0 -60
- package/build/abi/index.d.ts +0 -31
- package/build/abi/index.js +0 -327
- package/build/abi/multicall.d.ts +0 -23
- package/build/abi/multicall.js +0 -382
- package/build/abi/multicall3.d.ts +0 -7
- package/build/abi/multicall3.js +0 -397
- package/build/abi/rpcCall.d.ts +0 -4
- package/build/abi/rpcCall.js +0 -62
- package/build/abi/tron.d.ts +0 -33
- package/build/abi/tron.js +0 -110
- package/build/api.d.ts +0 -10
- package/build/api.js +0 -45
- package/build/api2.d.ts +0 -5
- package/build/api2.js +0 -41
- package/build/chains/algorand.d.ts +0 -277
- package/build/chains/algorand.js +0 -618
- package/build/chains/aptos.d.ts +0 -230
- package/build/chains/aptos.js +0 -612
- package/build/chains/cardano.d.ts +0 -242
- package/build/chains/cardano.js +0 -407
- package/build/chains/cosmos.d.ts +0 -252
- package/build/chains/cosmos.js +0 -618
- package/build/chains/icp.d.ts +0 -235
- package/build/chains/icp.js +0 -1040
- package/build/chains/index.d.ts +0 -23
- package/build/chains/index.js +0 -59
- package/build/chains/near.d.ts +0 -192
- package/build/chains/near.js +0 -446
- package/build/chains/rpc.d.ts +0 -125
- package/build/chains/rpc.js +0 -326
- package/build/chains/starknet.d.ts +0 -205
- package/build/chains/starknet.js +0 -884
- package/build/chains/stellar.d.ts +0 -410
- package/build/chains/stellar.js +0 -1082
- package/build/chains/substrate.d.ts +0 -333
- package/build/chains/substrate.js +0 -1042
- package/build/chains/sui.d.ts +0 -365
- package/build/chains/sui.js +0 -1135
- package/build/chains/svm.d.ts +0 -340
- package/build/chains/svm.js +0 -760
- package/build/chains/tezos.d.ts +0 -225
- package/build/chains/tezos.js +0 -412
- package/build/chains/ton.d.ts +0 -353
- package/build/chains/ton.js +0 -788
- package/build/chains/tron.d.ts +0 -45
- package/build/chains/tron.js +0 -110
- package/build/chains/utxo.d.ts +0 -202
- package/build/chains/utxo.js +0 -592
- package/build/chains/xrpl.d.ts +0 -179
- package/build/chains/xrpl.js +0 -467
- package/build/computeTVL/blocks.d.ts +0 -1
- package/build/computeTVL/blocks.js +0 -12
- package/build/computeTVL/humanizeNumber.d.ts +0 -1
- package/build/computeTVL/humanizeNumber.js +0 -19
- package/build/erc20/index.d.ts +0 -31
- package/build/erc20/index.js +0 -56
- package/build/eth/index.d.ts +0 -22
- package/build/eth/index.js +0 -118
- package/build/general.d.ts +0 -5
- package/build/general.js +0 -20
- package/build/generalUtil.d.ts +0 -8
- package/build/generalUtil.js +0 -73
- package/build/index.d.ts +0 -32
- package/build/index.js +0 -74
- package/build/providers.json +0 -1
- package/build/types.d.ts +0 -76
- package/build/types.js +0 -2
- package/build/util/LlamaProvider.d.ts +0 -46
- package/build/util/LlamaProvider.js +0 -365
- package/build/util/blocks.d.ts +0 -36
- package/build/util/blocks.js +0 -292
- package/build/util/cache.d.ts +0 -45
- package/build/util/cache.js +0 -309
- package/build/util/chainUtils/data.json +0 -1356
- package/build/util/chainUtils/index.d.ts +0 -11
- package/build/util/chainUtils/index.js +0 -136
- package/build/util/coins.d.ts +0 -19
- package/build/util/coins.js +0 -113
- package/build/util/common.d.ts +0 -34
- package/build/util/common.js +0 -373
- package/build/util/computeTVL.d.ts +0 -19
- package/build/util/computeTVL.js +0 -102
- package/build/util/cosmos.d.ts +0 -1
- package/build/util/cosmos.js +0 -8
- package/build/util/debugLog.d.ts +0 -4
- package/build/util/debugLog.js +0 -18
- package/build/util/discord.d.ts +0 -1
- package/build/util/discord.js +0 -33
- package/build/util/elastic.d.ts +0 -43
- package/build/util/elastic.js +0 -113
- package/build/util/env.d.ts +0 -19
- package/build/util/env.js +0 -158
- package/build/util/graph.d.ts +0 -8
- package/build/util/graph.js +0 -50
- package/build/util/index.d.ts +0 -32
- package/build/util/index.js +0 -227
- package/build/util/indexer.compatibility.d.ts +0 -6
- package/build/util/indexer.compatibility.js +0 -64
- package/build/util/indexer.d.ts +0 -92
- package/build/util/indexer.js +0 -744
- package/build/util/indexerSql.d.ts +0 -9
- package/build/util/indexerSql.js +0 -102
- package/build/util/internal-cache.d.ts +0 -11
- package/build/util/internal-cache.js +0 -77
- package/build/util/logs.d.ts +0 -55
- package/build/util/logs.decode.shared.d.ts +0 -8
- package/build/util/logs.decode.shared.js +0 -289
- package/build/util/logs.js +0 -401
- package/build/util/promisePool.d.ts +0 -8
- package/build/util/promisePool.js +0 -31
- package/build/util/r2.d.ts +0 -4
- package/build/util/r2.js +0 -52
- package/build/util/removeRedundantRPCs.d.ts +0 -1
- package/build/util/removeRedundantRPCs.js +0 -49
- package/build/util/transactions.d.ts +0 -35
- package/build/util/transactions.js +0 -22
- package/build/util/updateChainLabels.d.ts +0 -1
- package/build/util/updateChainLabels.js +0 -5
- package/build/util/updateProviderList.d.ts +0 -1
- package/build/util/updateProviderList.js +0 -274
package/build/chains/tron.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { evmToTronAddress, tronToEvmAddress } from "../util/common";
|
|
2
|
-
export { call, multiCall, getBalance, getBalances, unhexifyTarget, hexifyTarget } from "../abi/tron";
|
|
3
|
-
export { evmToTronAddress, tronToEvmAddress };
|
|
4
|
-
export declare const DEFAULT_WALLET_ENDPOINTS = "https://api.trongrid.io";
|
|
5
|
-
export declare const DEFAULT_TRONSCAN_ENDPOINT = "https://apilist.tronscanapi.com";
|
|
6
|
-
/** TronGrid style `wallet/*` REST endpoints, `TRON_WALLET_RPC` (comma separated) overrides */
|
|
7
|
-
export declare function getWalletEndpoints(): string[];
|
|
8
|
-
export declare function getTronscanEndpoint(): string;
|
|
9
|
-
/** POST to a `wallet/*` endpoint (e.g. `wallet/getaccount`) with endpoint rotation */
|
|
10
|
-
export declare function walletPost({ path, body }: {
|
|
11
|
-
path: string;
|
|
12
|
-
body?: any;
|
|
13
|
-
}): Promise<any>;
|
|
14
|
-
/** Raw account record from `wallet/getaccount` (base58 `T...` or hex `41...` address) */
|
|
15
|
-
export declare function getAccount({ address }: {
|
|
16
|
-
address: string;
|
|
17
|
-
}): Promise<any>;
|
|
18
|
-
export declare function getAccountResource({ address }: {
|
|
19
|
-
address: string;
|
|
20
|
-
}): Promise<any>;
|
|
21
|
-
/**
|
|
22
|
-
* TRX balance in SUN including frozen (v1 + v2) and delegated resources, as the
|
|
23
|
-
* adapters helper did. Returns a string.
|
|
24
|
-
*/
|
|
25
|
-
export declare function getTrxBalance({ address, includeFrozen }: {
|
|
26
|
-
address: string;
|
|
27
|
-
includeFrozen?: boolean;
|
|
28
|
-
}): Promise<string>;
|
|
29
|
-
/** Total votes received by a super representative candidate (tronscan) */
|
|
30
|
-
export declare function getStakedTron({ address }: {
|
|
31
|
-
address: string;
|
|
32
|
-
}): Promise<number>;
|
|
33
|
-
export declare function getLatestBlock(): Promise<{
|
|
34
|
-
number: number;
|
|
35
|
-
timestamp: number;
|
|
36
|
-
hash: string;
|
|
37
|
-
}>;
|
|
38
|
-
export declare function getBlock({ number }: {
|
|
39
|
-
number: number;
|
|
40
|
-
}): Promise<{
|
|
41
|
-
number: number;
|
|
42
|
-
timestamp: number;
|
|
43
|
-
hash: string;
|
|
44
|
-
}>;
|
|
45
|
-
export declare function isTronAddress(address: string): boolean;
|
package/build/chains/tron.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_TRONSCAN_ENDPOINT = exports.DEFAULT_WALLET_ENDPOINTS = exports.tronToEvmAddress = exports.evmToTronAddress = exports.hexifyTarget = exports.unhexifyTarget = exports.getBalances = exports.getBalance = exports.multiCall = exports.call = void 0;
|
|
4
|
-
exports.getWalletEndpoints = getWalletEndpoints;
|
|
5
|
-
exports.getTronscanEndpoint = getTronscanEndpoint;
|
|
6
|
-
exports.walletPost = walletPost;
|
|
7
|
-
exports.getAccount = getAccount;
|
|
8
|
-
exports.getAccountResource = getAccountResource;
|
|
9
|
-
exports.getTrxBalance = getTrxBalance;
|
|
10
|
-
exports.getStakedTron = getStakedTron;
|
|
11
|
-
exports.getLatestBlock = getLatestBlock;
|
|
12
|
-
exports.getBlock = getBlock;
|
|
13
|
-
exports.isTronAddress = isTronAddress;
|
|
14
|
-
/**
|
|
15
|
-
* Tron helpers that are not part of the EVM-style ABI path.
|
|
16
|
-
*
|
|
17
|
-
* The EVM-style contract calls (`call`, `multiCall`, `getBalance`) live in
|
|
18
|
-
* `src/abi/tron.ts` and are re-exported here so `sdk.chains.tron` is the single
|
|
19
|
-
* entry point.
|
|
20
|
-
*
|
|
21
|
-
* Replaces:
|
|
22
|
-
* - DefiLlama-Adapters projects/helper/chain/tron.js (getStakedTron, getTrxBalance)
|
|
23
|
-
*/
|
|
24
|
-
const env_1 = require("../util/env");
|
|
25
|
-
const common_1 = require("../util/common");
|
|
26
|
-
Object.defineProperty(exports, "evmToTronAddress", { enumerable: true, get: function () { return common_1.evmToTronAddress; } });
|
|
27
|
-
Object.defineProperty(exports, "tronToEvmAddress", { enumerable: true, get: function () { return common_1.tronToEvmAddress; } });
|
|
28
|
-
const rpc_1 = require("./rpc");
|
|
29
|
-
var tron_1 = require("../abi/tron");
|
|
30
|
-
Object.defineProperty(exports, "call", { enumerable: true, get: function () { return tron_1.call; } });
|
|
31
|
-
Object.defineProperty(exports, "multiCall", { enumerable: true, get: function () { return tron_1.multiCall; } });
|
|
32
|
-
Object.defineProperty(exports, "getBalance", { enumerable: true, get: function () { return tron_1.getBalance; } });
|
|
33
|
-
Object.defineProperty(exports, "getBalances", { enumerable: true, get: function () { return tron_1.getBalances; } });
|
|
34
|
-
Object.defineProperty(exports, "unhexifyTarget", { enumerable: true, get: function () { return tron_1.unhexifyTarget; } });
|
|
35
|
-
Object.defineProperty(exports, "hexifyTarget", { enumerable: true, get: function () { return tron_1.hexifyTarget; } });
|
|
36
|
-
exports.DEFAULT_WALLET_ENDPOINTS = 'https://api.trongrid.io';
|
|
37
|
-
exports.DEFAULT_TRONSCAN_ENDPOINT = 'https://apilist.tronscanapi.com';
|
|
38
|
-
/** TronGrid style `wallet/*` REST endpoints, `TRON_WALLET_RPC` (comma separated) overrides */
|
|
39
|
-
function getWalletEndpoints() {
|
|
40
|
-
return (0, rpc_1.getEndpoints)('tron', exports.DEFAULT_WALLET_ENDPOINTS, { envKey: 'TRON_WALLET_RPC' });
|
|
41
|
-
}
|
|
42
|
-
function getTronscanEndpoint() {
|
|
43
|
-
return (0, rpc_1.getEndpoints)('tron', exports.DEFAULT_TRONSCAN_ENDPOINT, { envKey: 'TRONSCAN_API' })[0];
|
|
44
|
-
}
|
|
45
|
-
function walletHeaders() {
|
|
46
|
-
const headers = { 'Content-Type': 'application/json' };
|
|
47
|
-
const apiKey = (0, env_1.getEnvValue)('TRON_PRO_API_KEY');
|
|
48
|
-
if (apiKey)
|
|
49
|
-
headers['TRON-PRO-API-KEY'] = apiKey;
|
|
50
|
-
return headers;
|
|
51
|
-
}
|
|
52
|
-
function tronscanHeaders() {
|
|
53
|
-
const headers = {};
|
|
54
|
-
const apiKey = (0, env_1.getEnvValue)('TRONSCAN_API_KEY');
|
|
55
|
-
if (apiKey)
|
|
56
|
-
headers['TRON-PRO-API-KEY'] = apiKey;
|
|
57
|
-
return headers;
|
|
58
|
-
}
|
|
59
|
-
/** POST to a `wallet/*` endpoint (e.g. `wallet/getaccount`) with endpoint rotation */
|
|
60
|
-
async function walletPost({ path, body = {} }) {
|
|
61
|
-
return (0, rpc_1.httpPost)(getWalletEndpoints(), body, { path, headers: walletHeaders() });
|
|
62
|
-
}
|
|
63
|
-
/** Raw account record from `wallet/getaccount` (base58 `T...` or hex `41...` address) */
|
|
64
|
-
async function getAccount({ address }) {
|
|
65
|
-
return walletPost({ path: 'wallet/getaccount', body: { address, visible: !address.startsWith('41') } });
|
|
66
|
-
}
|
|
67
|
-
async function getAccountResource({ address }) {
|
|
68
|
-
return walletPost({ path: 'wallet/getaccountresource', body: { address, visible: !address.startsWith('41') } });
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* TRX balance in SUN including frozen (v1 + v2) and delegated resources, as the
|
|
72
|
-
* adapters helper did. Returns a string.
|
|
73
|
-
*/
|
|
74
|
-
async function getTrxBalance({ address, includeFrozen = true }) {
|
|
75
|
-
var _a, _b, _c, _d, _e, _f;
|
|
76
|
-
const data = await getAccount({ address });
|
|
77
|
-
const free = Number((_a = data === null || data === void 0 ? void 0 : data.balance) !== null && _a !== void 0 ? _a : 0);
|
|
78
|
-
if (!includeFrozen)
|
|
79
|
-
return String(free);
|
|
80
|
-
const frozen = ((_b = data === null || data === void 0 ? void 0 : data.frozen) !== null && _b !== void 0 ? _b : []).reduce((t, i) => { var _a; return t + Number((_a = i.frozen_balance) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
81
|
-
const frozenV2 = ((_c = data === null || data === void 0 ? void 0 : data.frozenV2) !== null && _c !== void 0 ? _c : []).reduce((t, i) => { var _a; return t + Number((_a = i.amount) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
82
|
-
const delegatedBandwidth = Number((_d = data === null || data === void 0 ? void 0 : data.delegated_frozenV2_balance_for_bandwidth) !== null && _d !== void 0 ? _d : 0);
|
|
83
|
-
const delegatedEnergy = Number((_f = (_e = data === null || data === void 0 ? void 0 : data.account_resource) === null || _e === void 0 ? void 0 : _e.delegated_frozenV2_balance_for_energy) !== null && _f !== void 0 ? _f : 0);
|
|
84
|
-
return String(free + frozen + frozenV2 + delegatedBandwidth + delegatedEnergy);
|
|
85
|
-
}
|
|
86
|
-
/** Total votes received by a super representative candidate (tronscan) */
|
|
87
|
-
async function getStakedTron({ address }) {
|
|
88
|
-
var _a;
|
|
89
|
-
const data = await (0, rpc_1.httpGet)(getTronscanEndpoint(), { path: 'api/vote', params: { candidate: address }, headers: tronscanHeaders() });
|
|
90
|
-
return Number((_a = data === null || data === void 0 ? void 0 : data.totalVotes) !== null && _a !== void 0 ? _a : 0);
|
|
91
|
-
}
|
|
92
|
-
async function getLatestBlock() {
|
|
93
|
-
const data = await walletPost({ path: 'wallet/getnowblock' });
|
|
94
|
-
return {
|
|
95
|
-
number: data.block_header.raw_data.number,
|
|
96
|
-
timestamp: Math.floor(data.block_header.raw_data.timestamp / 1000),
|
|
97
|
-
hash: data.blockID,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
async function getBlock({ number }) {
|
|
101
|
-
const data = await walletPost({ path: 'wallet/getblockbynum', body: { num: number } });
|
|
102
|
-
return {
|
|
103
|
-
number: data.block_header.raw_data.number,
|
|
104
|
-
timestamp: Math.floor(data.block_header.raw_data.timestamp / 1000),
|
|
105
|
-
hash: data.blockID,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
function isTronAddress(address) {
|
|
109
|
-
return /^T[1-9A-HJ-NP-Za-km-z]{33}$/.test(address) || /^41[0-9a-fA-F]{40}$/.test(address);
|
|
110
|
-
}
|
package/build/chains/utxo.d.ts
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
export interface UtxoChainConfig {
|
|
2
|
-
decimals: number;
|
|
3
|
-
/** explorer base urls in fallback order, overridable with `<CHAIN>_EXPLORER_API` */
|
|
4
|
-
endpoints: string[];
|
|
5
|
-
/** max parallel explorer requests, overridable with `<CHAIN>_RPC_CONCURRENCY` */
|
|
6
|
-
concurrency: number;
|
|
7
|
-
/** pause before every request (free-tier rate limits), applied inside the limiter */
|
|
8
|
-
sleepMs?: number;
|
|
9
|
-
}
|
|
10
|
-
export declare const CHAINS: Record<string, UtxoChainConfig>;
|
|
11
|
-
export declare const utxoChains: string[];
|
|
12
|
-
/** mempool.space base url, used for the timestamp -> block lookup (`BITCOIN_MEMPOOL_API`). */
|
|
13
|
-
export declare const DEFAULT_MEMPOOL_API = "https://mempool.space/api";
|
|
14
|
-
/** blockchain.info multiaddr endpoint for bulk bitcoin balances (`BITCOIN_MULTIADDR_API`). */
|
|
15
|
-
export declare const DEFAULT_MULTIADDR_API = "https://blockchain.info/multiaddr";
|
|
16
|
-
/** blockchain.info multiaddr accepts ~100 addresses per call */
|
|
17
|
-
export declare const MULTIADDR_CHUNK_SIZE = 100;
|
|
18
|
-
/** pause between multiaddr chunks (blockchain.info rate limit), as in the adapters helper */
|
|
19
|
-
export declare const MULTIADDR_SLEEP_MS = 10000;
|
|
20
|
-
/** bitcoin cache api accepts up to 700 addresses per call */
|
|
21
|
-
export declare const CACHE_API_CHUNK_SIZE = 700;
|
|
22
|
-
export declare function isUtxoChain(chain: any): boolean;
|
|
23
|
-
/** Explorer base urls for `chain`: env `<CHAIN>_EXPLORER_API` wins, then `CHAINS[chain].endpoints`. */
|
|
24
|
-
export declare function getEndpoints({ chain }?: {
|
|
25
|
-
chain?: string;
|
|
26
|
-
}): string[];
|
|
27
|
-
export type NumLike = string | number | bigint;
|
|
28
|
-
export interface AddressStats {
|
|
29
|
-
address?: string;
|
|
30
|
-
/** confirmed balance in base units */
|
|
31
|
-
confirmed: string;
|
|
32
|
-
/** mempool (unconfirmed) delta in base units, may be negative */
|
|
33
|
-
unconfirmed: string;
|
|
34
|
-
/** confirmed + unconfirmed */
|
|
35
|
-
total: string;
|
|
36
|
-
/** confirmed tx count */
|
|
37
|
-
txCount: number;
|
|
38
|
-
}
|
|
39
|
-
export interface Utxo {
|
|
40
|
-
txid: string;
|
|
41
|
-
vout: number;
|
|
42
|
-
/** value in base units */
|
|
43
|
-
value: string;
|
|
44
|
-
status: {
|
|
45
|
-
confirmed: boolean;
|
|
46
|
-
block_height?: number;
|
|
47
|
-
block_hash?: string;
|
|
48
|
-
block_time?: number;
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
export interface BlockInfo {
|
|
52
|
-
/** block height */
|
|
53
|
-
number: number;
|
|
54
|
-
/** unix timestamp in seconds */
|
|
55
|
-
timestamp: number;
|
|
56
|
-
hash: string;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Basic shape check for a bitcoin mainnet address: bech32 / bech32m (`bc1...`,
|
|
60
|
-
* single case) or base58 P2PKH / P2SH (`1...` / `3...`). No checksum validation.
|
|
61
|
-
*/
|
|
62
|
-
export declare function isBitcoinAddress(str: any): boolean;
|
|
63
|
-
/** Coerce integer-like values (decimal / bigint / integer number / integer string) to BigInt. */
|
|
64
|
-
export declare function toBigInt(value: NumLike | null | undefined): bigint;
|
|
65
|
-
/**
|
|
66
|
-
* Whole-coin amount (`'1.5'`, `1.5`, `'2e-3'`) -> base units as a decimal string,
|
|
67
|
-
* using string arithmetic so 8-decimal values never go through float rounding.
|
|
68
|
-
* Extra fractional digits are truncated.
|
|
69
|
-
*/
|
|
70
|
-
export declare function toBaseUnits(value: NumLike, decimals: number): string;
|
|
71
|
-
/** Base units -> whole coins as a JS number (`fromBaseUnits('150000000', 8) === 1.5`). */
|
|
72
|
-
export declare function fromBaseUnits(raw: NumLike, decimals: number): number;
|
|
73
|
-
/**
|
|
74
|
-
* Parse an esplora `/address/{addr}` response (blockstream, mempool.space,
|
|
75
|
-
* litecoinspace) into base-unit strings. `confirmed` is `chain_stats.funded - spent`,
|
|
76
|
-
* matching the adapters' getBalanceNow and the coins server getBtcBalanceSats.
|
|
77
|
-
*/
|
|
78
|
-
export declare function parseBlockstreamAddressStats(json: any): AddressStats;
|
|
79
|
-
/**
|
|
80
|
-
* Confirmed balance in base units from any of the supported explorer dialects.
|
|
81
|
-
* Shape detection is ordered so ambiguous `balance` fields (coins vs base units)
|
|
82
|
-
* are only reached for providers that report base units (blockbook v2, kaspa).
|
|
83
|
-
*/
|
|
84
|
-
export declare function parseBalanceResponse(json: any, { address, decimals }: {
|
|
85
|
-
address: string;
|
|
86
|
-
decimals: number;
|
|
87
|
-
}): string;
|
|
88
|
-
export interface GetBalanceOptions {
|
|
89
|
-
chain?: string;
|
|
90
|
-
address: string;
|
|
91
|
-
/** attempts per endpoint before moving to the next one, default 2 */
|
|
92
|
-
retries?: number;
|
|
93
|
-
timeout?: number;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Confirmed balance of `address` in base units. Tries every configured endpoint in
|
|
97
|
-
* order (blockstream -> mempool.space -> blockbook for bitcoin) and throws only
|
|
98
|
-
* when all of them fail.
|
|
99
|
-
*/
|
|
100
|
-
export declare function getBalance({ chain, address, retries, timeout }: GetBalanceOptions): Promise<string>;
|
|
101
|
-
export interface GetBalancesOptions {
|
|
102
|
-
chain?: string;
|
|
103
|
-
addresses: string[];
|
|
104
|
-
/** bitcoin only: skip blockchain.info multiaddr and go per address, default false */
|
|
105
|
-
skipMultiaddr?: boolean;
|
|
106
|
-
retries?: number;
|
|
107
|
-
timeout?: number;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Confirmed balances of many addresses as `{ [address]: baseUnits }`. Bitcoin
|
|
111
|
-
* batches through blockchain.info `multiaddr` (100 per call, 10s between chunks)
|
|
112
|
-
* and falls back to per-address explorer lookups; other chains go per address
|
|
113
|
-
* under the chain limiter.
|
|
114
|
-
*/
|
|
115
|
-
export declare function getBalances({ chain, addresses, skipMultiaddr, retries, timeout }: GetBalancesOptions): Promise<Record<string, string>>;
|
|
116
|
-
/** blockchain.info `multiaddr` base url (`BITCOIN_MULTIADDR_API` overrides). */
|
|
117
|
-
export declare function getMultiaddrEndpoints(): string[];
|
|
118
|
-
/**
|
|
119
|
-
* Bitcoin balances via blockchain.info `multiaddr?active=a|b|c` in chunks of 100.
|
|
120
|
-
* `final_balance` includes unconfirmed outputs, as in the adapters helper.
|
|
121
|
-
*/
|
|
122
|
-
export declare function getBitcoinBalancesMultiaddr({ addresses, chunkSize, sleepMs }: {
|
|
123
|
-
addresses: string[];
|
|
124
|
-
chunkSize?: number;
|
|
125
|
-
sleepMs?: number;
|
|
126
|
-
}): Promise<Record<string, string>>;
|
|
127
|
-
/** `BITCOIN_CACHE_API` url when configured (bulk bitcoin balance cache used by the adapters). */
|
|
128
|
-
export declare function getBitcoinCacheApi(): string | undefined;
|
|
129
|
-
/**
|
|
130
|
-
* Sum of bitcoin balances via the `BITCOIN_CACHE_API` bulk endpoint
|
|
131
|
-
* (`POST { addresses, network: 'BTC' }` -> total sats, 700 addresses per call),
|
|
132
|
-
* mirroring getCachedBitcoinBalances in the adapters. Throws when the env is not set.
|
|
133
|
-
*/
|
|
134
|
-
export declare function getCachedBitcoinTotal({ addresses, chunkSize }: {
|
|
135
|
-
addresses: string[];
|
|
136
|
-
chunkSize?: number;
|
|
137
|
-
}): Promise<string>;
|
|
138
|
-
export interface GetTotalBalanceOptions extends GetBalancesOptions {
|
|
139
|
-
/** bitcoin only: use `BITCOIN_CACHE_API` when set and there are more than this many addresses, default 51 */
|
|
140
|
-
cacheThreshold?: number;
|
|
141
|
-
/** bitcoin only: throw instead of falling back when the cache api fails, default false (forced above 1000 addresses) */
|
|
142
|
-
forceCacheUse?: boolean;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Sum of confirmed balances in base units. For bitcoin with `BITCOIN_CACHE_API`
|
|
146
|
-
* set and more than `cacheThreshold` addresses the bulk cache is used first
|
|
147
|
-
* (the adapters' `_sumTokensBlockchain` flow), then `getBalances` is summed.
|
|
148
|
-
*/
|
|
149
|
-
export declare function getTotalBalance({ chain, addresses, cacheThreshold, forceCacheUse, ...rest }: GetTotalBalanceOptions): Promise<string>;
|
|
150
|
-
/**
|
|
151
|
-
* Unspent outputs of `address` (`/address/{addr}/utxo`), values as base-unit strings.
|
|
152
|
-
* Blockstream answers 400 "Too many unspent outputs" for very large utxo sets
|
|
153
|
-
* (e.g. the genesis address); use `getBalance` for those.
|
|
154
|
-
*/
|
|
155
|
-
export declare function getUtxos({ chain, address }: {
|
|
156
|
-
chain?: string;
|
|
157
|
-
address: string;
|
|
158
|
-
}): Promise<Utxo[]>;
|
|
159
|
-
/**
|
|
160
|
-
* One page of transactions for `address`: `/address/{addr}/txs` (up to 25 mempool
|
|
161
|
-
* + 25 confirmed) or, with `lastSeenTxid`, `/address/{addr}/txs/chain/{txid}`
|
|
162
|
-
* (next 25 confirmed). An empty array means no more pages.
|
|
163
|
-
*/
|
|
164
|
-
export declare function getAddressTxs({ chain, address, lastSeenTxid }: {
|
|
165
|
-
chain?: string;
|
|
166
|
-
address: string;
|
|
167
|
-
lastSeenTxid?: string;
|
|
168
|
-
}): Promise<any[]>;
|
|
169
|
-
/**
|
|
170
|
-
* Bitcoin balance of `address` at `timestamp` (unix seconds) in base units, ported
|
|
171
|
-
* from the adapters' archive getBalance: for timestamps within the last 30 minutes
|
|
172
|
-
* the current utxo set is filtered by `block_time`; otherwise every confirmed tx is
|
|
173
|
-
* replayed (vout adds, vin.prevout subtracts) until the page list is exhausted.
|
|
174
|
-
* Unconfirmed txs (no `block_time`) are ignored.
|
|
175
|
-
*/
|
|
176
|
-
export declare function getBitcoinBalanceAt({ chain, address, timestamp, maxPages }: {
|
|
177
|
-
chain?: string;
|
|
178
|
-
address: string;
|
|
179
|
-
timestamp: number;
|
|
180
|
-
maxPages?: number;
|
|
181
|
-
}): Promise<string>;
|
|
182
|
-
/** Chain tip via `/blocks/tip/height` + `/block-height/{h}` + `/block/{hash}`. */
|
|
183
|
-
export declare function getLatestBlock({ chain }?: {
|
|
184
|
-
chain?: string;
|
|
185
|
-
}): Promise<BlockInfo>;
|
|
186
|
-
/** Block by height (`/block-height/{h}` then `/block/{hash}`). */
|
|
187
|
-
export declare function getBlock({ chain, height }: {
|
|
188
|
-
chain?: string;
|
|
189
|
-
height: number;
|
|
190
|
-
}): Promise<BlockInfo>;
|
|
191
|
-
/** mempool.space base urls (`BITCOIN_MEMPOOL_API` overrides; falls back to any configured mempool endpoint). */
|
|
192
|
-
export declare function getMempoolEndpoints(): string[];
|
|
193
|
-
/**
|
|
194
|
-
* Latest block mined at or before `timestamp` (unix seconds). Bitcoin asks
|
|
195
|
-
* mempool.space `/v1/mining/blocks/timestamp/{ts}` first (then walks back if the
|
|
196
|
-
* returned block is newer than `timestamp`); otherwise / on failure a binary
|
|
197
|
-
* search over `/block-height/{h}` is used.
|
|
198
|
-
*/
|
|
199
|
-
export declare function getBlockAtTimestamp({ chain, timestamp }: {
|
|
200
|
-
chain?: string;
|
|
201
|
-
timestamp: number;
|
|
202
|
-
}): Promise<BlockInfo>;
|