Sale Djenic 2be8bb55ee refactor: privacy methods added
- methods `changeDatabasePassword` and `getLinkPreviewWhitelist` added
to `privacy.nim`
- `hashPassword` moved to `utils.nim` since it's used from multiple paces
- `getEthAccounts` added to `eth.nim`
- `verifyAccountPassword` method updated so it returns `RpcResponse` now
2022-02-01 11:12:54 +01:00

36 lines
1.5 KiB
Nim

import json, strutils, strformat
import ./core, ./response_type
export response_type
proc getAccounts*(): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("eth_accounts")
proc getBlockByNumber*(blockNumber: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [blockNumber, false]
return core.callPrivateRPC("eth_getBlockByNumber", payload)
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 sendTransaction*(transactionData: string, password: string): RpcResponse[JsonNode] {.raises: [Exception].} =
core.sendTransaction(transactionData, password)
# This is the replacement of the `call` function
proc doEthCall*(payload = %* []): RpcResponse[JsonNode] {.raises: [Exception].} =
core.callPrivateRPC("eth_call", payload)
proc estimateGas*(payload = %* []): RpcResponse[JsonNode] {.raises: [Exception].} =
core.callPrivateRPC("eth_estimateGas", payload)
proc getEthAccounts*(): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("eth_accounts")