diff --git a/src/provider.ts b/src/provider.ts index b17fcba..5ae2ac7 100644 --- a/src/provider.ts +++ b/src/provider.ts @@ -16,6 +16,7 @@ import { GetNFTsByOwnerReply, GetNFTsByOwnerRequest, GetNftTransfersReply, + GetNftTransfersRequest, GetTokenHoldersCountReply, GetTokenHoldersCountRequest, GetTokenHoldersReply, @@ -45,84 +46,40 @@ export class AnkrProvider { requestConfig: AxiosRequestConfig _nextId: number - /** - * Constructs an instance of AnkrProvider. - * @param endpoint Advanced API endpoint. Example: https://rpc.ankr.com/multichain/YOUR-TOKEN - */ constructor(endpoint: string) { this.url = endpoint this.requestConfig = {headers: {'Content-Type': 'application/json', 'Accept-Encoding': 'gzip'}}; this._nextId = 1 } - /** - * Returns the array of Log matching the filter. - * @param params A GetLogsRequest object. - * @returns Promise - */ async getLogs(params: GetLogsRequest): Promise { return this.send("ankr_getLogs", params) } - /** - * Returns the array of Block within specified range. - * @param params A GetBlocksRequest object. - * @returns Promise - */ async getBlocks(params: GetBlocksRequest): Promise { return this.send("ankr_getBlocks", params) } - /** - * Returns the Transaction(s) with specified hash among all supported blockchains. - * @param params A GetTransactionsByHashRequest object. - * @returns Promise - */ async getTransactionsByHash(params: GetTransactionsByHashRequest): Promise { return this.send("ankr_getTransactionsByHash", params) } - /** - * Returns Transactions of specified address. - * @param params A GetTransactionsByAddressRequest object. - * @returns Promise - */ async getTransactionsByAddress(params: GetTransactionsByAddressRequest): Promise { return this.send("ankr_getTransactionsByAddress", params) } - /** - * Returns Transfers of specified address. - * @param params A GetTransfersRequest object. - * @returns Promise - */ async getTokenTransfers(params: GetTransfersRequest): Promise { return this.send("ankr_getTokenTransfers", params) } - /** - * Returns NFT Transfers of specified address. - * @param params A GetNftTransfersRequest object. - * @returns Promise - */ - async getNftTransfers(params: GetTransfersRequest): Promise { + async getNftTransfers(params: GetNftTransfersRequest): Promise { return this.send("ankr_getNftTransfers", params) } - /** - * Returns coin and token balances of the wallet. - * @param params A GetAccountBalanceRequest object. - * @returns Promise - */ async getAccountBalance(params: GetAccountBalanceRequest): Promise { return this.send("ankr_getAccountBalance", params) } - /** - * Returns NFT collectibles of the wallet. - * @param params A GetNFTsByOwnerRequest object. - * @returns Promise - */ async getNFTsByOwner(params: GetNFTsByOwnerRequest): Promise { return this.send("ankr_getNFTsByOwner", params) } @@ -130,7 +87,7 @@ export class AnkrProvider { /** * Returns NFT's contract metadata. * @param params A GetNFTMetadataRequest object. - * @returns Promise + * @returns Promise */ async getNFTMetadata(params: GetNFTMetadataRequest): Promise { return await this.send("ankr_getNFTMetadata", params) @@ -139,85 +96,44 @@ export class AnkrProvider { /** * Returns NFT's holders. * @param params A GetNFTHoldersRequest object. - * @returns Promise + * @returns Promise */ async getNFTHolders(params: GetNFTHoldersRequest): Promise { return await this.send("ankr_getNFTHolders", params) } - /** - * Returns list of token holders. - * @param params A GetTokenHoldersRequest object. - * @returns Promise - */ async getTokenHolders(params: GetTokenHoldersRequest): Promise { return this.send("ankr_getTokenHolders", params) } - /** - * Returns list of historical token holders count by day. - * @param params A GetTokenHoldersCountRequest object. - * @returns Promise - */ async getTokenHoldersCount(params: GetTokenHoldersCountRequest): Promise { return this.send("ankr_getTokenHoldersCount", params) } - /** - * Returns token USD price. - * @param params A GetTokenPriceRequest object. - * @returns Promise - */ async getTokenPrice(params: GetTokenPriceRequest): Promise { return this.send("ankr_getTokenPrice", params) } - /** - * Returns list of currencies. - * @param params A GetCurrenciesRequest object. - * @returns Promise - */ async getCurrencies(params: GetCurrenciesRequest): Promise { return this.send("ankr_getCurrencies", params) } - /** - * Returns history of the token price. - * @param params A GetTokenPriceHistoryRequest object. - * @returns Promise - */ async getTokenPriceHistory(params: GetTokenPriceHistoryRequest): Promise { return this.send("ankr_getTokenPriceHistory", params) } - /** - * Returns a list of tokens and the pool used for price calculation. - * @param params A ExplainTokenPriceRequest object. - * @returns Promise - */ async explainTokenPrice(params: ExplainTokenPriceRequest): Promise { return this.send("ankr_explainTokenPrice", params) } - /** - * Returns blockchain stats (num of txs, etc.). - * @param params A GetBlockchainStatsRequest object. - * @returns Promise - */ async getBlockchainStats(params: GetBlockchainStatsRequest): Promise { return this.send("ankr_getBlockchainStats", params) } - /** - * Returns on which chain address was interacting. - * @param params A GetInteractionsRequest object. - * @returns Promise - */ async getInteractions(params: GetInteractionsRequest): Promise { return this.send("ankr_getInteractions", params) } - private async send(method: string, params: any): Promise { const request = {method, params, id: (this._nextId++), jsonrpc: "2.0"}; const response = await axios.post(this.url, JSON.stringify(request), this.requestConfig);