@covalenthq/client-sdk
Advanced tools
Comparing version 0.0.2 to 0.0.3
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -24,31 +15,29 @@ exports.ApprovalService = void 0; | ||
*/ | ||
getApprovals(chainName, walletAddress) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/approvals/${walletAddress}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getApprovals(chainName, walletAddress) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/approvals/${walletAddress}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -55,0 +44,0 @@ } |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -29,46 +20,44 @@ exports.BalancesService = void 0; | ||
*/ | ||
getTokenBalances(chainName, walletAddress, quoteCurrency, nft, noNftFetch, noSpam, noNftAssetMetadata) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (quoteCurrency !== undefined) { | ||
urlParams.append("quote-currency", quoteCurrency.toString()); | ||
async getTokenBalances(chainName, walletAddress, quoteCurrency, nft, noNftFetch, noSpam, noNftAssetMetadata) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (quoteCurrency !== undefined) { | ||
urlParams.append("quote-currency", quoteCurrency.toString()); | ||
} | ||
if (nft !== undefined) { | ||
urlParams.append("nft", nft.toString()); | ||
} | ||
if (noNftFetch !== undefined) { | ||
urlParams.append("no-nft-fetch", noNftFetch.toString()); | ||
} | ||
if (noSpam !== undefined) { | ||
urlParams.append("no-spam", noSpam.toString()); | ||
} | ||
if (noNftAssetMetadata !== undefined) { | ||
urlParams.append("no-nft-asset-metadata", noNftAssetMetadata.toString()); | ||
} | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/balances_v2/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
if (nft !== undefined) { | ||
urlParams.append("nft", nft.toString()); | ||
} | ||
if (noNftFetch !== undefined) { | ||
urlParams.append("no-nft-fetch", noNftFetch.toString()); | ||
} | ||
if (noSpam !== undefined) { | ||
urlParams.append("no-spam", noSpam.toString()); | ||
} | ||
if (noNftAssetMetadata !== undefined) { | ||
urlParams.append("no-nft-asset-metadata", noNftAssetMetadata.toString()); | ||
} | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/balances_v2/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -83,37 +72,35 @@ /** | ||
*/ | ||
getAddressPortfolio(chainName, walletAddress, quoteCurrency, days) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (quoteCurrency !== undefined) { | ||
urlParams.append("quote-currency", quoteCurrency.toString()); | ||
async getAddressPortfolio(chainName, walletAddress, quoteCurrency, days) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (quoteCurrency !== undefined) { | ||
urlParams.append("quote-currency", quoteCurrency.toString()); | ||
} | ||
if (days !== undefined) { | ||
urlParams.append("days", days.toString()); | ||
} | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/portfolio_v2/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
if (days !== undefined) { | ||
urlParams.append("days", days.toString()); | ||
} | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/portfolio_v2/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -130,43 +117,41 @@ /** | ||
*/ | ||
getErc20Transfers(chainName, walletAddress, quoteCurrency, contractAddress, startingBlock, endingBlock) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (quoteCurrency !== undefined) { | ||
urlParams.append("quote-currency", quoteCurrency.toString()); | ||
async getErc20Transfers(chainName, walletAddress, quoteCurrency, contractAddress, startingBlock, endingBlock) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (quoteCurrency !== undefined) { | ||
urlParams.append("quote-currency", quoteCurrency.toString()); | ||
} | ||
if (contractAddress !== undefined) { | ||
urlParams.append("contract-address", contractAddress.toString()); | ||
} | ||
if (startingBlock !== undefined) { | ||
urlParams.append("starting-block", startingBlock.toString()); | ||
} | ||
if (endingBlock !== undefined) { | ||
urlParams.append("ending-block", endingBlock.toString()); | ||
} | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transfers_v2/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
if (contractAddress !== undefined) { | ||
urlParams.append("contract-address", contractAddress.toString()); | ||
} | ||
if (startingBlock !== undefined) { | ||
urlParams.append("starting-block", startingBlock.toString()); | ||
} | ||
if (endingBlock !== undefined) { | ||
urlParams.append("ending-block", endingBlock.toString()); | ||
} | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transfers_v2/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -182,40 +167,38 @@ /** | ||
*/ | ||
getTokenHoldersV2(chainName, tokenAddress, blockHeight, pageSize, pageNumber) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (blockHeight !== undefined) { | ||
urlParams.append("block-height", blockHeight.toString()); | ||
async getTokenHoldersV2(chainName, tokenAddress, blockHeight, pageSize, pageNumber) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (blockHeight !== undefined) { | ||
urlParams.append("block-height", blockHeight.toString()); | ||
} | ||
if (pageSize !== undefined) { | ||
urlParams.append("page-size", pageSize.toString()); | ||
} | ||
if (pageNumber !== undefined) { | ||
urlParams.append("page-number", pageNumber.toString()); | ||
} | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/tokens/${tokenAddress}/token_holders_v2/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
if (pageSize !== undefined) { | ||
urlParams.append("page-size", pageSize.toString()); | ||
} | ||
if (pageNumber !== undefined) { | ||
urlParams.append("page-number", pageNumber.toString()); | ||
} | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/tokens/${tokenAddress}/token_holders_v2/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -228,31 +211,29 @@ /** | ||
*/ | ||
getTokenHoldersChanges(chainName, tokenAddress) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/tokens/${tokenAddress}/token_holders_changes/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getTokenHoldersChanges(chainName, tokenAddress) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/tokens/${tokenAddress}/token_holders_changes/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -259,0 +240,0 @@ } |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -24,31 +15,29 @@ exports.BaseService = void 0; | ||
*/ | ||
getBlock(chainName, blockHeight) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/block_v2/${blockHeight}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getBlock(chainName, blockHeight) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/block_v2/${blockHeight}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -62,31 +51,29 @@ /** | ||
*/ | ||
getBlockHeights(chainName, startDate, endDate) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/block_v2/${startDate}/${endDate}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getBlockHeights(chainName, startDate, endDate) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/block_v2/${startDate}/${endDate}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -101,37 +88,35 @@ /** | ||
*/ | ||
getLogEventsByAddress(chainName, contractAddress, startingBlock, endingBlock) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (startingBlock !== undefined) { | ||
urlParams.append("starting-block", startingBlock.toString()); | ||
async getLogEventsByAddress(chainName, contractAddress, startingBlock, endingBlock) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (startingBlock !== undefined) { | ||
urlParams.append("starting-block", startingBlock.toString()); | ||
} | ||
if (endingBlock !== undefined) { | ||
urlParams.append("ending-block", endingBlock.toString()); | ||
} | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/events/address/${contractAddress}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
if (endingBlock !== undefined) { | ||
urlParams.append("ending-block", endingBlock.toString()); | ||
} | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/events/address/${contractAddress}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -147,40 +132,38 @@ /** | ||
*/ | ||
getLogEventsByTopicHash(chainName, topicHash, startingBlock, endingBlock, secondaryTopics) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (startingBlock !== undefined) { | ||
urlParams.append("starting-block", startingBlock.toString()); | ||
async getLogEventsByTopicHash(chainName, topicHash, startingBlock, endingBlock, secondaryTopics) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (startingBlock !== undefined) { | ||
urlParams.append("starting-block", startingBlock.toString()); | ||
} | ||
if (endingBlock !== undefined) { | ||
urlParams.append("ending-block", endingBlock.toString()); | ||
} | ||
if (secondaryTopics !== undefined) { | ||
urlParams.append("secondary-topics", secondaryTopics.toString()); | ||
} | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/events/topics/${topicHash}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
if (endingBlock !== undefined) { | ||
urlParams.append("ending-block", endingBlock.toString()); | ||
} | ||
if (secondaryTopics !== undefined) { | ||
urlParams.append("secondary-topics", secondaryTopics.toString()); | ||
} | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/events/topics/${topicHash}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -192,31 +175,29 @@ /** | ||
*/ | ||
getAllChains() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/chains/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getAllChains() { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/chains/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -228,31 +209,29 @@ /** | ||
*/ | ||
getAllChainStatus() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/chains/status/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getAllChainStatus() { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/chains/status/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -264,31 +243,29 @@ /** | ||
*/ | ||
getAddressActivity(address) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/activity/${address}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getAddressActivity(address) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/activity/${address}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -295,0 +272,0 @@ } |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -29,49 +20,47 @@ exports.LogEventService = void 0; | ||
*/ | ||
getLogs(chainName, startingBlock, endingBlock, address, topics, blockHash, skipDecode) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (startingBlock !== undefined) { | ||
urlParams.append("starting-block", startingBlock.toString()); | ||
async getLogs(chainName, startingBlock, endingBlock, address, topics, blockHash, skipDecode) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (startingBlock !== undefined) { | ||
urlParams.append("starting-block", startingBlock.toString()); | ||
} | ||
if (endingBlock !== undefined) { | ||
urlParams.append("ending-block", endingBlock.toString()); | ||
} | ||
if (address !== undefined) { | ||
urlParams.append("address", address.toString()); | ||
} | ||
if (topics !== undefined) { | ||
urlParams.append("topics", topics.toString()); | ||
} | ||
if (blockHash !== undefined) { | ||
urlParams.append("block-hash", blockHash.toString()); | ||
} | ||
if (skipDecode !== undefined) { | ||
urlParams.append("skip-decode", skipDecode.toString()); | ||
} | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/events/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
if (endingBlock !== undefined) { | ||
urlParams.append("ending-block", endingBlock.toString()); | ||
} | ||
if (address !== undefined) { | ||
urlParams.append("address", address.toString()); | ||
} | ||
if (topics !== undefined) { | ||
urlParams.append("topics", topics.toString()); | ||
} | ||
if (blockHash !== undefined) { | ||
urlParams.append("block-hash", blockHash.toString()); | ||
} | ||
if (skipDecode !== undefined) { | ||
urlParams.append("skip-decode", skipDecode.toString()); | ||
} | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/events/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -78,0 +67,0 @@ } |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -24,31 +15,29 @@ exports.NameResolverService = void 0; | ||
*/ | ||
getResolvedAddress(chainName, walletAddress) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/resolve_address/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getResolvedAddress(chainName, walletAddress) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/resolve_address/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -55,0 +44,0 @@ } |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -26,40 +17,38 @@ exports.NftService = void 0; | ||
*/ | ||
getChainCollections(chainName, pageSize, pageNumber, noSpam) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (pageSize !== undefined) { | ||
urlParams.append("page-size", pageSize.toString()); | ||
async getChainCollections(chainName, pageSize, pageNumber, noSpam) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (pageSize !== undefined) { | ||
urlParams.append("page-size", pageSize.toString()); | ||
} | ||
if (pageNumber !== undefined) { | ||
urlParams.append("page-number", pageNumber.toString()); | ||
} | ||
if (noSpam !== undefined) { | ||
urlParams.append("no-spam", noSpam.toString()); | ||
} | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/nft/collections/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
if (pageNumber !== undefined) { | ||
urlParams.append("page-number", pageNumber.toString()); | ||
} | ||
if (noSpam !== undefined) { | ||
urlParams.append("no-spam", noSpam.toString()); | ||
} | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/nft/collections/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -74,37 +63,35 @@ /** | ||
*/ | ||
getNftsForAddress(chainName, walletAddress, noSpam, noNftAssetMetadata) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (noSpam !== undefined) { | ||
urlParams.append("no-spam", noSpam.toString()); | ||
async getNftsForAddress(chainName, walletAddress, noSpam, noNftAssetMetadata) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (noSpam !== undefined) { | ||
urlParams.append("no-spam", noSpam.toString()); | ||
} | ||
if (noNftAssetMetadata !== undefined) { | ||
urlParams.append("no-nft-asset-metadata", noNftAssetMetadata.toString()); | ||
} | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/balances_nft/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
if (noNftAssetMetadata !== undefined) { | ||
urlParams.append("no-nft-asset-metadata", noNftAssetMetadata.toString()); | ||
} | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/balances_nft/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -122,46 +109,44 @@ /** | ||
*/ | ||
getTokenIdsForContractWithMetadata(chainName, contractAddress, noMetadata, pageSize, pageNumber, traitsFilter, valuesFilter) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (noMetadata !== undefined) { | ||
urlParams.append("no-metadata", noMetadata.toString()); | ||
async getTokenIdsForContractWithMetadata(chainName, contractAddress, noMetadata, pageSize, pageNumber, traitsFilter, valuesFilter) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (noMetadata !== undefined) { | ||
urlParams.append("no-metadata", noMetadata.toString()); | ||
} | ||
if (pageSize !== undefined) { | ||
urlParams.append("page-size", pageSize.toString()); | ||
} | ||
if (pageNumber !== undefined) { | ||
urlParams.append("page-number", pageNumber.toString()); | ||
} | ||
if (traitsFilter !== undefined) { | ||
urlParams.append("traits-filter", traitsFilter.toString()); | ||
} | ||
if (valuesFilter !== undefined) { | ||
urlParams.append("values-filter", valuesFilter.toString()); | ||
} | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
if (pageSize !== undefined) { | ||
urlParams.append("page-size", pageSize.toString()); | ||
} | ||
if (pageNumber !== undefined) { | ||
urlParams.append("page-number", pageNumber.toString()); | ||
} | ||
if (traitsFilter !== undefined) { | ||
urlParams.append("traits-filter", traitsFilter.toString()); | ||
} | ||
if (valuesFilter !== undefined) { | ||
urlParams.append("values-filter", valuesFilter.toString()); | ||
} | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -177,37 +162,35 @@ /** | ||
*/ | ||
getNftMetadataForGivenTokenIDForContract(chainName, contractAddress, noMetadata, withUncached, tokenId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (noMetadata !== undefined) { | ||
urlParams.append("no-metadata", noMetadata.toString()); | ||
async getNftMetadataForGivenTokenIDForContract(chainName, contractAddress, noMetadata, withUncached, tokenId) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (noMetadata !== undefined) { | ||
urlParams.append("no-metadata", noMetadata.toString()); | ||
} | ||
if (withUncached !== undefined) { | ||
urlParams.append("with-uncached", withUncached.toString()); | ||
} | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/${tokenId}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
if (withUncached !== undefined) { | ||
urlParams.append("with-uncached", withUncached.toString()); | ||
} | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/${tokenId}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -222,34 +205,32 @@ /** | ||
*/ | ||
getNftTransactionsForContractTokenId(chainName, contractAddress, tokenId, noSpam) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (noSpam !== undefined) { | ||
urlParams.append("no-spam", noSpam.toString()); | ||
async getNftTransactionsForContractTokenId(chainName, contractAddress, tokenId, noSpam) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (noSpam !== undefined) { | ||
urlParams.append("no-spam", noSpam.toString()); | ||
} | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/tokens/${contractAddress}/nft_transactions/${tokenId}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/tokens/${contractAddress}/nft_transactions/${tokenId}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -262,31 +243,29 @@ /** | ||
*/ | ||
getTraitsForCollection(chainName, collectionContract) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getTraitsForCollection(chainName, collectionContract) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -300,31 +279,29 @@ /** | ||
*/ | ||
getAttributesForTraitInCollection(chainName, collectionContract, trait) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits/${trait}/attributes/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getAttributesForTraitInCollection(chainName, collectionContract, trait) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits/${trait}/attributes/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -337,31 +314,29 @@ /** | ||
*/ | ||
getCollectionTraitsSummary(chainName, collectionContract) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits_summary/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getCollectionTraitsSummary(chainName, collectionContract) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits_summary/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -375,31 +350,29 @@ /** | ||
*/ | ||
checkOwnershipInNft(chainName, walletAddress, collectionContract) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/collection/${collectionContract}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async checkOwnershipInNft(chainName, walletAddress, collectionContract) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/collection/${collectionContract}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -414,31 +387,29 @@ /** | ||
*/ | ||
checkOwnershipInNftForSpecificTokenId(chainName, walletAddress, collectionContract, tokenId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/collection/${collectionContract}/token/${tokenId}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async checkOwnershipInNftForSpecificTokenId(chainName, walletAddress, collectionContract, tokenId) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/collection/${collectionContract}/token/${tokenId}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -452,31 +423,29 @@ /** | ||
*/ | ||
getNftExternalMetadataForContract(chainName, contractAddress, tokenId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/tokens/${contractAddress}/nft_metadata/${tokenId}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getNftExternalMetadataForContract(chainName, contractAddress, tokenId) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/tokens/${contractAddress}/nft_metadata/${tokenId}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -483,0 +452,0 @@ } |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -28,40 +19,38 @@ exports.PricingService = void 0; | ||
*/ | ||
getTokenPrices(chainName, quoteCurrency, contractAddress, from, to, pricesAtAsc) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (from !== undefined) { | ||
urlParams.append("from", from.toString()); | ||
async getTokenPrices(chainName, quoteCurrency, contractAddress, from, to, pricesAtAsc) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (from !== undefined) { | ||
urlParams.append("from", from.toString()); | ||
} | ||
if (to !== undefined) { | ||
urlParams.append("to", to.toString()); | ||
} | ||
if (pricesAtAsc !== undefined) { | ||
urlParams.append("prices-at-asc", pricesAtAsc.toString()); | ||
} | ||
const response = await fetch(`https://api.covalenthq.com/v1/pricing/historical_by_addresses_v2/${chainName}/${quoteCurrency}/${contractAddress}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
if (to !== undefined) { | ||
urlParams.append("to", to.toString()); | ||
} | ||
if (pricesAtAsc !== undefined) { | ||
urlParams.append("prices-at-asc", pricesAtAsc.toString()); | ||
} | ||
const response = yield fetch(`https://api.covalenthq.com/v1/pricing/historical_by_addresses_v2/${chainName}/${quoteCurrency}/${contractAddress}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -68,0 +57,0 @@ } |
@@ -153,3 +153,3 @@ interface TransactionResponse { | ||
*/ | ||
getRecentTransactionsForAddress(chainName: "btc-mainnet" | "eth-mainnet" | "matic-mainnet" | "bsc-mainnet" | "avalanche-mainnet" | "fantom-mainnet" | "moonbeam-mainnet" | "moonbeam-moonriver" | "rsk-mainnet" | "arbitrum-mainnet" | "palm-mainnet" | "klaytn-mainnet" | "heco-mainnet" | "nervos-godwoken-mainnet" | "axie-mainnet" | "evmos-mainnet" | "astar-mainnet" | "iotex-mainnet" | "harmony-mainnet" | "cronos-mainnet" | "aurora-mainnet" | "emerald-paratime-mainnet" | "boba-mainnet" | "eth-goerli" | "matic-mumbai" | "avalanche-testnet" | "bsc-testnet" | "moonbeam-moonbase-alpha" | "rsk-testnet" | "arbitrum-goerli" | "fantom-testnet" | "palm-testnet" | "heco-testnet" | "nervos-godwoken-testnet" | "evmos-testnet" | "astar-shiden" | "iotex-testnet" | "harmony-testnet" | "aurora-testnet" | "scroll-l2-testnet" | "scroll-l1-testnet" | "covalent-internal-network-v1" | "defi-kingdoms-mainnet" | "swimmer-mainnet" | "boba-avalanche-mainnet" | "boba-bobabeam-mainnet" | "boba-bnb-mainnet" | "boba-rinkeby-testnet" | "boba-bobabase-testnet" | "boba-bnb-testnet" | "boba-avalanche-testnet" | "klaytn-testnet" | "gather-mainnet" | "gather-testnet" | "optimism-mainnet" | "skale-calypso" | "skale-mainnet" | "skale-razor" | "avalanche-dexalot-mainnet" | "skale-omnus" | "avalanche-dexalot-testnet" | "astar-shibuya" | "cronos-testnet" | "defi-kingdoms-testnet" | "metis-mainnet" | "metis-testnet" | "milkomeda-a1-mainnet" | "milkomeda-a1-devnet" | "milkomeda-c1-mainnet" | "milkomeda-c1-devnet" | "swimmer-testnet" | "solana-mainnet" | "skale-europa" | "meter-mainnet" | "meter-testnet" | "skale-exorde" | "boba-goerli" | "neon-testnet" | "skale-staging-uum" | "skale-staging-lcc" | "arbitrum-nova-mainnet" | "canto-mainnet" | "bittorrent-mainnet" | "bittorrent-testnet" | "flarenetworks-flare-mainnet" | "flarenetworks-flare-testnet" | "flarenetworks-canary-mainnet" | "flarenetworks-canary-testnet" | "kcc-mainnet" | "kcc-testnet" | "polygon-zkevm-testnet" | "linea-testnet" | "base-testnet" | "mantle-testnet" | "scroll-alpha-testnet" | "oasys-mainnet" | "oasys-testnet" | "findora-mainnet" | "findora-forge-testnet" | "sx-mainnet", walletAddress: string, quoteCurrency?: "USD" | "CAD" | "EUR" | "SGD" | "INR" | "JPY" | "VND" | "CNY" | "KRW" | "RUB" | "TRY" | "NGN" | "ARS" | "AUD" | "CHF" | "GBP", noLogs?: boolean): Promise<Response<RecentTransactionsResponse>>; | ||
getRecentTransactionsForAddress(chainName: "btc-mainnet" | "eth-mainnet" | "matic-mainnet" | "bsc-mainnet" | "avalanche-mainnet" | "fantom-mainnet" | "moonbeam-mainnet" | "moonbeam-moonriver" | "rsk-mainnet" | "arbitrum-mainnet" | "palm-mainnet" | "klaytn-mainnet" | "heco-mainnet" | "nervos-godwoken-mainnet" | "axie-mainnet" | "evmos-mainnet" | "astar-mainnet" | "iotex-mainnet" | "harmony-mainnet" | "cronos-mainnet" | "aurora-mainnet" | "emerald-paratime-mainnet" | "boba-mainnet" | "eth-goerli" | "matic-mumbai" | "avalanche-testnet" | "bsc-testnet" | "moonbeam-moonbase-alpha" | "rsk-testnet" | "arbitrum-goerli" | "fantom-testnet" | "palm-testnet" | "heco-testnet" | "nervos-godwoken-testnet" | "evmos-testnet" | "astar-shiden" | "iotex-testnet" | "harmony-testnet" | "aurora-testnet" | "scroll-l2-testnet" | "scroll-l1-testnet" | "covalent-internal-network-v1" | "defi-kingdoms-mainnet" | "swimmer-mainnet" | "boba-avalanche-mainnet" | "boba-bobabeam-mainnet" | "boba-bnb-mainnet" | "boba-rinkeby-testnet" | "boba-bobabase-testnet" | "boba-bnb-testnet" | "boba-avalanche-testnet" | "klaytn-testnet" | "gather-mainnet" | "gather-testnet" | "optimism-mainnet" | "skale-calypso" | "skale-mainnet" | "skale-razor" | "avalanche-dexalot-mainnet" | "skale-omnus" | "avalanche-dexalot-testnet" | "astar-shibuya" | "cronos-testnet" | "defi-kingdoms-testnet" | "metis-mainnet" | "metis-testnet" | "milkomeda-a1-mainnet" | "milkomeda-a1-devnet" | "milkomeda-c1-mainnet" | "milkomeda-c1-devnet" | "swimmer-testnet" | "solana-mainnet" | "skale-europa" | "meter-mainnet" | "meter-testnet" | "skale-exorde" | "boba-goerli" | "neon-testnet" | "skale-staging-uum" | "skale-staging-lcc" | "arbitrum-nova-mainnet" | "canto-mainnet" | "bittorrent-mainnet" | "bittorrent-testnet" | "flarenetworks-flare-mainnet" | "flarenetworks-flare-testnet" | "flarenetworks-canary-mainnet" | "flarenetworks-canary-testnet" | "kcc-mainnet" | "kcc-testnet" | "polygon-zkevm-testnet" | "linea-testnet" | "base-testnet" | "mantle-testnet" | "scroll-alpha-testnet" | "oasys-mainnet" | "oasys-testnet" | "findora-mainnet" | "findora-forge-testnet" | "sx-mainnet", walletAddress: string, quoteCurrency?: "USD" | "CAD" | "EUR" | "SGD" | "INR" | "JPY" | "VND" | "CNY" | "KRW" | "RUB" | "TRY" | "NGN" | "ARS" | "AUD" | "CHF" | "GBP", noLogs?: boolean): AsyncIterable<Response<RecentTransactionsResponse>>; | ||
/** | ||
@@ -156,0 +156,0 @@ * |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TransactionsService = void 0; | ||
const baseDelayMs = 1000; // Base delay in milliseconds | ||
async function* paginateEndpoint(url, apiKey, urlsParams) { | ||
let hasNext = true; | ||
let retryCount = 0; | ||
while (hasNext) { | ||
try { | ||
const response = await fetch(`${url}?${urlsParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${apiKey}` | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 404) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
else { | ||
yield data; | ||
if (data.data.links.prev === null) { | ||
hasNext = false; | ||
} | ||
url = data.data.links.prev || ""; | ||
} | ||
} | ||
catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
} | ||
class TransactionsService { | ||
@@ -29,46 +49,44 @@ constructor(apiKey) { | ||
*/ | ||
getTransaction(chainName, txHash, quoteCurrency, noLogs, withDex, withNftSales, withLending) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (quoteCurrency !== undefined) { | ||
urlParams.append("quote-currency", quoteCurrency.toString()); | ||
async getTransaction(chainName, txHash, quoteCurrency, noLogs, withDex, withNftSales, withLending) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (quoteCurrency !== undefined) { | ||
urlParams.append("quote-currency", quoteCurrency.toString()); | ||
} | ||
if (noLogs !== undefined) { | ||
urlParams.append("no-logs", noLogs.toString()); | ||
} | ||
if (withDex !== undefined) { | ||
urlParams.append("with-dex", withDex.toString()); | ||
} | ||
if (withNftSales !== undefined) { | ||
urlParams.append("with-nft-sales", withNftSales.toString()); | ||
} | ||
if (withLending !== undefined) { | ||
urlParams.append("with-lending", withLending.toString()); | ||
} | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/transaction_v2/${txHash}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
if (noLogs !== undefined) { | ||
urlParams.append("no-logs", noLogs.toString()); | ||
} | ||
if (withDex !== undefined) { | ||
urlParams.append("with-dex", withDex.toString()); | ||
} | ||
if (withNftSales !== undefined) { | ||
urlParams.append("with-nft-sales", withNftSales.toString()); | ||
} | ||
if (withLending !== undefined) { | ||
urlParams.append("with-lending", withLending.toString()); | ||
} | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/transaction_v2/${txHash}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -84,40 +102,38 @@ /** | ||
*/ | ||
getTransactionsForAddress(chainName, walletAddress, quoteCurrency, noLogs, blockSignedAtAsc) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (quoteCurrency !== undefined) { | ||
urlParams.append("quote-currency", quoteCurrency.toString()); | ||
async getTransactionsForAddress(chainName, walletAddress, quoteCurrency, noLogs, blockSignedAtAsc) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (quoteCurrency !== undefined) { | ||
urlParams.append("quote-currency", quoteCurrency.toString()); | ||
} | ||
if (noLogs !== undefined) { | ||
urlParams.append("no-logs", noLogs.toString()); | ||
} | ||
if (blockSignedAtAsc !== undefined) { | ||
urlParams.append("block-signed-at-asc", blockSignedAtAsc.toString()); | ||
} | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v2/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
if (noLogs !== undefined) { | ||
urlParams.append("no-logs", noLogs.toString()); | ||
} | ||
if (blockSignedAtAsc !== undefined) { | ||
urlParams.append("block-signed-at-asc", blockSignedAtAsc.toString()); | ||
} | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v2/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -132,37 +148,24 @@ /** | ||
*/ | ||
getRecentTransactionsForAddress(chainName, walletAddress, quoteCurrency, noLogs) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (quoteCurrency !== undefined) { | ||
urlParams.append("quote-currency", quoteCurrency.toString()); | ||
} | ||
if (noLogs !== undefined) { | ||
urlParams.append("no-logs", noLogs.toString()); | ||
} | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v3/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
async *getRecentTransactionsForAddress(chainName, walletAddress, quoteCurrency, noLogs) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (quoteCurrency !== undefined) { | ||
urlParams.append("quote-currency", quoteCurrency.toString()); | ||
} | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
if (noLogs !== undefined) { | ||
urlParams.append("no-logs", noLogs.toString()); | ||
} | ||
for await (const response of paginateEndpoint(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v3/`, this.apiKey, urlParams)) { | ||
yield response; | ||
} | ||
success = true; | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -178,37 +181,35 @@ /** | ||
*/ | ||
getTransactionsForAddressV3(chainName, walletAddress, page, quoteCurrency, noLogs) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (quoteCurrency !== undefined) { | ||
urlParams.append("quote-currency", quoteCurrency.toString()); | ||
async getTransactionsForAddressV3(chainName, walletAddress, page, quoteCurrency, noLogs) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (quoteCurrency !== undefined) { | ||
urlParams.append("quote-currency", quoteCurrency.toString()); | ||
} | ||
if (noLogs !== undefined) { | ||
urlParams.append("no-logs", noLogs.toString()); | ||
} | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v3/page/${page}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
if (noLogs !== undefined) { | ||
urlParams.append("no-logs", noLogs.toString()); | ||
} | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v3/page/${page}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -224,37 +225,35 @@ /** | ||
*/ | ||
getTimeBucketTransactionsForAddress(chainName, walletAddress, timeBucket, quoteCurrency, noLogs) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (quoteCurrency !== undefined) { | ||
urlParams.append("quote-currency", quoteCurrency.toString()); | ||
async getTimeBucketTransactionsForAddress(chainName, walletAddress, timeBucket, quoteCurrency, noLogs) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (quoteCurrency !== undefined) { | ||
urlParams.append("quote-currency", quoteCurrency.toString()); | ||
} | ||
if (noLogs !== undefined) { | ||
urlParams.append("no-logs", noLogs.toString()); | ||
} | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/bulk/transactions/${walletAddress}/${timeBucket}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
if (noLogs !== undefined) { | ||
urlParams.append("no-logs", noLogs.toString()); | ||
} | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/bulk/transactions/${walletAddress}/${timeBucket}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -269,37 +268,35 @@ /** | ||
*/ | ||
getEarliestTimeBucketTransactionsForAddress(chainName, walletAddress, quoteCurrency, noLogs) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (quoteCurrency !== undefined) { | ||
urlParams.append("quote-currency", quoteCurrency.toString()); | ||
async getEarliestTimeBucketTransactionsForAddress(chainName, walletAddress, quoteCurrency, noLogs) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (quoteCurrency !== undefined) { | ||
urlParams.append("quote-currency", quoteCurrency.toString()); | ||
} | ||
if (noLogs !== undefined) { | ||
urlParams.append("no-logs", noLogs.toString()); | ||
} | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/bulk/transactions/${walletAddress}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
if (noLogs !== undefined) { | ||
urlParams.append("no-logs", noLogs.toString()); | ||
} | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/bulk/transactions/${walletAddress}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -315,37 +312,35 @@ /** | ||
*/ | ||
getTransactionsForBlockByPage(chainName, blockHeight, page, quoteCurrency, noLogs) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (quoteCurrency !== undefined) { | ||
urlParams.append("quote-currency", quoteCurrency.toString()); | ||
async getTransactionsForBlockByPage(chainName, blockHeight, page, quoteCurrency, noLogs) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (quoteCurrency !== undefined) { | ||
urlParams.append("quote-currency", quoteCurrency.toString()); | ||
} | ||
if (noLogs !== undefined) { | ||
urlParams.append("no-logs", noLogs.toString()); | ||
} | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/block/${blockHeight}/transactions_v3/page/${page}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
if (noLogs !== undefined) { | ||
urlParams.append("no-logs", noLogs.toString()); | ||
} | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/block/${blockHeight}/transactions_v3/page/${page}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -360,37 +355,35 @@ /** | ||
*/ | ||
getTransactionsForBlock(chainName, blockHeight, quoteCurrency, noLogs) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (quoteCurrency !== undefined) { | ||
urlParams.append("quote-currency", quoteCurrency.toString()); | ||
async getTransactionsForBlock(chainName, blockHeight, quoteCurrency, noLogs) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
if (quoteCurrency !== undefined) { | ||
urlParams.append("quote-currency", quoteCurrency.toString()); | ||
} | ||
if (noLogs !== undefined) { | ||
urlParams.append("no-logs", noLogs.toString()); | ||
} | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/block/${blockHeight}/transactions_v3/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
if (noLogs !== undefined) { | ||
urlParams.append("no-logs", noLogs.toString()); | ||
} | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/block/${blockHeight}/transactions_v3/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -403,31 +396,29 @@ /** | ||
*/ | ||
getTransactionSummary(chainName, walletAddress) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_summary/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getTransactionSummary(chainName, walletAddress) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_summary/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -434,0 +425,0 @@ } |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -24,31 +15,29 @@ exports.XykService = void 0; | ||
*/ | ||
getPools(chainName, dexName) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/pools/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getPools(chainName, dexName) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/pools/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -62,31 +51,29 @@ /** | ||
*/ | ||
getPoolByAddress(chainName, dexName, poolAddress) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/pools/address/${poolAddress}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getPoolByAddress(chainName, dexName, poolAddress) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/pools/address/${poolAddress}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -100,31 +87,29 @@ /** | ||
*/ | ||
getAddressExchangeBalances(chainName, dexName, accountAddress) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/address/${accountAddress}/balances/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getAddressExchangeBalances(chainName, dexName, accountAddress) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/address/${accountAddress}/balances/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -137,31 +122,29 @@ /** | ||
*/ | ||
getNetworkExchangeTokens(chainName, dexName) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/tokens/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getNetworkExchangeTokens(chainName, dexName) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/tokens/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -173,31 +156,29 @@ /** | ||
*/ | ||
getSupportedDEXes() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/xyk/supported_dexes/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getSupportedDEXes() { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/xyk/supported_dexes/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -211,31 +192,29 @@ /** | ||
*/ | ||
getSingleNetworkExchangeToken(chainName, dexName, tokenAddress) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/tokens/address/${tokenAddress}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getSingleNetworkExchangeToken(chainName, dexName, tokenAddress) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/tokens/address/${tokenAddress}/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -249,31 +228,29 @@ /** | ||
*/ | ||
getTransactionsForAccountAddress(chainName, dexName, accountAddress) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/address/${accountAddress}/transactions/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getTransactionsForAccountAddress(chainName, dexName, accountAddress) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/address/${accountAddress}/transactions/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -287,31 +264,29 @@ /** | ||
*/ | ||
getTransactionsForTokenAddress(chainName, dexName, tokenAddress) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/tokens/address/${tokenAddress}/transactions/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getTransactionsForTokenAddress(chainName, dexName, tokenAddress) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/tokens/address/${tokenAddress}/transactions/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -325,31 +300,29 @@ /** | ||
*/ | ||
getTransactionsForExchange(chainName, dexName, poolAddress) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/pools/address/${poolAddress}/transactions/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getTransactionsForExchange(chainName, dexName, poolAddress) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/pools/address/${poolAddress}/transactions/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -362,31 +335,29 @@ /** | ||
*/ | ||
getEcosystemChartData(chainName, dexName) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/ecosystem/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getEcosystemChartData(chainName, dexName) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/ecosystem/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -399,31 +370,29 @@ /** | ||
*/ | ||
getHealthData(chainName, dexName) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/health/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
}); | ||
const data = yield response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
yield new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
async getHealthData(chainName, dexName) { | ||
let retryCount = 0; | ||
let success = false; | ||
while (!success) { | ||
try { | ||
const urlParams = new URLSearchParams(); | ||
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/health/?${urlParams}`, { | ||
headers: { | ||
"Authorization": `Bearer ${this.apiKey}` | ||
} | ||
else { | ||
success = true; | ||
return data; | ||
} | ||
}); | ||
const data = await response.json(); | ||
if (data.error && data.error_code === 429) { | ||
retryCount++; | ||
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation | ||
await new Promise((resolve) => setTimeout(resolve, delayMs)); | ||
} | ||
catch (error) { | ||
else { | ||
success = true; | ||
return error.message; | ||
return data; | ||
} | ||
} | ||
}); | ||
catch (error) { | ||
success = true; | ||
return error.message; | ||
} | ||
} | ||
} | ||
@@ -430,0 +399,0 @@ } |
{ | ||
"name": "@covalenthq/client-sdk", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
280048
3784