mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-10 14:26:34 +00:00
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"
|
nzPcxEzGExhBdJGYihtAYQlO+tUZvqrPbqeudo5iJGEJjCE15a3VtodH3q2ImYgiNITTlTdG1nUZ5a92VITQxITFiJmIIjSE0htAYQrMHAAD//+wwFVpz+yqXAAAAAElFTkSuQmCC"
|
||||||
readonly property var data: [
|
readonly property var data: [
|
||||||
{
|
{
|
||||||
ensName: "carmen.eth",
|
name: "carmen.eth",
|
||||||
walletAddress: "0xb794f5450ba39494ce839613fffba74279579268",
|
walletAddress: "0xb794f5450ba39494ce839613fffba74279579261",
|
||||||
imageSource: image,
|
imageSource: image,
|
||||||
amount: 15,
|
amount: 15
|
||||||
selfDestructAmount: 2,
|
|
||||||
selfDestruct: false
|
|
||||||
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ensName: "chris.eth",
|
name: "chris.eth",
|
||||||
walletAddress: "0xb794f5ea0ba39494ce839613fffba74279579268",
|
walletAddress: "0xb794f5ea0ba39494ce839613fffba74279579262",
|
||||||
imageSource: image,
|
imageSource: image,
|
||||||
amount: 5,
|
amount: 5
|
||||||
selfDestructAmount: 4,
|
|
||||||
selfDestruct: false
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ensName: "emily.eth",
|
name: "emily.eth",
|
||||||
walletAddress: "0xb794f5ea0ba39494ce839613fffba74279579268",
|
walletAddress: "0xb794f5ea0ba39494ce839613fffba74279579263",
|
||||||
imageSource: image,
|
imageSource: image,
|
||||||
amount: 2,
|
amount: 2
|
||||||
selfDestructAmount: 2,
|
|
||||||
selfDestruct: false
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ensName: "",
|
name: "",
|
||||||
walletAddress: "0xb794f5ea0ba39494ce839613fffba74279579268",
|
walletAddress: "0xb794f5ea0ba39494ce839613fffba74279579268",
|
||||||
imageSource: "",
|
imageSource: "",
|
||||||
amount: 1,
|
amount: 1
|
||||||
selfDestructAmount: 1,
|
|
||||||
selfDestruct: false
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ SettingsPageLayout {
|
|||||||
|
|
||||||
signal signMintTransactionOpened(int chainId, string accountAddress)
|
signal signMintTransactionOpened(int chainId, string accountAddress)
|
||||||
|
|
||||||
signal remoteSelfDestructCollectibles(var tokenOwnersModel,
|
signal remoteSelfDestructCollectibles(var selfDestructTokensList, // [key , amount]
|
||||||
int chainId,
|
int chainId,
|
||||||
string accountName,
|
string accountName,
|
||||||
string accountAddress)
|
string accountAddress)
|
||||||
@ -90,6 +90,7 @@ SettingsPageLayout {
|
|||||||
property string chainName
|
property string chainName
|
||||||
|
|
||||||
property var tokenOwnersModel
|
property var tokenOwnersModel
|
||||||
|
property var selfDestructTokensList
|
||||||
|
|
||||||
readonly property var initialItem: (root.tokensModel && root.tokensModel.count > 0) ? mintedTokensView : welcomeView
|
readonly property var initialItem: (root.tokensModel && root.tokensModel.count > 0) ? mintedTokensView : welcomeView
|
||||||
onInitialItemChanged: updateInitialStackView()
|
onInitialItemChanged: updateInitialStackView()
|
||||||
@ -287,6 +288,7 @@ SettingsPageLayout {
|
|||||||
model: d.tokenOwnersModel
|
model: d.tokenOwnersModel
|
||||||
|
|
||||||
onSelfDestructClicked: {
|
onSelfDestructClicked: {
|
||||||
|
d.selfDestructTokensList = selfDestructTokensList
|
||||||
alertPopup.tokenCount = tokenCount
|
alertPopup.tokenCount = tokenCount
|
||||||
alertPopup.open()
|
alertPopup.open()
|
||||||
}
|
}
|
||||||
@ -304,7 +306,7 @@ SettingsPageLayout {
|
|||||||
function signSelfRemoteDestructTransaction() {
|
function signSelfRemoteDestructTransaction() {
|
||||||
root.isFeeLoading = true
|
root.isFeeLoading = true
|
||||||
root.feeText = ""
|
root.feeText = ""
|
||||||
root.remoteSelfDestructCollectibles(d.tokenOwnersModel,
|
root.remoteSelfDestructCollectibles(d.selfDestructTokensList,
|
||||||
d.chainId,
|
d.chainId,
|
||||||
d.accountName,
|
d.accountName,
|
||||||
d.accountAddress)
|
d.accountAddress)
|
||||||
|
@ -21,8 +21,8 @@ Control {
|
|||||||
property string tokenName
|
property string tokenName
|
||||||
property bool isSelectorMode: false
|
property bool isSelectorMode: false
|
||||||
|
|
||||||
signal selfDestructChanged()
|
signal selfDestructAmountChanged(string walletAddress, int amount)
|
||||||
|
signal selfDestructRemoved(string walletAddress)
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: d
|
id: d
|
||||||
@ -125,8 +125,8 @@ Control {
|
|||||||
}
|
}
|
||||||
|
|
||||||
control.onDisplayTextChanged: {
|
control.onDisplayTextChanged: {
|
||||||
selfDestructAmount = combo.currentIndex + 1
|
if(checkBox.checked)
|
||||||
root.selfDestructChanged()
|
root.selfDestructAmountChanged(walletAddress, Number(combo.currentIndex) + 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,11 +135,12 @@ Control {
|
|||||||
|
|
||||||
Layout.leftMargin: Style.current.padding
|
Layout.leftMargin: Style.current.padding
|
||||||
visible: root.isSelectorMode
|
visible: root.isSelectorMode
|
||||||
checked: root.isSelectorMode ? selfDestruct : false
|
|
||||||
padding: 0
|
padding: 0
|
||||||
onCheckStateChanged: {
|
onCheckStateChanged: {
|
||||||
selfDestruct = checked
|
if(checked)
|
||||||
root.selfDestructChanged()
|
root.selfDestructAmountChanged(model.walletAddress, Number(combo.currentIndex) + 1)
|
||||||
|
else
|
||||||
|
root.selfDestructRemoved(model.walletAddress)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,13 +20,14 @@ StatusDialog {
|
|||||||
|
|
||||||
property string collectibleName
|
property string collectibleName
|
||||||
|
|
||||||
signal selfDestructClicked(int tokenCount)
|
signal selfDestructClicked(int tokenCount, var selfDestructTokensList)
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: d
|
id: d
|
||||||
|
|
||||||
readonly property int maxHeight: 560 // by design
|
readonly property int maxHeight: 560 // by design
|
||||||
property int tokenCount: 0
|
property int tokenCount: 0
|
||||||
|
readonly property ListModel selfDestructTokensList: ListModel {}
|
||||||
|
|
||||||
function getVerticalPadding() {
|
function getVerticalPadding() {
|
||||||
return root.topPadding + root.bottomPadding
|
return root.topPadding + root.bottomPadding
|
||||||
@ -36,14 +37,25 @@ StatusDialog {
|
|||||||
return root.leftPadding + root.rightPadding
|
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
|
d.tokenCount = 0
|
||||||
for(var i = 0; i < tokenHoldersPanel.model.count; i ++) {
|
for(var i = 0; i < d.selfDestructTokensList.count; i ++)
|
||||||
var item = ModelUtils.get(tokenHoldersPanel.model, i)
|
d.tokenCount += ModelUtils.get(d.selfDestructTokensList, i, "amount")
|
||||||
if(item.selfDestruct) {
|
|
||||||
d.tokenCount += item.selfDestructAmount
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +78,8 @@ StatusDialog {
|
|||||||
tokenName: root.collectibleName
|
tokenName: root.collectibleName
|
||||||
isSelectorMode: true
|
isSelectorMode: true
|
||||||
|
|
||||||
onSelfDestructChanged: d.calculateTotalTokensToDestruct()
|
onSelfDestructAmountChanged: d.updateTokensToDestruct(walletAddress, amount)
|
||||||
|
onSelfDestructRemoved: d.clearTokensToDesctruct(walletAddress)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +90,9 @@ StatusDialog {
|
|||||||
enabled: d.tokenCount > 0
|
enabled: d.tokenCount > 0
|
||||||
text: qsTr("Self-destruct %n token(s)", "", d.tokenCount)
|
text: qsTr("Self-destruct %n token(s)", "", d.tokenCount)
|
||||||
type: StatusBaseButton.Type.Danger
|
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)
|
onSignSelfDestructTransactionOpened: communityTokensStore.computeSelfDestructFee(chainId)
|
||||||
onRemoteSelfDestructCollectibles: {
|
onRemoteSelfDestructCollectibles: {
|
||||||
communityTokensStore.remoteSelfDestructCollectibles(tokenOwnersModel,
|
communityTokensStore.remoteSelfDestructCollectibles(selfDestructTokensList,
|
||||||
chainId,
|
chainId,
|
||||||
accountName,
|
accountName,
|
||||||
accountAddress)
|
accountAddress)
|
||||||
|
@ -46,8 +46,9 @@ QtObject {
|
|||||||
console.warn("TODO: Compute self-destruct fee backend")
|
console.warn("TODO: Compute self-destruct fee backend")
|
||||||
}
|
}
|
||||||
|
|
||||||
function remoteSelfDestructCollectibles(holdersModel, chainId, accountName, accountAddress) {
|
function remoteSelfDestructCollectibles(selfDestructTokensList, chainId, accountName, accountAddress) {
|
||||||
// TODO BACKEND
|
// TODO BACKEND
|
||||||
|
// selfDestructTokensList is a js array with properties: `walletAddress` and `amount`
|
||||||
console.warn("TODO: Remote self-destruct collectible backend")
|
console.warn("TODO: Remote self-destruct collectible backend")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user