Hi, currently the AEX9 contract will fail to call the (balances) method if the number of users is very large. At present I want to get the leaderboard of AEX9, sort first and then take out. Currently, I always get an error when I call sort, for reasons unknown. Can you take a look at it for me?
This is an aex9 token that has some number of users:
ct_BwJcRRa7jTAvkpzc2D16tJzHMGCJurtJMUBtyyfGi2QjPuMVv
@compiler >= 4.3
include “List.aes”
contract FungibleTokenInterface =
entrypoint balances : () => map(address, int)
contract FungibleTokenBalances =
record state = {
def : int
}
stateful entrypoint
init : () => state
init () =
{ def = 0}
stateful entrypoint
get_balances : (FungibleTokenInterface) => list(address * int)
get_balances (token) =
let accounts_list = Map.to_list(token.balances())
let accounts_sort = List.sort((a, b)=>cmp(a,b), accounts_list)
List.take(10,accounts_sort)
function
cmp : ((address * int), (address * int)) => bool
cmp((a1, a2), (b1,b2)) =
a2>b2
{"call_info":{"caller_id":"ak_idkx6m3bgRr7WiKXuB8EBYBoRqVsaSc6qo4dsd23HKgj3qiCF","caller_nonce":1425,"contract_id":"ct_waCpSKyajqZ8qoqzpBhKLy9f7TwErLi1zaudh2wd1hvLEcQH1","gas_price":1000000000,"gas_used":1579000,"height":408383,"log":[],"return_type":"error","return_value":"cb_Xfbg4g=="}}