mirror of
https://github.com/status-im/status-lib.git
synced 2025-01-17 16:01:21 +00:00
b9e1c230ca
* 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>
35 lines
1.1 KiB
Nim
35 lines
1.1 KiB
Nim
import
|
|
json, options, strutils
|
|
|
|
import
|
|
web3/[conversions, ethtypes], stint
|
|
|
|
import ../types/transaction
|
|
|
|
# TODO: make this public in nim-web3 lib
|
|
template stripLeadingZeros*(value: string): string =
|
|
var cidx = 0
|
|
# ignore the last character so we retain '0' on zero value
|
|
while cidx < value.len - 1 and value[cidx] == '0':
|
|
cidx.inc
|
|
value[cidx .. ^1]
|
|
|
|
proc `%`*(x: TransactionData): JsonNode =
|
|
result = newJobject()
|
|
result["from"] = %x.source
|
|
result["type"] = %x.txType
|
|
if x.to.isSome:
|
|
result["to"] = %x.to.unsafeGet
|
|
if x.gas.isSome:
|
|
result["gas"] = %x.gas.unsafeGet
|
|
if x.gasPrice.isSome:
|
|
result["gasPrice"] = %("0x" & x.gasPrice.unsafeGet.toHex.stripLeadingZeros)
|
|
if x.maxFeePerGas.isSome:
|
|
result["maxFeePerGas"] = %("0x" & x.maxFeePerGas.unsafeGet.toHex)
|
|
if x.maxPriorityFeePerGas.isSome:
|
|
result["maxPriorityFeePerGas"] = %("0x" & x.maxPriorityFeePerGas.unsafeGet.toHex)
|
|
if x.value.isSome:
|
|
result["value"] = %("0x" & x.value.unsafeGet.toHex)
|
|
result["data"] = %x.data
|
|
if x.nonce.isSome:
|
|
result["nonce"] = %x.nonce.unsafeGet |