WIP: post-rebase fixes
This commit is contained in:
parent
8d67fa7c5f
commit
b7b99a001a
|
@ -18,13 +18,16 @@ import # nim-status libs
|
|||
./settings
|
||||
|
||||
type StatusObject* = ref object
|
||||
dataDir*: string
|
||||
accountsDB*: DbConn
|
||||
dataDir*: string
|
||||
userDB*: DbConn
|
||||
|
||||
proc new*(T: type StatusObject, dataDir, accountsDbFileName: string = "accounts.sql"): T =
|
||||
# Disabling migrations because we are reusing a status-go DB
|
||||
T(accountsDB: initializeDB(dataDir / accountsDbFileName, acc_migration.newMigrationDefinition(), true))
|
||||
proc new*(T: type StatusObject, dataDir: string,
|
||||
accountsDbFileName: string = "accounts.sql"): T =
|
||||
|
||||
T(accountsDB: initializeDB(dataDir / accountsDbFileName,
|
||||
acc_migration.newMigrationDefinition(), true),
|
||||
dataDir: dataDir)
|
||||
|
||||
proc getAccounts*(self: StatusObject): seq[accounts.Account] =
|
||||
getAccounts(self.accountsDB)
|
||||
|
|
|
@ -36,14 +36,14 @@ proc getValueForBlock*(address: types.Address, blockNumber: string, methodName:
|
|||
|
||||
let jsonNode = parseJson(fmt"""["{address}", "{blockNumber}"]""")
|
||||
let resp = callRPC(web3Obj, methodName, jsonNode)
|
||||
let txCount = fromHex[int](resp.result.getStr)
|
||||
let txCount = fromHex[int](resp.getStr)
|
||||
|
||||
return txCount
|
||||
|
||||
proc getLastBlockNumber*(): int =
|
||||
var jsonNode = parseJSON("""[]""")
|
||||
var resp = callRPC(web3Obj, RemoteMethod.eth_blockNumber, jsonNode)
|
||||
return fromHex[int](resp.result.getStr)
|
||||
return fromHex[int](resp.getStr)
|
||||
|
||||
# Find lowest block number for which a condition
|
||||
# procPtr(address, blockNumber) >= targetValue holds
|
||||
|
@ -137,9 +137,9 @@ proc filterTxsForAddress*(address: types.Address, blockNumbers: BlockSeq, txToDa
|
|||
let jsonNode = parseJSON(fmt"""["{blockNumber}", true]""")
|
||||
let resp = callRPC(web3Obj, RemoteMethod.eth_getBlockByNumber, jsonNode)
|
||||
|
||||
let blockHash = resp.result["hash"].getStr
|
||||
let timestamp = fromHex[int](resp.result["timestamp"].getStr)
|
||||
for tx in items(resp.result["transactions"]):
|
||||
let blockHash = resp["hash"].getStr
|
||||
let timestamp = fromHex[int](resp["timestamp"].getStr)
|
||||
for tx in items(resp["transactions"]):
|
||||
if cmpIgnoreCase(tx["from"].getStr, address) == 0 or
|
||||
cmpIgnoreCase(tx["to"].getStr, address) == 0:
|
||||
let txHash = tx["hash"].getStr
|
||||
|
@ -215,7 +215,7 @@ proc fetchErc20Logs*(address: types.Address, blockRange: BlockRange, txToData: v
|
|||
var outgoingLogs = callRPC(web3Obj, RemoteMethod.eth_getLogs, jsonNode)
|
||||
#echo "outgoingLogs: ", outgoingLogs
|
||||
|
||||
var logs: seq[JsonNode] = concat(incomingLogs.result.getElems, outgoingLogs.result.getElems)
|
||||
var logs: seq[JsonNode] = concat(incomingLogs.getElems, outgoingLogs.getElems)
|
||||
for obj in logs:
|
||||
let txHash = obj["transactionHash"].getStr
|
||||
let blockNumber = fromHex[int](obj["blockNumber"].getStr)
|
||||
|
@ -246,19 +246,19 @@ proc fetchTxDetails*(address: types.Address, txToData: var TransferMap) =
|
|||
echo "fetchTxDetails txReceipt: ", txReceipt
|
||||
|
||||
var trView = txToData[tx]
|
||||
trView.gasPrice = fromHex[int](txInfo.result["gasPrice"].getStr)
|
||||
trView.gasLimit = fromHex[int](txInfo.result["gas"].getStr)
|
||||
trView.gasUsed = fromHex[int](txReceipt.result["gasUsed"].getStr)
|
||||
trView.nonce = fromHex[int](txInfo.result["nonce"].getStr)
|
||||
trView.txStatus = fromHex[int](txReceipt.result["status"].getStr)
|
||||
trView.input = txInfo.result["input"].getStr
|
||||
trView.gasPrice = fromHex[int](txInfo["gasPrice"].getStr)
|
||||
trView.gasLimit = fromHex[int](txInfo["gas"].getStr)
|
||||
trView.gasUsed = fromHex[int](txReceipt["gasUsed"].getStr)
|
||||
trView.nonce = fromHex[int](txInfo["nonce"].getStr)
|
||||
trView.txStatus = fromHex[int](txReceipt["status"].getStr)
|
||||
trView.input = txInfo["input"].getStr
|
||||
if trView.txType == eth:
|
||||
trView.contract = txReceipt.result["contractAddress"].getStr
|
||||
trView.value = fromHex[int](txInfo.result["value"].getStr)
|
||||
trView.fromAddr = txInfo.result["from"].getStr
|
||||
trView.toAddr = txInfo.result["to"].getStr
|
||||
trView.contract = txReceipt["contractAddress"].getStr
|
||||
trView.value = fromHex[int](txInfo["value"].getStr)
|
||||
trView.fromAddr = txInfo["from"].getStr
|
||||
trView.toAddr = txInfo["to"].getStr
|
||||
|
||||
echo "gasLimit, ", fromHex[int](txInfo.result["gas"].getStr)
|
||||
echo "gasLimit, ", fromHex[int](txInfo["gas"].getStr)
|
||||
echo "trView.gasLimit, ", trView.gasLimit
|
||||
txToData[tx] = trView
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ procSuite "client":
|
|||
statusObj.updateAccountTimestamp(1, "0x1234")
|
||||
let accounts = statusObj.getAccounts()
|
||||
check:
|
||||
statusObj.config.rootDataDir == dataDir
|
||||
statusObj.dataDir == dataDir
|
||||
accounts[0].keyUid == "0x1234"
|
||||
|
||||
let password = "qwerty"
|
||||
|
|
Loading…
Reference in New Issue