feat(SelfDestructPopup): Updated self destruct tokens lists management
- Updated expected model roles (removed `selfDestruct` and `selfDestructAmount`) - Self destruct tokens list management is now done inside `SelfDestructPopup). - Store receives a js array with {walletAddress, amount} roles.
This commit is contained in:
parent
2087616b82
commit
42a5236b10
|
@ -6,37 +6,28 @@ ListModel {
|
|||
nzPcxEzGExhBdJGYihtAYQlO+tUZvqrPbqeudo5iJGEJjCE15a3VtodH3q2ImYgiNITTlTdG1nUZ5a92VITQxITFiJmIIjSE0htAYQrMHAAD//+wwFVpz+yqXAAAAAElFTkSuQmCC"
|
||||
readonly property var data: [
|
||||
{
|
||||
ensName: "carmen.eth",
|
||||
walletAddress: "0xb794f5450ba39494ce839613fffba74279579268",
|
||||
name: "carmen.eth",
|
||||
walletAddress: "0xb794f5450ba39494ce839613fffba74279579261",
|
||||
imageSource: image,
|
||||
amount: 15,
|
||||
selfDestructAmount: 2,
|
||||
selfDestruct: false
|
||||
|
||||
amount: 15
|
||||
},
|
||||
{
|
||||
ensName: "chris.eth",
|
||||
walletAddress: "0xb794f5ea0ba39494ce839613fffba74279579268",
|
||||
name: "chris.eth",
|
||||
walletAddress: "0xb794f5ea0ba39494ce839613fffba74279579262",
|
||||
imageSource: image,
|
||||
amount: 5,
|
||||
selfDestructAmount: 4,
|
||||
selfDestruct: false
|
||||
amount: 5
|
||||
},
|
||||
{
|
||||
ensName: "emily.eth",
|
||||
walletAddress: "0xb794f5ea0ba39494ce839613fffba74279579268",
|
||||
name: "emily.eth",
|
||||
walletAddress: "0xb794f5ea0ba39494ce839613fffba74279579263",
|
||||
imageSource: image,
|
||||
amount: 2,
|
||||
selfDestructAmount: 2,
|
||||
selfDestruct: false
|
||||
amount: 2
|
||||
},
|
||||
{
|
||||
ensName: "",
|
||||
name: "",
|
||||
walletAddress: "0xb794f5ea0ba39494ce839613fffba74279579268",
|
||||
imageSource: "",
|
||||
amount: 1,
|
||||
selfDestructAmount: 1,
|
||||
selfDestruct: false
|
||||
amount: 1
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ SettingsPageLayout {
|
|||
|
||||
signal signMintTransactionOpened(int chainId, string accountAddress)
|
||||
|
||||
signal remoteSelfDestructCollectibles(var tokenOwnersModel,
|
||||
signal remoteSelfDestructCollectibles(var selfDestructTokensList, // [key , amount]
|
||||
int chainId,
|
||||
string accountName,
|
||||
string accountAddress)
|
||||
|
@ -90,6 +90,7 @@ SettingsPageLayout {
|
|||
property string chainName
|
||||
|
||||
property var tokenOwnersModel
|
||||
property var selfDestructTokensList
|
||||
|
||||
readonly property var initialItem: (root.tokensModel && root.tokensModel.count > 0) ? mintedTokensView : welcomeView
|
||||
onInitialItemChanged: updateInitialStackView()
|
||||
|
@ -287,6 +288,7 @@ SettingsPageLayout {
|
|||
model: d.tokenOwnersModel
|
||||
|
||||
onSelfDestructClicked: {
|
||||
d.selfDestructTokensList = selfDestructTokensList
|
||||
alertPopup.tokenCount = tokenCount
|
||||
alertPopup.open()
|
||||
}
|
||||
|
@ -304,7 +306,7 @@ SettingsPageLayout {
|
|||
function signSelfRemoteDestructTransaction() {
|
||||
root.isFeeLoading = true
|
||||
root.feeText = ""
|
||||
root.remoteSelfDestructCollectibles(d.tokenOwnersModel,
|
||||
root.remoteSelfDestructCollectibles(d.selfDestructTokensList,
|
||||
d.chainId,
|
||||
d.accountName,
|
||||
d.accountAddress)
|
||||
|
|
|
@ -21,8 +21,8 @@ Control {
|
|||
property string tokenName
|
||||
property bool isSelectorMode: false
|
||||
|
||||
signal selfDestructChanged()
|
||||
|
||||
signal selfDestructAmountChanged(string walletAddress, int amount)
|
||||
signal selfDestructRemoved(string walletAddress)
|
||||
|
||||
QtObject {
|
||||
id: d
|
||||
|
@ -125,8 +125,8 @@ Control {
|
|||
}
|
||||
|
||||
control.onDisplayTextChanged: {
|
||||
selfDestructAmount = combo.currentIndex + 1
|
||||
root.selfDestructChanged()
|
||||
if(checkBox.checked)
|
||||
root.selfDestructAmountChanged(walletAddress, Number(combo.currentIndex) + 1)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,11 +135,12 @@ Control {
|
|||
|
||||
Layout.leftMargin: Style.current.padding
|
||||
visible: root.isSelectorMode
|
||||
checked: root.isSelectorMode ? selfDestruct : false
|
||||
padding: 0
|
||||
onCheckStateChanged: {
|
||||
selfDestruct = checked
|
||||
root.selfDestructChanged()
|
||||
if(checked)
|
||||
root.selfDestructAmountChanged(model.walletAddress, Number(combo.currentIndex) + 1)
|
||||
else
|
||||
root.selfDestructRemoved(model.walletAddress)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,13 +20,14 @@ StatusDialog {
|
|||
|
||||
property string collectibleName
|
||||
|
||||
signal selfDestructClicked(int tokenCount)
|
||||
signal selfDestructClicked(int tokenCount, var selfDestructTokensList)
|
||||
|
||||
QtObject {
|
||||
id: d
|
||||
|
||||
readonly property int maxHeight: 560 // by design
|
||||
property int tokenCount: 0
|
||||
readonly property ListModel selfDestructTokensList: ListModel {}
|
||||
|
||||
function getVerticalPadding() {
|
||||
return root.topPadding + root.bottomPadding
|
||||
|
@ -36,14 +37,25 @@ StatusDialog {
|
|||
return root.leftPadding + root.rightPadding
|
||||
}
|
||||
|
||||
function calculateTotalTokensToDestruct() {
|
||||
function updateTokensToDestruct(walletAddress, amount) {
|
||||
if(ModelUtils.contains(d.selfDestructTokensList, "walletAddress", walletAddress))
|
||||
clearTokensToDesctruct(walletAddress)
|
||||
|
||||
d.selfDestructTokensList.append({"walletAddress": walletAddress,
|
||||
"amount": amount})
|
||||
updateTokensCount()
|
||||
}
|
||||
|
||||
function clearTokensToDesctruct(walletAddress) {
|
||||
var index = ModelUtils.indexOf(d.selfDestructTokensList, "walletAddress", walletAddress)
|
||||
d.selfDestructTokensList.remove(index)
|
||||
updateTokensCount()
|
||||
}
|
||||
|
||||
function updateTokensCount() {
|
||||
d.tokenCount = 0
|
||||
for(var i = 0; i < tokenHoldersPanel.model.count; i ++) {
|
||||
var item = ModelUtils.get(tokenHoldersPanel.model, i)
|
||||
if(item.selfDestruct) {
|
||||
d.tokenCount += item.selfDestructAmount
|
||||
}
|
||||
}
|
||||
for(var i = 0; i < d.selfDestructTokensList.count; i ++)
|
||||
d.tokenCount += ModelUtils.get(d.selfDestructTokensList, i, "amount")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,7 +78,8 @@ StatusDialog {
|
|||
tokenName: root.collectibleName
|
||||
isSelectorMode: true
|
||||
|
||||
onSelfDestructChanged: d.calculateTotalTokensToDestruct()
|
||||
onSelfDestructAmountChanged: d.updateTokensToDestruct(walletAddress, amount)
|
||||
onSelfDestructRemoved: d.clearTokensToDesctruct(walletAddress)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +90,9 @@ StatusDialog {
|
|||
enabled: d.tokenCount > 0
|
||||
text: qsTr("Self-destruct %n token(s)", "", d.tokenCount)
|
||||
type: StatusBaseButton.Type.Danger
|
||||
onClicked: root.selfDestructClicked(d.tokenCount)
|
||||
onClicked: root.selfDestructClicked(d.tokenCount,
|
||||
ModelUtils.modelToArray(d.selfDestructTokensList,
|
||||
["walletAddress", "amount"]))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -302,7 +302,7 @@ StatusSectionLayout {
|
|||
}
|
||||
onSignSelfDestructTransactionOpened: communityTokensStore.computeSelfDestructFee(chainId)
|
||||
onRemoteSelfDestructCollectibles: {
|
||||
communityTokensStore.remoteSelfDestructCollectibles(tokenOwnersModel,
|
||||
communityTokensStore.remoteSelfDestructCollectibles(selfDestructTokensList,
|
||||
chainId,
|
||||
accountName,
|
||||
accountAddress)
|
||||
|
|
|
@ -46,8 +46,9 @@ QtObject {
|
|||
console.warn("TODO: Compute self-destruct fee backend")
|
||||
}
|
||||
|
||||
function remoteSelfDestructCollectibles(holdersModel, chainId, accountName, accountAddress) {
|
||||
function remoteSelfDestructCollectibles(selfDestructTokensList, chainId, accountName, accountAddress) {
|
||||
// TODO BACKEND
|
||||
// selfDestructTokensList is a js array with properties: `walletAddress` and `amount`
|
||||
console.warn("TODO: Remote self-destruct collectible backend")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue