saledjenic b9e1c230ca
Base branch for refactoring (#88)
* added new backend for refactoring purpose, contacts added

* initial chat class added

* initial community class added

* initial accounts class added

* login method added

* Refactor/wallet 1 (#89)

* refactor: add custom token new backend

* refactor: add transactions new backend

* refactor: add collectible new backend

* refactor: add accounts backend

* refactor: add settings backend

* refactor: Add eth call to fetch balance

* refactor: add call to get eth block

* refactor: remove bookmarks (#90)

* refactor: dapp permissions (#92)

* Refactor/wallet part 2 (#91)

* refactor: add save account

* refactor: add account generation

* refactor: save settings

* refactor: add update account in new be

* add getTransfersByAddress (#93)

Co-authored-by: Jonathan Rainville <rainville.jonathan@gmail.com>

* initial messages class added

* fix: transaction request loading contracts (#96)

* add/remove reactions added

* - pin/unpin message added
- fetch message's details by message id added
- fetch reactions for message with id added

* bump status-go

Co-authored-by: Anthony Laibe <anthony@laibe.cc>
Co-authored-by: Richard Ramos <info@richardramos.me>
Co-authored-by: Jonathan Rainville <rainville.jonathan@gmail.com>
Co-authored-by: Iuri Matias <iuri.matias@gmail.com>
2021-11-05 09:55:48 -04:00

42 lines
1.2 KiB
Nim

import json, json_serialization, strformat, chronicles
import status_go
import response_type
export response_type
logScope:
topics = "rpc"
proc callRPC*(inputJSON: string): string =
return $status_go.callRPC(inputJSON)
proc callPrivateRPCRaw*(inputJSON: string): string {.raises: [].} =
result = $status_go.callPrivateRPC(inputJSON)
proc callPrivateRPC*(methodName: string, payload = %* []): RpcResponse[JsonNode]
{.raises: [RpcException, ValueError, Defect, SerializationError].} =
try:
let inputJSON = %* {
"jsonrpc": "2.0",
"method": methodName,
"params": %payload
}
debug "NewBE_callPrivateRPC", rpc_method=methodName
let rpcResponseRaw = status_go.callPrivateRPC($inputJSON)
result = Json.decode(rpcResponseRaw, RpcResponse[JsonNode])
if(not result.error.isNil):
var err = "\nstatus-go error ["
err &= fmt"methodName:{methodName}, "
err &= fmt"code:{result.error.code}, "
err &= fmt"message:{result.error.message} "
err &= "]\n"
error "rpc response error", err
raise newException(ValueError, err)
except RpcException as e:
error "error doing rpc request", methodName = methodName, exception=e.msg
raise newException(RpcException, e.msg)