From 536ccbcad20f605024993e878b720ad2cbbade94 Mon Sep 17 00:00:00 2001
From: Phillip Lang Martinez
Date: Sat, 27 Aug 2022 15:28:37 +0300
Subject: [PATCH] fix bugs: key already existing publickey missing
---
.../src/components/start-minting.js | 27 ++++++++---
qortal-ui-core/src/plugins/routes.js | 8 +++-
.../sponsorship-list/sponsorship-list.src.js | 45 ++++++++++---------
3 files changed, 53 insertions(+), 27 deletions(-)
diff --git a/qortal-ui-core/src/components/start-minting.js b/qortal-ui-core/src/components/start-minting.js
index 361efdd0..bc4a68c0 100644
--- a/qortal-ui-core/src/components/start-minting.js
+++ b/qortal-ui-core/src/components/start-minting.js
@@ -234,15 +234,23 @@ class StartMinting extends connect(store)(LitElement) {
}
async changeStatus(value){
+ const myNode =
+ store.getState().app.nodeConfig.knownNodes[
+ store.getState().app.nodeConfig.node
+ ];
+
+ const nodeUrl =
+ myNode.protocol + '://' + myNode.domain + ':' + myNode.port;
this.status = value
const publicAddress =
window.parent.reduxStore.getState().app?.selectedAddress
?.base58PublicKey;
// Check to see if a sponsorship key on a newly-level 1 minter exists. If it does, remove it.
- const findMintingAccountFromOtherUser = mintingAccountData.find(
+ const findMintingAccountFromOtherUser = this.mintingAccountData.find(
(ma) => !ma.publicKey.includes(publicAddress)
);
const removeMintingAccount = async (publicKey) => {
+
const url = `${nodeUrl}/admin/mintingaccounts?apiKey=${myNode.apiKey}`;
return await fetch(url, {
@@ -275,7 +283,7 @@ class StartMinting extends connect(store)(LitElement) {
}
try {
- await addMintingAccount(sponsorshipKeyValue);
+ await addMintingAccount(this.privateRewardShareKey);
routes.showSnackBar({
data: translate('becomeMinterPage.bchange19'),
});
@@ -291,6 +299,13 @@ class StartMinting extends connect(store)(LitElement) {
async confirmRelationship(){
+ const myNode =
+ store.getState().app.nodeConfig.knownNodes[
+ store.getState().app.nodeConfig.node
+ ];
+ const nodeUrl =
+ myNode.protocol + '://' + myNode.domain + ':' + myNode.port;
+
let interval = null
let stop = false
this.status = 2
@@ -386,8 +401,8 @@ class StartMinting extends connect(store)(LitElement) {
};
const getTxnRequestResponse = (txnResponse) => {
-
- if(txnResponse?.message?.includes('multiple')){
+ let err6string = get('rewardsharepage.rchange21');
+ if(txnResponse?.extraData?.rewardSharePrivateKey && txnResponse.success === true){
return err6string
}
if (txnResponse.success === false && txnResponse.message) {
@@ -396,7 +411,7 @@ class StartMinting extends connect(store)(LitElement) {
txnResponse.success === true &&
!txnResponse.data.error
) {
- let err6string = get('rewardsharepage.rchange21');
+
return err6string;
} else {
throw(txnResponse);
@@ -410,7 +425,7 @@ class StartMinting extends connect(store)(LitElement) {
let myTransaction = await makeTransactionRequest(lastRef);
getTxnRequestResponse(myTransaction);
- return myTransaction.data;
+ return myTransaction?.extraData?.rewardSharePrivateKey
};
diff --git a/qortal-ui-core/src/plugins/routes.js b/qortal-ui-core/src/plugins/routes.js
index 215e653d..3ce4ec66 100644
--- a/qortal-ui-core/src/plugins/routes.js
+++ b/qortal-ui-core/src/plugins/routes.js
@@ -140,15 +140,21 @@ export const routes = {
req.data.params
);
- if (!req.disableModal) {
+ if (!req.disableModal && !req.data.disableModal) {
await requestTransactionDialog.requestTransaction(tx);
}
const res = await processTransaction(tx.signedBytes);
+ let extraData = {}
+ if(req.data.type === 38 && tx?._rewardShareKeyPair?.secretKey){
+ extraData.rewardSharePrivateKey = Base58.encode(tx._rewardShareKeyPair.secretKey)
+ }
+
response = {
success: true,
data: res,
+ extraData
};
} catch (e) {
console.error(e);
diff --git a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js
index 5010f1f8..38bf91be 100644
--- a/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js
+++ b/qortal-ui-plugins/plugins/core/sponsorship-list/sponsorship-list.src.js
@@ -156,9 +156,8 @@ class SponsorshipList extends LitElement {
const address =
window.parent.reduxStore.getState().app?.selectedAddress
?.address
-
-
+
let rewardShares = await this.getRewardShareRelationship(
address
@@ -171,7 +170,6 @@ class SponsorshipList extends LitElement {
type: "api",
url: `/addresses/${rs.recipient}`,
})
-
let blocksRemaining = this._levelUpBlocks(addressInfo)
blocksRemaining = +blocksRemaining > 0 ? +blocksRemaining : 0
return {
@@ -294,7 +292,10 @@ class SponsorshipList extends LitElement {
async createRewardShare(publicKeyValue) {
this.openDialogRewardShare = true
-
+ if(!publicKeyValue){
+ this.errorMessage = "unable to pull public key from the chain, account has no outgoing transactions"
+ return
+ }
this.privateRewardShareKey = ""
this.errorMessage = ""
@@ -348,7 +349,7 @@ class SponsorshipList extends LitElement {
getTxnRequestResponse(myTransaction)
} catch (error) {
- this.errorMessage = error?.message || 'Error creating relationship'
+ this.errorMessage = error
}
@@ -379,37 +380,35 @@ class SponsorshipList extends LitElement {
rewarddialog3: rewarddialog3,
rewarddialog4: rewarddialog4,
},
+ disableModal: true
})
return myTxnrequest
}
const getTxnRequestResponse = (txnResponse) => {
-
- if(txnResponse.message.includes('multiple')){
- this.isLoadingCreateSponsorship = false
+
+ if(txnResponse?.extraData?.rewardSharePrivateKey && txnResponse.success === true){
- this.privateRewardShareKey = txnResponse.data
- this.confirmRelationship(recipientPublicKey)
- }
- if (txnResponse.success === false && txnResponse.message) {
+ this.privateRewardShareKey = txnResponse?.extraData?.rewardSharePrivateKey
+ this.confirmRelationship()
+ } else if (txnResponse.success === false && txnResponse?.message) {
- this.errorMessage = txnResponse.message
+ this.errorMessage = txnResponse?.message
this.isLoadingCreateSponsorship = false
- throw(txnResponse)
+ throw(txnResponse?.message)
} else if (
txnResponse.success === true &&
!txnResponse.data.error
) {
- this.isLoadingCreateSponsorship = false
- this.privateRewardShareKey = txnResponse.data
+ this.privateRewardShareKey = txnResponse?.extraData?.rewardSharePrivateKey
this.confirmRelationship()
} else {
- this.errorMessage = txnResponse.data.message
+ this.errorMessage = txnResponse?.data?.message || txnResponse?.message
this.isLoadingCreateSponsorship = false
- throw(txnResponse)
+ throw(txnResponse?.data?.message || txnResponse?.message)
}
}
validateReceiver()
@@ -419,10 +418,12 @@ class SponsorshipList extends LitElement {
async confirmRelationship(recipientPublicKey){
+ this.status = 2
let interval = null
let stop = false
const getAnswer = async () => {
+
if (!stop) {
stop= true;
@@ -458,7 +459,6 @@ class SponsorshipList extends LitElement {
render() {
- console.log({sponsors: this.sponsorships})
return html`
${
this.isPageLoading
@@ -528,7 +528,11 @@ class SponsorshipList extends LitElement {
Copy Sponsorship Key
- this.createRewardShare(sponsorship.publicKey)}>copy
+ {
+
+
+ this.createRewardShare(sponsorship?.publicKey)
+ } }>copy