refactor: transactions and ens procs updated

- `getGasPrice` proc added
- `PendingTransactionType` should be part of the desktop app,
not needed here in this context, removed.
This commit is contained in:
Sale Djenic 2022-01-18 13:43:22 +01:00 committed by saledjenic
parent 9b7f9a086d
commit af79b4f758
2 changed files with 18 additions and 10 deletions

View File

@ -34,3 +34,6 @@ proc estimateGas*(payload = %* []): RpcResponse[JsonNode] {.raises: [Exception].
proc getEthAccounts*(): RpcResponse[JsonNode] {.raises: [Exception].} = proc getEthAccounts*(): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("eth_accounts") return core.callPrivateRPC("eth_accounts")
proc getGasPrice*(payload = %* []): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("eth_gasPrice", payload)

View File

@ -2,13 +2,6 @@ import json, stint, chronicles, strutils
import ./core as core import ./core as core
type PendingTransactionType* {.pure.} = enum
RegisterENS = "RegisterENS",
SetPubKey = "SetPubKey",
ReleaseENS = "ReleaseENS",
BuyStickerPack = "BuyStickerPack"
WalletTransfer = "WalletTransfer"
proc checkRecentHistory*(addresses: seq[string]) {.raises: [Exception].} = proc checkRecentHistory*(addresses: seq[string]) {.raises: [Exception].} =
let payload = %* [addresses] let payload = %* [addresses]
discard callPrivateRPC("wallet_checkRecentHistory", payload) discard callPrivateRPC("wallet_checkRecentHistory", payload)
@ -19,6 +12,18 @@ proc getTransfersByAddress*(address: string, toBlock: Uint256, limitAsHexWithout
callPrivateRPC("wallet_getTransfersByAddress", %* [address, toBlockParsed, limitAsHexWithoutLeadingZeros, loadMore]) callPrivateRPC("wallet_getTransfersByAddress", %* [address, toBlockParsed, limitAsHexWithoutLeadingZeros, loadMore])
proc trackPendingTransaction*(hash: string, fromAddress: string, toAddress: string, trxType: PendingTransactionType, data: string): RpcResponse[JsonNode] {.raises: [Exception].} = proc trackPendingTransaction*(hash: string, fromAddress: string, toAddress: string, trxType: string, data: string):
let payload = %* [{"hash": hash, "from": fromAddress, "to": toAddress, "type": $trxType, "additionalData": data, "data": "", "value": 0, "timestamp": 0, "gasPrice": 0, "gasLimit": 0}] RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [{
"hash": hash,
"from": fromAddress,
"to": toAddress,
"type": trxType,
"additionalData": data,
"data": "",
"value": 0,
"timestamp": 0,
"gasPrice": 0,
"gasLimit": 0
}]
callPrivateRPC("wallet_storePendingTransaction", payload) callPrivateRPC("wallet_storePendingTransaction", payload)