fix: account selector in browser
This commit is contained in:
parent
08a7baed8f
commit
b0829a4615
|
@ -32,6 +32,8 @@ proc init*(self: WalletController) =
|
||||||
self.view.addAccountToList(account)
|
self.view.addAccountToList(account)
|
||||||
self.view.setTotalFiatBalance(self.status.wallet.getTotalFiatBalance())
|
self.view.setTotalFiatBalance(self.status.wallet.getTotalFiatBalance())
|
||||||
|
|
||||||
|
self.view.setDappBrowserAddress()
|
||||||
|
|
||||||
self.status.events.on("accountsUpdated") do(e: Args):
|
self.status.events.on("accountsUpdated") do(e: Args):
|
||||||
self.view.updateView()
|
self.view.updateView()
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ import ../../status/[status, wallet, threads]
|
||||||
import ../../status/wallet/collectibles as status_collectibles
|
import ../../status/wallet/collectibles as status_collectibles
|
||||||
import ../../status/libstatus/accounts/constants
|
import ../../status/libstatus/accounts/constants
|
||||||
import ../../status/libstatus/wallet as status_wallet
|
import ../../status/libstatus/wallet as status_wallet
|
||||||
|
import ../../status/libstatus/settings as status_settings
|
||||||
import ../../status/libstatus/tokens
|
import ../../status/libstatus/tokens
|
||||||
import ../../status/libstatus/types
|
import ../../status/libstatus/types
|
||||||
import ../../status/libstatus/utils as status_utils
|
import ../../status/libstatus/utils as status_utils
|
||||||
|
@ -18,6 +19,7 @@ QtObject:
|
||||||
currentCollectiblesLists*: CollectiblesList
|
currentCollectiblesLists*: CollectiblesList
|
||||||
currentAccount: AccountItemView
|
currentAccount: AccountItemView
|
||||||
focusedAccount: AccountItemView
|
focusedAccount: AccountItemView
|
||||||
|
dappBrowserAccount: AccountItemView
|
||||||
currentTransactions: TransactionList
|
currentTransactions: TransactionList
|
||||||
defaultTokenList: TokenList
|
defaultTokenList: TokenList
|
||||||
customTokenList: TokenList
|
customTokenList: TokenList
|
||||||
|
@ -37,6 +39,7 @@ QtObject:
|
||||||
self.currentAssetList.delete
|
self.currentAssetList.delete
|
||||||
self.currentAccount.delete
|
self.currentAccount.delete
|
||||||
self.focusedAccount.delete
|
self.focusedAccount.delete
|
||||||
|
self.dappBrowserAccount.delete
|
||||||
self.currentTransactions.delete
|
self.currentTransactions.delete
|
||||||
self.defaultTokenList.delete
|
self.defaultTokenList.delete
|
||||||
self.customTokenList.delete
|
self.customTokenList.delete
|
||||||
|
@ -45,12 +48,15 @@ QtObject:
|
||||||
proc setup(self: WalletView) =
|
proc setup(self: WalletView) =
|
||||||
self.QAbstractListModel.setup
|
self.QAbstractListModel.setup
|
||||||
|
|
||||||
|
proc setDappBrowserAddress*(self: WalletView)
|
||||||
|
|
||||||
proc newWalletView*(status: Status): WalletView =
|
proc newWalletView*(status: Status): WalletView =
|
||||||
new(result, delete)
|
new(result, delete)
|
||||||
result.status = status
|
result.status = status
|
||||||
result.accounts = newAccountList()
|
result.accounts = newAccountList()
|
||||||
result.currentAccount = newAccountItemView()
|
result.currentAccount = newAccountItemView()
|
||||||
result.focusedAccount = newAccountItemView()
|
result.focusedAccount = newAccountItemView()
|
||||||
|
result.dappBrowserAccount = newAccountItemView()
|
||||||
result.currentAssetList = newAssetList()
|
result.currentAssetList = newAssetList()
|
||||||
result.currentTransactions = newTransactionList()
|
result.currentTransactions = newTransactionList()
|
||||||
result.currentCollectiblesLists = newCollectiblesList()
|
result.currentCollectiblesLists = newCollectiblesList()
|
||||||
|
@ -583,3 +589,23 @@ QtObject:
|
||||||
self.ensWasResolved(address, uuid)
|
self.ensWasResolved(address, uuid)
|
||||||
|
|
||||||
proc transactionCompleted*(self: WalletView, success: bool, txHash: string, revertReason: string = "") {.signal.}
|
proc transactionCompleted*(self: WalletView, success: bool, txHash: string, revertReason: string = "") {.signal.}
|
||||||
|
|
||||||
|
proc dappBrowserAccountChanged*(self: WalletView) {.signal.}
|
||||||
|
|
||||||
|
proc setDappBrowserAddress*(self: WalletView) {.slot.} =
|
||||||
|
if(self.accounts.rowCount() == 0): return
|
||||||
|
|
||||||
|
let dappAddress = status_settings.getSetting[string](Setting.DappsAddress)
|
||||||
|
var index = self.accounts.getAccountindexByAddress(dappAddress)
|
||||||
|
if index == -1: index = 0
|
||||||
|
let selectedAccount = self.accounts.getAccount(index)
|
||||||
|
if self.dappBrowserAccount.address == selectedAccount.address: return
|
||||||
|
self.dappBrowserAccount.setAccountItem(selectedAccount)
|
||||||
|
self.dappBrowserAccountChanged()
|
||||||
|
|
||||||
|
proc getDappBrowserAccount*(self: WalletView): QVariant {.slot.} =
|
||||||
|
result = newQVariant(self.dappBrowserAccount)
|
||||||
|
|
||||||
|
QtProperty[QVariant] dappBrowserAccount:
|
||||||
|
read = getDappBrowserAccount
|
||||||
|
notify = dappBrowserAccountChanged
|
||||||
|
|
|
@ -100,7 +100,7 @@ Popup {
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
id: titleText
|
id: titleText
|
||||||
text: qsTr('"%1" woudl like to connect to').arg(request.title)
|
text: qsTr('"%1" would like to connect to').arg(request.title)
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
|
@ -116,7 +116,7 @@ Popup {
|
||||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
||||||
showAccountDetails: false
|
showAccountDetails: false
|
||||||
accounts: walletModel.accounts
|
accounts: walletModel.accounts
|
||||||
selectedAccount: walletModel.currentAccount
|
selectedAccount: walletModel.dappBrowserAccount
|
||||||
currency: walletModel.defaultCurrency
|
currency: walletModel.defaultCurrency
|
||||||
onSelectedAccountChanged: {
|
onSelectedAccountChanged: {
|
||||||
if (!root.currentAddress) {
|
if (!root.currentAddress) {
|
||||||
|
@ -132,7 +132,8 @@ Popup {
|
||||||
web3Provider.dappsAddress = selectedAccount.address;
|
web3Provider.dappsAddress = selectedAccount.address;
|
||||||
web3Provider.clearPermissions();
|
web3Provider.clearPermissions();
|
||||||
if (selectField.menu.currentIndex !== -1) {
|
if (selectField.menu.currentIndex !== -1) {
|
||||||
walletModel.setCurrentAccountByIndex(selectField.menu.currentIndex-1)
|
web3Provider.dappsAddress = selectedAccount.address;
|
||||||
|
walletModel.setDappBrowserAddress()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,8 +182,8 @@ Rectangle {
|
||||||
icon.source: "../../img/walletIcon.svg"
|
icon.source: "../../img/walletIcon.svg"
|
||||||
icon.width: 18
|
icon.width: 18
|
||||||
icon.height: 18
|
icon.height: 18
|
||||||
icon.color: walletModel.currentAccount.iconColor
|
icon.color: walletModel.dappBrowserAccount.iconColor
|
||||||
text: walletModel.currentAccount.name
|
text: walletModel.dappBrowserAccount.name
|
||||||
implicitHeight: 32
|
implicitHeight: 32
|
||||||
type: "secondary"
|
type: "secondary"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
|
|
@ -159,10 +159,8 @@ Rectangle {
|
||||||
}
|
}
|
||||||
} else if (request.type === Constants.web3SendAsyncReadOnly &&
|
} else if (request.type === Constants.web3SendAsyncReadOnly &&
|
||||||
request.payload.method === "eth_sendTransaction") {
|
request.payload.method === "eth_sendTransaction") {
|
||||||
walletModel.setFocusedAccountByAddress(request.payload.params[0].from)
|
var acc = walletModel.dappBrowserAccount
|
||||||
var acc = walletModel.focusedAccount
|
|
||||||
const value = utilsModel.wei2Eth(request.payload.params[0].value, 18);
|
const value = utilsModel.wei2Eth(request.payload.params[0].value, 18);
|
||||||
|
|
||||||
const sendDialog = sendTransactionModalComponent.createObject(browserWindow, {
|
const sendDialog = sendTransactionModalComponent.createObject(browserWindow, {
|
||||||
trxData:request.payload.params[0].data,
|
trxData:request.payload.params[0].data,
|
||||||
selectedAccount: {
|
selectedAccount: {
|
||||||
|
@ -232,8 +230,8 @@ Rectangle {
|
||||||
const signDialog = signMessageModalComponent.createObject(browserWindow, {
|
const signDialog = signMessageModalComponent.createObject(browserWindow, {
|
||||||
request,
|
request,
|
||||||
selectedAccount: {
|
selectedAccount: {
|
||||||
name: walletModel.currentAccount.name,
|
name: walletModel.dappBrowserAccount.name,
|
||||||
iconColor: walletModel.currentAccount.iconColor
|
iconColor: walletModel.dappBrowserAccount.iconColor
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
signDialog.web3Response = web3Response
|
signDialog.web3Response = web3Response
|
||||||
|
|
|
@ -103,7 +103,7 @@ Popup {
|
||||||
anchors.right: copyBtn.left
|
anchors.right: copyBtn.left
|
||||||
anchors.rightMargin: Style.current.padding
|
anchors.rightMargin: Style.current.padding
|
||||||
accounts: walletModel.accounts
|
accounts: walletModel.accounts
|
||||||
selectedAccount: walletModel.currentAccount
|
selectedAccount: walletModel.dappBrowserAccount
|
||||||
currency: walletModel.defaultCurrency
|
currency: walletModel.defaultCurrency
|
||||||
onSelectedAccountChanged: {
|
onSelectedAccountChanged: {
|
||||||
if (!accountSelectorRow.currentAddress) {
|
if (!accountSelectorRow.currentAddress) {
|
||||||
|
@ -117,10 +117,8 @@ Popup {
|
||||||
|
|
||||||
accountSelectorRow.currentAddress = selectedAccount.address
|
accountSelectorRow.currentAddress = selectedAccount.address
|
||||||
web3Provider.dappsAddress = selectedAccount.address;
|
web3Provider.dappsAddress = selectedAccount.address;
|
||||||
|
walletModel.setDappBrowserAddress()
|
||||||
web3Provider.clearPermissions();
|
web3Provider.clearPermissions();
|
||||||
if (selectField.menu.currentIndex !== -1) {
|
|
||||||
walletModel.setCurrentAccountByIndex(selectField.menu.currentIndex-1)
|
|
||||||
}
|
|
||||||
for (let i = 0; i < tabs.count; ++i){
|
for (let i = 0; i < tabs.count; ++i){
|
||||||
tabs.getTab(i).item.reload();
|
tabs.getTab(i).item.reload();
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,7 @@ ModalPopup {
|
||||||
accounts: walletModel.accounts
|
accounts: walletModel.accounts
|
||||||
currency: walletModel.defaultCurrency
|
currency: walletModel.defaultCurrency
|
||||||
width: stack.width
|
width: stack.width
|
||||||
|
selectedAccount: root.selectedAccount
|
||||||
//% "Choose account"
|
//% "Choose account"
|
||||||
label: qsTrId("choose-account")
|
label: qsTrId("choose-account")
|
||||||
showBalanceForAssetSymbol: root.selectedAsset.symbol
|
showBalanceForAssetSymbol: root.selectedAsset.symbol
|
||||||
|
@ -180,7 +181,7 @@ ModalPopup {
|
||||||
asset: root.selectedAsset
|
asset: root.selectedAsset
|
||||||
amount: { "value": root.selectedAmount, "fiatValue": root.selectedFiatAmount }
|
amount: { "value": root.selectedAmount, "fiatValue": root.selectedFiatAmount }
|
||||||
currency: walletModel.defaultCurrency
|
currency: walletModel.defaultCurrency
|
||||||
isFromEditable: true
|
isFromEditable: false
|
||||||
isGasEditable: true
|
isGasEditable: true
|
||||||
fromValid: balanceValidator.isValid
|
fromValid: balanceValidator.isValid
|
||||||
gasValid: gasValidator.isValid
|
gasValid: gasValidator.isValid
|
||||||
|
|
|
@ -45,7 +45,7 @@ Button {
|
||||||
ColorOverlay {
|
ColorOverlay {
|
||||||
anchors.fill: iconImg
|
anchors.fill: iconImg
|
||||||
source: iconImg
|
source: iconImg
|
||||||
color: buttonLabel.color
|
color: control.icon.color
|
||||||
antialiasing: true
|
antialiasing: true
|
||||||
smooth: true
|
smooth: true
|
||||||
rotation: control.iconRotation
|
rotation: control.iconRotation
|
||||||
|
|
Loading…
Reference in New Issue