feat: new token API to fetch balance

This commit is contained in:
Anthony Laibe 2022-01-06 10:27:36 +01:00 committed by Anthony Laibe
parent d51b70c703
commit 50993fda1c
3 changed files with 8 additions and 9 deletions

View File

@ -14,13 +14,5 @@ proc getEthBalance*(address: string): RpcResponse[JsonNode] {.raises: [Exception
let payload = %* [address, "latest"]
return core.callPrivateRPC("eth_getBalance", payload)
proc getTokenBalance*(tokenAddress: string, accountAddress: string): RpcResponse[JsonNode] {.raises: [Exception].} =
var postfixedAccount: string = accountAddress
postfixedAccount.removePrefix("0x")
let payload = %* [{
"to": tokenAddress, "from": accountAddress, "data": fmt"0x70a08231000000000000000000000000{postfixedAccount}"
}, "latest"]
return core.callPrivateRPC("eth_call", payload)
proc call*(payload = %* []): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("eth_call", payload)

View File

@ -3,6 +3,13 @@ import ./core, ./response_type
export response_type
proc getTokens*(chainId: int): RpcResponse[JsonNode] {.raises: [Exception].} =
return callPrivateRPC("wallet_getTokens", %* [chainId])
proc getBalances*(chainId: int, accounts: seq[string], tokens: seq[string]): RpcResponse[JsonNode] {.raises: [Exception].} =
return callPrivateRPC("wallet_getTokensBalancesForChainIDs", %* [@[chainId], accounts, tokens])
proc getCustomTokens*(): RpcResponse[JsonNode] {.raises: [Exception].} =
return callPrivateRPC("wallet_getCustomTokens", %* [])

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 6f26d00bd54a7d2f608199877358ba3112d328a3
Subproject commit 9d8ec4432ebc0530788a87512a7e257efc465e75