fix logic- is user sponsored
This commit is contained in:
parent
c4a65987c1
commit
67cec578df
@ -27,6 +27,7 @@ class BecomeMinter extends LitElement {
|
|||||||
isPageLoading: { type: Boolean },
|
isPageLoading: { type: Boolean },
|
||||||
addressInfo: { type: Object },
|
addressInfo: { type: Object },
|
||||||
rewardSharePublicKey: { type: String },
|
rewardSharePublicKey: { type: String },
|
||||||
|
mintingAccountData: { type: Array },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,6 +43,7 @@ class BecomeMinter extends LitElement {
|
|||||||
this.nodeInfo = {};
|
this.nodeInfo = {};
|
||||||
this.addressInfo = {};
|
this.addressInfo = {};
|
||||||
this.rewardSharePublicKey = '';
|
this.rewardSharePublicKey = '';
|
||||||
|
this.mintingAccountData = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
changeLanguage() {
|
changeLanguage() {
|
||||||
@ -87,6 +89,13 @@ class BecomeMinter extends LitElement {
|
|||||||
return nodeInfo;
|
return nodeInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getMintingAcccounts() {
|
||||||
|
const mintingAccountData = await parentEpml.request('apiCall', {
|
||||||
|
url: `/admin/mintingaccounts`,
|
||||||
|
});
|
||||||
|
return mintingAccountData;
|
||||||
|
}
|
||||||
|
|
||||||
async firstUpdated() {
|
async firstUpdated() {
|
||||||
this.changeLanguage();
|
this.changeLanguage();
|
||||||
|
|
||||||
@ -94,18 +103,21 @@ class BecomeMinter extends LitElement {
|
|||||||
window.parent.reduxStore.getState().app.accountInfo.addressInfo;
|
window.parent.reduxStore.getState().app.accountInfo.addressInfo;
|
||||||
this.isPageLoading = true;
|
this.isPageLoading = true;
|
||||||
try {
|
try {
|
||||||
const [nodeInfo, myRewardShareArray] = await Promise.all([
|
const [nodeInfo, myRewardShareArray, mintingaccounts] =
|
||||||
this.getNodeInfo(),
|
await Promise.all([
|
||||||
await this.getRewardShareRelationship(
|
this.getNodeInfo(),
|
||||||
window.parent.reduxStore.getState().app?.selectedAddress
|
this.getRewardShareRelationship(
|
||||||
?.address
|
window.parent.reduxStore.getState().app?.selectedAddress
|
||||||
),
|
?.address
|
||||||
]);
|
),
|
||||||
|
this.getMintingAcccounts(),
|
||||||
|
]);
|
||||||
|
|
||||||
this.nodeInfo = nodeInfo;
|
this.nodeInfo = nodeInfo;
|
||||||
this.rewardSharePublicKey =
|
this.rewardSharePublicKey =
|
||||||
myRewardShareArray[0]?.rewardSharePublicKey;
|
myRewardShareArray[0]?.rewardSharePublicKey;
|
||||||
this.isPageLoading = false;
|
this.isPageLoading = false;
|
||||||
|
this.mintingAccountData = mintingaccounts;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|
||||||
@ -116,7 +128,7 @@ class BecomeMinter extends LitElement {
|
|||||||
async getRewardShareRelationship(recipientAddress) {
|
async getRewardShareRelationship(recipientAddress) {
|
||||||
const myRewardShareArray = await parentEpml.request('apiCall', {
|
const myRewardShareArray = await parentEpml.request('apiCall', {
|
||||||
type: 'api',
|
type: 'api',
|
||||||
url: `/addresses/rewardshares?minters=${recipientAddress}&recipients=${recipientAddress}`,
|
url: `/addresses/rewardshares?recipients=${recipientAddress}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
return myRewardShareArray;
|
return myRewardShareArray;
|
||||||
@ -132,10 +144,15 @@ class BecomeMinter extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
console.log({ mintingAccountData: this.mintingAccountData });
|
||||||
|
const findMintingAccount = this.mintingAccountData?.find(
|
||||||
|
(ma) => !!ma.publicKey
|
||||||
|
);
|
||||||
|
|
||||||
const isAlreadySponsored =
|
const isAlreadySponsored =
|
||||||
this.addressInfo?.error !== 124 &&
|
this.addressInfo?.error !== 124 &&
|
||||||
this.addressInfo?.level === 0 &&
|
this.addressInfo?.level === 0 &&
|
||||||
this.rewardSharePublicKey;
|
findMintingAccount;
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
${this.isPageLoading
|
${this.isPageLoading
|
||||||
|
Loading…
x
Reference in New Issue
Block a user