mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-12 15:24:39 +00:00
4a097cfef7
Fixes #15382 So there is no easy way from the models and data we currently have in the client to know which account minted the owner token. So the easiest way to help the user is just to catch the error and show a better message.
74 lines
2.8 KiB
QML
74 lines
2.8 KiB
QML
import QtQuick 2.15
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import utils 1.0
|
|
/*!
|
|
\qmltype AirdropFeesSubscriber
|
|
\inherits QtObject
|
|
\brief Helper object that holds the request data and the fee response when available
|
|
*/
|
|
|
|
QtObject {
|
|
id: root
|
|
|
|
required property string communityId
|
|
required property var contractKeysAndAmounts
|
|
required property var addressesToAirdrop
|
|
required property string feeAccountAddress
|
|
required property bool enabled
|
|
|
|
// JS object specifing fees for the airdrop operation, should be set to
|
|
// provide response to airdropFeesRequested signal.
|
|
//
|
|
// The expected structure is as follows:
|
|
// {
|
|
// fees: [{
|
|
// ethFee: {CurrencyAmount JSON},
|
|
// fiatFee: {CurrencyAmount JSON},
|
|
// contractUniqueKey: string,
|
|
// errorCode: ComputeFeeErrorCode (int)
|
|
// }],
|
|
// totalEthFee: {CurrencyAmount JSON},
|
|
// totalFiatFee: {CurrencyAmount JSON},
|
|
// errorCode: ComputeFeeErrorCode (int)
|
|
// }
|
|
property var airdropFeesResponse: null
|
|
|
|
readonly property string feesError: {
|
|
if (!airdropFeesResponse) return ""
|
|
|
|
if (airdropFeesResponse.errorCode === Constants.ComputeFeeErrorCode.Success) return ""
|
|
|
|
if (airdropFeesResponse.errorCode === Constants.ComputeFeeErrorCode.Balance)
|
|
return qsTr("Your account does not have enough ETH to pay the gas fee for this airdrop. Try adding some ETH to your account.")
|
|
|
|
if (airdropFeesResponse.errorCode === Constants.ComputeFeeErrorCode.Infura)
|
|
return qsTr("Infura error")
|
|
|
|
if (airdropFeesResponse.errorCode === Constants.ComputeFeeErrorCode.Revert)
|
|
return qsTr("Estimation reverted. Make sure you are using the account that owns the TokenMaster or Owner Token.")
|
|
|
|
return qsTr("Unknown error")
|
|
}
|
|
readonly property string totalFee: {
|
|
if (!airdropFeesResponse || !Object.values(airdropFeesResponse.totalEthFee).length || !Object.values(airdropFeesResponse.totalFiatFee).length) return ""
|
|
|
|
if (airdropFeesResponse.errorCode !== Constants.ComputeFeeErrorCode.Success && airdropFeesResponse.errorCode !== Constants.ComputeFeeErrorCode.Balance)
|
|
return ""
|
|
|
|
return `${LocaleUtils.currencyAmountToLocaleString(airdropFeesResponse.totalEthFee)} (${LocaleUtils.currencyAmountToLocaleString(airdropFeesResponse.totalFiatFee)})`
|
|
}
|
|
|
|
readonly property var feesPerContract: {
|
|
if (!airdropFeesResponse || !Object.values(airdropFeesResponse.fees).length || totalFee == "") return []
|
|
|
|
return airdropFeesResponse.fees.map(fee => {
|
|
return {
|
|
contractUniqueKey: fee.contractUniqueKey,
|
|
feeText: `${LocaleUtils.currencyAmountToLocaleString(fee.ethFee)} (${LocaleUtils.currencyAmountToLocaleString(fee.fiatFee)})`
|
|
}
|
|
})
|
|
}
|
|
}
|