parent
dea975cd0a
commit
d3131c2bb9
|
@ -45,8 +45,7 @@ QtObject {
|
|||
string walletAddress)
|
||||
|
||||
// Minting tokens:
|
||||
function deployCollectible(communityId, collectibleItem)
|
||||
{
|
||||
function deployCollectible(communityId, collectibleItem) {
|
||||
if (collectibleItem.key !== "")
|
||||
deleteToken(communityId, collectibleItem.key)
|
||||
|
||||
|
@ -57,8 +56,7 @@ QtObject {
|
|||
collectibleItem.chainId, jsonArtworkFile)
|
||||
}
|
||||
|
||||
function deployAsset(communityId, assetItem)
|
||||
{
|
||||
function deployAsset(communityId, assetItem) {
|
||||
if (assetItem.key !== "")
|
||||
deleteToken(communityId, assetItem.key)
|
||||
|
||||
|
@ -68,11 +66,23 @@ QtObject {
|
|||
assetItem.infiniteSupply, assetItem.decimals, assetItem.chainId, jsonArtworkFile)
|
||||
}
|
||||
|
||||
function deployOwnerToken(communityId, ownerToken, tMasterToken)
|
||||
{
|
||||
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)
|
||||
|
||||
function deployOwnerToken(communityId, ownerToken, tMasterToken) {
|
||||
function deployOwnerTokenWithArtwork (communityId, artworkSource, ownerToken, tMasterToken) {
|
||||
const jsonArtworkFile = Utils.getImageAndCropInfoJson(artworkSource, ownerToken.artworkCropRect)
|
||||
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) {
|
||||
|
@ -90,9 +100,9 @@ QtObject {
|
|||
}
|
||||
|
||||
function ownershipDeclined(communityId, communityName) {
|
||||
communityTokensModuleInst.declineOwnership(communityId)
|
||||
root.communityOwnershipDeclined(communityName)
|
||||
}
|
||||
communityTokensModuleInst.declineOwnership(communityId)
|
||||
root.communityOwnershipDeclined(communityName)
|
||||
}
|
||||
|
||||
readonly property Connections connections: Connections {
|
||||
target: communityTokensModuleInst
|
||||
|
|
|
@ -983,4 +983,49 @@ QtObject {
|
|||
// #15331
|
||||
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