2024-05-15 23:22:13 +02:00
|
|
|
import QtQuick 2.15
|
|
|
|
|
2024-06-10 09:51:33 -03:00
|
|
|
import StatusQ 0.1
|
|
|
|
import StatusQ.Core.Utils 0.1
|
|
|
|
|
2024-05-15 23:22:13 +02:00
|
|
|
QtObject {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
/* TODO: all of these should come from their respective stores once the stores are reworked and
|
|
|
|
streamlined. This store should contain only swap specific properties/methods if any */
|
|
|
|
readonly property var accounts: walletSectionAccounts.accounts
|
|
|
|
readonly property var flatNetworks: networksModule.flatNetworks
|
|
|
|
readonly property bool areTestNetworksEnabled: networksModule.areTestNetworksEnabled
|
2024-06-10 09:51:33 -03:00
|
|
|
|
|
|
|
/* TODO: Send module should be reworked into a lighter, generic, "stateless" module.
|
|
|
|
Remove these and use the new TransactorStore in SwapModalAdaptor when that happens. */
|
|
|
|
readonly property var walletSectionSendInst: walletSectionSend
|
|
|
|
|
2024-07-19 00:36:36 -03:00
|
|
|
signal suggestedRoutesReady(var txRoutes, string errCode, string errDescription)
|
2024-09-13 13:39:12 +02:00
|
|
|
signal transactionSent(var uuid, var chainId, var approvalTx, var txHash, var error)
|
2024-06-24 15:52:10 +02:00
|
|
|
signal transactionSendingComplete(var txHash, var success)
|
2024-06-10 09:51:33 -03:00
|
|
|
|
|
|
|
readonly property Connections walletSectionSendConnections: Connections {
|
|
|
|
target: root.walletSectionSendInst
|
2024-07-19 00:36:36 -03:00
|
|
|
function onSuggestedRoutesReady(txRoutes, errCode, errDescription) {
|
|
|
|
root.suggestedRoutesReady(txRoutes, errCode, errDescription)
|
2024-06-10 09:51:33 -03:00
|
|
|
}
|
2024-09-13 13:39:12 +02:00
|
|
|
function onTransactionSent(uuid, chainId, approvalTx, txHash, error) {
|
|
|
|
root.transactionSent(uuid, chainId, approvalTx, txHash, error)
|
2024-06-24 15:52:10 +02:00
|
|
|
}
|
|
|
|
function onTransactionSendingComplete(txHash, success) {
|
|
|
|
root.transactionSendingComplete(txHash, success)
|
|
|
|
}
|
2024-06-10 09:51:33 -03:00
|
|
|
}
|
|
|
|
|
2024-06-30 19:08:08 -03:00
|
|
|
function fetchSuggestedRoutes(uuid, accountFrom, accountTo, amountIn, amountOut, tokenFrom, tokenTo,
|
2024-06-26 01:03:19 +02:00
|
|
|
disabledFromChainIDs, disabledToChainIDs, sendType, lockedInAmounts) {
|
|
|
|
const valueIn = AmountsArithmetic.fromNumber(amountIn)
|
|
|
|
const valueOut = AmountsArithmetic.fromNumber(amountOut)
|
2024-06-30 19:08:08 -03:00
|
|
|
root.walletSectionSendInst.fetchSuggestedRoutesWithParameters(uuid, accountFrom, accountTo, valueIn.toFixed(), valueOut.toFixed(),
|
2024-06-26 01:03:19 +02:00
|
|
|
tokenFrom, tokenTo, disabledFromChainIDs, disabledToChainIDs, sendType, lockedInAmounts)
|
2024-06-10 09:51:33 -03:00
|
|
|
}
|
|
|
|
|
2024-08-30 11:16:40 +02:00
|
|
|
function stopUpdatesForSuggestedRoute() {
|
|
|
|
root.walletSectionSendInst.stopUpdatesForSuggestedRoute()
|
|
|
|
}
|
|
|
|
|
2024-09-13 13:39:12 +02:00
|
|
|
function authenticateAndTransfer(uuid, slippagePercentage) {
|
|
|
|
root.walletSectionSendInst.authenticateAndTransfer(uuid, slippagePercentage)
|
2024-06-10 09:51:33 -03:00
|
|
|
}
|
2024-06-06 16:05:31 +02:00
|
|
|
|
|
|
|
function getWei2Eth(wei, decimals) {
|
|
|
|
return globalUtils.wei2Eth(wei, decimals)
|
|
|
|
}
|
2024-05-15 23:22:13 +02:00
|
|
|
}
|