diff --git a/src/encryption/encryption.ts b/src/encryption/encryption.ts index dae1709..09af412 100644 --- a/src/encryption/encryption.ts +++ b/src/encryption/encryption.ts @@ -148,6 +148,11 @@ export const encryptAndPublishSymmetricKeyGroupChat = async ({ service: 'DOCUMENT_PRIVATE', identifier: `symmetric-qchat-group-${groupId}`, uploadType: 'base64', + file: encryptedData, + service: 'DOCUMENT_PRIVATE', + identifier: `symmetric-qchat-group-${groupId}`, + uploadType: 'file', + isBase64: true, withFee: true, }); return { @@ -215,6 +220,9 @@ export const encryptAndPublishSymmetricKeyGroupChatForAdmins = async ({ service: 'DOCUMENT_PRIVATE', identifier: `admins-symmetric-qchat-group-${groupId}`, uploadType: 'base64', + file: encryptedData, + uploadType: 'file', + isBase64: true, withFee: true, }); return { @@ -249,9 +257,11 @@ export const publishGroupEncryptedResource = async ({ const data = await publishData({ registeredName, data: encryptedData, + uploadType: 'base64', + file: encryptedData, service: 'DOCUMENT', identifier, - uploadType: 'base64', + isBase64: true, withFee: true, }); return data; @@ -284,6 +294,9 @@ export const publishOnQDN = async ({ }) => { if (data && service) { const registeredName = name || (await getNameInfo()); +}) => { + if (data && service) { + const registeredName = await getNameInfo(); if (!registeredName) throw new Error( i18n.t('core:message.generic.name_publish', { @@ -294,9 +307,11 @@ export const publishOnQDN = async ({ const res = await publishData({ registeredName, data, + file: data, service, identifier, uploadType, + isBase64: true, withFee: true, title, description, diff --git a/src/qdn/publish/publish.ts b/src/qdn/publish/publish.ts index c73efd2..b105a1a 100644 --- a/src/qdn/publish/publish.ts +++ b/src/qdn/publish/publish.ts @@ -83,25 +83,29 @@ async function getKeyPair() { } export const publishData = async ({ - category, data, - description, feeAmount, filename, identifier, isBase64, registeredName, + file, service, + identifier, + uploadType, + withFee, + title, + description, + category, tag1, tag2, tag3, tag4, tag5, - title, - uploadType, - withFee, }: any) => { console.log('data', data); + feeAmount, +}: any) => { const validateName = async (receiverName: string) => { return await reusableGet(`/names/${receiverName}`); }; @@ -228,6 +232,7 @@ export const publishData = async ({ let transactionBytes = await uploadData(registeredName, data, fee); console.log('transactionBytes length', transactionBytes?.length); + if (!transactionBytes || transactionBytes.error) { throw new Error(transactionBytes?.message || 'Error when uploading'); } else if (transactionBytes.includes('Error 500 Internal Server Error')) {