Hello, can someone help in regards to the list of tokens not populating? When I click to select tokens, the ‘token’ select box comes up but the list of tokens do not show!! I have also tried ‘Moralis.start’ as the new standard and although the full code is posted above, that also does not work correct for some reason.
Thank you in advance.
async function init() {
await Moralis.initPlugins();
await Moralis.enable();
await listAvailableTokens();
}
async function listAvailableTokens(){
const result = await Moralis.Plugins.oneInch.getSupportedTokens({
chain: 'eth', // The blockchain you want to use (eth/bsc/polygon)
});
const tokens = result.tokens;
let parent = document.getElementById("token_list");
for (const address in tokens) {
let token = tokens[address];
let div = document.createElement("div");
div.className = "token_row";
let html = `
<img class="token_list_img" src = "${token.logoURI}">
<span class="token_list_text">${token.symbol}</span>
`
div.innerHTML = html;
parent.appendChild(div);
}
}
async function login() {
try {
currentUser = Moralis.User.current();
if (!currentUser) {
currentUser = await Moralis.Web3.authenticate();
}
} catch (error) {
console.log(error);
}
}
function openModal() {
document.getElementById("token_modal").style.display = "block";
}
function closeModal() {
document.getElementById("token_modal").style.display = "none";
}
init();
document.getElementById("modal_close").onclick = closeModal;
document.getElementById("from_token_select").onclick = openModal;
document.getElementById("login_button").onclick = login;
type or paste code here
Here is the modal:
<div class="modal" id="token_modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Select token</h5>
<button id="modal_close" type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div id="token_list"></div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="./main.js"></script>
</body>
</html>type or paste code here