2024-05-15 21:22:13 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
|
2024-06-10 12:51:33 +00:00
|
|
|
import StatusQ 0.1
|
|
|
|
import StatusQ.Core.Utils 0.1
|
|
|
|
|
2024-05-15 21:22:13 +00: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 12:51:33 +00: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 03:36:36 +00:00
|
|
|
signal suggestedRoutesReady(var txRoutes, string errCode, string errDescription)
|
2024-06-24 13:52:10 +00:00
|
|
|
signal transactionSent(var chainId, var txHash, var uuid, var error)
|
|
|
|
signal transactionSendingComplete(var txHash, var success)
|
2024-06-10 12:51:33 +00:00
|
|
|
|
|
|
|
readonly property Connections walletSectionSendConnections: Connections {
|
|
|
|
target: root.walletSectionSendInst
|
2024-07-19 03:36:36 +00:00
|
|
|
function onSuggestedRoutesReady(txRoutes, errCode, errDescription) {
|
|
|
|
root.suggestedRoutesReady(txRoutes, errCode, errDescription)
|
2024-06-10 12:51:33 +00:00
|
|
|
}
|
2024-06-24 13:52:10 +00:00
|
|
|
function onTransactionSent(chainId, txHash, uuid, error) {
|
|
|
|
root.transactionSent(chainId, txHash, uuid, error)
|
|
|
|
}
|
|
|
|
function onTransactionSendingComplete(txHash, success) {
|
|
|
|
root.transactionSendingComplete(txHash, success)
|
|
|
|
}
|
2024-06-10 12:51:33 +00:00
|
|
|
}
|
|
|
|
|
2024-06-30 22:08:08 +00:00
|
|
|
function fetchSuggestedRoutes(uuid, accountFrom, accountTo, amountIn, amountOut, tokenFrom, tokenTo,
|
2024-06-25 23:03:19 +00:00
|
|
|
disabledFromChainIDs, disabledToChainIDs, sendType, lockedInAmounts) {
|
|
|
|
const valueIn = AmountsArithmetic.fromNumber(amountIn)
|
|
|
|
const valueOut = AmountsArithmetic.fromNumber(amountOut)
|
2024-06-30 22:08:08 +00:00
|
|
|
root.walletSectionSendInst.fetchSuggestedRoutesWithParameters(uuid, accountFrom, accountTo, valueIn.toFixed(), valueOut.toFixed(),
|
2024-06-25 23:03:19 +00:00
|
|
|
tokenFrom, tokenTo, disabledFromChainIDs, disabledToChainIDs, sendType, lockedInAmounts)
|
2024-06-10 12:51:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function authenticateAndTransfer(uuid, accountFrom, accountTo,
|
2024-06-17 00:18:55 +00:00
|
|
|
tokenFrom, tokenTo, sendType, tokenName, tokenIsOwnerToken, paths, slippagePercentage) {
|
2024-06-10 12:51:33 +00:00
|
|
|
root.walletSectionSendInst.authenticateAndTransferWithParameters(uuid, accountFrom, accountTo,
|
2024-06-17 00:18:55 +00:00
|
|
|
tokenFrom, tokenTo, sendType, tokenName, tokenIsOwnerToken, paths, slippagePercentage)
|
2024-06-10 12:51:33 +00:00
|
|
|
}
|
2024-06-06 14:05:31 +00:00
|
|
|
|
|
|
|
function getWei2Eth(wei, decimals) {
|
|
|
|
return globalUtils.wei2Eth(wei, decimals)
|
|
|
|
}
|
2024-05-15 21:22:13 +00:00
|
|
|
}
|