2023-05-10 11:05:45 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
|
2023-11-28 19:16:18 +00:00
|
|
|
import StatusQ 0.1
|
2023-09-26 13:45:44 +00:00
|
|
|
import StatusQ.Core 0.1
|
2024-07-09 22:10:13 +00:00
|
|
|
import StatusQ.Core.Utils 0.1
|
2023-09-26 13:45:44 +00:00
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
2023-05-10 11:05:45 +00:00
|
|
|
import Storybook 1.0
|
2024-07-09 22:10:13 +00:00
|
|
|
import Models 1.0
|
2023-05-10 11:05:45 +00:00
|
|
|
import utils 1.0
|
|
|
|
|
2023-09-05 15:27:30 +00:00
|
|
|
import shared.popups.send 1.0
|
2023-05-10 11:05:45 +00:00
|
|
|
import shared.stores 1.0
|
2023-09-15 08:51:06 +00:00
|
|
|
import shared.stores.send 1.0
|
2023-05-10 11:05:45 +00:00
|
|
|
|
2023-11-28 19:16:18 +00:00
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
import AppLayouts.Wallet.stores 1.0
|
|
|
|
|
2023-05-10 11:05:45 +00:00
|
|
|
SplitView {
|
|
|
|
id: root
|
|
|
|
|
2023-09-26 13:45:44 +00:00
|
|
|
orientation: Qt.Horizontal
|
|
|
|
|
2023-11-28 19:16:18 +00:00
|
|
|
property WalletAssetsStore walletAssetStore: WalletAssetsStore {
|
|
|
|
|
2024-07-09 22:10:13 +00:00
|
|
|
// Workaround to satisfy stub which is not empty (but should be)
|
|
|
|
assetsWithFilteredBalances: ListModel {}
|
|
|
|
|
|
|
|
property var groupedAccountAssetsModel: ListModel {
|
|
|
|
Component.onCompleted: {
|
|
|
|
const data = [
|
|
|
|
{
|
|
|
|
tokensKey: "key_eth",
|
|
|
|
name: "Ethereum",
|
|
|
|
symbol: "ETH",
|
|
|
|
decimals: 18,
|
|
|
|
communityId: "",
|
|
|
|
balances: [
|
|
|
|
{
|
|
|
|
chainId: "1",
|
|
|
|
balance: "122082928968121891",
|
|
|
|
account: "0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
chainId: "420",
|
|
|
|
balance: "559133758939097000",
|
|
|
|
account: "0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
currentCurrencyBalance: 234.234,
|
|
|
|
marketDetails: {
|
|
|
|
currencyPrice: {
|
|
|
|
amount: 12234.23,
|
|
|
|
displayDecimals: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
tokensKey: "key_dai",
|
|
|
|
name: "DAI",
|
|
|
|
symbol: "DAI",
|
|
|
|
decimals: 18,
|
|
|
|
communityId: "",
|
|
|
|
balances: [
|
|
|
|
{
|
|
|
|
chainId: "420",
|
|
|
|
balance: "1142155111",
|
|
|
|
account: "0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
chainId: "1",
|
|
|
|
balance: "4411211243121551121",
|
|
|
|
account: "0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
currentCurrencyBalance: 234.234,
|
|
|
|
marketDetails: {
|
|
|
|
currencyPrice: {
|
|
|
|
amount: 234.23,
|
|
|
|
displayDecimals: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2023-11-28 19:16:18 +00:00
|
|
|
|
2024-07-09 22:10:13 +00:00
|
|
|
append(data)
|
2023-11-28 19:16:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-26 13:45:44 +00:00
|
|
|
TransactionStore {
|
|
|
|
id: txStore
|
2024-08-02 08:37:02 +00:00
|
|
|
|
|
|
|
property bool areTestNetworksEnabled: true
|
|
|
|
|
|
|
|
function setRouteDisabledChains(chainId, disabled) {}
|
|
|
|
|
2023-11-28 19:16:18 +00:00
|
|
|
walletAssetStore: root.walletAssetStore
|
2024-07-05 12:49:31 +00:00
|
|
|
tokensStore.showCommunityAssetsInSend: showCommunityAssetsCheckBox.checked
|
|
|
|
tokensStore.displayAssetsBelowBalance: balanceThresholdCheckbox.checked
|
|
|
|
tokensStore.getDisplayAssetsBelowBalanceThresholdDisplayAmount: () => Number(balanceThresholdValue.text)
|
2023-09-26 13:45:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: dummyEventData
|
|
|
|
|
|
|
|
property ListModel toModel: ListModel {
|
|
|
|
ListElement {
|
|
|
|
chainId: 420
|
|
|
|
amountOut: "3003845308235848343"
|
|
|
|
}
|
2024-08-02 08:37:02 +00:00
|
|
|
ListElement {
|
|
|
|
chainId: 1
|
|
|
|
amountOut: "30038453082358483445"
|
|
|
|
}
|
2023-09-26 13:45:44 +00:00
|
|
|
}
|
|
|
|
property var suggestesRoutes: [{
|
|
|
|
bridgeName:"Hop",
|
|
|
|
fromNetwork: 1,
|
|
|
|
toNetwork: 10,
|
|
|
|
maxAmountIn:"2649485258572837546",
|
|
|
|
amountIn:"200000000000000000",
|
|
|
|
amountOut:"200000000000000000",
|
|
|
|
gasAmount:501000,
|
|
|
|
gasFees: {
|
|
|
|
gasPrice:1.7e-08,
|
|
|
|
baseFee:1.0,
|
|
|
|
maxPriorityFeePerGas:2e-09,
|
|
|
|
maxFeePerGasL:1.1e-08,
|
|
|
|
maxFeePerGasM:1.0,
|
|
|
|
maxFeePerGasH:2.0,
|
|
|
|
eip1559Enabled:true
|
|
|
|
},
|
|
|
|
tokenFees:-0.004508663259772343,
|
|
|
|
cost:-6.39534887667951,
|
|
|
|
estimatedTime:1,
|
|
|
|
amountInLocked:false,
|
|
|
|
isFirstSimpleTx:true,
|
|
|
|
isFirstBridgeTx:true,
|
|
|
|
approvalRequired:false,
|
|
|
|
approvalGasFees:0.0,
|
|
|
|
approvalAmountRequired:"0",
|
|
|
|
approvalContractAddress:""
|
|
|
|
},
|
|
|
|
{
|
|
|
|
bridgeName:"Transfer",
|
|
|
|
fromNetwork: 10,
|
|
|
|
toNetwork:10,
|
|
|
|
maxAmountIn:"443890157817650036",
|
|
|
|
amountIn:"200000000000000000",
|
|
|
|
amountOut:"200000000000000000",
|
|
|
|
gasAmount:22000,
|
|
|
|
gasFees:{
|
|
|
|
gasPrice:0.10000005,
|
|
|
|
baseFee:4.4e-08,
|
|
|
|
maxPriorityFeePerGas:0.1,
|
|
|
|
maxFeePerGasL:5e-08,
|
|
|
|
maxFeePerGasM:0.1,
|
|
|
|
maxFeePerGasH:0.2,
|
|
|
|
eip1559Enabled:true
|
|
|
|
},
|
|
|
|
tokenFees:0.0,
|
|
|
|
bonderFees:"0x0",
|
|
|
|
cost:0.003510716,
|
|
|
|
estimatedTime:1,
|
|
|
|
amountInLocked:false,
|
|
|
|
isFirstSimpleTx:false,
|
|
|
|
isFirstBridgeTx:false,
|
|
|
|
approvalRequired:false,
|
|
|
|
approvalGasFees:0.0,
|
|
|
|
approvalAmountRequired:"0",
|
|
|
|
approvalContractAddress:""
|
|
|
|
}]
|
|
|
|
}
|
2023-05-10 11:05:45 +00:00
|
|
|
|
|
|
|
Item {
|
2023-09-26 13:45:44 +00:00
|
|
|
anchors.left: parent.left
|
2023-05-10 11:05:45 +00:00
|
|
|
SplitView.fillWidth: true
|
|
|
|
SplitView.fillHeight: true
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
anchors.fill: parent
|
|
|
|
color: "lightgray"
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: loader
|
|
|
|
|
2024-07-05 12:49:31 +00:00
|
|
|
property var preSelectedAccount: txStore.accounts.get(0)
|
2023-09-26 13:45:44 +00:00
|
|
|
property string preSelectedHoldingID
|
2023-11-07 22:45:47 +00:00
|
|
|
property int preSelectedHoldingType: Constants.TokenType.Unknown
|
2023-09-26 13:45:44 +00:00
|
|
|
property int preSelectedSendType: Constants.SendType.Unknown
|
|
|
|
property bool onlyAssets: false
|
|
|
|
property string preDefinedAmountToSend
|
|
|
|
property string preSelectedRecipient
|
|
|
|
|
2023-05-10 11:05:45 +00:00
|
|
|
active: false
|
|
|
|
|
|
|
|
sourceComponent: SendModal {
|
|
|
|
visible: true
|
|
|
|
modal: false
|
|
|
|
closePolicy: Popup.NoAutoClose
|
2024-07-05 12:49:31 +00:00
|
|
|
onlyAssets: loader.onlyAssets
|
2023-09-26 13:45:44 +00:00
|
|
|
store: txStore
|
2024-07-17 14:49:42 +00:00
|
|
|
preSelectedAccountAddress: loader.preSelectedAccount.address
|
2023-09-26 13:45:44 +00:00
|
|
|
preDefinedAmountToSend: loader.preDefinedAmountToSend
|
|
|
|
preSelectedRecipient: loader.preSelectedRecipient
|
|
|
|
preSelectedSendType: loader.preSelectedSendType
|
|
|
|
preSelectedHoldingID: loader.preSelectedHoldingID
|
|
|
|
preSelectedHoldingType: loader.preSelectedHoldingType
|
2024-08-10 12:39:56 +00:00
|
|
|
showCustomRoutingMode: ctrlShowCustomMode.checked
|
2024-09-09 11:29:40 +00:00
|
|
|
generateUuid: () => { return "12345" }
|
|
|
|
sendTransaction: () => {
|
|
|
|
if (!showSendErrorCheckBox.checked)
|
|
|
|
return
|
|
|
|
|
|
|
|
txStore.walletSectionSendInst.transactionSent(1, "0x123", generateUuid(), "Send error, please ignore")
|
|
|
|
}
|
2023-09-26 13:45:44 +00:00
|
|
|
}
|
|
|
|
Component.onCompleted: loader.active = true
|
|
|
|
}
|
|
|
|
}
|
2023-05-10 11:05:45 +00:00
|
|
|
|
2023-09-26 13:45:44 +00:00
|
|
|
LogsAndControlsPanel {
|
|
|
|
SplitView.minimumHeight: 100
|
|
|
|
SplitView.preferredHeight: 100
|
2023-05-10 11:05:45 +00:00
|
|
|
|
|
|
|
|
2023-09-26 13:45:44 +00:00
|
|
|
ColumnLayout {
|
|
|
|
width: parent.width
|
2024-08-10 12:39:56 +00:00
|
|
|
spacing: 10
|
2023-05-10 11:05:45 +00:00
|
|
|
|
2023-09-26 13:45:44 +00:00
|
|
|
ColumnLayout {
|
|
|
|
spacing: 0
|
|
|
|
Layout.topMargin: 20
|
|
|
|
width: parent.width
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.maximumWidth: parent.width
|
2024-07-05 12:49:31 +00:00
|
|
|
text: "This button can be used as response to the suggestedRoutes API called once a token and its amount is selected along with a valid recipient."
|
2023-09-26 13:45:44 +00:00
|
|
|
color: "orange"
|
|
|
|
wrapMode: Text.WrapAnywhere
|
|
|
|
}
|
|
|
|
StatusButton {
|
|
|
|
enabled: txStore.suggestedRoutesCalled
|
|
|
|
text: "emit suggestedRoutesReady"
|
|
|
|
onClicked: {
|
|
|
|
let txRoutes = {
|
|
|
|
suggestedRoutes: dummyEventData.suggestesRoutes,
|
|
|
|
gasTimeEstimate:{
|
|
|
|
totalFeesInEth:0.0005032000000000001,
|
|
|
|
totalTokenFees:-0.004508663259772343,
|
|
|
|
totalTime:2
|
|
|
|
},
|
|
|
|
amountToReceive: txStore.amountToSend - (txStore.amountToSend*5/100),
|
2024-07-03 08:51:15 +00:00
|
|
|
toNetworksRouteModel: dummyEventData.toModel
|
2023-05-10 11:05:45 +00:00
|
|
|
}
|
2024-07-19 03:36:36 +00:00
|
|
|
let errCode = ""
|
|
|
|
let errDescription = ""
|
2024-07-03 08:51:15 +00:00
|
|
|
txStore.fromNetworksRouteModel.updateFromNetworks(dummyEventData.suggestesRoutes)
|
|
|
|
txStore.toNetworksRouteModel.updateToNetworks(dummyEventData.suggestesRoutes)
|
2024-07-19 03:36:36 +00:00
|
|
|
txStore.walletSectionSendInst.suggestedRoutesReady(txRoutes, errCode, errDescription)
|
2023-09-26 13:45:44 +00:00
|
|
|
txStore.suggestedRoutesCalled = false
|
2023-05-10 11:05:45 +00:00
|
|
|
}
|
2023-09-26 13:45:44 +00:00
|
|
|
}
|
|
|
|
}
|
2023-05-10 11:05:45 +00:00
|
|
|
|
2023-09-26 13:45:44 +00:00
|
|
|
Rectangle {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: 1
|
|
|
|
color: "grey"
|
|
|
|
}
|
2023-05-10 11:05:45 +00:00
|
|
|
|
2023-09-26 13:45:44 +00:00
|
|
|
StatusBaseText {
|
|
|
|
Layout.maximumWidth: parent.width
|
|
|
|
text: "Note: After filling in the preSelected inputs you need to reload the SendModal as per current implementation"
|
|
|
|
color: "orange"
|
|
|
|
wrapMode: Text.WrapAnywhere
|
|
|
|
}
|
2023-05-10 11:05:45 +00:00
|
|
|
|
2023-09-26 13:45:44 +00:00
|
|
|
ColumnLayout {
|
|
|
|
spacing: 0
|
|
|
|
StatusBaseText {
|
|
|
|
text:"preSelectedAccount"
|
|
|
|
}
|
|
|
|
ComboBox {
|
|
|
|
textRole: "name"
|
2024-07-05 12:49:31 +00:00
|
|
|
model: SortFilterProxyModel {
|
|
|
|
sourceModel: txStore.accounts
|
|
|
|
filters: ValueFilter {
|
|
|
|
roleName: "canSend"
|
|
|
|
value: true
|
|
|
|
}
|
|
|
|
}
|
2024-07-03 03:55:05 +00:00
|
|
|
onCurrentIndexChanged: loader.preSelectedAccount = txStore.accounts.get(currentIndex)
|
2023-09-26 13:45:44 +00:00
|
|
|
}
|
|
|
|
}
|
2023-05-10 11:05:45 +00:00
|
|
|
|
2023-09-26 13:45:44 +00:00
|
|
|
ColumnLayout {
|
|
|
|
spacing: 0
|
|
|
|
StatusBaseText {
|
|
|
|
text:"preSelectedHoldingType"
|
|
|
|
}
|
|
|
|
ComboBox {
|
|
|
|
id: tokenType
|
2023-11-07 22:45:47 +00:00
|
|
|
model: ["Native", "Asset", "Collectible", "Fungible Token", "Unknown", "ENS"]
|
|
|
|
currentIndex: 4
|
|
|
|
onCurrentIndexChanged: {
|
|
|
|
loader.preSelectedHoldingType = currentIndex
|
|
|
|
}
|
2023-09-26 13:45:44 +00:00
|
|
|
}
|
|
|
|
}
|
2023-05-10 11:05:45 +00:00
|
|
|
|
2023-09-26 13:45:44 +00:00
|
|
|
StatusInput {
|
2023-11-07 22:45:47 +00:00
|
|
|
enabled: tokenType.currentIndex > 0 && tokenType.currentIndex < 3
|
2023-09-26 13:45:44 +00:00
|
|
|
label: "preSelectedHoldingID (case sensitive)"
|
|
|
|
onTextChanged: loader.preSelectedHoldingID = text
|
|
|
|
}
|
2023-05-10 11:05:45 +00:00
|
|
|
|
2023-09-26 13:45:44 +00:00
|
|
|
StatusInput {
|
|
|
|
label: "preDefinedAmountToSend"
|
|
|
|
onTextChanged: loader.preDefinedAmountToSend = text
|
2023-05-10 11:05:45 +00:00
|
|
|
}
|
|
|
|
|
2023-09-26 13:45:44 +00:00
|
|
|
ColumnLayout {
|
|
|
|
spacing: 0
|
|
|
|
StatusBaseText {
|
|
|
|
text:"preSelectedSendType"
|
2023-05-10 11:05:45 +00:00
|
|
|
}
|
2023-09-26 13:45:44 +00:00
|
|
|
ComboBox {
|
|
|
|
model: ["Transfer",
|
|
|
|
"ENSRegister",
|
|
|
|
"ENSRelease",
|
|
|
|
"ENSSetPubKey",
|
|
|
|
"StickersBuy",
|
|
|
|
"Bridge",
|
|
|
|
"ERC721Transfer",
|
|
|
|
"Unknown"]
|
|
|
|
onCurrentIndexChanged: loader.preSelectedSendType = currentIndex
|
|
|
|
}
|
|
|
|
}
|
2023-05-10 11:05:45 +00:00
|
|
|
|
2023-09-26 13:45:44 +00:00
|
|
|
StatusInput {
|
|
|
|
label: "preSelectedRecipient"
|
|
|
|
onTextChanged: loader.preSelectedRecipient = text
|
|
|
|
}
|
2023-05-10 11:05:45 +00:00
|
|
|
|
2023-09-26 13:45:44 +00:00
|
|
|
StatusButton {
|
|
|
|
text: "Reload popup"
|
|
|
|
onClicked: {
|
|
|
|
loader.item.close()
|
|
|
|
loader.item.open()
|
|
|
|
}
|
2023-05-10 11:05:45 +00:00
|
|
|
}
|
2024-01-30 13:15:58 +00:00
|
|
|
|
2024-08-10 12:39:56 +00:00
|
|
|
CheckBox {
|
|
|
|
id: ctrlShowCustomMode
|
|
|
|
text: "Show custom network routing panel"
|
|
|
|
checked: true
|
|
|
|
}
|
|
|
|
|
2024-09-09 11:29:40 +00:00
|
|
|
CheckBox {
|
|
|
|
id: showSendErrorCheckBox
|
|
|
|
text: "Show send error"
|
|
|
|
checked: false
|
|
|
|
}
|
|
|
|
|
2024-01-30 13:15:58 +00:00
|
|
|
CheckBox {
|
|
|
|
id: showCommunityAssetsCheckBox
|
|
|
|
text: "Show community assets when sending tokens"
|
|
|
|
checked: true
|
|
|
|
}
|
|
|
|
|
|
|
|
CheckBox {
|
|
|
|
id: balanceThresholdCheckbox
|
|
|
|
text: "Turn on balance threshold"
|
|
|
|
checked: false
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
border.width: 1
|
|
|
|
Layout.preferredWidth: 100
|
|
|
|
Layout.preferredHeight: 50
|
|
|
|
color: "lightgrey"
|
|
|
|
TextInput {
|
|
|
|
id: balanceThresholdValue
|
|
|
|
anchors.fill: parent
|
|
|
|
enabled: balanceThresholdCheckbox.checked
|
|
|
|
text: "0.10"
|
|
|
|
inputMethodHints: Qt.ImhFormattedNumbersOnly
|
|
|
|
}
|
|
|
|
}
|
2023-05-10 11:05:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-07-31 12:21:14 +00:00
|
|
|
|
|
|
|
// category: Popups
|