36 lines
1.6 KiB
Nim
Raw Normal View History

import json, tables
import ./core, ./response_type
from ./gen import rpc
export response_type
proc getAccounts*(): RpcResponse[JsonNode] =
return core.callPrivateRPC("eth_accounts")
proc getBlockByNumber*(chainId: int, blockNumber: string, fullTransactionObject = false): RpcResponse[JsonNode] =
let payload = %* [blockNumber, fullTransactionObject]
2022-06-07 15:57:09 +02:00
return core.callPrivateRPCWithChainId("eth_getBlockByNumber", chainId, payload)
proc getNativeChainBalance*(chainId: int, address: string): RpcResponse[JsonNode] =
let payload = %* [address, "latest"]
2022-02-17 10:15:37 +01:00
return core.callPrivateRPCWithChainId("eth_getBalance", chainId, payload)
# This is the replacement of the `call` function
proc doEthCall*(payload = %* []): RpcResponse[JsonNode] =
core.callPrivateRPC("eth_call", payload)
proc estimateGas*(chainId: int, payload = %* []): RpcResponse[JsonNode] =
core.callPrivateRPCWithChainId("eth_estimateGas", chainId, payload)
proc suggestedFees*(chainId: int): RpcResponse[JsonNode] =
let payload = %* [chainId]
return core.callPrivateRPC("wallet_getSuggestedFees", payload)
proc suggestedRoutes*(accountFrom: string, accountTo: string, amount: string, token: string, disabledFromChainIDs,
disabledToChainIDs, preferredChainIDs: seq[int], sendType: int, lockedInAmounts: var Table[string, string]): RpcResponse[JsonNode] =
let payload = %* [sendType, accountFrom, accountTo, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs, 1, lockedInAmounts]
return core.callPrivateRPC("wallet_getSuggestedRoutes", payload)
rpc(getEstimatedLatestBlockNumber, "wallet"):
chainId: int