2023-02-17 12:56:13 +01:00
|
|
|
import QtQuick 2.15
|
2023-04-11 10:09:01 +02:00
|
|
|
import utils 1.0
|
2022-08-23 10:46:37 +02:00
|
|
|
|
|
|
|
QtObject {
|
2022-11-25 18:35:30 +01:00
|
|
|
id: root
|
|
|
|
|
2023-03-09 11:03:17 +01:00
|
|
|
property var communityTokensModuleInst: communityTokensModule ?? null
|
2023-02-22 18:10:46 +01:00
|
|
|
|
|
|
|
// Network selection properties:
|
|
|
|
property var layer1Networks: networksModule.layer1
|
|
|
|
property var layer2Networks: networksModule.layer2
|
|
|
|
property var enabledNetworks: networksModule.enabled
|
2023-03-09 12:12:49 +01:00
|
|
|
property var allNetworks: networksModule.all
|
2023-03-07 12:32:45 +01:00
|
|
|
|
2023-04-13 10:09:06 +02:00
|
|
|
signal deployFeeUpdated(var ethCurrency, var fiatCurrency, int error)
|
2023-05-05 13:03:59 +02:00
|
|
|
signal selfDestructFeeUpdated(var ethCurrency, var fiatCurrency, int error)
|
2023-06-06 17:32:53 +02:00
|
|
|
signal airdropFeeUpdated(var airdropFees)
|
2023-06-06 14:54:35 +02:00
|
|
|
signal burnFeeUpdated(var ethCurrency, var fiatCurrency, int error)
|
2023-05-05 13:03:59 +02:00
|
|
|
|
2023-04-13 10:09:06 +02:00
|
|
|
signal deploymentStateChanged(string communityId, int status, string url)
|
2023-05-05 13:03:59 +02:00
|
|
|
signal remoteDestructStateChanged(string communityId, string tokenName, int status, string url)
|
2023-06-06 14:54:35 +02:00
|
|
|
signal burnStateChanged(string communityId, string tokenName, int status, string url)
|
|
|
|
signal airdropStateChanged(string communityId, string tokenName, string chainName, int status, string url)
|
2023-05-05 13:03:59 +02:00
|
|
|
|
2023-03-23 14:17:07 +01:00
|
|
|
// Minting tokens:
|
2023-06-01 12:38:56 +02:00
|
|
|
function deployCollectible(communityId, collectibleItem)
|
|
|
|
{
|
2023-07-25 16:11:10 +02:00
|
|
|
if (collectibleItem.key !== "") {
|
|
|
|
deleteToken(communityId, collectibleItem.key)
|
|
|
|
}
|
2023-06-01 12:38:56 +02:00
|
|
|
const jsonArtworkFile = Utils.getImageAndCropInfoJson(collectibleItem.artworkSource, collectibleItem.artworkCropRect)
|
|
|
|
communityTokensModuleInst.deployCollectible(communityId, collectibleItem.accountAddress, collectibleItem.name,
|
|
|
|
collectibleItem.symbol, collectibleItem.description, collectibleItem.supply,
|
|
|
|
collectibleItem.infiniteSupply, collectibleItem.transferable, collectibleItem.remotelyDestruct,
|
2023-07-03 12:55:23 +02:00
|
|
|
collectibleItem.chainId, jsonArtworkFile)
|
2023-03-23 14:17:07 +01:00
|
|
|
}
|
|
|
|
|
2023-06-01 12:38:56 +02:00
|
|
|
function deployAsset(communityId, assetItem)
|
2023-05-25 12:46:53 +02:00
|
|
|
{
|
2023-07-25 16:11:10 +02:00
|
|
|
if (assetItem.key !== "") {
|
|
|
|
deleteToken(communityId, assetItem.key)
|
|
|
|
}
|
2023-06-01 12:38:56 +02:00
|
|
|
const jsonArtworkFile = Utils.getImageAndCropInfoJson(assetItem.artworkSource, assetItem.artworkCropRect)
|
2023-06-14 09:50:54 +02:00
|
|
|
communityTokensModuleInst.deployAssets(communityId, assetItem.accountAddress, assetItem.name,
|
|
|
|
assetItem.symbol, assetItem.description, assetItem.supply,
|
2023-07-03 12:55:23 +02:00
|
|
|
assetItem.infiniteSupply, assetItem.decimals, assetItem.chainId, jsonArtworkFile)
|
2023-05-25 12:46:53 +02:00
|
|
|
}
|
|
|
|
|
2023-07-18 14:39:38 +02:00
|
|
|
function deployOwnerToken(communityId, ownerToken, tMasterToken)
|
|
|
|
{
|
|
|
|
// NOTE for backend team: `ownerToken` and `tMasterToken` can be used to do an assertion before the deployment process starts, since
|
|
|
|
// the objects have been created to display the token details to the user and must be the same than backend builds.
|
2023-07-18 19:34:57 +02:00
|
|
|
// TODO: Backend will need to check if the ownerToken or tMasterToken have a valid tokenKey, so it means a deployment retry,
|
|
|
|
// otherwise, it is a new deployment.
|
2023-07-18 14:39:38 +02:00
|
|
|
console.log("TODO: Backend Owner and Token Master token deployment!")
|
|
|
|
}
|
|
|
|
|
2023-05-30 17:18:45 +02:00
|
|
|
function deleteToken(communityId, contractUniqueKey) {
|
2023-07-24 15:09:45 +02:00
|
|
|
let parts = contractUniqueKey.split("_");
|
|
|
|
communityTokensModuleInst.removeCommunityToken(communityId, parts[0], parts[1])
|
2023-05-30 17:18:45 +02:00
|
|
|
}
|
|
|
|
|
2023-04-03 13:29:36 +02:00
|
|
|
readonly property Connections connections: Connections {
|
2023-06-06 17:32:53 +02:00
|
|
|
target: communityTokensModuleInst
|
|
|
|
|
|
|
|
function onDeployFeeUpdated(ethCurrency, fiatCurrency, errorCode) {
|
|
|
|
root.deployFeeUpdated(ethCurrency, fiatCurrency, errorCode)
|
|
|
|
}
|
|
|
|
|
|
|
|
function onSelfDestructFeeUpdated(ethCurrency, fiatCurrency, errorCode) {
|
|
|
|
root.selfDestructFeeUpdated(ethCurrency, fiatCurrency, errorCode)
|
|
|
|
}
|
|
|
|
|
|
|
|
function onAirdropFeesUpdated(jsonFees) {
|
|
|
|
root.airdropFeeUpdated(JSON.parse(jsonFees))
|
|
|
|
}
|
|
|
|
|
|
|
|
function onDeploymentStateChanged(communityId, status, url) {
|
|
|
|
root.deploymentStateChanged(communityId, status, url)
|
|
|
|
}
|
|
|
|
|
|
|
|
function onRemoteDestructStateChanged(communityId, tokenName, status, url) {
|
|
|
|
root.remoteDestructStateChanged(communityId, tokenName, status, url)
|
|
|
|
}
|
2023-06-06 14:54:35 +02:00
|
|
|
|
|
|
|
function onAirdropStateChanged(communityId, tokenName, chainName, status, url) {
|
|
|
|
root.airdropStateChanged(communityId, tokenName, chainName, status, url)
|
|
|
|
}
|
|
|
|
|
|
|
|
function onBurnStateChanged(communityId, tokenName, status, url) {
|
|
|
|
root.burnStateChanged(communityId, tokenName, status, url)
|
|
|
|
}
|
|
|
|
|
|
|
|
function onBurnFeeUpdated(ethCurrency, fiatCurrency, errorCode) {
|
|
|
|
root.burnFeeUpdated(ethCurrency, fiatCurrency, errorCode)
|
|
|
|
}
|
2023-04-03 13:29:36 +02:00
|
|
|
}
|
|
|
|
|
2023-06-14 09:50:54 +02:00
|
|
|
function computeDeployFee(chainId, accountAddress, tokenType) {
|
|
|
|
communityTokensModuleInst.computeDeployFee(chainId, accountAddress, tokenType)
|
2023-03-23 14:17:07 +01:00
|
|
|
}
|
|
|
|
|
2023-05-26 17:00:51 +02:00
|
|
|
function computeSelfDestructFee(selfDestructTokensList, tokenKey) {
|
|
|
|
communityTokensModuleInst.computeSelfDestructFee(JSON.stringify(selfDestructTokensList), tokenKey)
|
2023-03-31 14:52:51 +02:00
|
|
|
}
|
|
|
|
|
2023-05-26 17:00:51 +02:00
|
|
|
function remoteSelfDestructCollectibles(communityId, selfDestructTokensList, tokenKey) {
|
|
|
|
communityTokensModuleInst.selfDestructCollectibles(communityId, JSON.stringify(selfDestructTokensList), tokenKey)
|
2023-03-31 14:52:51 +02:00
|
|
|
}
|
|
|
|
|
2023-05-18 17:01:48 +02:00
|
|
|
// Burn:
|
2023-08-07 15:31:07 +02:00
|
|
|
function computeBurnFee(tokenKey, amount, accountAddress) {
|
|
|
|
// TODO: Backend. It should include the account address in the calculation.
|
|
|
|
communityTokensModuleInst.computeBurnFee(tokenKey, amount/*, accountAddress*/)
|
2023-05-18 17:01:48 +02:00
|
|
|
}
|
|
|
|
|
2023-08-07 15:31:07 +02:00
|
|
|
function burnToken(communityId, tokenKey, burnAmount, accountAddress) {
|
|
|
|
// TODO: Backend. It should include the account address in the burn action.
|
|
|
|
communityTokensModuleInst.burnTokens(communityId, tokenKey, burnAmount/*, accountAddress*/)
|
2023-05-18 17:01:48 +02:00
|
|
|
}
|
|
|
|
|
2023-03-13 17:32:14 +01:00
|
|
|
// Airdrop tokens:
|
2023-07-25 16:14:42 +02:00
|
|
|
function airdrop(communityId, airdropTokens, addresses, feeAccountAddress) {
|
|
|
|
// TODO: Take `feeAccountAddress` into account for the airdrop
|
2023-06-21 13:22:11 +02:00
|
|
|
communityTokensModuleInst.airdropTokens(communityId, JSON.stringify(airdropTokens), JSON.stringify(addresses))
|
2023-03-13 17:32:14 +01:00
|
|
|
}
|
2023-05-25 12:00:38 +02:00
|
|
|
|
2023-07-25 16:14:42 +02:00
|
|
|
function computeAirdropFee(communityId, contractKeysAndAmounts, addresses, feeAccountAddress) {
|
|
|
|
// TODO: Take `feeAccountAddress` into account when calculating fee
|
2023-06-21 13:22:11 +02:00
|
|
|
communityTokensModuleInst.computeAirdropFee(
|
2023-06-06 17:32:53 +02:00
|
|
|
communityId, JSON.stringify(contractKeysAndAmounts),
|
|
|
|
JSON.stringify(addresses))
|
2023-05-25 12:00:38 +02:00
|
|
|
}
|
2022-08-23 10:46:37 +02:00
|
|
|
}
|