mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-24 13:32:22 +00:00
feat: track pending transactions for wallet transfers
This commit is contained in:
parent
797da0a962
commit
b0c9155e70
@ -60,6 +60,13 @@ proc init*(self: WalletController) =
|
||||
# TODO: handle these data.eventType: history, reorg
|
||||
# see status-react/src/status_im/ethereum/subscriptions.cljs
|
||||
|
||||
self.status.events.on(PendingTransactionType.WalletTransfer.confirmed) do(e: Args):
|
||||
let tx = TransactionMinedArgs(e)
|
||||
if tx.success:
|
||||
debug "SUCCESSS TRANSACTION", transactionHash = tx.transactionHash
|
||||
else:
|
||||
debug "ERROR TRANSACTION", revertReason = tx.revertReason
|
||||
|
||||
proc checkPendingTransactions*(self: WalletController) =
|
||||
self.status.wallet.checkPendingTransactions() # TODO: consider doing this in a spawnAndSend
|
||||
|
||||
|
@ -25,6 +25,7 @@ proc confirmed*(self:PendingTransactionType):string =
|
||||
|
||||
type TransactionMinedArgs* = ref object of Args
|
||||
data*: string
|
||||
transactionHash*: string
|
||||
success*: bool
|
||||
revertReason*: string # TODO: possible to get revert reason in here?
|
||||
|
||||
@ -47,14 +48,14 @@ proc newWalletModel*(events: EventEmitter): WalletModel =
|
||||
result.totalBalance = 0.0
|
||||
|
||||
proc initEvents*(self: WalletModel) =
|
||||
self.events.on("currencyChanged") do(e: Args):
|
||||
self.events.on("currencyChanged") do(e: Args):
|
||||
self.defaultCurrency = self.getDefaultCurrency()
|
||||
for account in self.accounts:
|
||||
updateBalance(account, self.getDefaultCurrency())
|
||||
self.calculateTotalFiatBalance()
|
||||
self.events.emit("accountsUpdated", Args())
|
||||
|
||||
self.events.on("newAccountAdded") do(e: Args):
|
||||
self.events.on("newAccountAdded") do(e: Args):
|
||||
self.calculateTotalFiatBalance()
|
||||
|
||||
proc delete*(self: WalletModel) =
|
||||
@ -88,6 +89,7 @@ proc confirmTransactionStatus(self: WalletModel, pendingTransactions: JsonNode,
|
||||
status_wallet.deletePendingTransaction(trx["transactionHash"].getStr)
|
||||
let ev = TransactionMinedArgs(
|
||||
data: trx["data"].getStr,
|
||||
transactionHash: trx["transactionHash"].getStr,
|
||||
success: transactionReceipt{"status"}.getStr == "0x1",
|
||||
revertReason: ""
|
||||
)
|
||||
@ -127,6 +129,7 @@ proc sendTransaction*(self: WalletModel, source, to, value, gas, gasPrice, passw
|
||||
|
||||
try:
|
||||
result = eth.sendTransaction(tx, password)
|
||||
trackPendingTransaction(result, $source, $to, PendingTransactionType.WalletTransfer, "")
|
||||
except RpcException as e:
|
||||
raise
|
||||
|
||||
@ -146,6 +149,7 @@ proc sendTokenTransaction*(self: WalletModel, source, to, assetAddress, value, g
|
||||
)
|
||||
try:
|
||||
result = contract.methods["transfer"].send(tx, transfer, password)
|
||||
trackPendingTransaction(result, $source, $to, PendingTransactionType.WalletTransfer, "")
|
||||
except RpcException as e:
|
||||
raise
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user