mirror of
https://github.com/Qortal/chrome-extension.git
synced 2025-02-11 17:55:49 +00:00
fixes: minting
This commit is contained in:
parent
7d96cfdded
commit
e7e7871dca
@ -11,7 +11,7 @@ module.exports = {
|
|||||||
plugins: ['react-refresh'],
|
plugins: ['react-refresh'],
|
||||||
rules: {
|
rules: {
|
||||||
'react-refresh/only-export-components': [
|
'react-refresh/only-export-components': [
|
||||||
'warn',
|
'off',
|
||||||
{ allowConstantExport: true },
|
{ allowConstantExport: true },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -470,7 +470,12 @@ export default ({
|
|||||||
}, [enableMentions])
|
}, [enableMentions])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div style={{
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
height: '100%'
|
||||||
|
}}>
|
||||||
<EditorProvider
|
<EditorProvider
|
||||||
slotBefore={
|
slotBefore={
|
||||||
(isFocusedParent || !isMobile || overrideMobile) && (
|
(isFocusedParent || !isMobile || overrideMobile) && (
|
||||||
|
@ -54,10 +54,12 @@ export const Minting = ({
|
|||||||
const [nodeInfos, setNodeInfos] = useState({});
|
const [nodeInfos, setNodeInfos] = useState({});
|
||||||
const [openSnack, setOpenSnack] = useState(false);
|
const [openSnack, setOpenSnack] = useState(false);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const { isShow, onCancel, onOk, show: showKey, message } = useModal();
|
const { show: showKey, message } = useModal();
|
||||||
|
const { isShow: isShowNext, onOk, show: showNext } = useModal();
|
||||||
const [info, setInfo] = useState(null);
|
const [info, setInfo] = useState(null);
|
||||||
const [names, setNames] = useState({});
|
const [names, setNames] = useState({});
|
||||||
const [accountInfos, setAccountInfos] = useState({});
|
const [accountInfos, setAccountInfos] = useState({});
|
||||||
|
const [showWaitDialog, setShowWaitDialog] = useState(false)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -199,6 +201,7 @@ export const Minting = ({
|
|||||||
}
|
}
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
setRewardShares(data);
|
setRewardShares(data);
|
||||||
|
return data
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@ -341,6 +344,31 @@ export const Minting = ({
|
|||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const waitUntilRewardShareIsConfirmed = async (timeoutMs = 600000) => {
|
||||||
|
const pollingInterval = 30000;
|
||||||
|
const startTime = Date.now();
|
||||||
|
|
||||||
|
const sleep = (ms) => new Promise((res) => setTimeout(res, ms));
|
||||||
|
|
||||||
|
while (Date.now() - startTime < timeoutMs) {
|
||||||
|
|
||||||
|
const rewardShares = await getRewardShares(myAddress);
|
||||||
|
const findRewardShare = rewardShares?.find(
|
||||||
|
(item) =>
|
||||||
|
item?.recipient === myAddress && item?.mintingAccount === myAddress
|
||||||
|
);
|
||||||
|
|
||||||
|
if (findRewardShare) {
|
||||||
|
return true; // Exit early if found
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
await sleep(pollingInterval); // Wait before the next poll
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error("Timeout waiting for reward share confirmation");
|
||||||
|
};
|
||||||
|
|
||||||
const startMinting = async () => {
|
const startMinting = async () => {
|
||||||
try {
|
try {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
@ -355,12 +383,20 @@ export const Minting = ({
|
|||||||
addMintingAccount(privateRewardShare);
|
addMintingAccount(privateRewardShare);
|
||||||
} else {
|
} else {
|
||||||
await createRewardShare(accountInfo?.publicKey, myAddress);
|
await createRewardShare(accountInfo?.publicKey, myAddress);
|
||||||
|
setShowWaitDialog(true)
|
||||||
|
await waitUntilRewardShareIsConfirmed()
|
||||||
|
await showNext({
|
||||||
|
message: ''
|
||||||
|
})
|
||||||
const privateRewardShare = await getRewardSharePrivateKey(
|
const privateRewardShare = await getRewardSharePrivateKey(
|
||||||
accountInfo?.publicKey
|
accountInfo?.publicKey
|
||||||
);
|
);
|
||||||
|
setShowWaitDialog(false)
|
||||||
addMintingAccount(privateRewardShare);
|
addMintingAccount(privateRewardShare);
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
setShowWaitDialog(false)
|
||||||
setInfo({
|
setInfo({
|
||||||
type: "error",
|
type: "error",
|
||||||
message: error?.message || "Unable to start minting",
|
message: error?.message || "Unable to start minting",
|
||||||
@ -724,63 +760,7 @@ export const Minting = ({
|
|||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
</Card>
|
</Card>
|
||||||
{txList?.filter(
|
|
||||||
(item) =>
|
|
||||||
!item?.done &&
|
|
||||||
(item?.type === "remove-rewardShare" ||
|
|
||||||
item?.type === "add-rewardShare")
|
|
||||||
)?.length > 0 && (
|
|
||||||
<>
|
|
||||||
<Spacer height="20px" />
|
|
||||||
<Typography>Ongoing transactions</Typography>
|
|
||||||
<Card
|
|
||||||
sx={{
|
|
||||||
backgroundColor: "var(--bg-2)",
|
|
||||||
padding: "10px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
display: "flex",
|
|
||||||
gap: "5px",
|
|
||||||
flexDirection: "column",
|
|
||||||
width: "100%",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{txList
|
|
||||||
?.filter(
|
|
||||||
(item) =>
|
|
||||||
!item.done &&
|
|
||||||
(item?.type === "remove-rewardShare" ||
|
|
||||||
item?.type === "add-rewardShare")
|
|
||||||
)
|
|
||||||
?.map((txItem) => (
|
|
||||||
<Box
|
|
||||||
key={txItem?.signature}
|
|
||||||
sx={{
|
|
||||||
display: "flex",
|
|
||||||
gap: "5px",
|
|
||||||
flexDirection: "column",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{txItem?.type === "remove-rewardShare" && (
|
|
||||||
<Typography>Reward share being removed</Typography>
|
|
||||||
)}
|
|
||||||
{txItem?.type === "add-rewardShare" && (
|
|
||||||
<Typography>Reward share being created</Typography>
|
|
||||||
)}
|
|
||||||
<Typography>
|
|
||||||
Recipient: {handleNames(txItem?.recipient)}
|
|
||||||
</Typography>
|
|
||||||
|
|
||||||
<Divider />
|
|
||||||
<Spacer height="10px" />
|
|
||||||
</Box>
|
|
||||||
))}
|
|
||||||
</Box>
|
|
||||||
</Card>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
<Spacer height="20px" />
|
<Spacer height="20px" />
|
||||||
{!isPartOfMintingGroup && (
|
{!isPartOfMintingGroup && (
|
||||||
<Card
|
<Card
|
||||||
@ -834,6 +814,39 @@ export const Minting = ({
|
|||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{showWaitDialog && (
|
||||||
|
<Dialog
|
||||||
|
open={showWaitDialog}
|
||||||
|
aria-labelledby="alert-dialog-title"
|
||||||
|
aria-describedby="alert-dialog-description"
|
||||||
|
>
|
||||||
|
<DialogTitle id="alert-dialog-title">
|
||||||
|
{isShowNext ? "Confirmed" : "Please Wait"}
|
||||||
|
</DialogTitle>
|
||||||
|
<DialogContent>
|
||||||
|
{!isShowNext && (
|
||||||
|
<Typography>
|
||||||
|
Confirming creation of rewardshare on chain. Please be patient, this could take up to 90 seconds.
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
{isShowNext && (
|
||||||
|
<Typography>
|
||||||
|
Rewardshare confirmed. Please click Next.
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
|
||||||
|
</DialogContent>
|
||||||
|
|
||||||
|
<DialogActions>
|
||||||
|
<Button disabled={!isShowNext} variant="contained" onClick={onOk} autoFocus>
|
||||||
|
Next
|
||||||
|
</Button>
|
||||||
|
</DialogActions>
|
||||||
|
|
||||||
|
|
||||||
|
</Dialog>
|
||||||
|
)}
|
||||||
|
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button
|
<Button
|
||||||
|
@ -2231,7 +2231,7 @@ export const getTxActivitySummary = async (data) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { coin, type } = data;
|
const { coin, type } = data;
|
||||||
const url = `/crosschain/${coin}/${type}`;
|
const url = `/crosschain/${coin.toLowerCase()}/${type}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const endpoint = await createEndpoint(url);
|
const endpoint = await createEndpoint(url);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user