eos-utils
Version:
Powerful util library based on eosjs.
42 lines (41 loc) • 1.45 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
/* eslint-disable no-console,no-await-in-loop */
const eosjs_1 = require('eosjs');
const node_fetch_1 = require('node-fetch');
const index_1 = require('./index');
async function checkApiEndpoint(url) {
try {
await index_1.getTableRows(
{
code: 'newdexpublic',
scope: 'newdexpublic',
table: 'globalconfig',
},
url,
);
await index_1.accountExists('cryptoforest', url);
await index_1.getCurrencyBalance('cryptoforest', 'EOS', url);
await index_1.getKeyAccounts('EOS6zQQQXEgT9jmy9NHahAXqTRV4LaeCUwsE8XP8MP557Kn6s3KxP', url);
await index_1.getKeyAccounts('EOS71uwakr9eo8NMARvtaeA5mfccyWtJyXHCeiSzsrbdhnn5DJXu3', url);
return true;
} catch (e) {
console.error(
`${url}:\n RpcError: ${e instanceof eosjs_1.RpcError}, FetchError: ${e instanceof
node_fetch_1.FetchError} \n ${e.message}`,
);
return false;
}
}
(async () => {
console.info(index_1.numericFromName('cryptoforest'));
console.info(await index_1.getCurrencyStats('eosiopowcoin', 'POW'));
const requests = index_1.EOS_API_ENDPOINTS.map(x => checkApiEndpoint(x));
const success = await Promise.all(requests);
const result = [];
for (let i = 0; i < index_1.EOS_API_ENDPOINTS.length; i += 1) {
if (success[i]) result.push(index_1.EOS_API_ENDPOINTS[i]);
}
console.info(result);
})();