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:
And the github repo is here:
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!