2023-02-17 11:56:13 +00:00
|
|
|
import QtQuick 2.15
|
2024-03-13 17:38:16 +00:00
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
2023-04-11 08:09:01 +00:00
|
|
|
import utils 1.0
|
2022-08-23 08:46:37 +00:00
|
|
|
|
|
|
|
QtObject {
|
2022-11-25 17:35:30 +00:00
|
|
|
id: root
|
|
|
|
|
2023-03-09 10:03:17 +00:00
|
|
|
property var communityTokensModuleInst: communityTokensModule ?? null
|
2023-02-22 17:10:46 +00:00
|
|
|
|
|
|
|
// Network selection properties:
|
2024-03-13 17:38:16 +00:00
|
|
|
property var flatNetworks: networksModule.flatNetworks
|
|
|
|
property SortFilterProxyModel filteredFlatModel: SortFilterProxyModel {
|
|
|
|
sourceModel: root.flatNetworks
|
|
|
|
filters: ValueFilter { roleName: "isTest"; value: networksModule.areTestNetworksEnabled }
|
|
|
|
}
|
2023-03-07 11:32:45 +00:00
|
|
|
|
2023-10-23 11:36:33 +00:00
|
|
|
// set by asyncGetOwnerTokenDetails
|
|
|
|
readonly property var ownerTokenDetails: {
|
|
|
|
JSON.parse(communityTokensModuleInst.ownerTokenDetails)
|
|
|
|
}
|
|
|
|
|
2023-09-01 09:27:44 +00:00
|
|
|
signal deployFeeUpdated(var ethCurrency, var fiatCurrency, int error, string responseId)
|
|
|
|
signal selfDestructFeeUpdated(var ethCurrency, var fiatCurrency, int error, string responseId)
|
2023-06-06 15:32:53 +00:00
|
|
|
signal airdropFeeUpdated(var airdropFees)
|
2023-09-01 09:27:44 +00:00
|
|
|
signal burnFeeUpdated(var ethCurrency, var fiatCurrency, int error, string responseId)
|
2023-10-23 11:32:50 +00:00
|
|
|
signal setSignerFeeUpdated(var ethCurrency, var fiatCurrency, int error, string responseId)
|
2023-05-05 11:03:59 +00:00
|
|
|
|
2023-04-13 08:09:06 +00:00
|
|
|
signal deploymentStateChanged(string communityId, int status, string url)
|
2023-07-11 13:23:00 +00:00
|
|
|
signal ownerTokenDeploymentStateChanged(string communityId, int status, string url)
|
2023-05-05 11:03:59 +00:00
|
|
|
signal remoteDestructStateChanged(string communityId, string tokenName, int status, string url)
|
2023-06-06 12:54:35 +00:00
|
|
|
signal burnStateChanged(string communityId, string tokenName, int status, string url)
|
|
|
|
signal airdropStateChanged(string communityId, string tokenName, string chainName, int status, string url)
|
2023-07-11 13:23:00 +00:00
|
|
|
signal ownerTokenDeploymentStarted(string communityId, string url)
|
2023-10-23 11:32:50 +00:00
|
|
|
signal setSignerStateChanged(string communityId, string communityName, int status, string url)
|
2023-10-23 11:36:33 +00:00
|
|
|
signal ownershipLost(string communityId, string communityName)
|
2023-11-03 15:55:04 +00:00
|
|
|
signal communityOwnershipDeclined(string communityName)
|
|
|
|
signal sendOwnerTokenStateChanged(string tokenName, int status, string url)
|
|
|
|
signal ownerTokenReceived(string communityId, string communityName)
|
2024-02-19 13:58:20 +00:00
|
|
|
signal communityTokenReceived(string name, string symbol, string image,
|
2024-01-19 11:40:41 +00:00
|
|
|
string communityId, string communityName,
|
|
|
|
string balance, int chainId,
|
|
|
|
string txHash, bool isFirst,
|
2024-02-22 14:41:13 +00:00
|
|
|
int tokenType, string walletAccountName,
|
|
|
|
string walletAddress)
|
2023-05-05 11:03:59 +00:00
|
|
|
|
2023-03-23 13:17:07 +00:00
|
|
|
// Minting tokens:
|
2023-06-01 10:38:56 +00:00
|
|
|
function deployCollectible(communityId, collectibleItem)
|
2023-08-10 12:23:59 +00:00
|
|
|
{
|
|
|
|
if (collectibleItem.key !== "")
|
2023-07-25 14:11:10 +00:00
|
|
|
deleteToken(communityId, collectibleItem.key)
|
2023-08-10 12:23:59 +00:00
|
|
|
|
2023-06-01 10:38:56 +00: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 10:55:23 +00:00
|
|
|
collectibleItem.chainId, jsonArtworkFile)
|
2023-03-23 13:17:07 +00:00
|
|
|
}
|
|
|
|
|
2023-06-01 10:38:56 +00:00
|
|
|
function deployAsset(communityId, assetItem)
|
2023-05-25 10:46:53 +00:00
|
|
|
{
|
2023-08-10 12:23:59 +00:00
|
|
|
if (assetItem.key !== "")
|
2023-07-25 14:11:10 +00:00
|
|
|
deleteToken(communityId, assetItem.key)
|
2023-08-10 12:23:59 +00:00
|
|
|
|
2023-06-01 10:38:56 +00:00
|
|
|
const jsonArtworkFile = Utils.getImageAndCropInfoJson(assetItem.artworkSource, assetItem.artworkCropRect)
|
2023-06-14 07:50:54 +00:00
|
|
|
communityTokensModuleInst.deployAssets(communityId, assetItem.accountAddress, assetItem.name,
|
|
|
|
assetItem.symbol, assetItem.description, assetItem.supply,
|
2023-07-03 10:55:23 +00:00
|
|
|
assetItem.infiniteSupply, assetItem.decimals, assetItem.chainId, jsonArtworkFile)
|
2023-05-25 10:46:53 +00:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:39:38 +00:00
|
|
|
function deployOwnerToken(communityId, ownerToken, tMasterToken)
|
|
|
|
{
|
2023-07-11 13:23:00 +00:00
|
|
|
const jsonArtworkFile = Utils.getImageAndCropInfoJson(ownerToken.artworkSource, ownerToken.artworkCropRect)
|
|
|
|
communityTokensModuleInst.deployOwnerToken(communityId, ownerToken.accountAddress, ownerToken.name, ownerToken.symbol, ownerToken.description,
|
|
|
|
tMasterToken.name, tMasterToken.symbol, tMasterToken.description, ownerToken.chainId, jsonArtworkFile)
|
2023-07-18 12:39:38 +00:00
|
|
|
}
|
|
|
|
|
2023-05-30 15:18:45 +00:00
|
|
|
function deleteToken(communityId, contractUniqueKey) {
|
2023-07-24 13:09:45 +00:00
|
|
|
let parts = contractUniqueKey.split("_");
|
|
|
|
communityTokensModuleInst.removeCommunityToken(communityId, parts[0], parts[1])
|
2023-05-30 15:18:45 +00:00
|
|
|
}
|
|
|
|
|
2024-05-21 08:53:33 +00:00
|
|
|
function refreshToken(contractUniqueKey) {
|
|
|
|
let parts = contractUniqueKey.split("_");
|
|
|
|
communityTokensModuleInst.refreshCommunityToken(parts[0], parts[1])
|
|
|
|
}
|
|
|
|
|
2023-10-23 11:36:33 +00:00
|
|
|
function updateSmartContract(communityId, chainId, contractAddress, accountAddress) {
|
|
|
|
communityTokensModuleInst.setSigner(communityId, chainId, contractAddress, accountAddress)
|
2023-10-23 11:32:50 +00:00
|
|
|
}
|
|
|
|
|
2023-11-03 15:55:04 +00:00
|
|
|
function ownershipDeclined(communityId, communityName) {
|
2023-10-23 11:36:33 +00:00
|
|
|
communityTokensModuleInst.declineOwnership(communityId)
|
2023-11-03 15:55:04 +00:00
|
|
|
root.communityOwnershipDeclined(communityName)
|
|
|
|
}
|
2023-09-28 10:09:47 +00:00
|
|
|
|
2023-04-03 11:29:36 +00:00
|
|
|
readonly property Connections connections: Connections {
|
2023-06-06 15:32:53 +00:00
|
|
|
target: communityTokensModuleInst
|
|
|
|
|
2023-09-01 09:27:44 +00:00
|
|
|
function onDeployFeeUpdated(ethCurrency, fiatCurrency, errorCode, responseId) {
|
|
|
|
root.deployFeeUpdated(ethCurrency, fiatCurrency, errorCode, responseId)
|
2023-06-06 15:32:53 +00:00
|
|
|
}
|
|
|
|
|
2023-09-01 09:27:44 +00:00
|
|
|
function onSelfDestructFeeUpdated(ethCurrency, fiatCurrency, errorCode, responseId) {
|
|
|
|
root.selfDestructFeeUpdated(ethCurrency, fiatCurrency, errorCode, responseId)
|
2023-06-06 15:32:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function onAirdropFeesUpdated(jsonFees) {
|
|
|
|
root.airdropFeeUpdated(JSON.parse(jsonFees))
|
|
|
|
}
|
|
|
|
|
2023-09-01 09:27:44 +00:00
|
|
|
function onBurnFeeUpdated(ethCurrency, fiatCurrency, errorCode, responseId) {
|
|
|
|
root.burnFeeUpdated(ethCurrency, fiatCurrency, errorCode, responseId)
|
|
|
|
}
|
|
|
|
|
2023-10-23 11:32:50 +00:00
|
|
|
function onSetSignerFeeUpdated(ethCurrency, fiatCurrency, errorCode, responseId) {
|
2023-10-23 11:36:33 +00:00
|
|
|
root.setSignerFeeUpdated(ethCurrency, fiatCurrency, errorCode, responseId)
|
2023-10-23 11:32:50 +00:00
|
|
|
}
|
|
|
|
|
2023-06-06 15:32:53 +00:00
|
|
|
function onDeploymentStateChanged(communityId, status, url) {
|
|
|
|
root.deploymentStateChanged(communityId, status, url)
|
|
|
|
}
|
|
|
|
|
2023-07-11 13:23:00 +00:00
|
|
|
function onOwnerTokenDeploymentStateChanged(communityId, status, url) {
|
|
|
|
root.ownerTokenDeploymentStateChanged(communityId, status, url)
|
|
|
|
}
|
|
|
|
|
|
|
|
function onOwnerTokenDeploymentStarted(communityId, url) {
|
|
|
|
root.ownerTokenDeploymentStarted(communityId, url)
|
|
|
|
}
|
|
|
|
|
2023-06-06 15:32:53 +00:00
|
|
|
function onRemoteDestructStateChanged(communityId, tokenName, status, url) {
|
|
|
|
root.remoteDestructStateChanged(communityId, tokenName, status, url)
|
|
|
|
}
|
2023-06-06 12:54:35 +00: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)
|
|
|
|
}
|
2023-10-23 11:32:50 +00:00
|
|
|
|
|
|
|
function onOwnerTokenReceived(communityId, communityName, chainId, communityAddress) {
|
2023-11-03 15:55:04 +00:00
|
|
|
root.ownerTokenReceived(communityId, communityName)
|
2023-10-23 11:32:50 +00:00
|
|
|
}
|
|
|
|
|
2024-02-22 14:41:13 +00:00
|
|
|
function onCommunityTokenReceived(name, symbol, image, communityId, communityName, balance, chainId, txHash, isFirst, tokenType, walletAccountName, walletAccountName, walletAddress) {
|
|
|
|
root.communityTokenReceived(name, symbol, image, communityId, communityName, balance, chainId, txHash, isFirst, tokenType, walletAccountName, walletAccountName, walletAddress)
|
2024-01-04 12:22:12 +00:00
|
|
|
}
|
|
|
|
|
2023-10-23 11:32:50 +00:00
|
|
|
function onSetSignerStateChanged(communityId, communityName, status, url) {
|
2023-10-23 11:36:33 +00:00
|
|
|
root.setSignerStateChanged(communityId, communityName, status, url)
|
|
|
|
}
|
|
|
|
|
|
|
|
function onOwnershipLost(communityId, communityName) {
|
|
|
|
root.ownershipLost(communityId, communityName)
|
2023-10-23 11:32:50 +00:00
|
|
|
}
|
2023-11-03 15:55:04 +00:00
|
|
|
|
|
|
|
function onSendOwnerTokenStateChanged(tokenName, status, url) {
|
2023-11-24 08:48:50 +00:00
|
|
|
root.sendOwnerTokenStateChanged(tokenName, status, url)
|
2023-11-03 15:55:04 +00:00
|
|
|
}
|
2023-09-01 09:27:44 +00:00
|
|
|
}
|
2023-06-06 12:54:35 +00:00
|
|
|
|
2023-11-03 15:55:04 +00:00
|
|
|
// Burn:
|
2023-09-01 09:27:44 +00:00
|
|
|
function computeBurnFee(tokenKey, amount, accountAddress, requestId) {
|
|
|
|
console.assert(typeof amount === "string")
|
|
|
|
communityTokensModuleInst.computeBurnFee(tokenKey, amount, accountAddress, requestId)
|
|
|
|
}
|
|
|
|
|
|
|
|
function computeAirdropFee(communityId, contractKeysAndAmounts, addresses, feeAccountAddress, requestId) {
|
|
|
|
communityTokensModuleInst.computeAirdropFee(
|
|
|
|
communityId, JSON.stringify(contractKeysAndAmounts),
|
|
|
|
JSON.stringify(addresses), feeAccountAddress, requestId)
|
2023-04-03 11:29:36 +00:00
|
|
|
}
|
|
|
|
|
2023-08-30 07:20:28 +00:00
|
|
|
function computeDeployFee(communityId, chainId, accountAddress, tokenType, isOwnerDeployment, requestId) {
|
|
|
|
communityTokensModuleInst.computeDeployFee(communityId, chainId, accountAddress, tokenType, isOwnerDeployment, requestId)
|
2023-03-23 13:17:07 +00:00
|
|
|
}
|
|
|
|
|
2023-10-23 11:36:33 +00:00
|
|
|
function computeSetSignerFee(chainId, contractAddress, accountAddress, requestId) {
|
|
|
|
communityTokensModuleInst.computeSetSignerFee(chainId, contractAddress, accountAddress, requestId)
|
2023-10-23 11:32:50 +00:00
|
|
|
}
|
|
|
|
|
2023-08-17 13:58:04 +00:00
|
|
|
/**
|
|
|
|
* walletsAndAmounts - array of following structure is expected:
|
|
|
|
* [
|
|
|
|
* {
|
|
|
|
* walletAddress: string
|
|
|
|
* amount: int
|
|
|
|
* }
|
|
|
|
* ]
|
|
|
|
*/
|
2023-09-01 09:27:44 +00:00
|
|
|
function computeSelfDestructFee(walletsAndAmounts, tokenKey, accountAddress, requestId) {
|
|
|
|
communityTokensModuleInst.computeSelfDestructFee(JSON.stringify(walletsAndAmounts), tokenKey, accountAddress, requestId)
|
2023-03-31 12:52:51 +00:00
|
|
|
}
|
|
|
|
|
2023-08-17 13:58:04 +00:00
|
|
|
function remoteSelfDestructCollectibles(communityId, walletsAndAmounts, tokenKey, accountAddress) {
|
2023-08-17 07:51:08 +00:00
|
|
|
communityTokensModuleInst.selfDestructCollectibles(communityId, JSON.stringify(walletsAndAmounts), tokenKey, accountAddress)
|
2023-03-31 12:52:51 +00:00
|
|
|
}
|
|
|
|
|
2023-09-21 13:02:18 +00:00
|
|
|
function remotelyDestructAndBan(communityId, contactId, tokenKey, accountAddress, deleteMessages) {
|
|
|
|
console.warn("remotelyDestructAndBan, not implemented yet!")
|
|
|
|
}
|
|
|
|
|
|
|
|
function remotelyDestructAndKick(communityId, contactId, tokenKey, accountAddress) {
|
|
|
|
console.warn("remotelyDestructAndKick, not implemented yet!")
|
|
|
|
}
|
|
|
|
|
2023-08-07 13:31:07 +00:00
|
|
|
function burnToken(communityId, tokenKey, burnAmount, accountAddress) {
|
2023-08-10 12:23:59 +00:00
|
|
|
console.assert(typeof burnAmount === "string")
|
2023-08-17 07:51:08 +00:00
|
|
|
communityTokensModuleInst.burnTokens(communityId, tokenKey, burnAmount, accountAddress)
|
2023-05-18 15:01:48 +00:00
|
|
|
}
|
|
|
|
|
2023-03-13 16:32:14 +00:00
|
|
|
// Airdrop tokens:
|
2023-07-25 14:14:42 +00:00
|
|
|
function airdrop(communityId, airdropTokens, addresses, feeAccountAddress) {
|
2023-08-17 07:51:08 +00:00
|
|
|
communityTokensModuleInst.airdropTokens(communityId, JSON.stringify(airdropTokens), JSON.stringify(addresses), feeAccountAddress)
|
2023-03-13 16:32:14 +00:00
|
|
|
}
|
2023-10-23 11:36:33 +00:00
|
|
|
|
|
|
|
function asyncGetOwnerTokenDetails(communityId) {
|
|
|
|
communityTokensModuleInst.asyncGetOwnerTokenDetails(communityId)
|
|
|
|
}
|
2024-06-03 08:31:26 +00:00
|
|
|
|
|
|
|
function startTokenHoldersManagement(chainId, contractAddress) {
|
|
|
|
communityTokensModuleInst.startTokenHoldersManagement(chainId, contractAddress)
|
|
|
|
}
|
|
|
|
|
|
|
|
function stopTokenHoldersManagement() {
|
|
|
|
communityTokensModuleInst.stopTokenHoldersManagement()
|
|
|
|
}
|
2022-08-23 08:46:37 +00:00
|
|
|
}
|