diff --git a/packages/web3/package.json b/packages/web3/package.json index 52c9a7696..936128041 100644 --- a/packages/web3/package.json +++ b/packages/web3/package.json @@ -34,7 +34,7 @@ "author": "Alephium dev ", "config": { "alephium_version": "3.3.0", - "explorer_backend_version": "1.19.3" + "explorer_backend_version": "2.0.0" }, "scripts": { "build": "rm -rf dist/* && npx tsc --build . && webpack", diff --git a/packages/web3/src/api/api-explorer.ts b/packages/web3/src/api/api-explorer.ts index c499cc02d..9401557d3 100644 --- a/packages/web3/src/api/api-explorer.ts +++ b/packages/web3/src/api/api-explorer.ts @@ -9,40 +9,57 @@ * --------------------------------------------------------------- */ -export interface AcceptedTransaction { - /** @format 32-byte-hash */ - hash: string - /** @format block-hash */ - blockHash: string - /** @format int64 */ - timestamp: number - inputs?: Input[] - outputs?: Output[] +/** Val */ +export type Val = ValAddress | ValArray | ValBool | ValByteVec | ValI256 | ValU256 + +/** ContractOutput */ +export interface ContractOutput { + /** @format address */ + address: string /** @format int32 */ - gasAmount: number + hint: number + /** @format 32-byte-hash */ + spent?: string /** @format uint256 */ - gasPrice: string - scriptExecutionOk: boolean - coinbase: boolean + attoAlphAmount: string + tokens?: Token[] + fixedOutput: boolean type: string + /** @format 32-byte-hash */ + key: string } -export interface AddressBalance { - /** @format uint256 */ - balance: string - /** @format uint256 */ - lockedBalance: string +/** IntervalType */ +export enum IntervalType { + Daily = 'daily', + Hourly = 'hourly', + Weekly = 'weekly' } -export interface AddressInfo { - /** @format uint256 */ - balance: string +/** Token */ +export interface Token { /** @format uint256 */ - lockedBalance: string - /** @format int32 */ - txNumber: number + amount: string + /** @format 32-byte-hash */ + id: string +} + +/** ContractLivenessLocation */ +export interface ContractLivenessLocation { + /** @format block-hash */ + blockHash: string + /** @format 32-byte-hash */ + txHash: string + /** @format int64 */ + timestamp: number +} + +/** NonStandard */ +export interface NonStandard { + type: string } +/** AddressTokenBalance */ export interface AddressTokenBalance { /** @format 32-byte-hash */ tokenId: string @@ -52,421 +69,532 @@ export interface AddressTokenBalance { lockedBalance: string } -export interface AmountHistory { - amountHistory?: TimedAmount[] -} - -export interface AssetOutput { +/** OutputRef */ +export interface OutputRef { /** @format int32 */ hint: number /** @format 32-byte-hash */ key: string - /** @format uint256 */ - attoAlphAmount: string +} + +/** Input */ +export interface Input { /** @format address */ - address: string - tokens?: Token[] - /** @format int64 */ - lockTime?: number + address?: string + contractInput: boolean /** @format hex-string */ - message?: string + unlockScript?: string + /** @format uint256 */ + attoAlphAmount?: string + tokens?: Token[] /** @format 32-byte-hash */ - spent?: string - type: string + txHashRef?: string + outputRef: OutputRef } -export interface BadRequest { - detail: string +/** PerChainCount */ +export interface PerChainCount { + /** @format int32 */ + chainFrom: number + /** @format int32 */ + chainTo: number + /** @format int64 */ + count: number } -export interface BlockEntryLite { +/** Unknown */ +export interface Unknown { + id: string + type: string +} + +/** BlockEntry */ +export interface BlockEntry { /** @format block-hash */ - hash: string - /** @format int64 */ - timestamp: number + parent?: string /** @format group-index */ chainFrom: number + /** @format 32-byte-hash */ + depStateHash: string + deps?: string[] + /** @format hex-string */ + nonce: string + version: number + /** @format hex-string */ + target: string + mainChain: boolean + /** @format 32-byte-hash */ + txsHash: string /** @format group-index */ chainTo: number - /** @format int32 */ - height: number + ghostUncles?: GhostUncle[] + /** @format bigint */ + hashRate: string /** @format int32 */ txNumber: number - mainChain: boolean + /** @format block-hash */ + hash: string + /** @format int32 */ + height: number + /** @format int64 */ + timestamp: number +} + +/** ContractParent */ +export interface ContractParent { + /** @format address */ + parent?: string +} + +/** ServiceUnavailable */ +export interface ServiceUnavailable { + detail: string +} + +/** ValI256 */ +export interface ValI256 { + type: string /** @format bigint */ - hashRate: string + value: string } +/** ContractLiveness */ export interface ContractLiveness { /** @format address */ parent?: string - creation: ContractLivenessLocation - destruction?: ContractLivenessLocation interfaceId?: StdInterfaceId + destruction?: ContractLivenessLocation + creation: ContractLivenessLocation } -export interface ContractLivenessLocation { - /** @format block-hash */ - blockHash: string - /** @format 32-byte-hash */ - txHash: string +/** AssetOutput */ +export interface AssetOutput { + /** @format address */ + address: string /** @format int64 */ - timestamp: number -} - -export interface ContractOutput { + lockTime?: number /** @format int32 */ hint: number /** @format 32-byte-hash */ - key: string + spent?: string /** @format uint256 */ attoAlphAmount: string - /** @format address */ - address: string tokens?: Token[] - /** @format 32-byte-hash */ - spent?: string + fixedOutput: boolean type: string + /** @format hex-string */ + message?: string + /** @format 32-byte-hash */ + key: string } -export interface ContractParent { - /** @format address */ - parent?: string +/** NFT */ +export interface NFT { + type: string } -export interface Event { +/** AcceptedTransaction */ +export interface AcceptedTransaction { + outputs?: Output[] /** @format block-hash */ blockHash: string - /** @format 32-byte-hash */ - txHash: string - /** @format address */ - contractAddress: string - /** @format address */ - inputAddress?: string - /** @format int32 */ - eventIndex: number - fields?: Val[] -} - -export interface ExplorerInfo { - releaseVersion: string - commit: string - /** @format int32 */ - migrationsVersion: number - /** @format int64 */ - lastFinalizedInputTime: number -} - -export interface FungibleToken { + scriptSignatures?: string[] + inputs?: Input[] + scriptExecutionOk: boolean type: string -} - -export interface FungibleTokenMetadata { + scriptOpt?: string + version: number + coinbase: boolean + inputSignatures?: string[] + /** @format int32 */ + gasAmount: number + networkId: number /** @format 32-byte-hash */ - id: string - symbol: string - name: string + hash: string /** @format uint256 */ - decimals: string + gasPrice: string + /** @format int64 */ + timestamp: number } -export interface Hashrate { +/** TokenSupply */ +export interface TokenSupply { + /** @format uint256 */ + circulating: string + /** @format uint256 */ + total: string + /** @format uint256 */ + reserved: string + /** @format uint256 */ + maximum: string + /** @format uint256 */ + locked: string /** @format int64 */ timestamp: number - hashrate: number - value: number } -export interface Input { - outputRef: OutputRef - /** @format hex-string */ - unlockScript?: string +/** PendingTransaction */ +export interface PendingTransaction { + outputs?: Output[] + /** @format group-index */ + chainFrom: number + /** @format int64 */ + lastSeen: number + /** @format group-index */ + chainTo: number + inputs?: Input[] + /** @format int32 */ + gasAmount: number + type: string /** @format 32-byte-hash */ - txHashRef?: string - /** @format address */ - address?: string + hash: string /** @format uint256 */ - attoAlphAmount?: string - tokens?: Token[] -} - -export interface InternalServerError { - detail: string -} - -export enum IntervalType { - Daily = 'daily', - Hourly = 'hourly', - Weekly = 'weekly' + gasPrice: string } -export interface ListBlocks { - /** @format int32 */ - total: number - blocks?: BlockEntryLite[] -} +/** TransactionLike */ +export type TransactionLike = AcceptedTransaction | PendingTransaction +/** LogbackValue */ export interface LogbackValue { - name: string level: string + name: string } -export interface MempoolTransaction { - /** @format 32-byte-hash */ - hash: string +/** ValU256 */ +export interface ValU256 { + type: string + /** @format uint256 */ + value: string +} + +/** BlockEntryLite */ +export interface BlockEntryLite { + mainChain: boolean /** @format group-index */ chainFrom: number /** @format group-index */ chainTo: number - inputs?: Input[] - outputs?: Output[] + /** @format bigint */ + hashRate: string /** @format int32 */ - gasAmount: number - /** @format uint256 */ - gasPrice: string + txNumber: number + /** @format block-hash */ + hash: string + /** @format int32 */ + height: number /** @format int64 */ - lastSeen: number + timestamp: number } -export interface NFT { - type: string +/** PerChainHeight */ +export interface PerChainHeight { + /** @format int32 */ + chainFrom: number + /** @format int32 */ + chainTo: number + /** @format int64 */ + value: number + /** @format int64 */ + height: number } -export interface NFTCollection { +/** ValByteVec */ +export interface ValByteVec { type: string + /** @format hex-string */ + value: string } -export interface NFTCollectionMetadata { - /** @format address */ - address: string - collectionUri: string -} - -export interface NFTCollectionWithRoyalty { - type: string +/** TokenStdInterfaceId */ +export enum TokenStdInterfaceId { + Fungible = 'fungible', + NonFungible = 'non-fungible', + NonStandard = 'non-standard' } -export interface NFTMetadata { - /** @format 32-byte-hash */ - id: string - tokenUri: string - /** @format 32-byte-hash */ - collectionId: string - /** @format uint256 */ - nftIndex: string +/** ExplorerInfo */ +export interface ExplorerInfo { + releaseVersion: string + commit: string + /** @format int32 */ + migrationsVersion: number + /** @format int64 */ + lastFinalizedInputTime: number } -export interface NonStandard { +/** ValArray */ +export interface ValArray { type: string + value: Val[] } -export interface NotFound { +/** BadRequest */ +export interface BadRequest { detail: string - resource: string } -export type Output = AssetOutput | ContractOutput - -export interface OutputRef { - /** @format int32 */ - hint: number - /** @format 32-byte-hash */ - key: string +/** Hashrate */ +export interface Hashrate { + hashrate: number + value: number + /** @format int64 */ + timestamp: number } -export interface PendingTransaction { - /** @format 32-byte-hash */ - hash: string - /** @format group-index */ - chainFrom: number - /** @format group-index */ - chainTo: number - inputs?: Input[] +/** Transaction */ +export interface Transaction { outputs?: Output[] + /** @format block-hash */ + blockHash: string + scriptSignatures?: string[] + inputs?: Input[] + scriptExecutionOk: boolean + scriptOpt?: string + version: number + coinbase: boolean + inputSignatures?: string[] /** @format int32 */ gasAmount: number + networkId: number + /** @format 32-byte-hash */ + hash: string /** @format uint256 */ gasPrice: string /** @format int64 */ - lastSeen: number - type: string + timestamp: number } -export interface PerChainCount { - /** @format int32 */ - chainFrom: number - /** @format int32 */ - chainTo: number - /** @format int64 */ - count: number +/** FungibleToken */ +export interface FungibleToken { + type: string } -export interface PerChainDuration { - /** @format int32 */ - chainFrom: number - /** @format int32 */ - chainTo: number - /** @format int64 */ - duration: number - /** @format int64 */ - value: number +/** GhostUncle */ +export interface GhostUncle { + /** @format block-hash */ + blockHash: string + /** @format address */ + miner: string } -export interface PerChainHeight { - /** @format int32 */ - chainFrom: number - /** @format int32 */ - chainTo: number - /** @format int64 */ - height: number - /** @format int64 */ - value: number +/** NFTCollectionWithRoyalty */ +export interface NFTCollectionWithRoyalty { + type: string } +/** PerChainTimedCount */ export interface PerChainTimedCount { + totalCountPerChain?: PerChainCount[] /** @format int64 */ timestamp: number - totalCountPerChain?: PerChainCount[] -} - -export interface ServiceUnavailable { - detail: string } -export type StdInterfaceId = FungibleToken | NFT | NFTCollection | NFTCollectionWithRoyalty | NonStandard | Unknown - -export interface SubContracts { - subContracts?: string[] +/** MempoolTransaction */ +export interface MempoolTransaction { + outputs?: Output[] + /** @format group-index */ + chainFrom: number + /** @format int64 */ + lastSeen: number + /** @format group-index */ + chainTo: number + inputs?: Input[] + /** @format int32 */ + gasAmount: number + /** @format 32-byte-hash */ + hash: string + /** @format uint256 */ + gasPrice: string } -export interface TimedAmount { - /** @format int64 */ - timestamp: number - /** @format bigint */ - amount: string +export enum TokensWithPrice { + WETH = 'WETH', + ALPH = 'ALPH', + USDT = 'USDT', + AYIN = 'AYIN', + DAI = 'DAI', + USDC = 'USDC', + WBTC = 'WBTC' } -export interface TimedCount { - /** @format int64 */ - timestamp: number - /** @format int64 */ - totalCountAllChains: number +export enum MaxSizeTokens { + Value80 = 80 } -export interface TimedPrices { - timestamps?: number[] - prices?: number[] +/** NFTCollection */ +export interface NFTCollection { + type: string } -export interface Token { - /** @format 32-byte-hash */ - id: string - /** @format uint256 */ - amount: string +export enum MaxSizeAddressesForTokens { + Value80 = 80 } -export interface TokenInfo { - /** @format 32-byte-hash */ - token: string - /** Raw interface id, e.g. 0001 */ - stdInterfaceId?: TokenStdInterfaceId | string +/** InternalServerError */ +export interface InternalServerError { + detail: string } -export enum TokenStdInterfaceId { - Fungible = 'fungible', - NonFungible = 'non-fungible', - NonStandard = 'non-standard' +/** TimedPrices */ +export interface TimedPrices { + timestamps?: number[] + prices?: number[] } -export interface TokenSupply { +/** TimedCount */ +export interface TimedCount { + /** @format int64 */ + totalCountAllChains: number /** @format int64 */ timestamp: number - /** @format uint256 */ - total: string - /** @format uint256 */ - circulating: string - /** @format uint256 */ - reserved: string - /** @format uint256 */ - locked: string - /** @format uint256 */ - maximum: string } -export interface Transaction { +/** NFTMetadata */ +export interface NFTMetadata { + /** @format uint256 */ + nftIndex: string + tokenUri: string /** @format 32-byte-hash */ - hash: string - /** @format block-hash */ - blockHash: string + id: string + /** @format 32-byte-hash */ + collectionId: string +} + +/** PerChainDuration */ +export interface PerChainDuration { /** @format int64 */ - timestamp: number - inputs?: Input[] - outputs?: Output[] + duration: number /** @format int32 */ - gasAmount: number - /** @format uint256 */ - gasPrice: string - scriptExecutionOk: boolean - coinbase: boolean + chainFrom: number + /** @format int32 */ + chainTo: number + /** @format int64 */ + value: number } -export type TransactionLike = AcceptedTransaction | PendingTransaction +/** StdInterfaceId */ +export type StdInterfaceId = FungibleToken | NFT | NFTCollection | NFTCollectionWithRoyalty | NonStandard | Unknown +/** Output */ +export type Output = AssetOutput | ContractOutput + +/** Unauthorized */ export interface Unauthorized { detail: string } -export interface Unknown { - id: string - type: string +/** NFTCollectionMetadata */ +export interface NFTCollectionMetadata { + collectionUri: string + /** @format address */ + address: string } -export type Val = ValAddress | ValArray | ValBool | ValByteVec | ValI256 | ValU256 - +/** ValAddress */ export interface ValAddress { + type: string /** @format address */ value: string - type: string } -export interface ValArray { - value: Val[] +/** ValBool */ +export interface ValBool { type: string + value: boolean } -export interface ValBool { - value: boolean - type: string +/** FungibleTokenMetadata */ +export interface FungibleTokenMetadata { + symbol: string + /** @format uint256 */ + decimals: string + name: string + /** @format 32-byte-hash */ + id: string } -export interface ValByteVec { - /** @format hex-string */ - value: string - type: string +export enum MaxSizeAddresses { + Value80 = 80 } -export interface ValI256 { - /** @format bigint */ - value: string - type: string +export enum Currencies { + Btc = 'btc', + Eth = 'eth', + Usd = 'usd', + Eur = 'eur', + Chf = 'chf', + Gbp = 'gbp', + Idr = 'idr', + Vnd = 'vnd', + Rub = 'rub', + Try = 'try', + Cad = 'cad', + Aud = 'aud' } -export interface ValU256 { +/** AddressInfo */ +export interface AddressInfo { /** @format uint256 */ - value: string - type: string + balance: string + /** @format uint256 */ + lockedBalance: string + /** @format int32 */ + txNumber: number } -export enum MaxSizeTokens { - Value80 = 80 +/** AddressBalance */ +export interface AddressBalance { + /** @format uint256 */ + balance: string + /** @format uint256 */ + lockedBalance: string } -export enum MaxSizeAddressesForTokens { - Value80 = 80 +/** AmountHistory */ +export interface AmountHistory { + amountHistory?: string[][] } -export enum MaxSizeAddresses { - Value80 = 80 +/** Event */ +export interface Event { + /** @format block-hash */ + blockHash: string + /** @format address */ + inputAddress?: string + /** @format address */ + contractAddress: string + /** @format int32 */ + eventIndex: number + fields?: Val[] + /** @format 32-byte-hash */ + txHash: string +} + +/** ListBlocks */ +export interface ListBlocks { + /** @format int32 */ + total: number + blocks?: BlockEntryLite[] +} + +/** SubContracts */ +export interface SubContracts { + subContracts?: string[] +} + +/** TokenInfo */ +export interface TokenInfo { + /** Raw interface id, e.g. 0001 */ + stdInterfaceId?: TokenStdInterfaceId | string + /** @format 32-byte-hash */ + token: string +} + +/** NotFound */ +export interface NotFound { + resource: string + detail: string } import 'cross-fetch/polyfill' @@ -684,144 +812,37 @@ export class HttpClient { /** * @title Alephium Explorer API * @version 1.0 - */ -export class Api extends HttpClient { - blocks = { - /** - * @description List latest blocks - * - * @tags Blocks - * @name GetBlocks - * @request GET:/blocks - */ - getBlocks: ( - query?: { - /** - * Page number - * @format int32 - */ - page?: number - /** - * Number of items per page - * @format int32 - */ - limit?: number - /** Reverse pagination */ - reverse?: boolean - }, - params: RequestParams = {} - ) => - this.request({ - path: `/blocks`, - method: 'GET', - query: query, - format: 'json', - ...params - }).then(convertHttpResponse), - - /** - * @description Get a block with hash - * - * @tags Blocks - * @name GetBlocksBlockHash - * @request GET:/blocks/{block_hash} - */ - getBlocksBlockHash: (blockHash: string, params: RequestParams = {}) => - this.request({ - path: `/blocks/${blockHash}`, - method: 'GET', - format: 'json', - ...params - }).then(convertHttpResponse), - - /** - * @description Get block's transactions - * - * @tags Blocks - * @name GetBlocksBlockHashTransactions - * @request GET:/blocks/{block_hash}/transactions - */ - getBlocksBlockHashTransactions: ( - blockHash: string, - query?: { - /** - * Page number - * @format int32 - */ - page?: number - /** - * Number of items per page - * @format int32 - */ - limit?: number - }, - params: RequestParams = {} - ) => - this.request({ - path: `/blocks/${blockHash}/transactions`, - method: 'GET', - query: query, - format: 'json', - ...params - }).then(convertHttpResponse) - } - transactions = { - /** - * @description Get a transaction with hash - * - * @tags Transactions - * @name GetTransactionsTransactionHash - * @request GET:/transactions/{transaction_hash} - */ - getTransactionsTransactionHash: (transactionHash: string, params: RequestParams = {}) => - this.request({ - path: `/transactions/${transactionHash}`, - method: 'GET', - format: 'json', - ...params - }).then(convertHttpResponse) - } - addresses = { - /** - * @description Get address information - * - * @tags Addresses - * @name GetAddressesAddress - * @request GET:/addresses/{address} - */ - getAddressesAddress: (address: string, params: RequestParams = {}) => - this.request({ - path: `/addresses/${address}`, - method: 'GET', - format: 'json', - ...params - }).then(convertHttpResponse), - + */ +export class Api extends HttpClient { + contracts = { /** - * @description List transactions of a given address + * @description Get sub contract addresses * - * @tags Addresses - * @name GetAddressesAddressTransactions - * @request GET:/addresses/{address}/transactions + * @tags Contracts + * @name GetContractsContractAddressSubContracts + * @request GET:/contracts/{contract_address}/sub-contracts */ - getAddressesAddressTransactions: ( - address: string, + getContractsContractAddressSubContracts: ( + contractAddress: string, query?: { /** * Page number * @format int32 + * @min 1 */ page?: number /** * Number of items per page * @format int32 + * @min 0 + * @max 100 */ limit?: number }, params: RequestParams = {} ) => - this.request({ - path: `/addresses/${address}/transactions`, + this.request({ + path: `/contracts/${contractAddress}/sub-contracts`, method: 'GET', query: query, format: 'json', @@ -829,32 +850,47 @@ export class Api extends HttpClient - this.request({ - path: `/addresses/transactions`, + getContractsContractAddressCurrentLiveness: (contractAddress: string, params: RequestParams = {}) => + this.request({ + path: `/contracts/${contractAddress}/current-liveness`, + method: 'GET', + format: 'json', + ...params + }).then(convertHttpResponse), + + /** + * @description Get contract parent address if exist + * + * @tags Contracts + * @name GetContractsContractAddressParent + * @request GET:/contracts/{contract_address}/parent + */ + getContractsContractAddressParent: (contractAddress: string, params: RequestParams = {}) => + this.request({ + path: `/contracts/${contractAddress}/parent`, + method: 'GET', + format: 'json', + ...params + }).then(convertHttpResponse) + } + addresses = { + /** + * @description Are the addresses used (at least 1 transaction) + * + * @tags Addresses, Addresses + * @name PostAddressesUsed + * @request POST:/addresses/used + */ + postAddressesUsed: (data?: string[], params: RequestParams = {}) => + this.request({ + path: `/addresses/used`, method: 'POST', - query: query, body: data, type: ContentType.Json, format: 'json', @@ -862,13 +898,13 @@ export class Api extends HttpClient extends HttpClient - this.request({ - path: `/addresses/${address}/timeranged-transactions`, + this.request({ + path: `/addresses/${address}/export-transactions/csv`, method: 'GET', query: query, - format: 'json', + format: 'text', ...params }).then(convertHttpResponse), /** - * @description Get total transactions of a given address + * @description Get address balance * * @tags Addresses - * @name GetAddressesAddressTotalTransactions - * @request GET:/addresses/{address}/total-transactions + * @name GetAddressesAddressBalance + * @request GET:/addresses/{address}/balance */ - getAddressesAddressTotalTransactions: (address: string, params: RequestParams = {}) => - this.request({ - path: `/addresses/${address}/total-transactions`, + getAddressesAddressBalance: (address: string, params: RequestParams = {}) => + this.request({ + path: `/addresses/${address}/balance`, method: 'GET', format: 'json', ...params @@ -935,47 +961,35 @@ export class Api extends HttpClient - this.request({ - path: `/addresses/${address}/balance`, - method: 'GET', - format: 'json', - ...params - }).then(convertHttpResponse), - /** * @description List address tokens * * @tags Addresses - * @name GetAddressesAddressTokens - * @request GET:/addresses/{address}/tokens - * @deprecated + * @name GetAddressesAddressTokensTokenIdTransactions + * @request GET:/addresses/{address}/tokens/{token_id}/transactions */ - getAddressesAddressTokens: ( + getAddressesAddressTokensTokenIdTransactions: ( address: string, + tokenId: string, query?: { /** * Page number * @format int32 + * @min 1 */ page?: number /** * Number of items per page * @format int32 + * @min 0 + * @max 100 */ limit?: number }, params: RequestParams = {} ) => - this.request({ - path: `/addresses/${address}/tokens`, + this.request({ + path: `/addresses/${address}/tokens/${tokenId}/transactions`, method: 'GET', query: query, format: 'json', @@ -983,31 +997,58 @@ export class Api extends HttpClient + this.request({ + path: `/addresses/${address}/total-transactions`, + method: 'GET', + format: 'json', + ...params + }).then(convertHttpResponse), + + /** + * @description List transactions of a given address within a time-range + * + * @tags Addresses + * @name GetAddressesAddressTimerangedTransactions + * @request GET:/addresses/{address}/timeranged-transactions + */ + getAddressesAddressTimerangedTransactions: ( address: string, - tokenId: string, - query?: { + query: { + /** + * @format int64 + * @min 0 + */ + fromTs: number + /** + * @format int64 + * @min 0 + */ + toTs: number /** * Page number * @format int32 + * @min 1 */ page?: number /** * Number of items per page * @format int32 + * @min 0 + * @max 1000 */ limit?: number }, params: RequestParams = {} ) => this.request({ - path: `/addresses/${address}/tokens/${tokenId}/transactions`, + path: `/addresses/${address}/timeranged-transactions`, method: 'GET', query: query, format: 'json', @@ -1015,83 +1056,101 @@ export class Api extends HttpClient - this.request< - AddressTokenBalance, - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable - >({ - path: `/addresses/${address}/tokens/${tokenId}/balance`, + getAddressesAddressTransactions: ( + address: string, + query?: { + /** + * Page number + * @format int32 + * @min 1 + */ + page?: number + /** + * Number of items per page + * @format int32 + * @min 0 + * @max 100 + */ + limit?: number + }, + params: RequestParams = {} + ) => + this.request({ + path: `/addresses/${address}/transactions`, method: 'GET', + query: query, format: 'json', ...params }).then(convertHttpResponse), /** - * @description Get public key of p2pkh addresses, the address needs to have at least one input. + * No description * * @tags Addresses - * @name GetAddressesAddressPublicKey - * @request GET:/addresses/{address}/public-key + * @name GetAddressesAddressAmountHistory + * @request GET:/addresses/{address}/amount-history */ - getAddressesAddressPublicKey: (address: string, params: RequestParams = {}) => - this.request({ - path: `/addresses/${address}/public-key`, + getAddressesAddressAmountHistory: ( + address: string, + query: { + /** + * @format int64 + * @min 0 + */ + fromTs: number + /** + * @format int64 + * @min 0 + */ + toTs: number + 'interval-type': IntervalType + }, + params: RequestParams = {} + ) => + this.request({ + path: `/addresses/${address}/amount-history`, method: 'GET', + query: query, format: 'json', ...params }).then(convertHttpResponse), /** - * @description Get address tokens with balance + * @description List transactions for given addresses * * @tags Addresses - * @name GetAddressesAddressTokensBalance - * @request GET:/addresses/{address}/tokens-balance + * @name PostAddressesTransactions + * @request POST:/addresses/transactions */ - getAddressesAddressTokensBalance: ( - address: string, + postAddressesTransactions: ( query?: { /** * Page number * @format int32 + * @min 1 */ page?: number /** * Number of items per page * @format int32 + * @min 0 + * @max 100 */ limit?: number }, + data?: string[], params: RequestParams = {} ) => - this.request< - AddressTokenBalance[], - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable - >({ - path: `/addresses/${address}/tokens-balance`, - method: 'GET', - query: query, - format: 'json', - ...params - }).then(convertHttpResponse), - - /** - * @description Are the addresses used (at least 1 transaction) - * - * @tags Addresses, Addresses - * @name PostAddressesUsed - * @request POST:/addresses/used - */ - postAddressesUsed: (data?: string[], params: RequestParams = {}) => - this.request({ - path: `/addresses/used`, + this.request({ + path: `/addresses/transactions`, method: 'POST', + query: query, body: data, type: ContentType.Json, format: 'json', @@ -1102,10 +1161,11 @@ export class Api extends HttpClient extends HttpClient this.request({ - path: `/addresses/${address}/export-transactions/csv`, + path: `/addresses/${address}/amount-history-DEPRECATED`, method: 'GET', query: query, - format: 'text', + format: 'json', ...params }).then(convertHttpResponse), /** - * No description + * @description List address tokens * * @tags Addresses - * @name GetAddressesAddressAmountHistoryDeprecated - * @request GET:/addresses/{address}/amount-history-DEPRECATED + * @name GetAddressesAddressTokens + * @request GET:/addresses/{address}/tokens * @deprecated */ - getAddressesAddressAmountHistoryDeprecated: ( + getAddressesAddressTokens: ( address: string, - query: { + query?: { /** - * @format int64 - * @min 0 + * Page number + * @format int32 + * @min 1 */ - fromTs: number + page?: number /** - * @format int64 + * Number of items per page + * @format int32 * @min 0 + * @max 100 */ - toTs: number - 'interval-type': IntervalType + limit?: number }, params: RequestParams = {} ) => - this.request({ - path: `/addresses/${address}/amount-history-DEPRECATED`, + this.request({ + path: `/addresses/${address}/tokens`, method: 'GET', query: query, format: 'json', @@ -1163,68 +1226,91 @@ export class Api extends HttpClient - this.request({ - path: `/addresses/${address}/amount-history`, + this.request< + AddressTokenBalance[], + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + >({ + path: `/addresses/${address}/tokens-balance`, method: 'GET', query: query, format: 'json', ...params - }).then(convertHttpResponse) - } - infos = { + }).then(convertHttpResponse), + /** - * @description Get explorer informations + * @description Get address balance of given token * - * @tags Infos - * @name GetInfos - * @request GET:/infos + * @tags Addresses + * @name GetAddressesAddressTokensTokenIdBalance + * @request GET:/addresses/{address}/tokens/{token_id}/balance */ - getInfos: (params: RequestParams = {}) => - this.request({ - path: `/infos`, + getAddressesAddressTokensTokenIdBalance: (address: string, tokenId: string, params: RequestParams = {}) => + this.request< + AddressTokenBalance, + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + >({ + path: `/addresses/${address}/tokens/${tokenId}/balance`, method: 'GET', format: 'json', ...params }).then(convertHttpResponse), /** - * @description List latest height for each chain + * @description Get address information * - * @tags Infos - * @name GetInfosHeights - * @request GET:/infos/heights + * @tags Addresses + * @name GetAddressesAddress + * @request GET:/addresses/{address} */ - getInfosHeights: (params: RequestParams = {}) => - this.request({ - path: `/infos/heights`, + getAddressesAddress: (address: string, params: RequestParams = {}) => + this.request({ + path: `/addresses/${address}`, method: 'GET', format: 'json', ...params }).then(convertHttpResponse), + /** + * @description Get public key of p2pkh addresses, the address needs to have at least one input. + * + * @tags Addresses + * @name GetAddressesAddressPublicKey + * @request GET:/addresses/{address}/public-key + */ + getAddressesAddressPublicKey: (address: string, params: RequestParams = {}) => + this.request({ + path: `/addresses/${address}/public-key`, + method: 'GET', + format: 'json', + ...params + }).then(convertHttpResponse) + } + infos = { /** * @description Get token supply list * @@ -1237,11 +1323,14 @@ export class Api extends HttpClient extends HttpClient + getInfosSupplyLockedAlph: (params: RequestParams = {}) => this.request({ - path: `/infos/supply/total-alph`, + path: `/infos/supply/locked-alph`, method: 'GET', format: 'text', ...params }).then(convertHttpResponse), + /** + * @description Get explorer informations + * + * @tags Infos + * @name GetInfos + * @request GET:/infos + */ + getInfos: (params: RequestParams = {}) => + this.request({ + path: `/infos`, + method: 'GET', + format: 'json', + ...params + }).then(convertHttpResponse), + /** * @description Get the ALPH circulating supply * @@ -1286,102 +1390,166 @@ export class Api extends HttpClient + getInfosSupplyTotalAlph: (params: RequestParams = {}) => this.request({ - path: `/infos/supply/reserved-alph`, + path: `/infos/supply/total-alph`, method: 'GET', format: 'text', ...params }).then(convertHttpResponse), /** - * @description Get the ALPH locked supply + * @description Get the total number of transactions * * @tags Infos - * @name GetInfosSupplyLockedAlph - * @request GET:/infos/supply/locked-alph + * @name GetInfosTotalTransactions + * @request GET:/infos/total-transactions */ - getInfosSupplyLockedAlph: (params: RequestParams = {}) => + getInfosTotalTransactions: (params: RequestParams = {}) => this.request({ - path: `/infos/supply/locked-alph`, + path: `/infos/total-transactions`, method: 'GET', format: 'text', ...params }).then(convertHttpResponse), /** - * @description Get the total number of transactions + * @description Get the ALPH reserved supply * * @tags Infos - * @name GetInfosTotalTransactions - * @request GET:/infos/total-transactions + * @name GetInfosSupplyReservedAlph + * @request GET:/infos/supply/reserved-alph */ - getInfosTotalTransactions: (params: RequestParams = {}) => + getInfosSupplyReservedAlph: (params: RequestParams = {}) => this.request({ - path: `/infos/total-transactions`, + path: `/infos/supply/reserved-alph`, method: 'GET', format: 'text', ...params }).then(convertHttpResponse), /** - * @description Get the average block time for each chain + * @description List latest height for each chain + * + * @tags Infos + * @name GetInfosHeights + * @request GET:/infos/heights + */ + getInfosHeights: (params: RequestParams = {}) => + this.request({ + path: `/infos/heights`, + method: 'GET', + format: 'json', + ...params + }).then(convertHttpResponse), + + /** + * @description Get the average block time for each chain + * + * @tags Infos + * @name GetInfosAverageBlockTimes + * @request GET:/infos/average-block-times + */ + getInfosAverageBlockTimes: (params: RequestParams = {}) => + this.request( + { + path: `/infos/average-block-times`, + method: 'GET', + format: 'json', + ...params + } + ).then(convertHttpResponse) + } + utils = { + /** + * @description Perform a sanity check + * + * @tags Utils + * @name PutUtilsSanityCheck + * @request PUT:/utils/sanity-check + */ + putUtilsSanityCheck: (params: RequestParams = {}) => + this.request({ + path: `/utils/sanity-check`, + method: 'PUT', + ...params + }).then(convertHttpResponse), + + /** + * @description Update global log level, accepted: TRACE, DEBUG, INFO, WARN, ERROR + * + * @tags Utils + * @name PutUtilsUpdateGlobalLoglevel + * @request PUT:/utils/update-global-loglevel + */ + putUtilsUpdateGlobalLoglevel: (data: 'TRACE' | 'DEBUG' | 'INFO' | 'WARN' | 'ERROR', params: RequestParams = {}) => + this.request({ + path: `/utils/update-global-loglevel`, + method: 'PUT', + body: data, + ...params + }).then(convertHttpResponse), + + /** + * @description Update logback values * - * @tags Infos - * @name GetInfosAverageBlockTimes - * @request GET:/infos/average-block-times + * @tags Utils + * @name PutUtilsUpdateLogConfig + * @request PUT:/utils/update-log-config */ - getInfosAverageBlockTimes: (params: RequestParams = {}) => - this.request( - { - path: `/infos/average-block-times`, - method: 'GET', - format: 'json', - ...params - } - ).then(convertHttpResponse) + putUtilsUpdateLogConfig: (data?: LogbackValue[], params: RequestParams = {}) => + this.request({ + path: `/utils/update-log-config`, + method: 'PUT', + body: data, + type: ContentType.Json, + ...params + }).then(convertHttpResponse) } - mempool = { + tokens = { /** - * @description list mempool transactions + * @description Return metadata for the given fungible tokens, if metadata doesn't exist or token isn't a fungible, it won't be in the output list * - * @tags Mempool - * @name GetMempoolTransactions - * @request GET:/mempool/transactions + * @tags Tokens + * @name PostTokensFungibleMetadata + * @request POST:/tokens/fungible-metadata */ - getMempoolTransactions: ( - query?: { - /** - * Page number - * @format int32 - */ - page?: number - /** - * Number of items per page - * @format int32 - */ - limit?: number - }, - params: RequestParams = {} - ) => + postTokensFungibleMetadata: (data?: string[], params: RequestParams = {}) => this.request< - MempoolTransaction[], + FungibleTokenMetadata[], BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable >({ - path: `/mempool/transactions`, - method: 'GET', - query: query, + path: `/tokens/fungible-metadata`, + method: 'POST', + body: data, + type: ContentType.Json, format: 'json', ...params - }).then(convertHttpResponse) - } - tokens = { + }).then(convertHttpResponse), + + /** + * @description List given tokens information + * + * @tags Tokens + * @name PostTokens + * @request POST:/tokens + */ + postTokens: (data?: string[], params: RequestParams = {}) => + this.request({ + path: `/tokens`, + method: 'POST', + body: data, + type: ContentType.Json, + format: 'json', + ...params + }).then(convertHttpResponse), + /** * @description List token information * @@ -1394,11 +1562,14 @@ export class Api extends HttpClient extends HttpClient - this.request({ - path: `/tokens`, - method: 'POST', - body: data, - type: ContentType.Json, - format: 'json', - ...params - }).then(convertHttpResponse), - /** * @description List token transactions * @@ -1447,11 +1601,14 @@ export class Api extends HttpClient extends HttpClient + this.request< + NFTCollectionMetadata[], + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + >({ + path: `/tokens/nft-collection-metadata`, + method: 'POST', + body: data, + type: ContentType.Json, + format: 'json', + ...params + }).then(convertHttpResponse), + /** * @description List token addresses * @@ -1478,11 +1655,14 @@ export class Api extends HttpClient extends HttpClient - this.request< - FungibleTokenMetadata[], - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable - >({ - path: `/tokens/fungible-metadata`, - method: 'POST', - body: data, - type: ContentType.Json, - format: 'json', - ...params - }).then(convertHttpResponse), - /** * @description Return metadata for the given nft tokens, if metadata doesn't exist or token isn't a nft, it won't be in the output list * @@ -1531,128 +1691,156 @@ export class Api extends HttpClient - this.request< - NFTCollectionMetadata[], - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable - >({ - path: `/tokens/nft-collection-metadata`, + postMarketPrices: ( + query: { + currency: string + }, + data?: string[], + params: RequestParams = {} + ) => + this.request({ + path: `/market/prices`, method: 'POST', + query: query, body: data, type: ContentType.Json, format: 'json', ...params - }).then(convertHttpResponse) - } - charts = { + }).then(convertHttpResponse), + /** - * @description `interval-type` query param: hourly, daily + * No description * - * @tags Charts - * @name GetChartsHashrates - * @summary Get hashrate chart in H/s - * @request GET:/charts/hashrates + * @tags Market + * @name GetMarketPricesSymbolCharts + * @request GET:/market/prices/{symbol}/charts */ - getChartsHashrates: ( + getMarketPricesSymbolCharts: ( + symbol: string, query: { - /** - * @format int64 - * @min 0 - */ - fromTs: number - /** - * @format int64 - * @min 0 - */ - toTs: number - 'interval-type': IntervalType + currency: string }, params: RequestParams = {} ) => - this.request({ - path: `/charts/hashrates`, + this.request({ + path: `/market/prices/${symbol}/charts`, method: 'GET', query: query, format: 'json', ...params - }).then(convertHttpResponse), - + }).then(convertHttpResponse) + } + blocks = { /** - * @description `interval-type` query param: hourly, daily + * @description Get block's transactions * - * @tags Charts - * @name GetChartsTransactionsCount - * @summary Get transaction count history - * @request GET:/charts/transactions-count + * @tags Blocks + * @name GetBlocksBlockHashTransactions + * @request GET:/blocks/{block_hash}/transactions */ - getChartsTransactionsCount: ( - query: { + getBlocksBlockHashTransactions: ( + blockHash: string, + query?: { /** - * @format int64 - * @min 0 + * Page number + * @format int32 + * @min 1 */ - fromTs: number + page?: number /** - * @format int64 + * Number of items per page + * @format int32 * @min 0 + * @max 100 */ - toTs: number - 'interval-type': IntervalType + limit?: number }, params: RequestParams = {} ) => - this.request({ - path: `/charts/transactions-count`, + this.request({ + path: `/blocks/${blockHash}/transactions`, + method: 'GET', + query: query, + format: 'json', + ...params + }).then(convertHttpResponse), + + /** + * @description Get a block with hash + * + * @tags Blocks + * @name GetBlocksBlockHash + * @request GET:/blocks/{block_hash} + */ + getBlocksBlockHash: (blockHash: string, params: RequestParams = {}) => + this.request({ + path: `/blocks/${blockHash}`, method: 'GET', - query: query, format: 'json', ...params }).then(convertHttpResponse), /** - * @description `interval-type` query param: hourly, daily + * @description List latest blocks * - * @tags Charts - * @name GetChartsTransactionsCountPerChain - * @summary Get transaction count history per chain - * @request GET:/charts/transactions-count-per-chain + * @tags Blocks + * @name GetBlocks + * @request GET:/blocks */ - getChartsTransactionsCountPerChain: ( - query: { + getBlocks: ( + query?: { /** - * @format int64 - * @min 0 + * Page number + * @format int32 + * @min 1 */ - fromTs: number + page?: number /** - * @format int64 + * Number of items per page + * @format int32 * @min 0 + * @max 100 */ - toTs: number - 'interval-type': IntervalType + limit?: number + /** Reverse pagination */ + reverse?: boolean }, params: RequestParams = {} ) => - this.request< - PerChainTimedCount[], - BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable - >({ - path: `/charts/transactions-count-per-chain`, + this.request({ + path: `/blocks`, method: 'GET', query: query, format: 'json', ...params }).then(convertHttpResponse) } + transactions = { + /** + * @description Get a transaction with hash + * + * @tags Transactions + * @name GetTransactionsTransactionHash + * @request GET:/transactions/{transaction_hash} + */ + getTransactionsTransactionHash: (transactionHash: string, params: RequestParams = {}) => + this.request({ + path: `/transactions/${transactionHash}`, + method: 'GET', + format: 'json', + ...params + }).then(convertHttpResponse) + } contractEvents = { /** * @description Get contract events by transaction id @@ -1682,11 +1870,14 @@ export class Api extends HttpClient extends HttpClient extends HttpClient - this.request({ - path: `/contracts/${contractAddress}/current-liveness`, - method: 'GET', - format: 'json', - ...params - }).then(convertHttpResponse), - - /** - * @description Get contract parent address if exist - * - * @tags Contracts - * @name GetContractsContractAddressParent - * @request GET:/contracts/{contract_address}/parent - */ - getContractsContractAddressParent: (contractAddress: string, params: RequestParams = {}) => - this.request({ - path: `/contracts/${contractAddress}/parent`, - method: 'GET', - format: 'json', - ...params - }).then(convertHttpResponse), - + charts = { /** - * @description Get sub contract addresses + * @description `interval-type` query param: hourly, daily * - * @tags Contracts - * @name GetContractsContractAddressSubContracts - * @request GET:/contracts/{contract_address}/sub-contracts + * @tags Charts + * @name GetChartsTransactionsCountPerChain + * @summary Get transaction count history per chain + * @request GET:/charts/transactions-count-per-chain */ - getContractsContractAddressSubContracts: ( - contractAddress: string, - query?: { + getChartsTransactionsCountPerChain: ( + query: { /** - * Page number - * @format int32 + * @format int64 + * @min 0 */ - page?: number + fromTs: number /** - * Number of items per page - * @format int32 + * @format int64 + * @min 0 */ - limit?: number + toTs: number + 'interval-type': IntervalType }, params: RequestParams = {} ) => - this.request({ - path: `/contracts/${contractAddress}/sub-contracts`, + this.request< + PerChainTimedCount[], + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + >({ + path: `/charts/transactions-count-per-chain`, method: 'GET', query: query, format: 'json', ...params - }).then(convertHttpResponse) - } - market = { + }).then(convertHttpResponse), + /** - * No description + * @description `interval-type` query param: hourly, daily * - * @tags Market - * @name PostMarketPrices - * @request POST:/market/prices + * @tags Charts + * @name GetChartsTransactionsCount + * @summary Get transaction count history + * @request GET:/charts/transactions-count */ - postMarketPrices: ( + getChartsTransactionsCount: ( query: { - currency: string + /** + * @format int64 + * @min 0 + */ + fromTs: number + /** + * @format int64 + * @min 0 + */ + toTs: number + 'interval-type': IntervalType }, - data?: string[], params: RequestParams = {} ) => - this.request({ - path: `/market/prices`, - method: 'POST', + this.request({ + path: `/charts/transactions-count`, + method: 'GET', query: query, - body: data, - type: ContentType.Json, format: 'json', ...params }).then(convertHttpResponse), /** - * No description + * @description `interval-type` query param: hourly, daily * - * @tags Market - * @name GetMarketPricesSymbolCharts - * @request GET:/market/prices/{symbol}/charts + * @tags Charts + * @name GetChartsHashrates + * @summary Get hashrate chart in H/s + * @request GET:/charts/hashrates */ - getMarketPricesSymbolCharts: ( - symbol: string, + getChartsHashrates: ( query: { - currency: string + /** + * @format int64 + * @min 0 + */ + fromTs: number + /** + * @format int64 + * @min 0 + */ + toTs: number + 'interval-type': IntervalType }, params: RequestParams = {} ) => - this.request({ - path: `/market/prices/${symbol}/charts`, + this.request({ + path: `/charts/hashrates`, method: 'GET', query: query, format: 'json', ...params }).then(convertHttpResponse) } - utils = { - /** - * @description Perform a sanity check - * - * @tags Utils - * @name PutUtilsSanityCheck - * @request PUT:/utils/sanity-check - */ - putUtilsSanityCheck: (params: RequestParams = {}) => - this.request({ - path: `/utils/sanity-check`, - method: 'PUT', - ...params - }).then(convertHttpResponse), - - /** - * @description Update global log level, accepted: TRACE, DEBUG, INFO, WARN, ERROR - * - * @tags Utils - * @name PutUtilsUpdateGlobalLoglevel - * @request PUT:/utils/update-global-loglevel - */ - putUtilsUpdateGlobalLoglevel: (data: 'TRACE' | 'DEBUG' | 'INFO' | 'WARN' | 'ERROR', params: RequestParams = {}) => - this.request({ - path: `/utils/update-global-loglevel`, - method: 'PUT', - body: data, - ...params - }).then(convertHttpResponse), - + mempool = { /** - * @description Update logback values + * @description list mempool transactions * - * @tags Utils - * @name PutUtilsUpdateLogConfig - * @request PUT:/utils/update-log-config + * @tags Mempool + * @name GetMempoolTransactions + * @request GET:/mempool/transactions */ - putUtilsUpdateLogConfig: (data?: LogbackValue[], params: RequestParams = {}) => - this.request({ - path: `/utils/update-log-config`, - method: 'PUT', - body: data, - type: ContentType.Json, + getMempoolTransactions: ( + query?: { + /** + * Page number + * @format int32 + * @min 1 + */ + page?: number + /** + * Number of items per page + * @format int32 + * @min 0 + * @max 100 + */ + limit?: number + }, + params: RequestParams = {} + ) => + this.request< + MempoolTransaction[], + BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable + >({ + path: `/mempool/transactions`, + method: 'GET', + query: query, + format: 'json', ...params }).then(convertHttpResponse) }