parent
04b6fb54c3
commit
a5aba6e4e2
|
@ -11,6 +11,7 @@ type
|
||||||
isWatchOnlyAccount: bool
|
isWatchOnlyAccount: bool
|
||||||
isAllAccounts: bool
|
isAllAccounts: bool
|
||||||
colorIds: seq[string]
|
colorIds: seq[string]
|
||||||
|
canSend: bool
|
||||||
|
|
||||||
proc initItem*(
|
proc initItem*(
|
||||||
name: string = "",
|
name: string = "",
|
||||||
|
@ -21,7 +22,8 @@ proc initItem*(
|
||||||
emoji: string,
|
emoji: string,
|
||||||
isWatchOnlyAccount: bool=false,
|
isWatchOnlyAccount: bool=false,
|
||||||
isAllAccounts: bool = false,
|
isAllAccounts: bool = false,
|
||||||
colorIds: seq[string] = @[]
|
colorIds: seq[string] = @[],
|
||||||
|
canSend: bool = true,
|
||||||
): Item =
|
): Item =
|
||||||
result.name = name
|
result.name = name
|
||||||
result.mixedCaseAddress = mixedCaseAddress
|
result.mixedCaseAddress = mixedCaseAddress
|
||||||
|
@ -32,6 +34,7 @@ proc initItem*(
|
||||||
result.isAllAccounts = isAllAccounts
|
result.isAllAccounts = isAllAccounts
|
||||||
result.colorIds = colorIds
|
result.colorIds = colorIds
|
||||||
result.isWatchOnlyAccount = isWatchOnlyAccount
|
result.isWatchOnlyAccount = isWatchOnlyAccount
|
||||||
|
result.canSend = canSend
|
||||||
|
|
||||||
proc `$`*(self: Item): string =
|
proc `$`*(self: Item): string =
|
||||||
result = fmt"""OverviewItem(
|
result = fmt"""OverviewItem(
|
||||||
|
@ -72,3 +75,6 @@ proc getColorIds*(self: Item): string =
|
||||||
|
|
||||||
proc getIsWatchOnlyAccount*(self: Item): bool =
|
proc getIsWatchOnlyAccount*(self: Item): bool =
|
||||||
return self.isWatchOnlyAccount
|
return self.isWatchOnlyAccount
|
||||||
|
|
||||||
|
proc getCanSend*(self: Item): bool =
|
||||||
|
return self.canSend
|
||||||
|
|
|
@ -82,6 +82,7 @@ method filterChanged*(self: Module, addresses: seq[string], chainIds: seq[int],
|
||||||
self.view.setData(item)
|
self.view.setData(item)
|
||||||
else:
|
else:
|
||||||
let walletAccount = walletAccounts[0]
|
let walletAccount = walletAccounts[0]
|
||||||
|
let isWatchOnlyAccount = walletAccount.walletType == "watch"
|
||||||
let item = initItem(
|
let item = initItem(
|
||||||
walletAccount.name,
|
walletAccount.name,
|
||||||
walletAccount.mixedCaseAddress,
|
walletAccount.mixedCaseAddress,
|
||||||
|
@ -89,7 +90,8 @@ method filterChanged*(self: Module, addresses: seq[string], chainIds: seq[int],
|
||||||
walletAccount.assetsLoading,
|
walletAccount.assetsLoading,
|
||||||
walletAccount.colorId,
|
walletAccount.colorId,
|
||||||
walletAccount.emoji,
|
walletAccount.emoji,
|
||||||
isWatchOnlyAccount=walletAccount.walletType == "watch"
|
isWatchOnlyAccount=isWatchOnlyAccount,
|
||||||
|
canSend=not isWatchOnlyAccount and (walletAccount.operable==AccountFullyOperable or walletAccount.operable==AccountPartiallyOperable)
|
||||||
)
|
)
|
||||||
self.view.setData(item)
|
self.view.setData(item)
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ QtObject:
|
||||||
isAllAccounts: bool
|
isAllAccounts: bool
|
||||||
colorIds: string
|
colorIds: string
|
||||||
isWatchOnlyAccount: bool
|
isWatchOnlyAccount: bool
|
||||||
|
canSend: bool
|
||||||
|
|
||||||
proc setup(self: View) =
|
proc setup(self: View) =
|
||||||
self.QObject.setup
|
self.QObject.setup
|
||||||
|
@ -112,6 +113,13 @@ QtObject:
|
||||||
read = getIsWatchOnlyAccount
|
read = getIsWatchOnlyAccount
|
||||||
notify = isWatchOnlyAccountChanged
|
notify = isWatchOnlyAccountChanged
|
||||||
|
|
||||||
|
proc getCanSend(self: View): bool {.slot.} =
|
||||||
|
return self.canSend
|
||||||
|
proc canSendChanged(self: View) {.signal.}
|
||||||
|
QtProperty[bool] canSend:
|
||||||
|
read = getCanSend
|
||||||
|
notify = canSendChanged
|
||||||
|
|
||||||
proc setData*(self: View, item: Item) =
|
proc setData*(self: View, item: Item) =
|
||||||
if(self.name != item.getName()):
|
if(self.name != item.getName()):
|
||||||
self.name = item.getName()
|
self.name = item.getName()
|
||||||
|
@ -136,6 +144,9 @@ QtObject:
|
||||||
if(self.isWatchOnlyAccount != item.getIsWatchOnlyAccount()):
|
if(self.isWatchOnlyAccount != item.getIsWatchOnlyAccount()):
|
||||||
self.isWatchOnlyAccount = item.getIsWatchOnlyAccount()
|
self.isWatchOnlyAccount = item.getIsWatchOnlyAccount()
|
||||||
self.isWatchOnlyAccountChanged()
|
self.isWatchOnlyAccountChanged()
|
||||||
|
if(self.canSend != item.getCanSend()):
|
||||||
|
self.canSend = item.getCanSend()
|
||||||
|
self.canSendChanged()
|
||||||
if(self.isAllAccounts != item.getIsAllAccounts()):
|
if(self.isAllAccounts != item.getIsAllAccounts()):
|
||||||
self.isAllAccounts = item.getIsAllAccounts()
|
self.isAllAccounts = item.getIsAllAccounts()
|
||||||
self.isAllAccountsChanged()
|
self.isAllAccountsChanged()
|
||||||
|
|
|
@ -9,6 +9,7 @@ QtObject:
|
||||||
type AccountItem* = ref object of WalletAccountItem
|
type AccountItem* = ref object of WalletAccountItem
|
||||||
assets: token_model.Model
|
assets: token_model.Model
|
||||||
currencyBalance: CurrencyAmount
|
currencyBalance: CurrencyAmount
|
||||||
|
canSend: bool
|
||||||
|
|
||||||
proc setup*(self: AccountItem,
|
proc setup*(self: AccountItem,
|
||||||
name: string,
|
name: string,
|
||||||
|
@ -21,7 +22,8 @@ QtObject:
|
||||||
position: int,
|
position: int,
|
||||||
areTestNetworksEnabled: bool,
|
areTestNetworksEnabled: bool,
|
||||||
prodPreferredChainIds: string,
|
prodPreferredChainIds: string,
|
||||||
testPreferredChainIds: string
|
testPreferredChainIds: string,
|
||||||
|
canSend: bool
|
||||||
) =
|
) =
|
||||||
self.QObject.setup
|
self.QObject.setup
|
||||||
self.WalletAccountItem.setup(name,
|
self.WalletAccountItem.setup(name,
|
||||||
|
@ -39,6 +41,7 @@ QtObject:
|
||||||
testPreferredChainIds)
|
testPreferredChainIds)
|
||||||
self.assets = assets
|
self.assets = assets
|
||||||
self.currencyBalance = currencyBalance
|
self.currencyBalance = currencyBalance
|
||||||
|
self.canSend = canSend
|
||||||
|
|
||||||
proc delete*(self: AccountItem) =
|
proc delete*(self: AccountItem) =
|
||||||
self.QObject.delete
|
self.QObject.delete
|
||||||
|
@ -55,9 +58,10 @@ QtObject:
|
||||||
prodPreferredChainIds: string = "",
|
prodPreferredChainIds: string = "",
|
||||||
testPreferredChainIds: string = "",
|
testPreferredChainIds: string = "",
|
||||||
position: int = 0,
|
position: int = 0,
|
||||||
|
canSend: bool = true,
|
||||||
): AccountItem =
|
): AccountItem =
|
||||||
new(result, delete)
|
new(result, delete)
|
||||||
result.setup(name, address, colorId, emoji, walletType, assets, currencyBalance, position, areTestNetworksEnabled, prodPreferredChainIds, testPreferredChainIds)
|
result.setup(name, address, colorId, emoji, walletType, assets, currencyBalance, position, areTestNetworksEnabled, prodPreferredChainIds, testPreferredChainIds, canSend)
|
||||||
|
|
||||||
proc `$`*(self: AccountItem): string =
|
proc `$`*(self: AccountItem): string =
|
||||||
result = "WalletSection-Send-Item("
|
result = "WalletSection-Send-Item("
|
||||||
|
@ -83,3 +87,6 @@ QtObject:
|
||||||
QtProperty[QVariant] currencyBalance:
|
QtProperty[QVariant] currencyBalance:
|
||||||
read = getCurrencyBalanceAsQVariant
|
read = getCurrencyBalanceAsQVariant
|
||||||
notify = currencyBalanceChanged
|
notify = currencyBalanceChanged
|
||||||
|
|
||||||
|
proc canSend*(self: AccountItem): bool =
|
||||||
|
return self.canSend
|
|
@ -184,8 +184,8 @@ QtObject:
|
||||||
self.accounts.setItems(items)
|
self.accounts.setItems(items)
|
||||||
self.accountsChanged()
|
self.accountsChanged()
|
||||||
|
|
||||||
# need to remove watch only accounts as a user cant send a tx with a watch only account
|
# need to remove watch only accounts as a user cant send a tx with a watch only account + remove not operable account
|
||||||
self.senderAccounts.setItems(items.filter(a => a.walletType() != WalletTypeWatch))
|
self.senderAccounts.setItems(items.filter(a => a.canSend()))
|
||||||
self.senderAccountsChanged()
|
self.senderAccountsChanged()
|
||||||
|
|
||||||
proc setNetworkItems*(self: View, fromNetworks: seq[NetworkItem], toNetworks: seq[NetworkItem]) =
|
proc setNetworkItems*(self: View, fromNetworks: seq[NetworkItem], toNetworks: seq[NetworkItem]) =
|
||||||
|
|
|
@ -119,5 +119,6 @@ proc walletAccountToWalletSendAccountItem*(w: WalletAccountDto, tokens: seq[Wall
|
||||||
currencyAmountToItem(currencyBalance, currencyFormat),
|
currencyAmountToItem(currencyBalance, currencyFormat),
|
||||||
areTestNetworksEnabled,
|
areTestNetworksEnabled,
|
||||||
w.prodPreferredChainIds,
|
w.prodPreferredChainIds,
|
||||||
w.testPreferredChainIds
|
w.testPreferredChainIds,
|
||||||
|
canSend=w.walletType != "watch" and (w.operable==AccountFullyOperable or w.operable==AccountPartiallyOperable)
|
||||||
)
|
)
|
||||||
|
|
|
@ -46,7 +46,7 @@ Rectangle {
|
||||||
interactive: networkConnectionStore.sendBuyBridgeEnabled
|
interactive: networkConnectionStore.sendBuyBridgeEnabled
|
||||||
onClicked: root.launchSendModal()
|
onClicked: root.launchSendModal()
|
||||||
tooltipText: networkConnectionStore.sendBuyBridgeToolTipText
|
tooltipText: networkConnectionStore.sendBuyBridgeToolTipText
|
||||||
visible: !walletStore.overview.isWatchOnlyAccount
|
visible: !walletStore.overview.isWatchOnlyAccount && walletStore.overview.canSend
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusFlatButton {
|
StatusFlatButton {
|
||||||
|
@ -64,7 +64,7 @@ Rectangle {
|
||||||
interactive: networkConnectionStore.sendBuyBridgeEnabled
|
interactive: networkConnectionStore.sendBuyBridgeEnabled
|
||||||
onClicked: root.launchBridgeModal()
|
onClicked: root.launchBridgeModal()
|
||||||
tooltipText: networkConnectionStore.sendBuyBridgeToolTipText
|
tooltipText: networkConnectionStore.sendBuyBridgeToolTipText
|
||||||
visible: !walletStore.overview.isWatchOnlyAccount && !root.isCommunityOwnershipTransfer
|
visible: !walletStore.overview.isWatchOnlyAccount && !root.isCommunityOwnershipTransfer && walletStore.overview.canSend
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusFlatButton {
|
StatusFlatButton {
|
||||||
|
|
Loading…
Reference in New Issue