parent
dea975cd0a
commit
d3131c2bb9
|
@ -45,8 +45,7 @@ QtObject {
|
||||||
string walletAddress)
|
string walletAddress)
|
||||||
|
|
||||||
// Minting tokens:
|
// Minting tokens:
|
||||||
function deployCollectible(communityId, collectibleItem)
|
function deployCollectible(communityId, collectibleItem) {
|
||||||
{
|
|
||||||
if (collectibleItem.key !== "")
|
if (collectibleItem.key !== "")
|
||||||
deleteToken(communityId, collectibleItem.key)
|
deleteToken(communityId, collectibleItem.key)
|
||||||
|
|
||||||
|
@ -57,8 +56,7 @@ QtObject {
|
||||||
collectibleItem.chainId, jsonArtworkFile)
|
collectibleItem.chainId, jsonArtworkFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
function deployAsset(communityId, assetItem)
|
function deployAsset(communityId, assetItem) {
|
||||||
{
|
|
||||||
if (assetItem.key !== "")
|
if (assetItem.key !== "")
|
||||||
deleteToken(communityId, assetItem.key)
|
deleteToken(communityId, assetItem.key)
|
||||||
|
|
||||||
|
@ -68,11 +66,23 @@ QtObject {
|
||||||
assetItem.infiniteSupply, assetItem.decimals, assetItem.chainId, jsonArtworkFile)
|
assetItem.infiniteSupply, assetItem.decimals, assetItem.chainId, jsonArtworkFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
function deployOwnerToken(communityId, ownerToken, tMasterToken)
|
|
||||||
{
|
function deployOwnerToken(communityId, ownerToken, tMasterToken) {
|
||||||
const jsonArtworkFile = Utils.getImageAndCropInfoJson(ownerToken.artworkSource, ownerToken.artworkCropRect)
|
function deployOwnerTokenWithArtwork (communityId, artworkSource, ownerToken, tMasterToken) {
|
||||||
communityTokensModuleInst.deployOwnerToken(communityId, ownerToken.accountAddress, ownerToken.name, ownerToken.symbol, ownerToken.description,
|
const jsonArtworkFile = Utils.getImageAndCropInfoJson(artworkSource, ownerToken.artworkCropRect)
|
||||||
tMasterToken.name, tMasterToken.symbol, tMasterToken.description, ownerToken.chainId, jsonArtworkFile)
|
communityTokensModuleInst.deployOwnerToken(communityId, ownerToken.accountAddress, ownerToken.name, ownerToken.symbol, ownerToken.description,
|
||||||
|
tMasterToken.name, tMasterToken.symbol, tMasterToken.description, ownerToken.chainId, jsonArtworkFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (String(ownerToken.artworkSource).startsWith("https://localhost:")) {
|
||||||
|
const ownerTokenCopy = Object.assign({}, ownerToken)
|
||||||
|
const tMasterTokenCopy = Object.assign({}, tMasterToken)
|
||||||
|
Utils.fetchImageBase64(ownerToken.artworkSource, (dataUrl) => {
|
||||||
|
deployOwnerTokenWithArtwork(communityId, dataUrl, ownerTokenCopy, tMasterTokenCopy)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
deployOwnerTokenWithArtwork(communityId, ownerToken.artworkSource, ownerToken, tMasterToken);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteToken(communityId, contractUniqueKey) {
|
function deleteToken(communityId, contractUniqueKey) {
|
||||||
|
@ -90,9 +100,9 @@ QtObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
function ownershipDeclined(communityId, communityName) {
|
function ownershipDeclined(communityId, communityName) {
|
||||||
communityTokensModuleInst.declineOwnership(communityId)
|
communityTokensModuleInst.declineOwnership(communityId)
|
||||||
root.communityOwnershipDeclined(communityName)
|
root.communityOwnershipDeclined(communityName)
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly property Connections connections: Connections {
|
readonly property Connections connections: Connections {
|
||||||
target: communityTokensModuleInst
|
target: communityTokensModuleInst
|
||||||
|
|
|
@ -983,4 +983,49 @@ QtObject {
|
||||||
// #15331
|
// #15331
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toBase64(buffer) {
|
||||||
|
const base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
|
const bufferView = new Uint8Array(buffer);
|
||||||
|
let result = "";
|
||||||
|
let i;
|
||||||
|
|
||||||
|
for (i = 0; i < bufferView.length - 2; i += 3) {
|
||||||
|
const chunk = (bufferView[i] << 16) | (bufferView[i + 1] << 8) | bufferView[i + 2];
|
||||||
|
result += base64Chars[(chunk >> 18) & 0x3F] +
|
||||||
|
base64Chars[(chunk >> 12) & 0x3F] +
|
||||||
|
base64Chars[(chunk >> 6) & 0x3F] +
|
||||||
|
base64Chars[chunk & 0x3F];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bufferView.length % 3 === 1) {
|
||||||
|
const chunk = bufferView[i] << 16;
|
||||||
|
result += base64Chars[(chunk >> 18) & 0x3F] +
|
||||||
|
base64Chars[(chunk >> 12) & 0x3F] +
|
||||||
|
"==";
|
||||||
|
} else if (bufferView.length % 3 === 2) {
|
||||||
|
const chunk = (bufferView[i] << 16) | (bufferView[i + 1] << 8);
|
||||||
|
result += base64Chars[(chunk >> 18) & 0x3F] +
|
||||||
|
base64Chars[(chunk >> 12) & 0x3F] +
|
||||||
|
base64Chars[(chunk >> 6) & 0x3F] +
|
||||||
|
"=";
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchImageBase64(url, callback) {
|
||||||
|
let xhr = new XMLHttpRequest();
|
||||||
|
xhr.open("GET", url, true);
|
||||||
|
xhr.responseType = "arraybuffer";
|
||||||
|
xhr.onload = function() {
|
||||||
|
if (xhr.status === 200) {
|
||||||
|
const base64Image = toBase64(xhr.response);
|
||||||
|
const mimeType = xhr.getResponseHeader("Content-Type") || "image/png";
|
||||||
|
callback(`data:${mimeType};base64,${base64Image}`);
|
||||||
|
} else {
|
||||||
|
callback("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xhr.send();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue