import type { RequestInit, RequestInfo } from "./internal/builtin-types.js"; import type { PromiseOrValue, MergedRequestInit, FinalizedRequestInit } from "./internal/types.js"; export type { Logger, LogLevel } from "./internal/utils/log.js"; import * as Opts from "./internal/request-options.js"; import * as Errors from "./core/error.js"; import * as Uploads from "./core/uploads.js"; import * as API from "./resources/index.js"; import { APIPromise } from "./core/api-promise.js"; import { type Fetch } from "./internal/builtin-types.js"; import { HeadersLike, NullableHeaders } from "./internal/headers.js"; import { FinalRequestOptions, RequestOptions } from "./internal/request-options.js"; import { Enrichment, EnrichmentReportAccount, EnrichmentReportAddress, EnrichmentReportAddresses, EnrichmentReportMetadata, EnrichmentReportSource, EnrichmentRequest } from "./resources/enrichment.js"; import { Scan, ScanReportParams, ScanReportResponse, ScanStatusParams, ScanStatusResponse } from "./resources/scan.js"; import { Site, SiteReportParams, SiteReportResponse, SiteScanHitResponse, SiteScanMissResponse, SiteScanParams, SiteScanResponse } from "./resources/site.js"; import { FinancialStats, MarketType, Token, TokenMarket, TokenReportParams, TokenReportResponse, TokenScanParams, TokenScanResponse, TopHolder, TopHolderLabel } from "./resources/token.js"; import { TokenBulk, TokenBulkScanParams, TokenBulkScanResponse } from "./resources/token-bulk.js"; import { TokenSnapshot, TokenSnapshotDiffParams, TokenSnapshotDiffResponse, TokenSnapshotFullParams, TokenSnapshotFullResponse } from "./resources/token-snapshot.js"; import { TokenWebhookCreateParams, TokenWebhookCreateResponse, TokenWebhookGetAllResponse, TokenWebhookGetResponse, TokenWebhooks } from "./resources/token-webhooks.js"; import { type LogLevel, type Logger } from "./internal/utils/log.js"; import { Bitcoin, BitcoinTransactionScanRequest, BitcoinTransactionScanResponse } from "./resources/bitcoin/bitcoin.js"; import { ChainAgnostic } from "./resources/chain-agnostic/chain-agnostic.js"; import { AddressReportParams, AddressValidation, Authorization, Evm, MetadataParam, TokenScanSupportedChain, TransactionScanSupportedChain, UserOperationData, UserOperationRequest, UserOperationV6, UserOperationV6GasEstimation, UserOperationV7, UserOperationV7GasEstimation, ValidateAddress, ValidateBulkAddresses, ValidateBulkExtendedAddressesRequest, ValidateBulkExtendedAddressesResponse } from "./resources/evm/evm.js"; import { ExchangeProtection } from "./resources/exchange-protection/exchange-protection.js"; import { Hedera } from "./resources/hedera/hedera.js"; import { Solana } from "./resources/solana/solana.js"; import { Starknet, StarknetErc1155Details, StarknetErc1155Diff, StarknetErc20Details, StarknetErc20Diff, StarknetErc721Details, StarknetErc721Diff, StarknetTransactionScanRequest, StarknetTransactionScanResponse } from "./resources/starknet/starknet.js"; import { Stellar, StellarAssetContractDetails, StellarAssetTransferDetails, StellarLegacyAssetDetails, StellarNativeAssetDetails, StellarSingleAssetExposure, StellarTransactionScanRequest, StellarTransactionScanResponse } from "./resources/stellar/stellar.js"; import { Sui, SuiAssetTransferDetailsSchema, SuiNFTDetailsSchema, SuiNFTDiffSchema, SuiNativeAssetDetailsSchema, SuiTransactionScanResponse } from "./resources/sui/sui.js"; declare const environments: { production: string; client: string; }; type Environment = keyof typeof environments; export interface ClientOptions { /** * Authentication method to api.blockaid.io */ apiKey?: string | null | undefined; /** * Authentication method to client.blockaid.io */ clientID?: string | null | undefined; /** * Specifies the environment to use for the API. * * Each environment maps to a different base URL: * - `production` corresponds to `https://api.blockaid.io` * - `client` corresponds to `https://client.blockaid.io` */ environment?: Environment | undefined; /** * Override the default base URL for the API, e.g., "https://api.example.com/v2/" * * Defaults to process.env['BLOCKAID_BASE_URL']. */ baseURL?: string | null | undefined; /** * The maximum amount of time (in milliseconds) that the client should wait for a response * from the server before timing out a single request. * * Note that request timeouts are retried by default, so in a worst-case scenario you may wait * much longer than this timeout before the promise succeeds or fails. * * @unit milliseconds */ timeout?: number | undefined; /** * Additional `RequestInit` options to be passed to `fetch` calls. * Properties will be overridden by per-request `fetchOptions`. */ fetchOptions?: MergedRequestInit | undefined; /** * Specify a custom `fetch` function implementation. * * If not provided, we expect that `fetch` is defined globally. */ fetch?: Fetch | undefined; /** * The maximum number of times that the client will retry a request in case of a * temporary failure, like a network error or a 5XX error from the server. * * @default 2 */ maxRetries?: number | undefined; /** * Default headers to include with every request to the API. * * These can be removed in individual requests by explicitly setting the * header to `null` in request options. */ defaultHeaders?: HeadersLike | undefined; /** * Default query parameters to include with every request to the API. * * These can be removed in individual requests by explicitly setting the * param to `undefined` in request options. */ defaultQuery?: Record | undefined; /** * Set the log level. * * Defaults to process.env['BLOCKAID_LOG'] or 'warn' if it isn't set. */ logLevel?: LogLevel | undefined; /** * Set the logger. * * Defaults to globalThis.console. */ logger?: Logger | undefined; } /** * API Client for interfacing with the Blockaid API. */ export declare class Blockaid { #private; apiKey: string | null; clientID: string | null; baseURL: string; maxRetries: number; timeout: number; logger: Logger; logLevel: LogLevel | undefined; fetchOptions: MergedRequestInit | undefined; private fetch; protected idempotencyHeader?: string; private _options; /** * API Client for interfacing with the Blockaid API. * * @param {string | null | undefined} [opts.apiKey=process.env['BLOCKAID_CLIENT_API_KEY'] ?? null] * @param {string | null | undefined} [opts.clientID=process.env['BLOCKAID_CLIENT_ID_KEY'] ?? null] * @param {Environment} [opts.environment=production] - Specifies the environment URL to use for the API. * @param {string} [opts.baseURL=process.env['BLOCKAID_BASE_URL'] ?? https://api.blockaid.io] - Override the default base URL for the API. * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out. * @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls. * @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation. * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request. * @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API. * @param {Record} opts.defaultQuery - Default query parameters to include with every request to the API. */ constructor({ baseURL, apiKey, clientID, ...opts }?: ClientOptions); /** * Create a new client instance re-using the same options given to the current client with optional overriding. */ withOptions(options: Partial): this; protected defaultQuery(): Record | undefined; protected validateHeaders({ values, nulls }: NullableHeaders): void; protected authHeaders(opts: FinalRequestOptions): Promise; protected apiKeyAuth(opts: FinalRequestOptions): Promise; protected clientIDAuth(opts: FinalRequestOptions): Promise; /** * Basic re-implementation of `qs.stringify` for primitive types. */ protected stringifyQuery(query: object | Record): string; private getUserAgent; protected defaultIdempotencyKey(): string; protected makeStatusError(status: number, error: Object, message: string | undefined, headers: Headers): Errors.APIError; buildURL(path: string, query: Record | null | undefined, defaultBaseURL?: string | undefined): string; /** * Used as a callback for mutating the given `FinalRequestOptions` object. */ protected prepareOptions(options: FinalRequestOptions): Promise; /** * Used as a callback for mutating the given `RequestInit` object. * * This is useful for cases where you want to add certain headers based off of * the request properties, e.g. `method` or `url`. */ protected prepareRequest(request: RequestInit, { url, options }: { url: string; options: FinalRequestOptions; }): Promise; get(path: string, opts?: PromiseOrValue): APIPromise; post(path: string, opts?: PromiseOrValue): APIPromise; patch(path: string, opts?: PromiseOrValue): APIPromise; put(path: string, opts?: PromiseOrValue): APIPromise; delete(path: string, opts?: PromiseOrValue): APIPromise; private methodRequest; request(options: PromiseOrValue, remainingRetries?: number | null): APIPromise; private makeRequest; fetchWithTimeout(url: RequestInfo, init: RequestInit | undefined, ms: number, controller: AbortController): Promise; private shouldRetry; private retryRequest; private calculateDefaultRetryTimeoutMillis; buildRequest(inputOptions: FinalRequestOptions, { retryCount }?: { retryCount?: number; }): Promise<{ req: FinalizedRequestInit; url: string; timeout: number; }>; private buildHeaders; private _makeAbort; private buildBody; static Blockaid: typeof Blockaid; static DEFAULT_TIMEOUT: number; static BlockaidError: typeof Errors.BlockaidError; static APIError: typeof Errors.APIError; static APIConnectionError: typeof Errors.APIConnectionError; static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError; static APIUserAbortError: typeof Errors.APIUserAbortError; static NotFoundError: typeof Errors.NotFoundError; static ConflictError: typeof Errors.ConflictError; static RateLimitError: typeof Errors.RateLimitError; static BadRequestError: typeof Errors.BadRequestError; static AuthenticationError: typeof Errors.AuthenticationError; static InternalServerError: typeof Errors.InternalServerError; static PermissionDeniedError: typeof Errors.PermissionDeniedError; static UnprocessableEntityError: typeof Errors.UnprocessableEntityError; static toFile: typeof Uploads.toFile; evm: API.Evm; solana: API.Solana; hedera: API.Hedera; stellar: API.Stellar; bitcoin: API.Bitcoin; starknet: API.Starknet; sui: API.Sui; site: API.Site; scan: API.Scan; token: API.Token; tokenBulk: API.TokenBulk; tokenWebhooks: API.TokenWebhooks; tokenSnapshot: API.TokenSnapshot; exchangeProtection: API.ExchangeProtection; chainAgnostic: API.ChainAgnostic; enrichment: API.Enrichment; } export declare namespace Blockaid { export type RequestOptions = Opts.RequestOptions; export { Evm as Evm, type AddressReportParams as AddressReportParams, type AddressValidation as AddressValidation, type Authorization as Authorization, type MetadataParam as MetadataParam, type TokenScanSupportedChain as TokenScanSupportedChain, type TransactionScanSupportedChain as TransactionScanSupportedChain, type UserOperationData as UserOperationData, type UserOperationRequest as UserOperationRequest, type UserOperationV6 as UserOperationV6, type UserOperationV6GasEstimation as UserOperationV6GasEstimation, type UserOperationV7 as UserOperationV7, type UserOperationV7GasEstimation as UserOperationV7GasEstimation, type ValidateAddress as ValidateAddress, type ValidateBulkAddresses as ValidateBulkAddresses, type ValidateBulkExtendedAddressesRequest as ValidateBulkExtendedAddressesRequest, type ValidateBulkExtendedAddressesResponse as ValidateBulkExtendedAddressesResponse, }; export { Solana as Solana }; export { Hedera as Hedera }; export { Stellar as Stellar, type StellarAssetContractDetails as StellarAssetContractDetails, type StellarAssetTransferDetails as StellarAssetTransferDetails, type StellarLegacyAssetDetails as StellarLegacyAssetDetails, type StellarNativeAssetDetails as StellarNativeAssetDetails, type StellarSingleAssetExposure as StellarSingleAssetExposure, type StellarTransactionScanRequest as StellarTransactionScanRequest, type StellarTransactionScanResponse as StellarTransactionScanResponse, }; export { Bitcoin as Bitcoin, type BitcoinTransactionScanRequest as BitcoinTransactionScanRequest, type BitcoinTransactionScanResponse as BitcoinTransactionScanResponse, }; export { Starknet as Starknet, type StarknetErc1155Details as StarknetErc1155Details, type StarknetErc1155Diff as StarknetErc1155Diff, type StarknetErc20Details as StarknetErc20Details, type StarknetErc20Diff as StarknetErc20Diff, type StarknetErc721Details as StarknetErc721Details, type StarknetErc721Diff as StarknetErc721Diff, type StarknetTransactionScanRequest as StarknetTransactionScanRequest, type StarknetTransactionScanResponse as StarknetTransactionScanResponse, }; export { Sui as Sui, type SuiAssetTransferDetailsSchema as SuiAssetTransferDetailsSchema, type SuiNativeAssetDetailsSchema as SuiNativeAssetDetailsSchema, type SuiNFTDetailsSchema as SuiNFTDetailsSchema, type SuiNFTDiffSchema as SuiNFTDiffSchema, type SuiTransactionScanResponse as SuiTransactionScanResponse, }; export { Site as Site, type SiteScanHitResponse as SiteScanHitResponse, type SiteScanMissResponse as SiteScanMissResponse, type SiteReportResponse as SiteReportResponse, type SiteScanResponse as SiteScanResponse, type SiteReportParams as SiteReportParams, type SiteScanParams as SiteScanParams, }; export { Scan as Scan, type ScanReportResponse as ScanReportResponse, type ScanStatusResponse as ScanStatusResponse, type ScanReportParams as ScanReportParams, type ScanStatusParams as ScanStatusParams, }; export { Token as Token, type FinancialStats as FinancialStats, type MarketType as MarketType, type TokenMarket as TokenMarket, type TopHolder as TopHolder, type TopHolderLabel as TopHolderLabel, type TokenReportResponse as TokenReportResponse, type TokenScanResponse as TokenScanResponse, type TokenReportParams as TokenReportParams, type TokenScanParams as TokenScanParams, }; export { TokenBulk as TokenBulk, type TokenBulkScanResponse as TokenBulkScanResponse, type TokenBulkScanParams as TokenBulkScanParams, }; export { TokenWebhooks as TokenWebhooks, type TokenWebhookCreateResponse as TokenWebhookCreateResponse, type TokenWebhookGetResponse as TokenWebhookGetResponse, type TokenWebhookGetAllResponse as TokenWebhookGetAllResponse, type TokenWebhookCreateParams as TokenWebhookCreateParams, }; export { TokenSnapshot as TokenSnapshot, type TokenSnapshotDiffResponse as TokenSnapshotDiffResponse, type TokenSnapshotFullResponse as TokenSnapshotFullResponse, type TokenSnapshotDiffParams as TokenSnapshotDiffParams, type TokenSnapshotFullParams as TokenSnapshotFullParams, }; export { ExchangeProtection as ExchangeProtection }; export { ChainAgnostic as ChainAgnostic }; export { Enrichment as Enrichment, type EnrichmentReportAccount as EnrichmentReportAccount, type EnrichmentReportAddress as EnrichmentReportAddress, type EnrichmentReportAddresses as EnrichmentReportAddresses, type EnrichmentReportMetadata as EnrichmentReportMetadata, type EnrichmentReportSource as EnrichmentReportSource, type EnrichmentRequest as EnrichmentRequest, }; } //# sourceMappingURL=client.d.ts.map