Jacek Sieka 427297068d
chore: clean up exception specifiers (#13735)
Annotating functions explicitly with `{.raises: [Exception].}` prevents
Nim from performing compile-time exception checking and is almost never
desired - it does have a tendency to spread through the codebase
however, similar to sub-par const correctness in C++.

The reason these annotations might have seemed necessary can be traced
to missing exception specifiers in the go imports bumped in this PR.

See
https://status-im.github.io/nim-style-guide/interop.c.html#functions-and-types
for background on Nim-go interop and
https://status-im.github.io/nim-style-guide/errors.exceptions.html for
more information on how exception tracking can be leveraged to find
missing error handling at compile-time.

This change has no runtime effect - it merely makes compile-time error
messages more informative or avoids them entirely.
2024-03-12 16:20:02 +01:00

36 lines
1.6 KiB
Nim

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]
return core.callPrivateRPCWithChainId("eth_getBlockByNumber", chainId, payload)
proc getNativeChainBalance*(chainId: int, address: string): RpcResponse[JsonNode] =
let payload = %* [address, "latest"]
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