parent
4c6af4f1ad
commit
3ce0215c88
|
@ -9,6 +9,23 @@ import AppLayouts.Communities.popups 1.0
|
||||||
|
|
||||||
SplitView {
|
SplitView {
|
||||||
Logs { id: logs }
|
Logs { id: logs }
|
||||||
|
ListModel {
|
||||||
|
id: accountsModel
|
||||||
|
|
||||||
|
ListElement {
|
||||||
|
name: "Test account"
|
||||||
|
emoji: "😋"
|
||||||
|
address: "0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240"
|
||||||
|
color: "red"
|
||||||
|
}
|
||||||
|
|
||||||
|
ListElement {
|
||||||
|
name: "Another account - generated"
|
||||||
|
emoji: "🚗"
|
||||||
|
address: "0x7F47C2e98a4BBf5487E6fb082eC2D9Ab0E6d8888"
|
||||||
|
color: "blue"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SplitView {
|
SplitView {
|
||||||
orientation: Qt.Vertical
|
orientation: Qt.Vertical
|
||||||
|
@ -35,8 +52,14 @@ SplitView {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
collectibleName: editorCollectible.text
|
collectibleName: editorCollectible.text
|
||||||
model: TokenHoldersModel {}
|
model: TokenHoldersModel {}
|
||||||
|
accounts: accountsModel
|
||||||
onRemotelyDestructClicked: logs.logEvent("RemoteSelfDestructPopup::onRemotelyDestructClicked")
|
chainName: "Optimism"
|
||||||
|
feeText: "0,01et(100Usd)"
|
||||||
|
onRemotelyDestructClicked: {
|
||||||
|
logs.logEvent("RemoteSelfDestructPopup::onRemotelyDestructClicked")
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
onRemotelyDestructFeesRequested: logs.logEvent("RemoteSelfDestructPopup::onRemotelyDestructClicked")
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
open()
|
open()
|
||||||
|
|
|
@ -67,10 +67,12 @@ StackView {
|
||||||
|
|
||||||
signal deployFeesRequested(int chainId, string accountAddress, int tokenType)
|
signal deployFeesRequested(int chainId, string accountAddress, int tokenType)
|
||||||
signal burnFeesRequested(string tokenKey, int amount, string accountAddress)
|
signal burnFeesRequested(string tokenKey, int amount, string accountAddress)
|
||||||
signal signRemoteDestructTransactionOpened(var remotelyDestructTokensList, // [key , amount]
|
signal remotelyDestructFeesRequest(var remotelyDestructTokensList, // [key , amount]
|
||||||
string tokenKey)
|
string tokenKey,
|
||||||
|
string accountAddress)
|
||||||
signal remotelyDestructCollectibles(var remotelyDestructTokensList, // [key , amount]
|
signal remotelyDestructCollectibles(var remotelyDestructTokensList, // [key , amount]
|
||||||
string tokenKey)
|
string tokenKey,
|
||||||
|
string accountAddress)
|
||||||
signal signBurnTransactionOpened(string tokenKey, int amount, string accountAddress)
|
signal signBurnTransactionOpened(string tokenKey, int amount, string accountAddress)
|
||||||
signal burnToken(string tokenKey, int amount, string accountAddress)
|
signal burnToken(string tokenKey, int amount, string accountAddress)
|
||||||
signal airdropToken(string tokenKey, int type, var addresses)
|
signal airdropToken(string tokenKey, int type, var addresses)
|
||||||
|
@ -630,9 +632,20 @@ StackView {
|
||||||
|
|
||||||
collectibleName: view.token.name
|
collectibleName: view.token.name
|
||||||
model: view.tokenOwnersModel || null
|
model: view.tokenOwnersModel || null
|
||||||
|
accounts: root.accounts
|
||||||
|
chainName: view.token.chainName
|
||||||
|
|
||||||
|
feeText: root.feeText
|
||||||
|
isFeeLoading: root.isFeeLoading
|
||||||
|
feeErrorText: root.feeErrorText
|
||||||
|
|
||||||
|
onRemotelyDestructFeesRequested:root.remotelyDestructFeesRequest(remotelyDestructTokensList,
|
||||||
|
tokenKey,
|
||||||
|
accountAddress)
|
||||||
|
|
||||||
onRemotelyDestructClicked: {
|
onRemotelyDestructClicked: {
|
||||||
remotelyDestructPopup.close()
|
remotelyDestructPopup.close()
|
||||||
|
footer.accountAddress = accountAddress
|
||||||
footer.remotelyDestructTokensList = remotelyDestructTokensList
|
footer.remotelyDestructTokensList = remotelyDestructTokensList
|
||||||
alertPopup.tokenCount = tokenCount
|
alertPopup.tokenCount = tokenCount
|
||||||
alertPopup.open()
|
alertPopup.open()
|
||||||
|
@ -664,8 +677,7 @@ StackView {
|
||||||
root.setFeeLoading()
|
root.setFeeLoading()
|
||||||
|
|
||||||
if(signTransactionPopup.isRemotelyDestructTransaction)
|
if(signTransactionPopup.isRemotelyDestructTransaction)
|
||||||
root.remotelyDestructCollectibles(
|
root.remotelyDestructCollectibles(footer.remotelyDestructTokensList, tokenKey, footer.accountAddress)
|
||||||
footer.remotelyDestructTokensList, tokenKey)
|
|
||||||
else
|
else
|
||||||
root.burnToken(tokenKey, footer.burnAmount, footer.accountAddress)
|
root.burnToken(tokenKey, footer.burnAmount, footer.accountAddress)
|
||||||
|
|
||||||
|
@ -686,7 +698,7 @@ StackView {
|
||||||
onOpened: {
|
onOpened: {
|
||||||
root.setFeeLoading()
|
root.setFeeLoading()
|
||||||
signTransactionPopup.isRemotelyDestructTransaction
|
signTransactionPopup.isRemotelyDestructTransaction
|
||||||
? root.signRemoteDestructTransactionOpened(footer.remotelyDestructTokensList, tokenKey)
|
? root.remotelyDestructFeesRequest(footer.remotelyDestructTokensList, tokenKey, footer.accountAddress)
|
||||||
: root.signBurnTransactionOpened(tokenKey, footer.burnAmount, footer.accountAddress)
|
: root.signBurnTransactionOpened(tokenKey, footer.burnAmount, footer.accountAddress)
|
||||||
}
|
}
|
||||||
onSignTransactionClicked: signTransaction()
|
onSignTransactionClicked: signTransaction()
|
||||||
|
|
|
@ -31,7 +31,7 @@ Item {
|
||||||
readonly property alias sortBy: d.sortBy
|
readonly property alias sortBy: d.sortBy
|
||||||
readonly property alias sortOrder: d.sorting
|
readonly property alias sortOrder: d.sorting
|
||||||
readonly property bool bottomSeparatorVisible: ((listView.contentY > 0) &&
|
readonly property bool bottomSeparatorVisible: ((listView.contentY > 0) &&
|
||||||
(listView.contentY < (listView.contentHeight - listView.height - 40/*margins*/)))
|
(listView.contentY < (listView.contentHeight - listView.height)))
|
||||||
|
|
||||||
signal selfDestructAmountChanged(string walletAddress, int amount)
|
signal selfDestructAmountChanged(string walletAddress, int amount)
|
||||||
signal selfDestructRemoved(string walletAddress)
|
signal selfDestructRemoved(string walletAddress)
|
||||||
|
|
|
@ -17,17 +17,28 @@ StatusDialog {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property alias model: tokenHoldersPanel.model
|
property alias model: tokenHoldersPanel.model
|
||||||
|
|
||||||
property string collectibleName
|
property string collectibleName
|
||||||
|
property string chainName
|
||||||
|
|
||||||
signal remotelyDestructClicked(int tokenCount, var remotelyDestructTokensList)
|
// Fees related properties:
|
||||||
|
property bool isFeeLoading
|
||||||
|
property string feeText: ""
|
||||||
|
property string feeErrorText: ""
|
||||||
|
property string feeLabel: qsTr("Remotely destruct %1 token on %2").arg(root.collectibleName).arg(root.chainName)
|
||||||
|
|
||||||
|
// Account expected roles: address, name, color, emoji, walletType
|
||||||
|
property var accounts
|
||||||
|
signal remotelyDestructClicked(int tokenCount, var remotelyDestructTokensList, string accountAddress)
|
||||||
|
signal remotelyDestructFeesRequested(int tokenCount, var remotelyDestructTokensList, string accountAddress)
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: d
|
id: d
|
||||||
|
|
||||||
|
property string accountAddress
|
||||||
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 {}
|
readonly property ListModel selfDestructTokensList: ListModel {}
|
||||||
|
readonly property bool isFeeError: root.feeErrorText !== ""
|
||||||
|
|
||||||
function getVerticalPadding() {
|
function getVerticalPadding() {
|
||||||
return root.topPadding + root.bottomPadding
|
return root.topPadding + root.bottomPadding
|
||||||
|
@ -56,6 +67,9 @@ StatusDialog {
|
||||||
d.tokenCount = 0
|
d.tokenCount = 0
|
||||||
for(var i = 0; i < d.selfDestructTokensList.count; i ++)
|
for(var i = 0; i < d.selfDestructTokensList.count; i ++)
|
||||||
d.tokenCount += ModelUtils.get(d.selfDestructTokensList, i, "amount")
|
d.tokenCount += ModelUtils.get(d.selfDestructTokensList, i, "amount")
|
||||||
|
if (d.tokenCount > 0) {
|
||||||
|
root.remotelyDestructFeesRequested(d.tokenCount, d.selfDestructTokensList, d.accountAddress);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,14 +77,65 @@ StatusDialog {
|
||||||
implicitWidth: 600 // by design
|
implicitWidth: 600 // by design
|
||||||
padding: 0
|
padding: 0
|
||||||
|
|
||||||
contentItem: TokenHoldersPanel {
|
contentItem: ColumnLayout {
|
||||||
|
spacing: Style.current.padding
|
||||||
|
TokenHoldersPanel {
|
||||||
id: tokenHoldersPanel
|
id: tokenHoldersPanel
|
||||||
tokenName: root.collectibleName
|
tokenName: root.collectibleName
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
isSelectorMode: true
|
isSelectorMode: true
|
||||||
onSelfDestructAmountChanged: d.updateTokensToDestruct(walletAddress, amount)
|
onSelfDestructAmountChanged: d.updateTokensToDestruct(walletAddress, amount)
|
||||||
onSelfDestructRemoved: d.clearTokensToDesctruct(walletAddress)
|
onSelfDestructRemoved: d.clearTokensToDesctruct(walletAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FeesBox {
|
||||||
|
id: feesBox
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.bottomMargin: 16
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
|
||||||
|
implicitWidth: 0
|
||||||
|
accountErrorText: root.feeErrorText
|
||||||
|
placeholderText: qsTr("Select a hodler to see remote destruction gas fees")
|
||||||
|
showAccountsSelector: true
|
||||||
|
model: d.tokenCount > 0 ? singleFeeModel : undefined
|
||||||
|
accountsSelector.model: root.accounts
|
||||||
|
|
||||||
|
accountsSelector.onCurrentIndexChanged: {
|
||||||
|
if (accountsSelector.currentIndex < 0)
|
||||||
|
return
|
||||||
|
|
||||||
|
const item = ModelUtils.get(accountsSelector.model, accountsSelector.currentIndex)
|
||||||
|
d.accountAddress = item.address
|
||||||
|
|
||||||
|
// Whenever a change in the form happens, new fee calculation:
|
||||||
|
if(d.tokenCount > 0)
|
||||||
|
root.remotelyDestructFeesRequested(d.tokenCount, d.selfDestructTokensList, d.accountAddress)
|
||||||
|
}
|
||||||
|
|
||||||
|
ModelChangeTracker {
|
||||||
|
model: d.selfDestructTokensList
|
||||||
|
|
||||||
|
// Whenever a change in the form happens, new fee calculation:
|
||||||
|
onRevisionChanged: {
|
||||||
|
root.remotelyDestructFeesRequested(d.tokenCount, d.selfDestructTokensList, d.accountAddress)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
id: singleFeeModel
|
||||||
|
|
||||||
|
readonly property string title: root.feeLabel
|
||||||
|
readonly property string feeText: root.isFeeLoading ?
|
||||||
|
"" : root.feeText
|
||||||
|
readonly property bool error: d.isFeeError
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
footer: StatusDialogFooter {
|
footer: StatusDialogFooter {
|
||||||
spacing: Style.current.padding
|
spacing: Style.current.padding
|
||||||
rightButtons: ObjectModel {
|
rightButtons: ObjectModel {
|
||||||
|
@ -85,8 +150,8 @@ StatusDialog {
|
||||||
text: qsTr("Remotely destruct %n token(s)", "", d.tokenCount)
|
text: qsTr("Remotely destruct %n token(s)", "", d.tokenCount)
|
||||||
type: StatusBaseButton.Type.Danger
|
type: StatusBaseButton.Type.Danger
|
||||||
onClicked: root.remotelyDestructClicked(d.tokenCount,
|
onClicked: root.remotelyDestructClicked(d.tokenCount,
|
||||||
ModelUtils.modelToArray(d.selfDestructTokensList,
|
ModelUtils.modelToArray(d.selfDestructTokensList,["walletAddress", "amount"]),
|
||||||
["walletAddress", "amount"]))
|
d.accountAddress)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -382,13 +382,13 @@ StatusSectionLayout {
|
||||||
communityTokensStore.deployOwnerToken(
|
communityTokensStore.deployOwnerToken(
|
||||||
root.community.id, ownerToken, tMasterToken)
|
root.community.id, ownerToken, tMasterToken)
|
||||||
|
|
||||||
onSignRemoteDestructTransactionOpened:
|
onRemotelyDestructFeesRequest:
|
||||||
communityTokensStore.computeSelfDestructFee(
|
communityTokensStore.computeSelfDestructFee(
|
||||||
remotelyDestructTokensList, tokenKey)
|
remotelyDestructTokensList, tokenKey, accountAddress)
|
||||||
|
|
||||||
onRemotelyDestructCollectibles:
|
onRemotelyDestructCollectibles:
|
||||||
communityTokensStore.remoteSelfDestructCollectibles(
|
communityTokensStore.remoteSelfDestructCollectibles(
|
||||||
root.community.id, remotelyDestructTokensList, tokenKey)
|
root.community.id, remotelyDestructTokensList, tokenKey, accountAddress)
|
||||||
|
|
||||||
onSignBurnTransactionOpened:
|
onSignBurnTransactionOpened:
|
||||||
communityTokensStore.computeBurnFee(tokenKey, amount, accountAddress)
|
communityTokensStore.computeBurnFee(tokenKey, amount, accountAddress)
|
||||||
|
|
|
@ -100,12 +100,14 @@ QtObject {
|
||||||
communityTokensModuleInst.computeDeployFee(chainId, accountAddress, tokenType)
|
communityTokensModuleInst.computeDeployFee(chainId, accountAddress, tokenType)
|
||||||
}
|
}
|
||||||
|
|
||||||
function computeSelfDestructFee(selfDestructTokensList, tokenKey) {
|
function computeSelfDestructFee(selfDestructTokensList, tokenKey, accountAddress) {
|
||||||
communityTokensModuleInst.computeSelfDestructFee(JSON.stringify(selfDestructTokensList), tokenKey)
|
//TODO uncomment accountAddress when supported in backend
|
||||||
|
communityTokensModuleInst.computeSelfDestructFee(JSON.stringify(selfDestructTokensList), tokenKey, /*accountAddress*/)
|
||||||
}
|
}
|
||||||
|
|
||||||
function remoteSelfDestructCollectibles(communityId, selfDestructTokensList, tokenKey) {
|
function remoteSelfDestructCollectibles(communityId, selfDestructTokensList, tokenKey, accountAddress) {
|
||||||
communityTokensModuleInst.selfDestructCollectibles(communityId, JSON.stringify(selfDestructTokensList), tokenKey)
|
//TODO uncomment accountAddress when supported in backend
|
||||||
|
communityTokensModuleInst.selfDestructCollectibles(communityId, JSON.stringify(selfDestructTokensList), tokenKey, /*accountAddress*/)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Burn:
|
// Burn:
|
||||||
|
|
Loading…
Reference in New Issue