mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-02-11 17:55:51 +00:00
fix url and get fee for modal
This commit is contained in:
parent
ccc7822646
commit
b6d9410621
@ -719,7 +719,8 @@
|
|||||||
"bchange43": "Do you give this application permission to add to this list?",
|
"bchange43": "Do you give this application permission to add to this list?",
|
||||||
"bchange44": "Do you give this application permission to delete from this list?",
|
"bchange44": "Do you give this application permission to delete from this list?",
|
||||||
"bchange45": "Encrypt",
|
"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": {
|
"datapage": {
|
||||||
"dchange1": "Data Management",
|
"dchange1": "Data Management",
|
||||||
|
@ -425,6 +425,22 @@ class WebBrowser extends LitElement {
|
|||||||
const joinFee = (Number(data) / 1e8).toFixed(8)
|
const joinFee = (Number(data) / 1e8).toFixed(8)
|
||||||
return joinFee
|
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() {
|
async sendQortFee() {
|
||||||
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
|
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 nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port
|
||||||
@ -975,6 +991,7 @@ class WebBrowser extends LitElement {
|
|||||||
const tag3 = data.tag3;
|
const tag3 = data.tag3;
|
||||||
const tag4 = data.tag4;
|
const tag4 = data.tag4;
|
||||||
const tag5 = data.tag5;
|
const tag5 = data.tag5;
|
||||||
|
let feeAmount = null
|
||||||
if (data.identifier == null) {
|
if (data.identifier == null) {
|
||||||
identifier = 'default';
|
identifier = 'default';
|
||||||
}
|
}
|
||||||
@ -994,6 +1011,8 @@ class WebBrowser extends LitElement {
|
|||||||
if (data.file) {
|
if (data.file) {
|
||||||
data64 = await fileToBase64(data.file)
|
data64 = await fileToBase64(data.file)
|
||||||
}
|
}
|
||||||
|
const getArbitraryFee = await this.getArbitraryFee()
|
||||||
|
feeAmount = getArbitraryFee.fee
|
||||||
|
|
||||||
if (data.encrypt) {
|
if (data.encrypt) {
|
||||||
try {
|
try {
|
||||||
@ -1014,6 +1033,7 @@ class WebBrowser extends LitElement {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const res2 = await showModalAndWait(
|
const res2 = await showModalAndWait(
|
||||||
@ -1022,7 +1042,8 @@ class WebBrowser extends LitElement {
|
|||||||
name,
|
name,
|
||||||
identifier,
|
identifier,
|
||||||
service,
|
service,
|
||||||
encrypt: data.encrypt
|
encrypt: data.encrypt,
|
||||||
|
feeAmount
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if (res2.action === 'accept') {
|
if (res2.action === 'accept') {
|
||||||
@ -1052,7 +1073,8 @@ class WebBrowser extends LitElement {
|
|||||||
tag4,
|
tag4,
|
||||||
tag5,
|
tag5,
|
||||||
apiVersion: 2,
|
apiVersion: 2,
|
||||||
withFee: res2.userData.isWithFee === true ? true : false
|
withFee: res2.userData.isWithFee === true ? true : false,
|
||||||
|
feeAmount: feeAmount
|
||||||
});
|
});
|
||||||
|
|
||||||
response = JSON.stringify(resPublish);
|
response = JSON.stringify(resPublish);
|
||||||
@ -1080,7 +1102,7 @@ class WebBrowser extends LitElement {
|
|||||||
case actions.PUBLISH_MULTIPLE_QDN_RESOURCES: {
|
case actions.PUBLISH_MULTIPLE_QDN_RESOURCES: {
|
||||||
const requiredFields = ['resources'];
|
const requiredFields = ['resources'];
|
||||||
const missingFields = [];
|
const missingFields = [];
|
||||||
|
let feeAmount = null
|
||||||
requiredFields.forEach((field) => {
|
requiredFields.forEach((field) => {
|
||||||
if (!data[field]) {
|
if (!data[field]) {
|
||||||
missingFields.push(field);
|
missingFields.push(field);
|
||||||
@ -1114,11 +1136,14 @@ class WebBrowser extends LitElement {
|
|||||||
response = JSON.stringify(data);
|
response = JSON.stringify(data);
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
const getArbitraryFee = await this.getArbitraryFee()
|
||||||
|
feeAmount = getArbitraryFee.fee
|
||||||
const res2 = await showModalAndWait(
|
const res2 = await showModalAndWait(
|
||||||
actions.PUBLISH_MULTIPLE_QDN_RESOURCES,
|
actions.PUBLISH_MULTIPLE_QDN_RESOURCES,
|
||||||
{
|
{
|
||||||
resources,
|
resources,
|
||||||
encrypt: data.encrypt
|
encrypt: data.encrypt,
|
||||||
|
feeAmount
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1217,7 +1242,8 @@ class WebBrowser extends LitElement {
|
|||||||
tag4,
|
tag4,
|
||||||
tag5,
|
tag5,
|
||||||
apiVersion: 2,
|
apiVersion: 2,
|
||||||
withFee: res2.userData.isWithFee === true ? true : false
|
withFee: res2.userData.isWithFee === true ? true : false,
|
||||||
|
feeAmount: feeAmount
|
||||||
});
|
});
|
||||||
|
|
||||||
worker.terminate();
|
worker.terminate();
|
||||||
@ -3001,7 +3027,7 @@ async function showModalAndWait(type, data) {
|
|||||||
</table>
|
</table>
|
||||||
<div class="checkbox-row">
|
<div class="checkbox-row">
|
||||||
<label for="isWithFee" id="isWithFeeLabel" style="color: var(--black);">
|
<label for="isWithFee" id="isWithFeeLabel" style="color: var(--black);">
|
||||||
${get('browserpage.bchange33')} ${data.resources.length * 0.001} QORT fee
|
${get('browserpage.bchange33')} ${data.resources.length * data.feeAmount} QORT fee
|
||||||
</label>
|
</label>
|
||||||
<mwc-checkbox checked style="margin-right: -15px;" id="isWithFee"></mwc-checkbox>
|
<mwc-checkbox checked style="margin-right: -15px;" id="isWithFee"></mwc-checkbox>
|
||||||
</div>
|
</div>
|
||||||
@ -3017,7 +3043,7 @@ async function showModalAndWait(type, data) {
|
|||||||
<p style="font-size: 16px;overflow-wrap: anywhere;" class="modal-paragraph"><span style="font-weight: bold">${get("browserpage.bchange45")}:</span> ${data.encrypt ? true : false}</p>
|
<p style="font-size: 16px;overflow-wrap: anywhere;" class="modal-paragraph"><span style="font-weight: bold">${get("browserpage.bchange45")}:</span> ${data.encrypt ? true : false}</p>
|
||||||
<div class="checkbox-row">
|
<div class="checkbox-row">
|
||||||
<label for="isWithFee" id="isWithFeeLabel" style="color: var(--black);">
|
<label for="isWithFee" id="isWithFeeLabel" style="color: var(--black);">
|
||||||
${get('browserpage.bchange29')}
|
${get('browserpage.bchange47')} ${data.feeAmount} QORT fee
|
||||||
</label>
|
</label>
|
||||||
<mwc-checkbox checked style="margin-right: -15px;" id="isWithFee"></mwc-checkbox>
|
<mwc-checkbox checked style="margin-right: -15px;" id="isWithFee"></mwc-checkbox>
|
||||||
</div>
|
</div>
|
||||||
|
@ -491,7 +491,7 @@ class PublishData extends LitElement {
|
|||||||
const getArbitraryFee = async () => {
|
const getArbitraryFee = async () => {
|
||||||
const timestamp = Date.now()
|
const timestamp = Date.now()
|
||||||
let fee = await parentEpml.request('apiCall', {
|
let fee = await parentEpml.request('apiCall', {
|
||||||
url: `/unitfee?txType=ARBITRARY×tamp=${timestamp}`
|
url: `/transactions/unitfee?txType=ARBITRARY×tamp=${timestamp}`
|
||||||
})
|
})
|
||||||
return {
|
return {
|
||||||
timestamp,
|
timestamp,
|
||||||
|
@ -28,7 +28,8 @@ export const publishData = async ({
|
|||||||
tag2,
|
tag2,
|
||||||
tag3,
|
tag3,
|
||||||
tag4,
|
tag4,
|
||||||
tag5
|
tag5,
|
||||||
|
feeAmount
|
||||||
}) => {
|
}) => {
|
||||||
const validateName = async (receiverName) => {
|
const validateName = async (receiverName) => {
|
||||||
let nameRes = await parentEpml.request("apiCall", {
|
let nameRes = await parentEpml.request("apiCall", {
|
||||||
@ -51,7 +52,7 @@ export const publishData = async ({
|
|||||||
const getArbitraryFee = async () => {
|
const getArbitraryFee = async () => {
|
||||||
const timestamp = Date.now()
|
const timestamp = Date.now()
|
||||||
let fee = await parentEpml.request('apiCall', {
|
let fee = await parentEpml.request('apiCall', {
|
||||||
url: `/unitfee?txType=ARBITRARY×tamp=${timestamp}`
|
url: `/transactions/unitfee?txType=ARBITRARY×tamp=${timestamp}`
|
||||||
})
|
})
|
||||||
return {
|
return {
|
||||||
timestamp,
|
timestamp,
|
||||||
@ -136,9 +137,11 @@ export const publishData = async ({
|
|||||||
throw new Error('Name not found');
|
throw new Error('Name not found');
|
||||||
}
|
}
|
||||||
let fee = null
|
let fee = null
|
||||||
if(withFee){
|
if(withFee && feeAmount){
|
||||||
|
fee= feeAmount
|
||||||
|
} else if(withFee){
|
||||||
const res = await getArbitraryFee()
|
const res = await getArbitraryFee()
|
||||||
if(res.fee){
|
if(res.fee){
|
||||||
fee= res.fee
|
fee= res.fee
|
||||||
} else {
|
} else {
|
||||||
throw new Error('unable to get fee')
|
throw new Error('unable to get fee')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user