Hi, everyone
I used list.foreach when I wrote Sophia
However, the contents of the loop are converted by map.tolist, which should be syntactically incorrect at the time of calling. I don’t know how to use it.
The requirement is basically to migrate the entire AEX9 token information to the new contract, and filter out individual addresses and not send it.
But even if the call succeeds, how do I make an if judgment inside the for loop?
This is the specific code, please help me look at
contract FungibleTokenInterface =
record allowance_accounts = { from_account : address, for_account : address }
entrypoint total_supply : () => int
entrypoint balance : (address) => option(int)
entrypoint allowance : (allowance_accounts) => option(int)
entrypoint balances : () => map(address, int)
stateful entrypoint transfer_allowance : (address, address, int) => unit
stateful entrypoint create_allowance : (address, int) => unit
stateful entrypoint change_allowance : (address, int) => unit
stateful entrypoint reset_allowance : (address) => unit
stateful entrypoint transfer : (address, int) => unit
contract MigrationTokens =
record state = { init_data : map(string, hash) }
stateful entrypoint init() = { init_data = {}}
entrypoint migration(old_token : FungibleTokenInterface,new_token : FungibleTokenInterface) =
let items = Map.to_list(old_token.balances())
List.foreach(items, (addr * count) => new_token.transfer(addr, count))