Some more modules for the stickers refactor (#112)

* refactor: add additional sticker functions

* refactor: add network module
This commit is contained in:
Jonathan Rainville 2021-11-24 12:28:29 -05:00 committed by saledjenic
parent b66a0fd88a
commit 323f53af32
3 changed files with 29 additions and 1 deletions

View File

@ -27,4 +27,7 @@ proc sendTransaction*(transactionData: string, password: string): RpcResponse[Js
# This is the replacement of the `call` function
proc doEthCall*(payload = %* []): RpcResponse[JsonNode] {.raises: [Exception].} =
core.callPrivateRPC("eth_call", payload)
core.callPrivateRPC("eth_call", payload)
proc estimateGas*(payload = %* []): RpcResponse[JsonNode] {.raises: [Exception].} =
core.callPrivateRPC("eth_estimateGas", payload)

View File

@ -0,0 +1,12 @@
import json
import ./core, ./response_type
proc getNetworks*(payload: JsonNode): RpcResponse[JsonNode] {.raises: [Exception].} =
core.callPrivateRPC("wallet_getEthereumChains", payload)
proc upsertNetwork*(payload: JsonNode): RpcResponse[JsonNode] {.raises: [Exception].} =
core.callPrivateRPC("wallet_addEthereumChain", payload)
proc deleteNetwork*(payload: JsonNode): RpcResponse[JsonNode] {.raises: [Exception].} =
core.callPrivateRPC("wallet_deleteEthereumChain", payload)

View File

@ -41,3 +41,16 @@ proc getPackIdFromTokenId*(address: string, data: string): RpcResponse[JsonNode]
raise newException(RpcException, "Error getting pack id from token id: " & response.error.message)
return response
proc getPackCount*(address: string, data: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [{
"to": address,
"data": data
}, "latest"]
let response = eth.doEthCall(payload)
if not response.error.isNil:
raise newException(RpcException, "Error getting stickers balance: " & response.error.message)
return response