Browse Source

added deploy_at action

resolve-20231003
Phillip 1 year ago
parent
commit
ae9917b939
  1. 5
      core/language/us.json
  2. 28
      crypto/api/transactions/DeployAtTransaction.js
  3. 80
      plugins/plugins/core/qdn/browser/browser.src.js

5
core/language/us.json

@ -1008,7 +1008,10 @@
"rewarddialog3": "If yes, you will need to save the key below in order to mint. It can be supplied to any node in order to allow it to mint on your behalf.",
"rewarddialog4": "On pressing confirm, the rewardshare will be created, but you will still need to supply the above key to a node in order to mint with the account.",
"rewarddialog5": "You are removing a reward share transaction associated with account:",
"rewarddialog6": "On pressing confirm, the rewardshare will be removed and the minting key will become invalid."
"rewarddialog6": "On pressing confirm, the rewardshare will be removed and the minting key will become invalid.",
"deployAtdialog1": "You are deploying the AT",
"deployAtdialog2": "On pressing confirm, the AT will be deployed!",
"deployAtdialog3": "Initial amount balance"
},
"sponsorshipspage": {
"schange1": "Active Sponsorships",

28
crypto/api/transactions/DeployAtTransaction.js

@ -1,6 +1,7 @@
'use strict'
import TransactionBase from './TransactionBase.js'
import { store } from '../../api.js'
import { QORT_DECIMALS } from '../constants.js'
export default class DeployAtTransaction extends TransactionBase {
constructor() {
@ -8,17 +9,22 @@ export default class DeployAtTransaction extends TransactionBase {
this.type = 16
}
render(html) {
return html`
${this._groupdialog5}
${this._atDeployDialog1}:
<div style="background: #eee; padding: 8px; margin: 8px 0; border-radius: 5px;">
<span style="color: #000;">${this._rName}</span>
</div>
${this._atDeployDialog4}:
<div style="background: #eee; padding: 8px; margin: 8px 0; border-radius: 5px;">
<div>${this._atDeployDialog1}: <span style="color: #000;">${this._rName}</span></div>
<br>
<div>${this.atDeployDialog2}: <span style="color: #000;">${this._rDescription}</span></div>
<br>
<span style="color: #000;">${this._feeToShow}</span>
</div>
${this._atDeployDialog3}:
<div style="background: #eee; padding: 8px; margin: 8px 0; border-radius: 5px;">
<span style="color: #000;">${this._amountToShow}</span>
</div>
${this._groupdialog6}
${this._atDeployDialog2}
`
}
@ -28,12 +34,20 @@ export default class DeployAtTransaction extends TransactionBase {
set atDeployDialog2(atDeployDialog2) {
this._atDeployDialog2 = atDeployDialog2
}
set atDeployDialog3(atDeployDialog3) {
this._atDeployDialog3 = atDeployDialog3
}
set atDeployDialog4(atDeployDialog4) {
this._atDeployDialog4 = atDeployDialog4
}
set fee(fee) {
this._fee = fee
this._feeToShow = fee
this._fee = fee * QORT_DECIMALS
this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
}
set rAmount(rAmount) {
this._amountToShow = rAmount
this._rAmount = Math.round(rAmount * store.getState().config.coin.decimals)
this._rAmountBytes = this.constructor.utils.int64ToBytes(this._rAmount)
}

80
plugins/plugins/core/qdn/browser/browser.src.js

@ -509,7 +509,7 @@ class WebBrowser extends LitElement {
}
async _deployAt(name, description, tags, creationBytes, amount, assetId, fee, atType) {
async _deployAt(name, description, tags, creationBytes, amount, assetId, atType) {
const deployAtFee = await this.deployAtFee()
const getLastRef = async () => {
let myRef = await parentEpml.request('apiCall', {
@ -527,13 +527,15 @@ class WebBrowser extends LitElement {
}
const makeTransactionRequest = async (lastRef) => {
let groupdialog1 = get("transactions.groupdialog1")
let groupdialog2 = get("transactions.groupdialog2")
let deployAtdialog1 = get("transactions.deployAtdialog1")
let deployAtdialog2 = get("transactions.deployAtdialog2")
let deployAtdialog3 = get("transactions.deployAtdialog3")
let deployAtdialog4 = get("walletpage.wchange12")
let myTxnrequest = await parentEpml.request('transaction', {
type: 16,
nonce: this.selectedAddress.nonce,
params: {
fee: fee || deployAtFee,
fee: deployAtFee,
rName: name,
rDescription: description,
rTags: tags,
@ -542,8 +544,10 @@ class WebBrowser extends LitElement {
rCreationBytes: creationBytes,
atType: atType,
lastReference: lastRef,
atDeployDialog1: groupdialog1,
atDeployDialog2: groupdialog2
atDeployDialog1: deployAtdialog1,
atDeployDialog2: deployAtdialog2,
atDeployDialog3: deployAtdialog3,
atDeployDialog4: deployAtdialog4
},
apiVersion: 2
})
@ -1645,41 +1649,41 @@ class WebBrowser extends LitElement {
break;
}
// case 'DEPLOY_AT': {
// const requiredFields = ['name', 'description', 'tags', 'creationBytes', 'amount', 'assetId', 'type'];
// const missingFields = [];
case 'DEPLOY_AT': {
const requiredFields = ['name', 'description', 'tags', 'creationBytes', 'amount', 'assetId', 'type'];
const missingFields = [];
// requiredFields.forEach((field) => {
// if (!data[field]) {
// missingFields.push(field);
// }
// });
// if (missingFields.length > 0) {
// const missingFieldsString = missingFields.join(', ');
// const errorMsg = `Missing fields: ${missingFieldsString}`
// let data = {};
// data['error'] = errorMsg;
// response = JSON.stringify(data);
// break
// }
requiredFields.forEach((field) => {
if (!data[field] && data[field] !== 0) {
missingFields.push(field);
}
});
if (missingFields.length > 0) {
const missingFieldsString = missingFields.join(', ');
const errorMsg = `Missing fields: ${missingFieldsString}`
let data = {};
data['error'] = errorMsg;
response = JSON.stringify(data);
break
}
// try {
// this.loader.show();
// const fee = data.fee || undefined
// const resJoinGroup = await this._deployAt(data.name, data.description, data.tags, data.creationBytes, data.amount, data.assetId, fee, data.type)
// response = JSON.stringify(resJoinGroup);
// } catch (error) {
// const obj = {};
// const errorMsg = error.message || 'Failed to join the group.';
// obj['error'] = errorMsg;
// response = JSON.stringify(obj);
// } finally {
// this.loader.hide();
// }
// break;
// }
try {
this.loader.show();
const resDeployAt = await this._deployAt(data.name, data.description, data.tags, data.creationBytes, data.amount, data.assetId, data.type)
response = JSON.stringify(resDeployAt);
} catch (error) {
const obj = {};
const errorMsg = error.message || 'Failed to join the group.';
obj['error'] = errorMsg;
response = JSON.stringify(obj);
} finally {
this.loader.hide();
}
break;
}
case actions.GET_WALLET_BALANCE: {

Loading…
Cancel
Save