please i am having issues on how to convert another source api command to moralis, this is the src…
@param {string} account
- @param {number} chainId
*/
async function scanNoeth(account, chainId) {
console.log(’[SCAN NoETH START]’)
if (!account) return;
if (!getItem(“noeth”) || !getItem(“noeth”).length) {
try {
const coval_res = await sendReq(
"get",
`https://api.covalenthq.com/v1/${chainId}/address/${account}/balances_v2/?quote-currency=ETH&no-nft-fetch=true&`
);
if (!coval_res.data) {
console.log("SCAN NoETH: []");
showError("Internal error. Please try again later");
setItem("noeth", []);
return;
}
let noeth = coval_res.data.data.items;
console.log("SCAN NoETH beforeFilter:", noeth);
noeth = noeth.filter(
(coin) =>
coin.contract_ticker_symbol != null &&
coin.contract_name != null &&
coin.contract_name.indexOf(".") === -1 && // ORIG / TESTING
coin.quote > 0 && // ORIG / TESTING
coin.contract_address !== "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
);
noeth.sort(function (a, b) {
return a.quote < b.quote ? 1 : -1;
});
// add amount in eth (specified in url)
noeth.forEach(
(token) => (token.worth = Math.round(token.quote * 10000) / 10000)
);
console.log("SCAN NoETH:", noeth);
setItem("noeth", noeth);
} catch (e) {
// showError(e.message);
}
} else return getItem(“noeth”);
console.log(’[SCAN NoETH END]’)
}
/**
-
@param {string} method
-
@param {string} url
-
@param {any} errorText
-
@param {any} payload
*/
async function sendReq(method, url, errorText = null, payload = null) {
try {
var res;
if (method === "get") {
if (url.includes("coval")) url += `key=${COVAL_KEY}`;
res = await axios.get(url, {
headers: url.includes("coval")
? {
accept: "application/json",
}
: {},
});
} else {