mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-04-25 04:17:52 +00:00
fixes: minting and publish
This commit is contained in:
parent
94c75bb23e
commit
a6de6e8a54
@ -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 },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -320,7 +320,7 @@ const UIQortalRequests = [
|
|||||||
|
|
||||||
// Handle the obj.file if it exists and is a File instance
|
// Handle the obj.file if it exists and is a File instance
|
||||||
if (obj.file) {
|
if (obj.file) {
|
||||||
const fileId = "objFile_qortalfile";
|
const fileId = Date.now() + "objFile_qortalfile";
|
||||||
|
|
||||||
// Store the file in IndexedDB
|
// Store the file in IndexedDB
|
||||||
const fileData = {
|
const fileData = {
|
||||||
@ -334,7 +334,7 @@ const UIQortalRequests = [
|
|||||||
delete obj.file;
|
delete obj.file;
|
||||||
}
|
}
|
||||||
if (obj.blob) {
|
if (obj.blob) {
|
||||||
const fileId = "objFile_qortalfile";
|
const fileId = Date.now() + "objFile_qortalfile";
|
||||||
|
|
||||||
// Store the file in IndexedDB
|
// Store the file in IndexedDB
|
||||||
const fileData = {
|
const fileData = {
|
||||||
@ -355,7 +355,7 @@ const UIQortalRequests = [
|
|||||||
// Iterate through resources to find files and save them to IndexedDB
|
// Iterate through resources to find files and save them to IndexedDB
|
||||||
for (let resource of (obj?.resources || [])) {
|
for (let resource of (obj?.resources || [])) {
|
||||||
if (resource.file) {
|
if (resource.file) {
|
||||||
const fileId = resource.identifier + "_qortalfile";
|
const fileId = resource.identifier + Date.now() + "_qortalfile";
|
||||||
|
|
||||||
// Store the file in IndexedDB
|
// Store the file in IndexedDB
|
||||||
const fileData = {
|
const fileData = {
|
||||||
@ -484,17 +484,8 @@ isDOMContentLoaded: false
|
|||||||
event?.data?.action === 'ENCRYPT_DATA' || event?.data?.action === 'ENCRYPT_DATA_WITH_SHARING_KEY' || event?.data?.action === 'ENCRYPT_QORTAL_GROUP_DATA'
|
event?.data?.action === 'ENCRYPT_DATA' || event?.data?.action === 'ENCRYPT_DATA_WITH_SHARING_KEY' || event?.data?.action === 'ENCRYPT_QORTAL_GROUP_DATA'
|
||||||
|
|
||||||
) {
|
) {
|
||||||
let data;
|
const data = event.data;
|
||||||
try {
|
|
||||||
data = await storeFilesInIndexedDB(event.data);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error storing files in IndexedDB:', error);
|
|
||||||
event.ports[0].postMessage({
|
|
||||||
result: null,
|
|
||||||
error: 'Failed to store files in IndexedDB',
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (data) {
|
if (data) {
|
||||||
sendMessageToRuntime(
|
sendMessageToRuntime(
|
||||||
{ action: event.data.action, type: 'qortalRequest', payload: data, isExtension: true },
|
{ action: event.data.action, type: 'qortalRequest', payload: data, isExtension: true },
|
||||||
|
@ -472,7 +472,12 @@ export default ({
|
|||||||
|
|
||||||
|
|
||||||
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,14 +54,13 @@ 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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const isPartOfMintingGroup = useMemo(() => {
|
const isPartOfMintingGroup = useMemo(() => {
|
||||||
if (groups?.length === 0) return false;
|
if (groups?.length === 0) return false;
|
||||||
return !!groups?.find((item) => item?.groupId?.toString() === "694");
|
return !!groups?.find((item) => item?.groupId?.toString() === "694");
|
||||||
@ -199,6 +198,7 @@ export const Minting = ({
|
|||||||
}
|
}
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
setRewardShares(data);
|
setRewardShares(data);
|
||||||
|
return data
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@ -338,6 +338,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);
|
||||||
@ -352,12 +377,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",
|
||||||
@ -436,8 +469,8 @@ export const Minting = ({
|
|||||||
const confirmReceiver = await getNameOrAddress(receiver);
|
const confirmReceiver = await getNameOrAddress(receiver);
|
||||||
if (confirmReceiver.error)
|
if (confirmReceiver.error)
|
||||||
throw new Error("Invalid receiver address or name");
|
throw new Error("Invalid receiver address or name");
|
||||||
const isInMinterGroup = await checkIfMinterGroup(confirmReceiver)
|
const isInMinterGroup = await checkIfMinterGroup(confirmReceiver);
|
||||||
if(!isInMinterGroup) throw new Error('Account not in Minter Group')
|
if (!isInMinterGroup) throw new Error("Account not in Minter Group");
|
||||||
const publicKey = await getPublicKeyFromAddress(confirmReceiver);
|
const publicKey = await getPublicKeyFromAddress(confirmReceiver);
|
||||||
const findRewardShare = rewardShares?.find(
|
const findRewardShare = rewardShares?.find(
|
||||||
(item) =>
|
(item) =>
|
||||||
@ -520,16 +553,6 @@ export const Minting = ({
|
|||||||
return "" + countBlocksString;
|
return "" + countBlocksString;
|
||||||
};
|
};
|
||||||
|
|
||||||
const showAndCopySponsorshipKey = async (rs) => {
|
|
||||||
try {
|
|
||||||
const sponsorshipKey = await getRewardSharePrivateKey(
|
|
||||||
rs?.rewardSharePublicKey
|
|
||||||
);
|
|
||||||
await showKey({
|
|
||||||
message: sponsorshipKey,
|
|
||||||
});
|
|
||||||
} catch (error) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -550,17 +573,17 @@ export const Minting = ({
|
|||||||
>
|
>
|
||||||
<DialogTitle id="alert-dialog-title">{"Manage your minting"}</DialogTitle>
|
<DialogTitle id="alert-dialog-title">{"Manage your minting"}</DialogTitle>
|
||||||
<IconButton
|
<IconButton
|
||||||
sx={{
|
sx={{
|
||||||
position: 'absolute',
|
position: "absolute",
|
||||||
right: 8,
|
right: 8,
|
||||||
top: 8,
|
top: 8,
|
||||||
}}
|
}}
|
||||||
color="inherit"
|
color="inherit"
|
||||||
onClick={()=> setIsOpenMinting(false)}
|
onClick={() => setIsOpenMinting(false)}
|
||||||
aria-label="close"
|
aria-label="close"
|
||||||
>
|
>
|
||||||
<CloseIcon />
|
<CloseIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<DialogContent
|
<DialogContent
|
||||||
sx={{
|
sx={{
|
||||||
position: "relative",
|
position: "relative",
|
||||||
@ -683,17 +706,6 @@ export const Minting = ({
|
|||||||
<Typography>
|
<Typography>
|
||||||
Minting account: {handleNames(acct?.mintingAccount)}
|
Minting account: {handleNames(acct?.mintingAccount)}
|
||||||
</Typography>
|
</Typography>
|
||||||
{/* <Typography>
|
|
||||||
Recipient account: {handleNames(acct?.recipientAccount)}
|
|
||||||
</Typography> */}
|
|
||||||
{/* {acct?.mintingAccount !== accountInfo?.address &&
|
|
||||||
acct?.recipientAccount === accountInfo?.address &&
|
|
||||||
(accountInfo?.level || 0) > 0 && (
|
|
||||||
<Typography>
|
|
||||||
You have reached level 1+. Remove this minting key and then
|
|
||||||
click "Start Minting".
|
|
||||||
</Typography>
|
|
||||||
)} */}
|
|
||||||
<Button
|
<Button
|
||||||
size="small"
|
size="small"
|
||||||
sx={{
|
sx={{
|
||||||
@ -728,63 +740,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
|
||||||
@ -837,342 +793,39 @@ export const Minting = ({
|
|||||||
</Box>
|
</Box>
|
||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
{/* {isPartOfMintingGroup && (
|
|
||||||
<>
|
|
||||||
{accountInfo?.level >= 5 && (
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
display: "flex",
|
|
||||||
gap: "5px",
|
|
||||||
flexDirection: "column",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{rewardShares?.filter((item) => item?.recipient !== myAddress)
|
|
||||||
?.length > 0 && (
|
|
||||||
<>
|
|
||||||
<Typography>Active sponsorships</Typography>
|
|
||||||
<Card
|
|
||||||
sx={{
|
|
||||||
backgroundColor: "var(--bg-2)",
|
|
||||||
padding: "10px",
|
|
||||||
display: "flex",
|
|
||||||
gap: "5px",
|
|
||||||
flexDirection: "column",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{rewardShares
|
|
||||||
?.filter((item) => item?.recipient !== myAddress)
|
|
||||||
.map((rs) => (
|
|
||||||
<Box
|
|
||||||
key={rs?.recipient}
|
|
||||||
sx={{
|
|
||||||
display: "flex",
|
|
||||||
gap: "10px",
|
|
||||||
flexDirection: "column",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography>
|
|
||||||
Recipient: {handleNames(rs?.recipient)}
|
|
||||||
</Typography>
|
|
||||||
<Typography>
|
|
||||||
Level:{" "}
|
|
||||||
{handleAccountInfos(rs?.recipient, "level")}
|
|
||||||
</Typography>
|
|
||||||
{handleAccountInfos(rs?.recipient, "level") !==
|
|
||||||
undefined && (
|
|
||||||
<>
|
|
||||||
{handleAccountInfos(rs?.recipient, "level") ===
|
|
||||||
0 && (
|
|
||||||
<Typography>
|
|
||||||
Blocks remaining until level 1:{" "}
|
|
||||||
{calculateBlocksRemainingToLevel1(
|
|
||||||
rs?.recipient
|
|
||||||
)}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
{(handleAccountInfos(rs?.recipient, "level") ||
|
|
||||||
0) > 0 && (
|
|
||||||
<Typography>
|
|
||||||
This account is above level 0. You may
|
|
||||||
remove this rewardshare
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
<Button
|
|
||||||
size="small"
|
|
||||||
sx={{
|
|
||||||
backgroundColor: "var(--danger)",
|
|
||||||
color: "black",
|
|
||||||
fontWeight: "bold",
|
|
||||||
opacity: 0.7,
|
|
||||||
maxWidth: "90%",
|
|
||||||
width: "200px",
|
|
||||||
"&:hover": {
|
|
||||||
backgroundColor: "var(--danger)",
|
|
||||||
color: "black",
|
|
||||||
opacity: 1,
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
onClick={() => {
|
|
||||||
handleRemoveRewardShare(rs);
|
|
||||||
}}
|
|
||||||
variant="contained"
|
|
||||||
>
|
|
||||||
Remove reward share
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
size="small"
|
|
||||||
sx={{
|
|
||||||
backgroundColor: "var(--green)",
|
|
||||||
color: "black",
|
|
||||||
fontWeight: "bold",
|
|
||||||
opacity: 0.7,
|
|
||||||
maxWidth: "90%",
|
|
||||||
width: "200px",
|
|
||||||
"&:hover": {
|
|
||||||
backgroundColor: "var(--green)",
|
|
||||||
color: "black",
|
|
||||||
opacity: 1,
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
onClick={() => {
|
|
||||||
showAndCopySponsorshipKey(rs);
|
|
||||||
}}
|
|
||||||
variant="contained"
|
|
||||||
>
|
|
||||||
Copy sponsorship key
|
|
||||||
</Button>
|
|
||||||
<Divider />
|
|
||||||
<Spacer height="10px" />
|
|
||||||
</Box>
|
|
||||||
))}
|
|
||||||
</Card>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Spacer height="10px" />
|
{showWaitDialog && (
|
||||||
|
|
||||||
<Typography>Sponsor a new Minter</Typography>
|
|
||||||
<Card
|
|
||||||
sx={{
|
|
||||||
backgroundColor: "var(--bg-2)",
|
|
||||||
padding: "10px",
|
|
||||||
display: "flex",
|
|
||||||
gap: "5px",
|
|
||||||
flexDirection: "column",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{rewardShares?.filter((item) => item?.recipient !== myAddress)
|
|
||||||
?.length > 0 ? (
|
|
||||||
<>
|
|
||||||
<Typography>
|
|
||||||
You are currently sponsoring one account. To sponsor
|
|
||||||
another account please remove the existing reward share.
|
|
||||||
</Typography>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<Typography>
|
|
||||||
Enter in the new Minter's address or name into the
|
|
||||||
input. Next, click on "Create reward share". If
|
|
||||||
successful, you will see a rewardshare key generated.
|
|
||||||
Copy the key and send it to your new Minter.
|
|
||||||
</Typography>
|
|
||||||
|
|
||||||
<InputBase
|
|
||||||
value={rewardSharePublicKey}
|
|
||||||
onChange={(e) =>
|
|
||||||
setRewardSharePublicKey(e.target.value)
|
|
||||||
}
|
|
||||||
sx={{
|
|
||||||
border: "0.5px solid var(--50-white, #FFFFFF80)",
|
|
||||||
padding: "0px 15px",
|
|
||||||
borderRadius: "5px",
|
|
||||||
height: "36px",
|
|
||||||
width: "350px",
|
|
||||||
maxWidth: "95%",
|
|
||||||
}}
|
|
||||||
placeholder="New minter's address or name"
|
|
||||||
inputProps={{
|
|
||||||
"aria-label": "New minter's address or name",
|
|
||||||
fontSize: "14px",
|
|
||||||
fontWeight: 400,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
size="small"
|
|
||||||
sx={{
|
|
||||||
backgroundColor: "var(--green)",
|
|
||||||
color: "black",
|
|
||||||
fontWeight: "bold",
|
|
||||||
opacity: 0.7,
|
|
||||||
maxWidth: "90%",
|
|
||||||
width: "200px",
|
|
||||||
"&:hover": {
|
|
||||||
backgroundColor: "var(--green)",
|
|
||||||
color: "black",
|
|
||||||
opacity: 1,
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
onClick={() => {
|
|
||||||
createRewardShareForPotentialMinter(
|
|
||||||
rewardSharePublicKey
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
disabled={!rewardSharePublicKey}
|
|
||||||
variant="contained"
|
|
||||||
>
|
|
||||||
Create reward share
|
|
||||||
</Button>
|
|
||||||
{rewardsharekey && (
|
|
||||||
<>
|
|
||||||
<Spacer height="10px" />
|
|
||||||
|
|
||||||
<Typography>
|
|
||||||
Click to copy the reward share key and share it with
|
|
||||||
your new minter
|
|
||||||
</Typography>
|
|
||||||
<Spacer height="10px" />
|
|
||||||
<CopyToClipboard text={rewardsharekey}>
|
|
||||||
<AddressBox
|
|
||||||
sx={{
|
|
||||||
width: "325px",
|
|
||||||
maxWidth: "95%",
|
|
||||||
height: "auto",
|
|
||||||
lineHeight: 1.2,
|
|
||||||
fontSize: "16px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{rewardsharekey} <img src={Copy} />
|
|
||||||
</AddressBox>
|
|
||||||
</CopyToClipboard>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Card>
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
{accountInfo?.level === 0 && !accountIsMinting && (
|
|
||||||
<>
|
|
||||||
<Typography>Become a minter!</Typography>
|
|
||||||
<Card
|
|
||||||
sx={{
|
|
||||||
backgroundColor: "var(--bg-2)",
|
|
||||||
padding: "10px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
display: "flex",
|
|
||||||
gap: "5px",
|
|
||||||
flexDirection: "column",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography>
|
|
||||||
Ask a level 5+ minter to send you a minting key
|
|
||||||
</Typography>
|
|
||||||
<Typography>
|
|
||||||
Add the minting key in the input below and click "Add
|
|
||||||
minting key"
|
|
||||||
</Typography>
|
|
||||||
<Spacer height="10px" />
|
|
||||||
<InputBase
|
|
||||||
value={mintingKey}
|
|
||||||
onChange={(e) => setMintingKey(e.target.value)}
|
|
||||||
sx={{
|
|
||||||
border: "0.5px solid var(--50-white, #FFFFFF80)",
|
|
||||||
padding: "0px 15px",
|
|
||||||
borderRadius: "5px",
|
|
||||||
height: "36px",
|
|
||||||
width: "250px",
|
|
||||||
}}
|
|
||||||
placeholder="Add minting key"
|
|
||||||
inputProps={{
|
|
||||||
"aria-label": "Add minting key",
|
|
||||||
fontSize: "14px",
|
|
||||||
fontWeight: 400,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
size="small"
|
|
||||||
onClick={() => {
|
|
||||||
addMintingAccount(mintingKey);
|
|
||||||
}}
|
|
||||||
sx={{
|
|
||||||
backgroundColor: "var(--green)",
|
|
||||||
color: "black",
|
|
||||||
fontWeight: "bold",
|
|
||||||
opacity: 0.7,
|
|
||||||
maxWidth: "90%",
|
|
||||||
width: "200px",
|
|
||||||
"&:hover": {
|
|
||||||
backgroundColor: "var(--green)",
|
|
||||||
color: "black",
|
|
||||||
opacity: 1,
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
disabled={!mintingKey}
|
|
||||||
variant="contained"
|
|
||||||
>
|
|
||||||
Add minting key
|
|
||||||
</Button>
|
|
||||||
</Box>
|
|
||||||
</Card>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{accountInfo?.level === 0 && accountIsMinting && (
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
display: "flex",
|
|
||||||
gap: "5px",
|
|
||||||
flexDirection: "column",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography>
|
|
||||||
You are currently on your way to level 1
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)} */}
|
|
||||||
{/* {isShow && (
|
|
||||||
<Dialog
|
<Dialog
|
||||||
open={isShow}
|
open={showWaitDialog}
|
||||||
aria-labelledby="alert-dialog-title"
|
aria-labelledby="alert-dialog-title"
|
||||||
aria-describedby="alert-dialog-description"
|
aria-describedby="alert-dialog-description"
|
||||||
>
|
>
|
||||||
<DialogTitle id="alert-dialog-title">
|
<DialogTitle id="alert-dialog-title">
|
||||||
{"Copy sponsorship key"}
|
{isShowNext ? "Confirmed" : "Please Wait"}
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<Typography>
|
{!isShowNext && (
|
||||||
Click to copy the reward share key and share it with your new
|
<Typography>
|
||||||
minter
|
Confirming creation of rewardshare on chain. Please be patient, this could take up to 90 seconds.
|
||||||
</Typography>
|
</Typography>
|
||||||
<Spacer height="10px" />
|
)}
|
||||||
<CopyToClipboard text={message?.message}>
|
{isShowNext && (
|
||||||
<AddressBox
|
<Typography>
|
||||||
sx={{
|
Rewardshare confirmed. Please click Next.
|
||||||
width: "325px",
|
</Typography>
|
||||||
maxWidth: "95%",
|
)}
|
||||||
height: "auto",
|
|
||||||
lineHeight: 1.2,
|
|
||||||
fontSize: "16px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{message?.message} <img src={Copy} />
|
|
||||||
</AddressBox>
|
|
||||||
</CopyToClipboard>
|
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
|
||||||
<Button variant="contained" onClick={onOk} autoFocus>
|
<DialogActions>
|
||||||
Close
|
<Button disabled={!isShowNext} variant="contained" onClick={onOk} autoFocus>
|
||||||
|
Next
|
||||||
</Button>
|
</Button>
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
|
|
||||||
|
|
||||||
</Dialog>
|
</Dialog>
|
||||||
)} */}
|
)}
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button
|
<Button
|
||||||
|
@ -50,6 +50,7 @@ import DeleteTradeOffer from "../transactions/TradeBotDeleteRequest";
|
|||||||
import signTradeBotTransaction from "../transactions/signTradeBotTransaction";
|
import signTradeBotTransaction from "../transactions/signTradeBotTransaction";
|
||||||
import { createTransaction } from "../transactions/transactions";
|
import { createTransaction } from "../transactions/transactions";
|
||||||
import { executeEvent } from "../utils/events";
|
import { executeEvent } from "../utils/events";
|
||||||
|
import { fileToBase64 } from "../utils/fileReading";
|
||||||
import { mimeToExtensionMap } from "../utils/memeTypes";
|
import { mimeToExtensionMap } from "../utils/memeTypes";
|
||||||
import utils from "../utils/utils";
|
import utils from "../utils/utils";
|
||||||
|
|
||||||
@ -396,8 +397,8 @@ export const getUserAccount = async ({ isFromExtension, appInfo }) => {
|
|||||||
export const encryptData = async (data, sender) => {
|
export const encryptData = async (data, sender) => {
|
||||||
let data64 = data.data64 || data.base64;
|
let data64 = data.data64 || data.base64;
|
||||||
let publicKeys = data.publicKeys || [];
|
let publicKeys = data.publicKeys || [];
|
||||||
if (data.fileId) {
|
if (data?.file || data?.blob) {
|
||||||
data64 = await getFileFromContentScript(data.fileId);
|
data64 = await fileToBase64(data?.file || data?.blob);
|
||||||
}
|
}
|
||||||
if (!data64) {
|
if (!data64) {
|
||||||
throw new Error("Please include data to encrypt");
|
throw new Error("Please include data to encrypt");
|
||||||
@ -427,8 +428,8 @@ export const encryptQortalGroupData = async (data, sender) => {
|
|||||||
if(!groupId){
|
if(!groupId){
|
||||||
throw new Error('Please provide a groupId')
|
throw new Error('Please provide a groupId')
|
||||||
}
|
}
|
||||||
if (data.fileId) {
|
if (data?.file || data?.blob) {
|
||||||
data64 = await getFileFromContentScript(data.fileId);
|
data64 = await fileToBase64(data?.file || data?.blob);
|
||||||
}
|
}
|
||||||
if (!data64) {
|
if (!data64) {
|
||||||
throw new Error("Please include data to encrypt");
|
throw new Error("Please include data to encrypt");
|
||||||
@ -611,8 +612,8 @@ url
|
|||||||
export const encryptDataWithSharingKey = async (data, sender) => {
|
export const encryptDataWithSharingKey = async (data, sender) => {
|
||||||
let data64 = data.data64;
|
let data64 = data.data64;
|
||||||
let publicKeys = data.publicKeys || [];
|
let publicKeys = data.publicKeys || [];
|
||||||
if (data.fileId) {
|
if (data?.file || data?.blob) {
|
||||||
data64 = await getFileFromContentScript(data.fileId);
|
data64 = await fileToBase64(data?.file || data?.blob);
|
||||||
}
|
}
|
||||||
if (!data64) {
|
if (!data64) {
|
||||||
throw new Error("Please include data to encrypt");
|
throw new Error("Please include data to encrypt");
|
||||||
@ -962,7 +963,7 @@ export const publishQDNResource = async (
|
|||||||
const errorMsg = `Missing fields: ${missingFieldsString}`;
|
const errorMsg = `Missing fields: ${missingFieldsString}`;
|
||||||
throw new Error(errorMsg);
|
throw new Error(errorMsg);
|
||||||
}
|
}
|
||||||
if (!data.fileId && !data.data64 && !data.base64) {
|
if (!data.file && !data.data64 && !data.base64) {
|
||||||
throw new Error("No data or file was submitted");
|
throw new Error("No data or file was submitted");
|
||||||
}
|
}
|
||||||
// Use "default" if user hasn't specified an identifer
|
// Use "default" if user hasn't specified an identifer
|
||||||
@ -999,8 +1000,8 @@ const { tag1, tag2, tag3, tag4, tag5 } = result;
|
|||||||
if (data.identifier == null) {
|
if (data.identifier == null) {
|
||||||
identifier = "default";
|
identifier = "default";
|
||||||
}
|
}
|
||||||
if (data.fileId) {
|
if (data?.file || data?.blob) {
|
||||||
data64 = await getFileFromContentScript(data.fileId);
|
data64 = await fileToBase64(data?.file || data?.blob);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
data.encrypt &&
|
data.encrypt &&
|
||||||
@ -1297,7 +1298,7 @@ export const publishMultipleQDNResources = async (
|
|||||||
});
|
});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!resource.fileId && !resource.data64 && !resource?.base64) {
|
if (!resource.file && !resource.data64 && !resource?.base64) {
|
||||||
const errorMsg = "No data or file was submitted";
|
const errorMsg = "No data or file was submitted";
|
||||||
failedPublishesIdentifiers.push({
|
failedPublishesIdentifiers.push({
|
||||||
reason: errorMsg,
|
reason: errorMsg,
|
||||||
@ -1334,8 +1335,8 @@ export const publishMultipleQDNResources = async (
|
|||||||
});
|
});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (resource.fileId) {
|
if (resource.file) {
|
||||||
data64 = await getFileFromContentScript(resource.fileId);
|
data64 = await fileToBase64(resource.file);
|
||||||
}
|
}
|
||||||
if (resourceEncrypt) {
|
if (resourceEncrypt) {
|
||||||
try {
|
try {
|
||||||
@ -1800,7 +1801,6 @@ export const saveFile = async (data, sender, isFromExtension, snackMethods) => {
|
|||||||
}
|
}
|
||||||
const filename = data.filename;
|
const filename = data.filename;
|
||||||
const blob = data.blob;
|
const blob = data.blob;
|
||||||
const fileId = data.fileId;
|
|
||||||
const resPermission = await getUserPermission(
|
const resPermission = await getUserPermission(
|
||||||
{
|
{
|
||||||
text1: "Would you like to download:",
|
text1: "Would you like to download:",
|
||||||
@ -2424,7 +2424,7 @@ export const getForeignFee = 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);
|
||||||
|
@ -29,32 +29,28 @@ let semaphore = new Semaphore(1)
|
|||||||
let reader = new FileReader()
|
let reader = new FileReader()
|
||||||
|
|
||||||
export const fileToBase64 = (file) => new Promise(async (resolve, reject) => {
|
export const fileToBase64 = (file) => new Promise(async (resolve, reject) => {
|
||||||
if (!reader) {
|
const reader = new FileReader(); // Create a new instance
|
||||||
reader = new FileReader()
|
await semaphore.acquire();
|
||||||
}
|
reader.readAsDataURL(file);
|
||||||
await semaphore.acquire()
|
|
||||||
reader.readAsDataURL(file)
|
|
||||||
reader.onload = () => {
|
reader.onload = () => {
|
||||||
const dataUrl = reader.result
|
const dataUrl = reader.result;
|
||||||
if (typeof dataUrl === "string") {
|
semaphore.release();
|
||||||
const base64String = dataUrl.split(',')[1]
|
if (typeof dataUrl === 'string') {
|
||||||
reader.onload = null
|
resolve(dataUrl.split(',')[1]);
|
||||||
reader.onerror = null
|
} else {
|
||||||
resolve(base64String)
|
reject(new Error('Invalid data URL'));
|
||||||
} else {
|
}
|
||||||
reader.onload = null
|
reader.onload = null; // Clear the handler
|
||||||
reader.onerror = null
|
reader.onerror = null; // Clear the handle
|
||||||
reject(new Error('Invalid data URL'))
|
};
|
||||||
}
|
|
||||||
semaphore.release()
|
|
||||||
}
|
|
||||||
reader.onerror = (error) => {
|
reader.onerror = (error) => {
|
||||||
reader.onload = null
|
semaphore.release();
|
||||||
reader.onerror = null
|
reject(error);
|
||||||
reject(error)
|
reader.onload = null; // Clear the handler
|
||||||
semaphore.release()
|
reader.onerror = null; // Clear the handle
|
||||||
}
|
};
|
||||||
})
|
});
|
||||||
|
|
||||||
|
|
||||||
export const base64ToBlobUrl = (base64, mimeType = "image/png") => {
|
export const base64ToBlobUrl = (base64, mimeType = "image/png") => {
|
||||||
const binary = atob(base64);
|
const binary = atob(base64);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user