fix(@desktop/wallet): send modal not working with bridge hop (mainnet to optimism)
Fixes #12615
This commit is contained in:
parent
52dd0abbce
commit
94953bb925
|
@ -104,8 +104,10 @@ proc authenticate*(self: Controller, keyUid = "") =
|
|||
keyUid: keyUid)
|
||||
self.events.emit(SIGNAL_SHARED_KEYCARD_MODULE_AUTHENTICATE_USER, data)
|
||||
|
||||
proc suggestedRoutes*(self: Controller, account: string, amount: Uint256, token: string, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[int], sendType: SendType, lockedInAmounts: string): string =
|
||||
let suggestedRoutes = self.transactionService.suggestedRoutes(account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs, sendType, lockedInAmounts)
|
||||
proc suggestedRoutes*(self: Controller, accountFrom: string, accountTo: string, amount: Uint256, token: string, disabledFromChainIDs,
|
||||
disabledToChainIDs, preferredChainIDs: seq[int], sendType: SendType, lockedInAmounts: string): string =
|
||||
let suggestedRoutes = self.transactionService.suggestedRoutes(accountFrom, accountTo, amount, token, disabledFromChainIDs,
|
||||
disabledToChainIDs, preferredChainIDs, sendType, lockedInAmounts)
|
||||
return suggestedRoutes.toJson()
|
||||
|
||||
proc transfer*(self: Controller, from_addr: string, to_addr: string, tokenSymbol: string,
|
||||
|
|
|
@ -24,7 +24,8 @@ method refreshWalletAccounts*(self: AccessInterface) {.base.} =
|
|||
method getTokenBalanceOnChain*(self: AccessInterface, address: string, chainId: int, symbol: string): CurrencyAmount {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method suggestedRoutes*(self: AccessInterface, account: string, amount: UInt256, token: string, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[int], sendType: SendType, lockedInAmounts: string): string {.base.} =
|
||||
method suggestedRoutes*(self: AccessInterface, accountFrom: string, accountTo: string, amount: UInt256, token: string, disabledFromChainIDs,
|
||||
disabledToChainIDs, preferredChainIDs: seq[int], sendType: SendType, lockedInAmounts: string): string {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method suggestedRoutesReady*(self: AccessInterface, suggestedRoutes: SuggestedRoutesDto) {.base.} =
|
||||
|
|
|
@ -25,7 +25,7 @@ export io_interface
|
|||
logScope:
|
||||
topics = "wallet-send-module"
|
||||
|
||||
const cancelledRequest* = "cancelled"
|
||||
const authenticationCanceled* = "authenticationCanceled"
|
||||
|
||||
# Shouldn't be public ever, use only within this module.
|
||||
type TmpSendTransactionDetails = object
|
||||
|
@ -279,7 +279,7 @@ method authenticateAndTransfer*(self: Module, fromAddr: string, toAddr: string,
|
|||
|
||||
method onUserAuthenticated*(self: Module, password: string, pin: string) =
|
||||
if password.len == 0:
|
||||
self.transactionWasSent()
|
||||
self.transactionWasSent(chainId = 0, txHash = "", uuid = self.tmpSendTransactionDetails.uuid, error = authenticationCanceled)
|
||||
else:
|
||||
self.tmpPin = pin
|
||||
let doHashing = self.tmpPin.len == 0
|
||||
|
@ -323,12 +323,13 @@ method onTransactionSigned*(self: Module, keycardFlowType: string, keycardEvent:
|
|||
|
||||
method transactionWasSent*(self: Module, chainId: int, txHash, uuid, error: string) =
|
||||
if txHash.len == 0:
|
||||
self.view.sendTransactionSentSignal(chainId = 0, txHash = "", uuid = self.tmpSendTransactionDetails.uuid, error = cancelledRequest)
|
||||
self.view.sendTransactionSentSignal(chainId = 0, txHash = "", uuid = self.tmpSendTransactionDetails.uuid, error)
|
||||
return
|
||||
self.view.sendTransactionSentSignal(chainId, txHash, uuid, error)
|
||||
|
||||
method suggestedRoutes*(self: Module, account: string, amount: UInt256, token: string, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[int], sendType: SendType, lockedInAmounts: string): string =
|
||||
return self.controller.suggestedRoutes(account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs, sendType, lockedInAmounts)
|
||||
method suggestedRoutes*(self: Module, accountFrom: string, accountTo: string, amount: UInt256, token: string, disabledFromChainIDs,
|
||||
disabledToChainIDs, preferredChainIDs: seq[int], sendType: SendType, lockedInAmounts: string): string =
|
||||
return self.controller.suggestedRoutes(accountFrom, accountTo, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs, sendType, lockedInAmounts)
|
||||
|
||||
method suggestedRoutesReady*(self: Module, suggestedRoutes: SuggestedRoutesDto) =
|
||||
self.tmpSendTransactionDetails.paths = suggestedRoutes.best
|
||||
|
|
|
@ -203,6 +203,7 @@ QtObject:
|
|||
proc setTransactionRoute*(self: View, routes: TransactionRoutes) =
|
||||
self.transactionRoutes = routes
|
||||
self.suggestedRoutesReady(newQVariant(self.transactionRoutes))
|
||||
|
||||
proc suggestedRoutes*(self: View, amount: string): string {.slot.} =
|
||||
var parsedAmount = stint.u256(0)
|
||||
try:
|
||||
|
@ -210,9 +211,10 @@ QtObject:
|
|||
except Exception as e:
|
||||
discard
|
||||
|
||||
return self.delegate.suggestedRoutes(self.selectedSenderAccount.address(),
|
||||
return self.delegate.suggestedRoutes(self.selectedSenderAccount.address(), self.selectedRecipient,
|
||||
parsedAmount, self.selectedAssetSymbol, self.fromNetworksModel.getRouteDisabledNetworkChainIds(),
|
||||
self.toNetworksModel.getRouteDisabledNetworkChainIds(), self.toNetworksModel.getRoutePreferredNetworkChainIds(), self.sendType, self.fromNetworksModel.getRouteLockedChainIds())
|
||||
self.toNetworksModel.getRouteDisabledNetworkChainIds(), self.toNetworksModel.getRoutePreferredNetworkChainIds(),
|
||||
self.sendType, self.fromNetworksModel.getRouteLockedChainIds())
|
||||
|
||||
proc switchSenderAccountByAddress*(self: View, address: string) =
|
||||
let (account, index) = self.senderAccounts.getItemByAddress(address)
|
||||
|
|
|
@ -91,11 +91,9 @@ proc toTransactionSignature(jsonObj: JsonNode): TransactionSignature =
|
|||
discard jsonObj.getProp(ResponseParamTxSignatureS, result.s)
|
||||
var v: int
|
||||
discard jsonObj.getProp(ResponseParamTxSignatureV, v)
|
||||
## The signature must conform to the secp256k1 curve R, S and V values, where the V value must be 27 or 28 for legacy reasons.
|
||||
## Transform V from 0/1 to 27/28 (1b/1c) according to the yellow paper https://ethereum.github.io/yellowpaper/paper.pdf
|
||||
result.v = "1b"
|
||||
result.v = "00"
|
||||
if v == 1:
|
||||
result.v = "1c"
|
||||
result.v = "01"
|
||||
|
||||
proc toKeycardEvent(jsonObj: JsonNode): KeycardEvent =
|
||||
discard jsonObj.getProp(ResponseParamErrorKey, result.error)
|
||||
|
|
|
@ -14,7 +14,8 @@ proc sortAsc[T](t1, t2: T): int =
|
|||
|
||||
type
|
||||
GetSuggestedRoutesTaskArg* = ref object of QObjectTaskArg
|
||||
account: string
|
||||
accountFrom: string
|
||||
accountTo: string
|
||||
amount: Uint256
|
||||
token: string
|
||||
disabledFromChainIDs: seq[int]
|
||||
|
@ -88,12 +89,14 @@ const getSuggestedRoutesTask*: Task = proc(argEncoded: string) {.gcsafe, nimcall
|
|||
except:
|
||||
discard
|
||||
|
||||
let response = eth.suggestedRoutes(arg.account, amountAsHex, arg.token, arg.disabledFromChainIDs, arg.disabledToChainIDs, arg.preferredChainIDs, ord(arg.sendType), lockedInAmounts).result
|
||||
let response = eth.suggestedRoutes(arg.accountFrom, arg.accountTo, amountAsHex, arg.token, arg.disabledFromChainIDs,
|
||||
arg.disabledToChainIDs, arg.preferredChainIDs, ord(arg.sendType), lockedInAmounts).result
|
||||
var bestPaths = response["Best"].getElems().map(x => x.toTransactionPathDto())
|
||||
|
||||
# retry along with unpreferred chains incase no route is possible with preferred chains
|
||||
if(bestPaths.len == 0 and arg.preferredChainIDs.len > 0):
|
||||
let response = eth.suggestedRoutes(arg.account, amountAsHex, arg.token, arg.disabledFromChainIDs, arg.disabledToChainIDs, @[], ord(arg.sendType), lockedInAmounts).result
|
||||
let response = eth.suggestedRoutes(arg.accountFrom, arg.accountTo, amountAsHex, arg.token, arg.disabledFromChainIDs,
|
||||
arg.disabledToChainIDs, @[], ord(arg.sendType), lockedInAmounts).result
|
||||
bestPaths = response["Best"].getElems().map(x => x.toTransactionPathDto())
|
||||
|
||||
bestPaths.sort(sortAsc[TransactionPathDto])
|
||||
|
|
|
@ -427,11 +427,6 @@ QtObject:
|
|||
try:
|
||||
let response = transactions.proceedWithTransactionsSignatures(signatures)
|
||||
self.sendTransactionSentSignal(fromAddr, toAddr, uuid, selectedRoutes, response)
|
||||
if response.result{"hashes"} != nil:
|
||||
for route in selectedRoutes:
|
||||
for hash in response.result["hashes"][$route.fromNetwork.chainID]:
|
||||
self.watchTransaction(hash.getStr, fromAddr, toAddr, $PendingTransactionTypeDto.WalletTransfer, " ", route.fromNetwork.chainID, track = false)
|
||||
self.events.emit(SIGNAL_TRANSACTION_SENT, TransactionSentArgs(chainId: route.fromNetwork.chainID, txHash: hash.getStr, uuid: uuid , error: ""))
|
||||
except Exception as e:
|
||||
self.sendTransactionSentSignal(fromAddr, toAddr, uuid, @[], RpcResponse[JsonNode](), fmt"Error proceeding with transactions signatures: {e.msg}")
|
||||
|
||||
|
@ -451,12 +446,14 @@ QtObject:
|
|||
error "error handling suggestedRoutesReady response", errDesription=e.msg
|
||||
self.events.emit(SIGNAL_SUGGESTED_ROUTES_READY, SuggestedRoutesArgs(suggestedRoutes: suggestedRoutesDto))
|
||||
|
||||
proc suggestedRoutes*(self: Service, account: string, amount: Uint256, token: string, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[int], sendType: SendType, lockedInAmounts: string): SuggestedRoutesDto =
|
||||
proc suggestedRoutes*(self: Service, accountFrom: string, accountTo: string, amount: Uint256, token: string, disabledFromChainIDs,
|
||||
disabledToChainIDs, preferredChainIDs: seq[int], sendType: SendType, lockedInAmounts: string): SuggestedRoutesDto =
|
||||
let arg = GetSuggestedRoutesTaskArg(
|
||||
tptr: cast[ByteAddress](getSuggestedRoutesTask),
|
||||
vptr: cast[ByteAddress](self.vptr),
|
||||
slot: "suggestedRoutesReady",
|
||||
account: account,
|
||||
accountFrom: accountFrom,
|
||||
accountTo: accountTo,
|
||||
amount: amount,
|
||||
token: token,
|
||||
disabledFromChainIDs: disabledFromChainIDs,
|
||||
|
|
|
@ -29,8 +29,9 @@ proc suggestedFees*(chainId: int): RpcResponse[JsonNode] {.raises: [Exception].}
|
|||
let payload = %* [chainId]
|
||||
return core.callPrivateRPC("wallet_getSuggestedFees", payload)
|
||||
|
||||
proc suggestedRoutes*(account: string, amount: string, token: string, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[int], sendType: int, lockedInAmounts: var Table[string, string]): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [sendType, account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs, 1 , lockedInAmounts]
|
||||
proc suggestedRoutes*(accountFrom: string, accountTo: string, amount: string, token: string, disabledFromChainIDs,
|
||||
disabledToChainIDs, preferredChainIDs: seq[int], sendType: int, lockedInAmounts: var Table[string, string]): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [sendType, accountFrom, accountTo, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs, 1, lockedInAmounts]
|
||||
return core.callPrivateRPC("wallet_getSuggestedRoutes", payload)
|
||||
|
||||
rpc(getEstimatedLatestBlockNumber, "wallet"):
|
||||
|
|
|
@ -507,7 +507,7 @@ StatusDialog {
|
|||
d.isPendingTx = false
|
||||
if (uuid !== d.uuid) return
|
||||
if (!!error) {
|
||||
if (error.includes(Constants.walletSection.cancelledMessage)) {
|
||||
if (error.includes(Constants.walletSection.authenticationCanceled)) {
|
||||
return
|
||||
}
|
||||
sendingError.text = error
|
||||
|
|
|
@ -1109,7 +1109,7 @@ QtObject {
|
|||
}
|
||||
|
||||
readonly property QtObject walletSection: QtObject {
|
||||
readonly property string cancelledMessage: "cancelled"
|
||||
readonly property string authenticationCanceled: "authenticationCanceled"
|
||||
}
|
||||
|
||||
// list of symbols for which pngs are stored to avoid
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 4fddcb54ff173a3dbfa3fb67710cce6dfe38af7c
|
||||
Subproject commit ce121710d9f3b13fd9a6562ca97c947c294564e2
|
Loading…
Reference in New Issue