Hi - I was following along the " Programming Token Swaps in 10 Minutes" tutorial with the 1INCH plugin and tried to quiclky expand functionality to build a regular swap interface as exercise.
I came across 2 doubts:
-
When the user has logged in using metamask, how can I detect the chain heâs currently logged in to? I would need to know this so I can show the proper list of tokens available on that chain.
-
The second doubt I have is not Moralis related but I havenât been able to solve this issue:
Whenever I get the full list of tokens on any chain using the Moralis.Plugins.oneInch.getSupportedTokens() function I get an object and iterate through it to create the options for my HTML select elements. The problem is that I canât get the list of options to be added in both select elements (swap from token & swap to token). Only one of the selects is filled with the options and the other stays empty. I have tried many ways now and havenât found a way to fill both selects so the user can select from which token they want to swap and to what token.
Iâve uploaded my code here:
https://simple-swap-dapp.netlify.app/
And the github repo is here:
https://github.com/mawmawmaw/simple-swap-dapp
Thereâs a function in the file âmain.jsâ in line 76 called âbuildDropDownsâ that should do the work but it doesnât
Hope someone can take a look at these and help me out
Much thanks in advance!