diff --git a/src/app/modules/main/wallet_section/send/network_model.nim b/src/app/modules/main/wallet_section/send/network_model.nim index 3156e9ed6e..cb7bcf3600 100644 --- a/src/app/modules/main/wallet_section/send/network_model.nim +++ b/src/app/modules/main/wallet_section/send/network_model.nim @@ -279,6 +279,12 @@ QtObject: return item.getChainName() return "" + proc getIconUrl*(self: NetworkModel, chainId: int): string = + for item in self.items: + if item.getChainId() == chainId: + return item.getIconURL() + return "" + proc toggleRouteDisabledChains*(self: NetworkModel, chainId: int) {.slot.} = for i in 0 ..< self.items.len: if(self.items[i].getChainId() == chainId): diff --git a/src/app/modules/main/wallet_section/send/view.nim b/src/app/modules/main/wallet_section/send/view.nim index 254972827f..b0989ec317 100644 --- a/src/app/modules/main/wallet_section/send/view.nim +++ b/src/app/modules/main/wallet_section/send/view.nim @@ -295,3 +295,6 @@ QtObject: for shortName in chainShortNames.split(':'): preferredChains.add(self.fromNetworksModel.getNetworkChainId(shortName)) return preferredChains.join(":") + + proc getIconUrl*(self: View, chainId: int): string {.slot.} = + return self.fromNetworksModel.getIconUrl(chainId) diff --git a/storybook/pages/SendModalPage.qml b/storybook/pages/SendModalPage.qml index 51d437ad98..af54921f0e 100644 --- a/storybook/pages/SendModalPage.qml +++ b/storybook/pages/SendModalPage.qml @@ -2,7 +2,9 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 -import Models 1.0 +import StatusQ.Core 0.1 +import StatusQ.Controls 0.1 + import Storybook 1.0 import utils 1.0 @@ -10,14 +12,87 @@ import shared.popups.send 1.0 import shared.stores 1.0 import shared.stores.send 1.0 -import StatusQ.Core.Utils 0.1 - SplitView { id: root - orientation: Qt.Vertical + orientation: Qt.Horizontal + + TransactionStore { + id: txStore + } + + QtObject { + id: dummyEventData + + property ListModel toModel: ListModel { + ListElement { + chainId: 420 + chainName: "Optimism" + iconUrl: "network/Network=Optimism" + amountOut: "3003845308235848343" + } + } + 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:"" + }] + } Item { + anchors.left: parent.left SplitView.fillWidth: true SplitView.fillHeight: true @@ -29,6 +104,14 @@ SplitView { Loader { id: loader + property var preSelectedAccount: txStore.selectedSenderAccount + property string preSelectedHoldingID + property int preSelectedHoldingType + property int preSelectedSendType: Constants.SendType.Unknown + property bool onlyAssets: false + property string preDefinedAmountToSend + property string preSelectedRecipient + active: false sourceComponent: SendModal { @@ -36,170 +119,15 @@ SplitView { modal: false closePolicy: Popup.NoAutoClose onlyAssets: false - - store: TransactionStore { - readonly property QtObject selectedSenderAccount: QtObject { - readonly property var assets: WalletAssetsModel {} - } - readonly property QtObject collectiblesModel: WalletCollectiblesModel {} - readonly property QtObject nestedCollectiblesModel: WalletNestedCollectiblesModel {} - - readonly property QtObject walletSectionSendInst: QtObject {} - readonly property QtObject mainModuleInst: QtObject {} - - readonly property var savedAddressesModel: ListModel { - Component.onCompleted: { - for (let i = 0; i < 10; i++) - append({ - name: "some saved addr name " + i, - ens: [], - address: "0x2B748A02e06B159C7C3E98F5064577B96E55A7b4", - chainShortNames: "eth:arb" - }) - } - } - - function splitAndFormatAddressPrefix(textAddrss, updateInStore) { - return textAddrss - } - - function resolveENS() { - return "" - } - - function getAsset(assetsList, symbol) { - const idx = ModelUtils.indexOf(assetsList, "symbol", symbol) - if (idx < 0) { - return {} - } - return ModelUtils.get(assetsList, idx) - } - - function getCollectible(uid) { - const idx = ModelUtils.indexOf(collectiblesModel, "uid", uid) - if (idx < 0) { - return {} - } - return ModelUtils.get(collectiblesModel, idx) - } - - function getSelectorCollectible(uid) { - const idx = ModelUtils.indexOf(nestedCollectiblesModel, "uid", uid) - if (idx < 0) { - return {} - } - return ModelUtils.get(nestedCollectiblesModel, idx) - } - - function getHolding(holdingId, holdingType) { - if (holdingType === Constants.HoldingType.Asset) { - return getAsset(selectedSenderAccount.assets, holdingId) - } else if (holdingType === Constants.HoldingType.Collectible) { - return getCollectible(holdingId) - } else { - return {} - } - } - - function getSelectorHolding(holdingId, holdingType) { - if (holdingType === Constants.HoldingType.Asset) { - return getAsset(selectedSenderAccount.assets, holdingId) - } else if (holdingType === Constants.HoldingType.Collectible) { - return getSelectorCollectible(holdingId) - } else { - return {} - } - } - - function assetToSelectorAsset(asset) { - return asset - } - - function collectibleToSelectorCollectible(collectible) { - return { - uid: collectible.uid, - chainId: collectible.chainId, - name: collectible.name, - iconUrl: collectible.imageUrl, - collectionUid: collectible.collectionUid, - collectionName: collectible.collectionName, - isCollection: false - } - } - - function holdingToSelectorHolding(holding, holdingType) { - if (holdingType === Constants.HoldingType.Asset) { - return assetToSelectorAsset(holding) - } else if (holdingType === Constants.HoldingType.Collectible) { - return collectibleToSelectorCollectible(holding) - } else { - return {} - } - } - - readonly property string currentCurrency: "USD" - - readonly property QtObject currencyStore: QtObject { - readonly property string currentCurrency: "USD" - - function formatCurrencyAmount() { - return "42" - } - - function getFiatValue() { - return "42.42" - } - } - - function getAllNetworksSupportedString() { - return "OPT" - } - - function plainText(text) { - return text - } - - function prepareTransactionsForAddress(address) { - console.log("prepareTransactionsForAddress:", address) - } - - function getTransactions() { - return transactions - } - - readonly property var transactions_: ListModel { - id: transactions - - Component.onCompleted: { - for (let i = 0; i < 10; i++) - append({ - to: "to", - loadingTransaction: false, - value: { - displayDecimals: true, - stripTrailingZeroes: true, - amount: 3.234 - }, - timestamp: new Date() - }) - } - } - - function findTokenSymbolByAddress() { - return "ETH" - } - } - } - - Component.onCompleted: { - RootStore.currencyStore = { - currentCurrencySymbol: "USD" - } - - RootStore.getNetworkIcon = () => "network/Network=Optimism" - - loader.active = true + store: txStore + preSelectedAccount: loader.preSelectedAccount + preDefinedAmountToSend: loader.preDefinedAmountToSend + preSelectedRecipient: loader.preSelectedRecipient + preSelectedSendType: loader.preSelectedSendType + preSelectedHoldingID: loader.preSelectedHoldingID + preSelectedHoldingType: loader.preSelectedHoldingType } + Component.onCompleted: loader.active = true } } @@ -207,7 +135,122 @@ SplitView { SplitView.minimumHeight: 100 SplitView.preferredHeight: 100 - SplitView.fillWidth: true + + ColumnLayout { + width: parent.width + spacing: 20 + + ColumnLayout { + spacing: 0 + Layout.topMargin: 20 + width: parent.width + StatusBaseText { + Layout.maximumWidth: parent.width + text: "This button can be used as respons eot the suggestedROutes API called once a token and its amount is selected along with a valid recipient." + 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), + toNetworksModel: dummyEventData.toModel + } + txStore.fromNetworksModel.updateFromNetworks(dummyEventData.suggestesRoutes) + txStore.toNetworksModel.updateToNetworks(dummyEventData.suggestesRoutes) + txStore.walletSectionSendInst.suggestedRoutesReady(txRoutes) + txStore.suggestedRoutesCalled = false + } + } + } + + Rectangle { + Layout.fillWidth: true + Layout.preferredHeight: 1 + color: "grey" + } + + 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 + } + + ColumnLayout { + spacing: 0 + StatusBaseText { + text:"preSelectedAccount" + } + ComboBox { + textRole: "name" + model: txStore.senderAccounts + onCurrentIndexChanged: loader.preSelectedAccount = txStore.senderAccounts.get(currentIndex) + } + } + + ColumnLayout { + spacing: 0 + StatusBaseText { + text:"preSelectedHoldingType" + } + ComboBox { + id: tokenType + model: ["Unknown", "Asset", "Collectible"] + onCurrentIndexChanged: loader.preSelectedHoldingType = currentIndex + } + } + + StatusInput { + enabled: tokenType.currentIndex !== 0 + label: "preSelectedHoldingID (case sensitive)" + onTextChanged: loader.preSelectedHoldingID = text + } + + StatusInput { + label: "preDefinedAmountToSend" + onTextChanged: loader.preDefinedAmountToSend = text + } + + ColumnLayout { + spacing: 0 + StatusBaseText { + text:"preSelectedSendType" + } + ComboBox { + model: ["Transfer", + "ENSRegister", + "ENSRelease", + "ENSSetPubKey", + "StickersBuy", + "Bridge", + "ERC721Transfer", + "Unknown"] + onCurrentIndexChanged: loader.preSelectedSendType = currentIndex + } + } + + StatusInput { + label: "preSelectedRecipient" + onTextChanged: loader.preSelectedRecipient = text + } + + StatusButton { + text: "Reload popup" + onClicked: { + loader.item.close() + loader.item.open() + } + } + } } } diff --git a/storybook/src/Models/NetworksModel.qml b/storybook/src/Models/NetworksModel.qml index b851660795..949b33b258 100644 --- a/storybook/src/Models/NetworksModel.qml +++ b/storybook/src/Models/NetworksModel.qml @@ -294,4 +294,224 @@ QtObject { } ]) } + + readonly property var sendFromNetworks: CustomNetworkModel { + function updateFromNetworks(paths){ + reset() + for(let i=0; i 5 minutes") + } + } + + function getNetworkIcon(chainId) { + return ModelUtils.getByKey(NetworksModel.allNetworks, "chainId", Number(chainId), "iconUrl") + } + + function resetStoredProperties() { + root.amountToSend = "" + root.sendType = Constants.SendType.Transfer + root.selectedRecipient = "" + root.selectedAssetSymbol = "" + root.showUnPreferredChains = false + root.fromNetworksModel.reset() + root.toNetworksModel.reset() + } + + function getNetworkName(chainId) { + return ModelUtils.getByKey(NetworksModel.allNetworks, "chainId", chainId, "chainName") + } +} diff --git a/ui/app/AppLayouts/Browser/BrowserLayout.qml b/ui/app/AppLayouts/Browser/BrowserLayout.qml index 905cf443dc..4970fa2d56 100644 --- a/ui/app/AppLayouts/Browser/BrowserLayout.qml +++ b/ui/app/AppLayouts/Browser/BrowserLayout.qml @@ -63,7 +63,7 @@ StatusSectionLayout { property Component sendTransactionModalComponent: SendModal { anchors.centerIn: parent - preSelectedHolding: store.getAsset(WalletStore.dappBrowserAccount.assets, "ETH") + preSelectedHoldingID: "ETH" preSelectedHoldingType: Constants.HoldingType.Asset } diff --git a/ui/app/AppLayouts/Communities/popups/TransferOwnershipPopup.qml b/ui/app/AppLayouts/Communities/popups/TransferOwnershipPopup.qml index 0e35b28f78..f6bbdb7edc 100644 --- a/ui/app/AppLayouts/Communities/popups/TransferOwnershipPopup.qml +++ b/ui/app/AppLayouts/Communities/popups/TransferOwnershipPopup.qml @@ -111,14 +111,7 @@ StatusDialog { // Pre-populated dialog with the relevant Owner token info: root.sendModalPopup.preSelectedSendType = Constants.SendType.Transfer root.sendModalPopup.preSelectedAccount = ModelUtils.getByKey(root.accounts, "address", token.accountAddress) - root.sendModalPopup.preSelectedHolding = { - uid : token.key, - chainId: token.chainId, - name: token.name, - imageUrl: token.artworkSource, - collectionUid: "", - collectionName: "" - } + root.sendModalPopup.preSelectedHoldingID = token.key root.sendModalPopup.preSelectedHoldingType = Constants.HoldingType.Collectible root.sendModalPopup.open() close() diff --git a/ui/app/AppLayouts/Profile/views/EnsDetailsView.qml b/ui/app/AppLayouts/Profile/views/EnsDetailsView.qml index 702372a60e..0732598ad4 100644 --- a/ui/app/AppLayouts/Profile/views/EnsDetailsView.qml +++ b/ui/app/AppLayouts/Profile/views/EnsDetailsView.qml @@ -121,7 +121,7 @@ Item { preSelectedSendType: Constants.SendType.ENSRelease preSelectedRecipient: root.ensUsernamesStore.getEnsRegisteredAddress() preDefinedAmountToSend: LocaleUtils.numberToLocaleString(0) - preSelectedHolding: store.getAsset(releaseEnsModal.store.assets, Constants.ethToken) + preSelectedHoldingID: Constants.ethToken preSelectedHoldingType: Constants.HoldingType.Asset sendTransaction: function() { if(bestRoutes.count === 1) { diff --git a/ui/app/AppLayouts/Profile/views/EnsSearchView.qml b/ui/app/AppLayouts/Profile/views/EnsSearchView.qml index 4109d52521..7778093782 100644 --- a/ui/app/AppLayouts/Profile/views/EnsSearchView.qml +++ b/ui/app/AppLayouts/Profile/views/EnsSearchView.qml @@ -66,7 +66,7 @@ Item { preSelectedSendType: Constants.SendType.ENSSetPubKey preSelectedRecipient: root.ensUsernamesStore.getEnsRegisteredAddress() preDefinedAmountToSend: LocaleUtils.numberToLocaleString(0) - preSelectedHolding: store.getAsset(connectEnsModal.store.assets, Constants.ethToken) + preSelectedHoldingID: Constants.ethToken preSelectedHoldingType: Constants.HoldingType.Asset sendTransaction: function() { if(bestRoutes.count === 1) { diff --git a/ui/app/AppLayouts/Profile/views/EnsTermsAndConditionsView.qml b/ui/app/AppLayouts/Profile/views/EnsTermsAndConditionsView.qml index 375524f47c..860d0c81a7 100644 --- a/ui/app/AppLayouts/Profile/views/EnsTermsAndConditionsView.qml +++ b/ui/app/AppLayouts/Profile/views/EnsTermsAndConditionsView.qml @@ -51,7 +51,7 @@ Item { preSelectedSendType: Constants.SendType.ENSRegister preSelectedRecipient: root.ensUsernamesStore.getEnsRegisteredAddress() preDefinedAmountToSend: LocaleUtils.numberToLocaleString(10) - preSelectedHolding: store.getAsset(buyEnsModal.store.assets, JSON.parse(root.stickersStore.getStatusToken()).symbol) + preSelectedHoldingID: JSON.parse(root.stickersStore.getStatusToken()).symbol preSelectedHoldingType: Constants.HoldingType.Asset sendTransaction: function() { if(bestRoutes.count === 1) { diff --git a/ui/app/mainui/AppMain.qml b/ui/app/mainui/AppMain.qml index 124ff7d6f9..a8d2272a82 100644 --- a/ui/app/mainui/AppMain.qml +++ b/ui/app/mainui/AppMain.qml @@ -1381,7 +1381,6 @@ Item { property var preSelectedAccount property var preSelectedRecipient property int preSelectedRecipientType - property var preSelectedHolding property string preSelectedHoldingID property int preSelectedHoldingType property int preSelectedSendType: Constants.SendType.Unknown @@ -1395,7 +1394,6 @@ Item { sendModal.preSelectedSendType = Constants.SendType.Unknown sendModal.preSelectedHoldingID = "" sendModal.preSelectedHoldingType = Constants.HoldingType.Unknown - sendModal.preSelectedHolding = undefined sendModal.preSelectedAccount = undefined sendModal.preSelectedRecipient = undefined sendModal.preDefinedAmountToSend = "" @@ -1416,9 +1414,6 @@ Item { item.preSelectedHoldingID = sendModal.preSelectedHoldingID item.preSelectedHoldingType = sendModal.preSelectedHoldingType } - if(!!preSelectedHolding) { - item.preSelectedHolding = preSelectedHolding - } if(preDefinedAmountToSend != "") { item.preDefinedAmountToSend = preDefinedAmountToSend } diff --git a/ui/imports/shared/popups/send/SendModal.qml b/ui/imports/shared/popups/send/SendModal.qml index cc88b92184..82c912a553 100644 --- a/ui/imports/shared/popups/send/SendModal.qml +++ b/ui/imports/shared/popups/send/SendModal.qml @@ -6,7 +6,6 @@ import QtGraphicalEffects 1.0 import SortFilterProxyModel 0.2 import utils 1.0 -import shared.stores 1.0 import shared.stores.send 1.0 import StatusQ.Components 0.1 @@ -24,25 +23,22 @@ import "./views" StatusDialog { id: popup + property var preSelectedAccount: store.selectedSenderAccount // expected content depends on the preSelectedRecipientType value. // If type Address this must be a string else it expects an object. See RecipientView.selectedRecipientType property var preSelectedRecipient property int preSelectedRecipientType: TabAddressSelectorView.Type.Address property string preDefinedAmountToSend - // requires to have assigned an item from assets model - property var preSelectedHolding // token symbol property string preSelectedHoldingID property int preSelectedHoldingType property int preSelectedSendType property bool interactive: true property alias onlyAssets: holdingSelector.onlyAssets - property var preSelectedAccount: store.selectedSenderAccount property alias modalHeader: modalHeader.text property TransactionStore store: TransactionStore {} - property CurrenciesStore currencyStore: store.currencyStore property var collectiblesModel: store.collectiblesModel property var nestedCollectiblesModel: store.nestedCollectiblesModel property var bestRoutes @@ -70,6 +66,7 @@ StatusDialog { QtObject { id: d + readonly property var currencyStore: store.currencyStore readonly property int errorType: !amountToSendInput.input.valid && !isERC721Transfer ? Constants.SendAmountExceedsBalance : (popup.bestRoutes && popup.bestRoutes.count === 0 && !!amountToSendInput.input.text && recipientLoader.ready && !popup.isLoading) ? @@ -77,7 +74,7 @@ StatusDialog { readonly property double maxFiatBalance: isSelectedHoldingValidAsset ? selectedHolding.totalCurrencyBalance.amount : 0 readonly property double maxCryptoBalance: isSelectedHoldingValidAsset ? selectedHolding.totalBalance.amount : 0 readonly property double maxInputBalance: amountToSendInput.inputIsFiat ? maxFiatBalance : maxCryptoBalance - readonly property string inputSymbol: amountToSendInput.inputIsFiat ? popup.currencyStore.currentCurrency : store.selectedAssetSymbol + readonly property string inputSymbol: amountToSendInput.inputIsFiat ? currencyStore.currentCurrency : store.selectedAssetSymbol readonly property bool errorMode: popup.isLoading || !recipientLoader.ready ? false : errorType !== Constants.NoError || networkSelector.errorMode || !amountToSendInput.inputNumberValid readonly property string uuid: Utils.uuid() property bool isPendingTx: false @@ -149,9 +146,7 @@ StatusDialog { if (popup.preSelectedHoldingType !== Constants.HoldingType.Unknown) { tokenListRect.browsingHoldingType = popup.preSelectedHoldingType - if(!!popup.preSelectedHolding) { - d.setSelectedHolding(popup.preSelectedHolding, popup.preSelectedHoldingType) - } else if (!!popup.preSelectedHoldingID) { + if (!!popup.preSelectedHoldingID) { d.setSelectedHoldingId(popup.preSelectedHoldingID, popup.preSelectedHoldingType) } } @@ -252,11 +247,11 @@ StatusDialog { Layout.fillHeight: true assetsModel: popup.preSelectedAccount && popup.preSelectedAccount.assets ? popup.preSelectedAccount.assets : null collectiblesModel: popup.preSelectedAccount ? popup.nestedCollectiblesModel : null - currentCurrencySymbol: RootStore.currencyStore.currentCurrencySymbol + currentCurrencySymbol: d.currencyStore.currentCurrencySymbol visible: (!!d.selectedHolding && d.selectedHoldingType !== Constants.HoldingType.Unknown) || (!!d.hoveredHolding && d.hoveredHoldingType !== Constants.HoldingType.Unknown) getNetworkIcon: function(chainId){ - return RootStore.getNetworkIcon(chainId) + return popup.store.getNetworkIcon(chainId) } onItemSelected: { d.setSelectedHoldingId(holdingId, holdingType) @@ -269,12 +264,12 @@ StatusDialog { visible: d.isSelectedHoldingValidAsset || d.isHoveredHoldingValidAsset && !d.isERC721Transfer title: { if(d.isHoveredHoldingValidAsset && !!d.hoveredHolding.symbol) { - const balance = popup.currencyStore.formatCurrencyAmount((amountToSendInput.inputIsFiat ? d.hoveredHolding.totalCurrencyBalance.amount : d.hoveredHolding.totalBalance.amount) , d.hoveredHolding.symbol) + const balance = d.currencyStore.formatCurrencyAmount((amountToSendInput.inputIsFiat ? d.hoveredHolding.totalCurrencyBalance.amount : d.hoveredHolding.totalBalance.amount) , d.hoveredHolding.symbol) return qsTr("Max: %1").arg(balance) } if (d.maxInputBalance <= 0) return qsTr("No balances active") - const balance = popup.currencyStore.formatCurrencyAmount(d.maxInputBalance, d.inputSymbol) + const balance = d.currencyStore.formatCurrencyAmount(d.maxInputBalance, d.inputSymbol) return qsTr("Max: %1").arg(balance) } tagClickable: true @@ -283,7 +278,7 @@ StatusDialog { bgColor: amountToSendInput.input.valid || !amountToSendInput.input.text ? Theme.palette.primaryColor3 : Theme.palette.dangerColor2 titleText.color: amountToSendInput.input.valid || !amountToSendInput.input.text ? Theme.palette.primaryColor1 : Theme.palette.dangerColor1 onTagClicked: { - amountToSendInput.input.text = popup.currencyStore.formatCurrencyAmount(d.maxInputBalance, d.inputSymbol, {noSymbol: true, rawAmount: true}, LocaleUtils.userInputLocale) + amountToSendInput.input.text = d.currencyStore.formatCurrencyAmount(d.maxInputBalance, d.inputSymbol, {noSymbol: true, rawAmount: true}, LocaleUtils.userInputLocale) } } } @@ -297,21 +292,21 @@ StatusDialog { interactive: popup.interactive selectedSymbol: store.selectedAssetSymbol maxInputBalance: d.maxInputBalance - currentCurrency: popup.currencyStore.currentCurrency + currentCurrency: d.currencyStore.currentCurrency multiplierIndex: holdingSelector.selectedItem ? holdingSelector.selectedItem.decimals : 0 getFiatValue: function(cryptoValue) { - return selectedSymbol ? popup.currencyStore.getFiatValue(cryptoValue, selectedSymbol, currentCurrency) : 0.0 + return selectedSymbol ? d.currencyStore.getFiatValue(cryptoValue, selectedSymbol, currentCurrency) : 0.0 } getCryptoValue: function(fiatValue) { - return selectedSymbol ? popup.currencyStore.getCryptoValue(fiatValue, selectedSymbol, currentCurrency) : 0.0 + return selectedSymbol ? d.currencyStore.getCryptoValue(fiatValue, selectedSymbol, currentCurrency) : 0.0 } - formatCurrencyAmount: popup.currencyStore.formatCurrencyAmount + formatCurrencyAmount: d.currencyStore.formatCurrencyAmount onReCalculateSuggestedRoute: popup.recalculateRoutesAndFees() } @@ -331,11 +326,11 @@ StatusDialog { inputIsFiat: amountToSendInput.inputIsFiat minCryptoDecimals: amountToSendInput.minReceiveCryptoDecimals minFiatDecimals: amountToSendInput.minReceiveFiatDecimals - currentCurrency: popup.currencyStore.currentCurrency + currentCurrency: d.currencyStore.currentCurrency getFiatValue: function(cryptoValue) { - return popup.currencyStore.getFiatValue(cryptoValue, selectedSymbol, currentCurrency) + return d.currencyStore.getFiatValue(cryptoValue, selectedSymbol, currentCurrency) } - formatCurrencyAmount: popup.currencyStore.formatCurrencyAmount + formatCurrencyAmount: d.currencyStore.formatCurrencyAmount } } } @@ -383,7 +378,7 @@ StatusDialog { return store.findTokenSymbolByAddress(address) } getNetworkIcon: function(chainId){ - return RootStore.getNetworkIcon(chainId) + return popup.store.getNetworkIcon(chainId) } onTokenSelected: { d.setSelectedHoldingId(symbol, holdingType) @@ -486,7 +481,7 @@ StatusDialog { footer: SendModalFooter { width: parent.width nextButtonText: d.isBridgeTx ? qsTr("Bridge") : qsTr("Send") - maxFiatFees: popup.isLoading ? "..." : popup.currencyStore.formatCurrencyAmount(d.totalFeesInFiat, popup.currencyStore.currentCurrency) + maxFiatFees: popup.isLoading ? "..." : d.currencyStore.formatCurrencyAmount(d.totalFeesInFiat, d.currencyStore.currentCurrency) totalTimeEstimate: popup.isLoading? "..." : d.totalTimeEstimate pending: d.isPendingTx || popup.isLoading visible: recipientLoader.ready && amountToSendInput.inputNumberValid && !d.errorMode @@ -499,8 +494,8 @@ StatusDialog { popup.bestRoutes = txRoutes.suggestedRoutes let gasTimeEstimate = txRoutes.gasTimeEstimate d.totalTimeEstimate = popup.store.getLabelForEstimatedTxTime(gasTimeEstimate.totalTime) - d.totalFeesInFiat = popup.currencyStore.getFiatValue( gasTimeEstimate.totalFeesInEth, "ETH", popup.currencyStore.currentCurrency) + - popup.currencyStore.getFiatValue(gasTimeEstimate.totalTokenFees, fees.selectedTokenSymbol, popup.currencyStore.currentCurrency) + d.totalFeesInFiat = d.currencyStore.getFiatValue( gasTimeEstimate.totalFeesInEth, "ETH", d.currencyStore.currentCurrency) + + d.currencyStore.getFiatValue(gasTimeEstimate.totalTokenFees, fees.selectedTokenSymbol, d.currencyStore.currentCurrency) d.totalAmountToReceive = popup.store.getWei2Eth(txRoutes.amountToReceive, d.selectedHolding.decimals) networkSelector.toNetworksList = txRoutes.toNetworksModel popup.isLoading = false diff --git a/ui/imports/shared/status/StatusStickerMarket.qml b/ui/imports/shared/status/StatusStickerMarket.qml index ce1306fa4f..61013e2e22 100644 --- a/ui/imports/shared/status/StatusStickerMarket.qml +++ b/ui/imports/shared/status/StatusStickerMarket.qml @@ -203,7 +203,7 @@ Item { preSelectedSendType: Constants.SendType.StickersBuy preSelectedRecipient: root.store.stickersStore.getStickersMarketAddress() preDefinedAmountToSend: LocaleUtils.numberToLocaleString(parseFloat(price)) - preSelectedHolding: store.getAsset(buyStickersModal.store.assets, JSON.parse(root.store.stickersStore.getStatusToken()).symbol) + preSelectedHoldingID: JSON.parse(root.store.stickersStore.getStatusToken()).symbol preSelectedHoldingType: Constants.HoldingType.Asset sendTransaction: function() { if(bestRoutes.count === 1) { diff --git a/ui/imports/shared/status/StatusStickerPackClickPopup.qml b/ui/imports/shared/status/StatusStickerPackClickPopup.qml index 15cd4f2459..78d525cb0d 100644 --- a/ui/imports/shared/status/StatusStickerPackClickPopup.qml +++ b/ui/imports/shared/status/StatusStickerPackClickPopup.qml @@ -72,7 +72,7 @@ ModalPopup { preSelectedSendType: Constants.SendType.StickersBuy preSelectedRecipient: stickerPackDetailsPopup.store.stickersStore.getStickersMarketAddress() preDefinedAmountToSend: LocaleUtils.numberToLocaleString(parseFloat(price)) - preSelectedHolding: store.getAsset(buyStickersPackModal.store.assets, JSON.parse(stickerPackDetailsPopup.store.stickersStore.getStatusToken()).symbol) + preSelectedHoldingID: JSON.parse(stickerPackDetailsPopup.store.stickersStore.getStatusToken()).symbol preSelectedHoldingType: Constants.HoldingType.Asset sendTransaction: function() { if(bestRoutes.count === 1) { diff --git a/ui/imports/shared/stores/send/TransactionStore.qml b/ui/imports/shared/stores/send/TransactionStore.qml index 24a3afefe9..ea5206f592 100644 --- a/ui/imports/shared/stores/send/TransactionStore.qml +++ b/ui/imports/shared/stores/send/TransactionStore.qml @@ -246,4 +246,8 @@ QtObject { function getShortChainIds(chainShortNames) { return walletSectionSendInst.getShortChainIds(chainShortNames) } + + function getNetworkIcon(chainId) { + return walletSectionSendInst.getIconUrl(chainId) + } }