diff --git a/core/language/us.json b/core/language/us.json
index cbf85a4f..768d9ac7 100644
--- a/core/language/us.json
+++ b/core/language/us.json
@@ -719,7 +719,8 @@
"bchange43": "Do you give this application permission to add to this list?",
"bchange44": "Do you give this application permission to delete from this list?",
"bchange45": "Encrypt",
- "bchange46": "Do you give this application permission to save the following file"
+ "bchange46": "Do you give this application permission to save the following file",
+ "bchange47": "Instant publish - requires"
},
"datapage": {
"dchange1": "Data Management",
diff --git a/plugins/plugins/core/qdn/browser/browser.src.js b/plugins/plugins/core/qdn/browser/browser.src.js
index db59e4fd..20b66767 100644
--- a/plugins/plugins/core/qdn/browser/browser.src.js
+++ b/plugins/plugins/core/qdn/browser/browser.src.js
@@ -425,6 +425,22 @@ class WebBrowser extends LitElement {
const joinFee = (Number(data) / 1e8).toFixed(8)
return joinFee
}
+ async getArbitraryFee (){
+ const timestamp = Date.now()
+ const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
+ const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port
+ const url = `${nodeUrl}/transactions/unitfee?txType=ARBITRARY×tamp=${timestamp}`
+ const response = await fetch(url)
+ if (!response.ok) {
+ throw new Error('Error when fetching arbitrary fee');
+ }
+ const data = await response.json()
+ const arbitraryFee = (Number(data) / 1e8).toFixed(8)
+ return {
+ timestamp,
+ fee : arbitraryFee
+ }
+ }
async sendQortFee() {
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port
@@ -975,6 +991,7 @@ class WebBrowser extends LitElement {
const tag3 = data.tag3;
const tag4 = data.tag4;
const tag5 = data.tag5;
+ let feeAmount = null
if (data.identifier == null) {
identifier = 'default';
}
@@ -994,6 +1011,8 @@ class WebBrowser extends LitElement {
if (data.file) {
data64 = await fileToBase64(data.file)
}
+ const getArbitraryFee = await this.getArbitraryFee()
+ feeAmount = getArbitraryFee.fee
if (data.encrypt) {
try {
@@ -1014,6 +1033,7 @@ class WebBrowser extends LitElement {
}
+
const res2 = await showModalAndWait(
@@ -1022,7 +1042,8 @@ class WebBrowser extends LitElement {
name,
identifier,
service,
- encrypt: data.encrypt
+ encrypt: data.encrypt,
+ feeAmount
}
);
if (res2.action === 'accept') {
@@ -1052,7 +1073,8 @@ class WebBrowser extends LitElement {
tag4,
tag5,
apiVersion: 2,
- withFee: res2.userData.isWithFee === true ? true : false
+ withFee: res2.userData.isWithFee === true ? true : false,
+ feeAmount: feeAmount
});
response = JSON.stringify(resPublish);
@@ -1080,7 +1102,7 @@ class WebBrowser extends LitElement {
case actions.PUBLISH_MULTIPLE_QDN_RESOURCES: {
const requiredFields = ['resources'];
const missingFields = [];
-
+ let feeAmount = null
requiredFields.forEach((field) => {
if (!data[field]) {
missingFields.push(field);
@@ -1114,11 +1136,14 @@ class WebBrowser extends LitElement {
response = JSON.stringify(data);
break
}
+ const getArbitraryFee = await this.getArbitraryFee()
+ feeAmount = getArbitraryFee.fee
const res2 = await showModalAndWait(
actions.PUBLISH_MULTIPLE_QDN_RESOURCES,
{
resources,
- encrypt: data.encrypt
+ encrypt: data.encrypt,
+ feeAmount
}
);
@@ -1217,7 +1242,8 @@ class WebBrowser extends LitElement {
tag4,
tag5,
apiVersion: 2,
- withFee: res2.userData.isWithFee === true ? true : false
+ withFee: res2.userData.isWithFee === true ? true : false,
+ feeAmount: feeAmount
});
worker.terminate();
@@ -3001,7 +3027,7 @@ async function showModalAndWait(type, data) {
@@ -3017,7 +3043,7 @@ async function showModalAndWait(type, data) {
${get("browserpage.bchange45")}: ${data.encrypt ? true : false}
diff --git a/plugins/plugins/core/qdn/publish/publish.src.js b/plugins/plugins/core/qdn/publish/publish.src.js
index 08372934..aaf16793 100644
--- a/plugins/plugins/core/qdn/publish/publish.src.js
+++ b/plugins/plugins/core/qdn/publish/publish.src.js
@@ -488,6 +488,16 @@ class PublishData extends LitElement {
this.successMessage = ''
console.error(errorMessage)
}
+ const getArbitraryFee = async () => {
+ const timestamp = Date.now()
+ let fee = await parentEpml.request('apiCall', {
+ url: `/transactions/unitfee?txType=ARBITRARY×tamp=${timestamp}`
+ })
+ return {
+ timestamp,
+ fee : (Number(fee) / 1e8).toFixed(8)
+ }
+ }
const validate = async () => {
let validNameRes = await validateName(registeredName)
@@ -501,8 +511,17 @@ class PublishData extends LitElement {
this.generalMessage = `${err6string}`
let transactionBytes
let previewUrlPath
+ let feeAmount = null
- let uploadDataRes = await uploadData(registeredName, path, file, preview, fee)
+ if(fee){
+ const res = await getArbitraryFee()
+ if(res.fee){
+ feeAmount= res.fee
+ } else {
+ throw new Error('unable to get fee')
+ }
+ }
+ let uploadDataRes = await uploadData(registeredName, path, file, preview, fee, feeAmount)
if (uploadDataRes.error) {
let err7string = get("publishpage.pchange20")
@@ -531,12 +550,13 @@ class PublishData extends LitElement {
if (fee) {
let err9string = get("publishpage.pchange26")
this.generalMessage = `${err9string}`
+
} else {
let err9string = get("publishpage.pchange22")
this.generalMessage = `${err9string}`
}
- let signAndProcessRes = await signAndProcess(transactionBytes, fee)
+ let signAndProcessRes = await signAndProcess(transactionBytes, fee, feeAmount)
if (signAndProcessRes.error) {
let err10string = get("publishpage.pchange20")
@@ -554,7 +574,9 @@ class PublishData extends LitElement {
this.successMessage = `${err11string}`
}
- const uploadData = async (registeredName, path, file, preview, fee) => {
+
+
+ const uploadData = async (registeredName, path, file, preview, fee, feeAmount) => {
let postBody = path
let urlSuffix = ""
if (file != null) {
@@ -592,9 +614,9 @@ class PublishData extends LitElement {
uploadDataUrl = `/arbitrary/${service}/${registeredName}/${this.identifier}${urlSuffix}?${metadataQueryString}&apiKey=${this.getApiKey()}&preview=${new Boolean(preview).toString()}`
}
} else if (fee) {
- uploadDataUrl = `/arbitrary/${this.service}/${registeredName}${urlSuffix}?${metadataQueryString}&fee=100000&apiKey=${this.getApiKey()}`
+ uploadDataUrl = `/arbitrary/${this.service}/${registeredName}${urlSuffix}?${metadataQueryString}&fee=${feeAmount}&apiKey=${this.getApiKey()}`
if (identifier != null && identifier.trim().length > 0) {
- uploadDataUrl = `/arbitrary/${service}/${registeredName}/${this.identifier}${urlSuffix}?${metadataQueryString}&fee=100000&apiKey=${this.getApiKey()}`
+ uploadDataUrl = `/arbitrary/${service}/${registeredName}/${this.identifier}${urlSuffix}?${metadataQueryString}&fee=${feeAmount}&apiKey=${this.getApiKey()}`
}
} else {
uploadDataUrl = `/arbitrary/${this.service}/${registeredName}${urlSuffix}?${metadataQueryString}&apiKey=${this.getApiKey()}`
diff --git a/plugins/plugins/utils/publish-image.js b/plugins/plugins/utils/publish-image.js
index b3511283..fde18985 100644
--- a/plugins/plugins/utils/publish-image.js
+++ b/plugins/plugins/utils/publish-image.js
@@ -28,7 +28,8 @@ export const publishData = async ({
tag2,
tag3,
tag4,
- tag5
+ tag5,
+ feeAmount
}) => {
const validateName = async (receiverName) => {
let nameRes = await parentEpml.request("apiCall", {
@@ -48,6 +49,16 @@ export const publishData = async ({
})
return convertedBytes
}
+ const getArbitraryFee = async () => {
+ const timestamp = Date.now()
+ let fee = await parentEpml.request('apiCall', {
+ url: `/transactions/unitfee?txType=ARBITRARY×tamp=${timestamp}`
+ })
+ return {
+ timestamp,
+ fee : (Number(fee) / 1e8).toFixed(8)
+ }
+ }
const signAndProcess = async (transactionBytesBase58) => {
let convertedBytesBase58 = await convertBytesForSigning(
@@ -125,7 +136,18 @@ export const publishData = async ({
if (validNameRes.error) {
throw new Error('Name not found');
}
- let transactionBytes = await uploadData(registeredName, path, file)
+ let fee = null
+ if(withFee && feeAmount){
+ fee= feeAmount
+ } else if(withFee){
+ const res = await getArbitraryFee()
+ if(res.fee){
+ fee= res.fee
+ } else {
+ throw new Error('unable to get fee')
+ }
+ }
+ let transactionBytes = await uploadData(registeredName, path, file, fee)
if (transactionBytes.error) {
throw new Error(transactionBytes.message || 'Error when uploading');
} else if (
@@ -149,7 +171,7 @@ export const publishData = async ({
return signAndProcessRes
}
- const uploadData = async (registeredName, path, file) => {
+ const uploadData = async (registeredName, path, file, fee) => {
if (identifier != null && identifier.trim().length > 0) {
let postBody = path
let urlSuffix = ""
@@ -181,7 +203,7 @@ export const publishData = async ({
}
if(withFee){
- uploadDataUrl = uploadDataUrl + '&fee=100000'
+ uploadDataUrl = uploadDataUrl + `&fee=${fee}`
}
if(filename != null && filename != "undefined"){