mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-04-28 13:57:51 +00:00
Compare commits
8 Commits
v0.5.4-pre
...
feature/in
Author | SHA1 | Date | |
---|---|---|---|
2e55c16f41 | |||
eb822cbcb4 | |||
8f8b7fc0cd | |||
534301294e | |||
7e7e914cf9 | |||
63c96f5ea0 | |||
15f6acfda1 | |||
9d890cdcd5 |
56
src/App.tsx
56
src/App.tsx
@ -19,6 +19,7 @@ import {
|
||||
DialogContent,
|
||||
DialogContentText,
|
||||
DialogTitle,
|
||||
FormControlLabel,
|
||||
Input,
|
||||
InputLabel,
|
||||
Popover,
|
||||
@ -48,6 +49,7 @@ import CloseIcon from "@mui/icons-material/Close";
|
||||
import './utils/seedPhrase/RandomSentenceGenerator';
|
||||
import EngineeringIcon from '@mui/icons-material/Engineering';
|
||||
import AccountBalanceWalletIcon from '@mui/icons-material/AccountBalanceWallet';
|
||||
import PriorityHighIcon from '@mui/icons-material/PriorityHigh';
|
||||
import {
|
||||
createAccount,
|
||||
generateRandomSentence,
|
||||
@ -427,6 +429,7 @@ function App() {
|
||||
});
|
||||
const [useLocalNode, setUseLocalNode] = useState(false);
|
||||
|
||||
const [confirmRequestRead, setConfirmRequestRead] = useState(false);
|
||||
const [isSettingsOpen, setIsSettingsOpen] = useState(false);
|
||||
const [showSeed, setShowSeed] = useState(false)
|
||||
const [creationStep, setCreationStep] = useState(1)
|
||||
@ -798,6 +801,7 @@ function App() {
|
||||
qortalRequestCheckbox1Ref.current =
|
||||
message?.payload?.checkbox1?.value || false;
|
||||
}
|
||||
setConfirmRequestRead(false)
|
||||
await showQortalRequestExtension(message?.payload);
|
||||
|
||||
if (qortalRequestCheckbox1Ref.current) {
|
||||
@ -2043,11 +2047,13 @@ function App() {
|
||||
justifyContent: "flex-start",
|
||||
paddingLeft: "22px",
|
||||
boxSizing: "border-box",
|
||||
maxWidth: '700px'
|
||||
}}
|
||||
>
|
||||
<img
|
||||
style={{
|
||||
cursor: "pointer",
|
||||
height: '24px'
|
||||
}}
|
||||
onClick={returnToMain}
|
||||
src={Return}
|
||||
@ -2546,11 +2552,13 @@ function App() {
|
||||
justifyContent: "flex-start",
|
||||
paddingLeft: "22px",
|
||||
boxSizing: "border-box",
|
||||
maxWidth: '700px'
|
||||
}}
|
||||
>
|
||||
<img
|
||||
style={{
|
||||
cursor: "pointer",
|
||||
height: '24px'
|
||||
}}
|
||||
onClick={() => {
|
||||
setRawWallet(null);
|
||||
@ -2574,11 +2582,13 @@ function App() {
|
||||
justifyContent: "flex-start",
|
||||
paddingLeft: "22px",
|
||||
boxSizing: "border-box",
|
||||
maxWidth: '700px'
|
||||
}}
|
||||
>
|
||||
<img
|
||||
style={{
|
||||
cursor: "pointer",
|
||||
height: '24px'
|
||||
}}
|
||||
onClick={() => {
|
||||
setRawWallet(null);
|
||||
@ -2679,11 +2689,13 @@ function App() {
|
||||
justifyContent: "flex-start",
|
||||
paddingLeft: "22px",
|
||||
boxSizing: "border-box",
|
||||
maxWidth: '700px'
|
||||
}}
|
||||
>
|
||||
<img
|
||||
style={{
|
||||
cursor: "pointer",
|
||||
height: '24px'
|
||||
}}
|
||||
onClick={returnToMain}
|
||||
src={Return}
|
||||
@ -2769,11 +2781,13 @@ function App() {
|
||||
justifyContent: "flex-start",
|
||||
paddingLeft: "22px",
|
||||
boxSizing: "border-box",
|
||||
maxWidth: '700px'
|
||||
}}
|
||||
>
|
||||
<img
|
||||
style={{
|
||||
cursor: "pointer",
|
||||
height: '24px'
|
||||
}}
|
||||
onClick={() => {
|
||||
if(creationStep === 2){
|
||||
@ -3205,7 +3219,7 @@ function App() {
|
||||
>
|
||||
<CountdownCircleTimer
|
||||
isPlaying
|
||||
duration={30}
|
||||
duration={60}
|
||||
colors={["#004777", "#F7B801", "#A30000", "#A30000"]}
|
||||
colorsTime={[7, 5, 2, 0]}
|
||||
onComplete={() => {
|
||||
@ -3438,6 +3452,36 @@ function App() {
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{messageQortalRequestExtension?.confirmCheckbox && (
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
onChange={(e) => setConfirmRequestRead(e.target.checked)}
|
||||
checked={confirmRequestRead}
|
||||
edge="start"
|
||||
tabIndex={-1}
|
||||
disableRipple
|
||||
sx={{
|
||||
"&.Mui-checked": {
|
||||
color: "white",
|
||||
},
|
||||
"& .MuiSvgIcon-root": {
|
||||
color: "white",
|
||||
},
|
||||
}}
|
||||
/>
|
||||
}
|
||||
label={
|
||||
<Box sx={{ display: 'flex', alignItems: 'center' }}>
|
||||
<Typography sx={{ fontSize: "14px" }}>
|
||||
I have read this request
|
||||
</Typography>
|
||||
<PriorityHighIcon color="warning" />
|
||||
</Box>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
<Spacer height="29px" />
|
||||
<Box
|
||||
sx={{
|
||||
@ -3451,8 +3495,16 @@ function App() {
|
||||
bgColor="var(--green)"
|
||||
sx={{
|
||||
minWidth: "102px",
|
||||
opacity: messageQortalRequestExtension?.confirmCheckbox && !confirmRequestRead ? 0.1 : 0.7,
|
||||
cursor: messageQortalRequestExtension?.confirmCheckbox && !confirmRequestRead ? 'default' : 'pointer',
|
||||
"&:hover": {
|
||||
opacity: messageQortalRequestExtension?.confirmCheckbox && !confirmRequestRead ? 0.1 : 1,
|
||||
}
|
||||
}}
|
||||
onClick={() => {
|
||||
if(messageQortalRequestExtension?.confirmCheckbox && !confirmRequestRead) return
|
||||
onOkQortalRequestExtension("accepted")
|
||||
}}
|
||||
onClick={() => onOkQortalRequestExtension("accepted")}
|
||||
>
|
||||
accept
|
||||
</CustomButtonAccept>
|
||||
|
@ -2,48 +2,61 @@ import { atom, selectorFamily } from 'recoil';
|
||||
|
||||
|
||||
export const sortablePinnedAppsAtom = atom({
|
||||
key: 'sortablePinnedAppsFromAtom',
|
||||
default: [{
|
||||
name: 'Q-Tube',
|
||||
service: 'APP'
|
||||
}, {
|
||||
name: 'Q-Mail',
|
||||
service: 'APP'
|
||||
}, {
|
||||
name: 'Q-Share',
|
||||
service: 'APP'
|
||||
}, {
|
||||
name: 'Q-Fund',
|
||||
service: 'APP'
|
||||
}, {
|
||||
name: 'Q-Shop',
|
||||
service: 'APP'
|
||||
},
|
||||
{
|
||||
name: 'Q-Trade',
|
||||
service: 'APP'
|
||||
},
|
||||
{
|
||||
name: 'Q-Support',
|
||||
service: 'APP'
|
||||
},
|
||||
{
|
||||
name: 'Q-Manager',
|
||||
service: 'APP'
|
||||
},
|
||||
{
|
||||
name: 'Q-Blog',
|
||||
service: 'APP'
|
||||
},
|
||||
{
|
||||
name: 'Q-Mintership',
|
||||
service: 'APP'
|
||||
},
|
||||
{
|
||||
name: 'Q-Wallets',
|
||||
service: 'APP'
|
||||
}
|
||||
],
|
||||
key: 'sortablePinnedAppsFromAtom',
|
||||
default: [
|
||||
{
|
||||
name: 'Q-Tube',
|
||||
service: 'APP',
|
||||
},
|
||||
{
|
||||
name: 'Q-Mail',
|
||||
service: 'APP',
|
||||
},
|
||||
{
|
||||
name: 'Q-Share',
|
||||
service: 'APP',
|
||||
},
|
||||
{
|
||||
name: 'Q-Fund',
|
||||
service: 'APP',
|
||||
},
|
||||
{
|
||||
name: 'Q-Shop',
|
||||
service: 'APP',
|
||||
},
|
||||
{
|
||||
name: 'Q-Trade',
|
||||
service: 'APP',
|
||||
},
|
||||
{
|
||||
name: 'Q-Support',
|
||||
service: 'APP',
|
||||
},
|
||||
{
|
||||
name: 'Q-Manager',
|
||||
service: 'APP',
|
||||
},
|
||||
{
|
||||
name: 'Q-Blog',
|
||||
service: 'APP',
|
||||
},
|
||||
{
|
||||
name: 'Q-Mintership',
|
||||
service: 'APP',
|
||||
},
|
||||
{
|
||||
name: 'Q-Wallets',
|
||||
service: 'APP',
|
||||
},
|
||||
{
|
||||
name: 'Q-Search',
|
||||
service: 'APP',
|
||||
},
|
||||
{
|
||||
name: 'Q-Nodecontrol',
|
||||
service: 'APP'
|
||||
}
|
||||
],
|
||||
});
|
||||
|
||||
export const canSaveSettingToQdnAtom = atom({
|
||||
@ -173,4 +186,9 @@ export const mailsAtom = atom({
|
||||
export const groupsPropertiesAtom = atom({
|
||||
key: 'groupsPropertiesAtom',
|
||||
default: {},
|
||||
});
|
||||
|
||||
export const isOpenBlockedModalAtom = atom({
|
||||
key: 'isOpenBlockedModalAtom',
|
||||
default: false,
|
||||
});
|
@ -2309,6 +2309,146 @@ export async function createGroup({
|
||||
throw new Error(res?.message || "Transaction was not able to be processed");
|
||||
return res;
|
||||
}
|
||||
export async function sellName({
|
||||
name,
|
||||
sellPrice
|
||||
}) {
|
||||
const wallet = await getSaveWallet();
|
||||
const address = wallet.address0;
|
||||
if (!address) throw new Error("Cannot find user");
|
||||
const lastReference = await getLastRef();
|
||||
const feeres = await getFee("SELL_NAME");
|
||||
const resKeyPair = await getKeyPair();
|
||||
const parsedData = resKeyPair;
|
||||
const uint8PrivateKey = Base58.decode(parsedData.privateKey);
|
||||
const uint8PublicKey = Base58.decode(parsedData.publicKey);
|
||||
const keyPair = {
|
||||
privateKey: uint8PrivateKey,
|
||||
publicKey: uint8PublicKey,
|
||||
};
|
||||
|
||||
const tx = await createTransaction(5, keyPair, {
|
||||
fee: feeres.fee,
|
||||
name,
|
||||
sellPrice: sellPrice,
|
||||
lastReference: lastReference,
|
||||
});
|
||||
|
||||
const signedBytes = Base58.encode(tx.signedBytes);
|
||||
|
||||
const res = await processTransactionVersion2(signedBytes);
|
||||
if (!res?.signature)
|
||||
throw new Error(res?.message || "Transaction was not able to be processed");
|
||||
return res;
|
||||
}
|
||||
|
||||
export async function cancelSellName({
|
||||
name
|
||||
}) {
|
||||
const wallet = await getSaveWallet();
|
||||
const address = wallet.address0;
|
||||
if (!address) throw new Error("Cannot find user");
|
||||
const lastReference = await getLastRef();
|
||||
const feeres = await getFee("SELL_NAME");
|
||||
const resKeyPair = await getKeyPair();
|
||||
const parsedData = resKeyPair;
|
||||
const uint8PrivateKey = Base58.decode(parsedData.privateKey);
|
||||
const uint8PublicKey = Base58.decode(parsedData.publicKey);
|
||||
const keyPair = {
|
||||
privateKey: uint8PrivateKey,
|
||||
publicKey: uint8PublicKey,
|
||||
};
|
||||
|
||||
const tx = await createTransaction(6, keyPair, {
|
||||
fee: feeres.fee,
|
||||
name,
|
||||
lastReference: lastReference,
|
||||
});
|
||||
|
||||
const signedBytes = Base58.encode(tx.signedBytes);
|
||||
|
||||
const res = await processTransactionVersion2(signedBytes);
|
||||
if (!res?.signature)
|
||||
throw new Error(res?.message || "Transaction was not able to be processed");
|
||||
return res;
|
||||
}
|
||||
|
||||
export async function buyName({
|
||||
name,
|
||||
sellerAddress,
|
||||
sellPrice
|
||||
}) {
|
||||
const wallet = await getSaveWallet();
|
||||
const address = wallet.address0;
|
||||
if (!address) throw new Error("Cannot find user");
|
||||
const lastReference = await getLastRef();
|
||||
const feeres = await getFee("BUY_NAME");
|
||||
const resKeyPair = await getKeyPair();
|
||||
const parsedData = resKeyPair;
|
||||
const uint8PrivateKey = Base58.decode(parsedData.privateKey);
|
||||
const uint8PublicKey = Base58.decode(parsedData.publicKey);
|
||||
const keyPair = {
|
||||
privateKey: uint8PrivateKey,
|
||||
publicKey: uint8PublicKey,
|
||||
};
|
||||
|
||||
const tx = await createTransaction(7, keyPair, {
|
||||
fee: feeres.fee,
|
||||
name,
|
||||
sellPrice,
|
||||
recipient: sellerAddress,
|
||||
lastReference: lastReference,
|
||||
});
|
||||
|
||||
const signedBytes = Base58.encode(tx.signedBytes);
|
||||
|
||||
const res = await processTransactionVersion2(signedBytes);
|
||||
if (!res?.signature)
|
||||
throw new Error(res?.message || "Transaction was not able to be processed");
|
||||
return res;
|
||||
}
|
||||
export async function updateGroup({
|
||||
groupId,
|
||||
newOwner,
|
||||
newIsOpen,
|
||||
newDescription,
|
||||
newApprovalThreshold,
|
||||
newMinimumBlockDelay,
|
||||
newMaximumBlockDelay
|
||||
}) {
|
||||
const wallet = await getSaveWallet();
|
||||
const address = wallet.address0;
|
||||
if (!address) throw new Error("Cannot find user");
|
||||
const lastReference = await getLastRef();
|
||||
const feeres = await getFee("UPDATE_GROUP");
|
||||
const resKeyPair = await getKeyPair();
|
||||
const parsedData = resKeyPair;
|
||||
const uint8PrivateKey = Base58.decode(parsedData.privateKey);
|
||||
const uint8PublicKey = Base58.decode(parsedData.publicKey);
|
||||
const keyPair = {
|
||||
privateKey: uint8PrivateKey,
|
||||
publicKey: uint8PublicKey,
|
||||
};
|
||||
|
||||
const tx = await createTransaction(23, keyPair, {
|
||||
fee: feeres.fee,
|
||||
_groupId: groupId,
|
||||
newOwner,
|
||||
newIsOpen,
|
||||
newDescription,
|
||||
newApprovalThreshold,
|
||||
newMinimumBlockDelay,
|
||||
newMaximumBlockDelay,
|
||||
lastReference: lastReference,
|
||||
});
|
||||
|
||||
const signedBytes = Base58.encode(tx.signedBytes);
|
||||
|
||||
const res = await processTransactionVersion2(signedBytes);
|
||||
if (!res?.signature)
|
||||
throw new Error(res?.message || "Transaction was not able to be processed");
|
||||
return res;
|
||||
}
|
||||
export async function inviteToGroup({ groupId, qortalAddress, inviteTime }) {
|
||||
const address = await getNameOrAddress(qortalAddress);
|
||||
if (!address) throw new Error("Cannot find user");
|
||||
|
@ -41,7 +41,9 @@ const officialAppList = [
|
||||
"q-trade",
|
||||
"q-support",
|
||||
"q-manager",
|
||||
"q-wallets"
|
||||
"q-wallets",
|
||||
"q-search",
|
||||
"q-nodecontrol"
|
||||
];
|
||||
|
||||
const ScrollerStyled = styled('div')({
|
||||
|
@ -49,7 +49,9 @@ const officialAppList = [
|
||||
"q-trade",
|
||||
"q-support",
|
||||
"q-manager",
|
||||
"q-wallets"
|
||||
"q-wallets",
|
||||
"q-search",
|
||||
"q-nodecontrol"
|
||||
];
|
||||
|
||||
const ScrollerStyled = styled("div")({
|
||||
|
@ -33,17 +33,19 @@ import { Virtuoso } from "react-virtuoso";
|
||||
import { executeEvent } from "../../utils/events";
|
||||
import { ComposeP, MailIconImg, ShowMessageReturnButton } from "../Group/Forum/Mail-styles";
|
||||
const officialAppList = [
|
||||
"q-tube",
|
||||
"q-blog",
|
||||
"q-share",
|
||||
"q-support",
|
||||
"q-mail",
|
||||
"q-fund",
|
||||
"q-shop",
|
||||
"q-trade",
|
||||
"q-support",
|
||||
"q-manager",
|
||||
"q-wallets"
|
||||
'q-tube',
|
||||
'q-blog',
|
||||
'q-share',
|
||||
'q-support',
|
||||
'q-mail',
|
||||
'q-fund',
|
||||
'q-shop',
|
||||
'q-trade',
|
||||
'q-support',
|
||||
'q-manager',
|
||||
'q-wallets',
|
||||
'q-search',
|
||||
"q-nodecontrol"
|
||||
];
|
||||
|
||||
const ScrollerStyled = styled('div')({
|
||||
|
@ -48,18 +48,20 @@ import { AppsNavBarDesktop } from "./AppsNavBarDesktop";
|
||||
import ReturnSVG from '../../assets/svgs/Return.svg'
|
||||
import { ComposeP, MailIconImg, ShowMessageReturnButton } from "../Group/Forum/Mail-styles";
|
||||
const officialAppList = [
|
||||
"q-tube",
|
||||
"q-blog",
|
||||
"q-share",
|
||||
"q-support",
|
||||
"q-mail",
|
||||
"q-fund",
|
||||
"q-shop",
|
||||
"q-trade",
|
||||
"q-support",
|
||||
"q-manager",
|
||||
"q-mintership",
|
||||
"q-wallets"
|
||||
'q-tube',
|
||||
'q-blog',
|
||||
'q-share',
|
||||
'q-support',
|
||||
'q-mail',
|
||||
'q-fund',
|
||||
'q-shop',
|
||||
'q-trade',
|
||||
'q-support',
|
||||
'q-manager',
|
||||
'q-mintership',
|
||||
'q-wallets',
|
||||
'q-search',
|
||||
"q-nodecontrol"
|
||||
];
|
||||
|
||||
const ScrollerStyled = styled("div")({
|
||||
|
@ -255,7 +255,11 @@ export const listOfAllQortalRequests = [
|
||||
'GET_NODE_INFO',
|
||||
'GET_NODE_STATUS',
|
||||
'GET_ARRR_SYNC_STATUS',
|
||||
'SHOW_PDF_READER'
|
||||
'SHOW_PDF_READER',
|
||||
'UPDATE_GROUP',
|
||||
'SELL_NAME',
|
||||
'CANCEL_SELL_NAME',
|
||||
'BUY_NAME'
|
||||
]
|
||||
|
||||
export const UIQortalRequests = [
|
||||
@ -311,7 +315,11 @@ export const UIQortalRequests = [
|
||||
'GET_NODE_INFO',
|
||||
'GET_NODE_STATUS',
|
||||
'GET_ARRR_SYNC_STATUS',
|
||||
'SHOW_PDF_READER'
|
||||
'SHOW_PDF_READER',
|
||||
'UPDATE_GROUP',
|
||||
'SELL_NAME',
|
||||
'CANCEL_SELL_NAME',
|
||||
'BUY_NAME'
|
||||
];
|
||||
|
||||
|
||||
@ -575,7 +583,7 @@ isDOMContentLoaded: false
|
||||
result: null,
|
||||
error: {
|
||||
error: response?.error,
|
||||
message: typeof response?.error === 'string' ? response?.error : 'An error has occurred'
|
||||
message: typeof response?.error === 'string' ? response?.error : typeof response?.message === 'string' ? response?.message : 'An error has occurred'
|
||||
},
|
||||
});
|
||||
} else {
|
||||
|
@ -79,7 +79,7 @@ export const AdminSpaceInner = ({
|
||||
const res = await fetch(
|
||||
`${getBaseApiReact()}/arbitrary/DOCUMENT_PRIVATE/${
|
||||
getLatestPublish.name
|
||||
}/${getLatestPublish.identifier}?encoding=base64`
|
||||
}/${getLatestPublish.identifier}?encoding=base64&rebuild=true`
|
||||
);
|
||||
data = await res.text();
|
||||
|
||||
|
@ -66,7 +66,7 @@ export const CreateCommonSecret = ({groupId, secretKey, isOwner, myAddress, sec
|
||||
const res = await fetch(
|
||||
`${getBaseApiReact()}/arbitrary/DOCUMENT_PRIVATE/${publish.name}/${
|
||||
publish.identifier
|
||||
}?encoding=base64`
|
||||
}?encoding=base64&rebuild=true`
|
||||
);
|
||||
const data = await res.text();
|
||||
|
||||
|
@ -10,15 +10,23 @@ import {
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import React, { useContext, useEffect, useState } from "react";
|
||||
import { MyContext } from "../../App";
|
||||
import { getBaseApiReact, MyContext } from "../../App";
|
||||
import { Spacer } from "../../common/Spacer";
|
||||
import { executeEvent } from "../../utils/events";
|
||||
|
||||
export const BlockedUsersModal = ({ close }) => {
|
||||
import { executeEvent, subscribeToEvent, unsubscribeFromEvent } from "../../utils/events";
|
||||
import { validateAddress } from "../../utils/validateAddress";
|
||||
import { getNameInfo, requestQueueMemberNames } from "./Group";
|
||||
import { useModal } from "../../common/useModal";
|
||||
import { useRecoilState } from "recoil";
|
||||
import { isOpenBlockedModalAtom } from "../../atoms/global";
|
||||
import InfoIcon from '@mui/icons-material/Info';
|
||||
export const BlockedUsersModal = () => {
|
||||
const [isOpenBlockedModal, setIsOpenBlockedModal] = useRecoilState(isOpenBlockedModalAtom)
|
||||
const [hasChanged, setHasChanged] = useState(false);
|
||||
const [value, setValue] = useState("");
|
||||
|
||||
const { getAllBlockedUsers, removeBlockFromList, addToBlockList } = useContext(MyContext);
|
||||
const [addressesWithNames, setAddressesWithNames] = useState({})
|
||||
const { isShow, onCancel, onOk, show, message } = useModal();
|
||||
const { getAllBlockedUsers, removeBlockFromList, addToBlockList, setOpenSnackGlobal, setInfoSnackCustom } =
|
||||
useContext(MyContext);
|
||||
const [blockedUsers, setBlockedUsers] = useState({
|
||||
addresses: {},
|
||||
names: {},
|
||||
@ -28,60 +36,162 @@ export const BlockedUsersModal = ({ close }) => {
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if(!isOpenBlockedModal) return
|
||||
fetchBlockedUsers();
|
||||
}, []);
|
||||
}, [isOpenBlockedModal]);
|
||||
|
||||
const getNames = async () => {
|
||||
// const validApi = await findUsableApi();
|
||||
const addresses = Object.keys(blockedUsers?.addresses)
|
||||
const addressNames = {}
|
||||
|
||||
|
||||
const getMemNames = addresses.map(async (address) => {
|
||||
const name = await requestQueueMemberNames.enqueue(() => {
|
||||
return getNameInfo(address);
|
||||
});
|
||||
if (name) {
|
||||
addressNames[address] = name
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
await Promise.all(getMemNames);
|
||||
|
||||
setAddressesWithNames(addressNames)
|
||||
};
|
||||
|
||||
const blockUser = async (e, user?: string) => {
|
||||
try {
|
||||
const valUser = user || value
|
||||
if (!valUser) return;
|
||||
const isAddress = validateAddress(valUser);
|
||||
let userName = null;
|
||||
let userAddress = null;
|
||||
if (isAddress) {
|
||||
userAddress = valUser;
|
||||
const name = await getNameInfo(valUser);
|
||||
if (name) {
|
||||
userName = name;
|
||||
}
|
||||
}
|
||||
if (!isAddress) {
|
||||
const response = await fetch(`${getBaseApiReact()}/names/${valUser}`);
|
||||
const data = await response.json();
|
||||
if (!data?.owner) throw new Error("Name does not exist");
|
||||
if (data?.owner) {
|
||||
userAddress = data.owner;
|
||||
userName = valUser;
|
||||
}
|
||||
}
|
||||
if(!userName){
|
||||
await addToBlockList(userAddress, null);
|
||||
fetchBlockedUsers();
|
||||
setHasChanged(true);
|
||||
executeEvent('updateChatMessagesWithBlocks', true)
|
||||
setValue('')
|
||||
return
|
||||
}
|
||||
const responseModal = await show({
|
||||
userName,
|
||||
userAddress,
|
||||
});
|
||||
if (responseModal === "both") {
|
||||
await addToBlockList(userAddress, userName);
|
||||
} else if (responseModal === "address") {
|
||||
await addToBlockList(userAddress, null);
|
||||
} else if (responseModal === "name") {
|
||||
await addToBlockList(null, userName);
|
||||
}
|
||||
fetchBlockedUsers();
|
||||
setHasChanged(true);
|
||||
setValue('')
|
||||
if(user){
|
||||
setIsOpenBlockedModal(false)
|
||||
}
|
||||
if(responseModal === 'both' || responseModal === 'address'){
|
||||
executeEvent('updateChatMessagesWithBlocks', true)
|
||||
}
|
||||
} catch (error) {
|
||||
setOpenSnackGlobal(true);
|
||||
|
||||
setInfoSnackCustom({
|
||||
type: "error",
|
||||
message: error?.message || "Unable to block user",
|
||||
});
|
||||
}
|
||||
};
|
||||
const blockUserFromOutsideModalFunc = (e) => {
|
||||
const user = e.detail?.user;
|
||||
setIsOpenBlockedModal(true)
|
||||
blockUser(null, user)
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
subscribeToEvent("blockUserFromOutside", blockUserFromOutsideModalFunc);
|
||||
|
||||
return () => {
|
||||
unsubscribeFromEvent("blockUserFromOutside", blockUserFromOutsideModalFunc);
|
||||
};
|
||||
}, []);
|
||||
return (
|
||||
<Dialog
|
||||
open={true}
|
||||
open={isOpenBlockedModal}
|
||||
aria-labelledby="alert-dialog-title"
|
||||
aria-describedby="alert-dialog-description"
|
||||
>
|
||||
<DialogTitle>Blocked Users</DialogTitle>
|
||||
<DialogContent sx={{
|
||||
padding: '20px'
|
||||
}}>
|
||||
<Box
|
||||
|
||||
sx={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
gap: "10px",
|
||||
<DialogTitle>Blocked Users</DialogTitle>
|
||||
<DialogContent
|
||||
sx={{
|
||||
padding: "20px",
|
||||
}}
|
||||
>
|
||||
<TextField
|
||||
placeholder="Name"
|
||||
value={value}
|
||||
onChange={(e) => {
|
||||
setValue(e.target.value);
|
||||
>
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
gap: "10px",
|
||||
}}
|
||||
/>
|
||||
<Button variant="contained" onClick={async ()=> {
|
||||
try {
|
||||
if(!value) return
|
||||
await addToBlockList(undefined, value)
|
||||
fetchBlockedUsers()
|
||||
setHasChanged(true)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}}>Block</Button>
|
||||
</Box>
|
||||
|
||||
>
|
||||
<TextField
|
||||
placeholder="Name or address"
|
||||
value={value}
|
||||
onChange={(e) => {
|
||||
setValue(e.target.value);
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
sx={{
|
||||
flexShrink: 0,
|
||||
}}
|
||||
variant="contained"
|
||||
onClick={blockUser}
|
||||
>
|
||||
Block
|
||||
</Button>
|
||||
</Box>
|
||||
|
||||
{Object.entries(blockedUsers?.addresses).length > 0 && (
|
||||
<>
|
||||
<Spacer height="20px" />
|
||||
<DialogContentText id="alert-dialog-description">
|
||||
Blocked Users for Chat ( addresses )
|
||||
Blocked addresses- blocks processing of txs
|
||||
</DialogContentText>
|
||||
<Spacer height="10px" />
|
||||
<Button variant="contained" size="small" onClick={getNames}>Fetch names</Button>
|
||||
<Spacer height="10px" />
|
||||
</>
|
||||
)}
|
||||
|
||||
<Box sx={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '10px'
|
||||
}}>
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
gap: "10px",
|
||||
}}
|
||||
>
|
||||
{Object.entries(blockedUsers?.addresses || {})?.map(
|
||||
([key, value]) => {
|
||||
return (
|
||||
@ -90,18 +200,22 @@ export const BlockedUsersModal = ({ close }) => {
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
gap: "10px",
|
||||
width: '100%',
|
||||
justifyContent: 'space-between'
|
||||
width: "100%",
|
||||
justifyContent: "space-between",
|
||||
}}
|
||||
>
|
||||
<Typography>{key}</Typography>
|
||||
<Typography>{addressesWithNames[key] || key}</Typography>
|
||||
<Button
|
||||
sx={{
|
||||
flexShrink: 0,
|
||||
}}
|
||||
size="small"
|
||||
variant="contained"
|
||||
onClick={async () => {
|
||||
try {
|
||||
await removeBlockFromList(key, undefined);
|
||||
setHasChanged(true);
|
||||
setValue('')
|
||||
setValue("");
|
||||
fetchBlockedUsers();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
@ -119,17 +233,19 @@ export const BlockedUsersModal = ({ close }) => {
|
||||
<>
|
||||
<Spacer height="20px" />
|
||||
<DialogContentText id="alert-dialog-description">
|
||||
Blocked Users for QDN and Chat (names)
|
||||
Blocked names for QDN
|
||||
</DialogContentText>
|
||||
<Spacer height="10px" />
|
||||
</>
|
||||
)}
|
||||
|
||||
<Box sx={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '10px'
|
||||
}}>
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
gap: "10px",
|
||||
}}
|
||||
>
|
||||
{Object.entries(blockedUsers?.names || {})?.map(([key, value]) => {
|
||||
return (
|
||||
<Box
|
||||
@ -137,12 +253,16 @@ export const BlockedUsersModal = ({ close }) => {
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
gap: "10px",
|
||||
width: '100%',
|
||||
justifyContent: 'space-between'
|
||||
width: "100%",
|
||||
justifyContent: "space-between",
|
||||
}}
|
||||
>
|
||||
<Typography>{key}</Typography>
|
||||
<Button
|
||||
size="small"
|
||||
sx={{
|
||||
flexShrink: 0,
|
||||
}}
|
||||
variant="contained"
|
||||
onClick={async () => {
|
||||
try {
|
||||
@ -175,16 +295,67 @@ export const BlockedUsersModal = ({ close }) => {
|
||||
},
|
||||
}}
|
||||
variant="contained"
|
||||
onClick={()=> {
|
||||
if(hasChanged){
|
||||
executeEvent('updateChatMessagesWithBlocks', true)
|
||||
onClick={() => {
|
||||
if (hasChanged) {
|
||||
executeEvent("updateChatMessagesWithBlocks", true);
|
||||
}
|
||||
close()
|
||||
setIsOpenBlockedModal(false);
|
||||
}}
|
||||
>
|
||||
close
|
||||
</Button>
|
||||
</DialogActions>
|
||||
|
||||
<Dialog
|
||||
open={isShow}
|
||||
aria-labelledby="alert-dialog-title"
|
||||
aria-describedby="alert-dialog-description"
|
||||
>
|
||||
<DialogTitle id="alert-dialog-title">
|
||||
{"Decide what to block"}
|
||||
</DialogTitle>
|
||||
<DialogContent>
|
||||
<DialogContentText id="alert-dialog-description">
|
||||
Blocking {message?.userName || message?.userAddress}
|
||||
</DialogContentText>
|
||||
<Box sx={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: '10px',
|
||||
marginTop: '20px'
|
||||
}}>
|
||||
<InfoIcon sx={{
|
||||
color: 'fff'
|
||||
}}/> <Typography>Choose "block txs" or "all" to block chat messages </Typography>
|
||||
</Box>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={() => {
|
||||
onOk("address");
|
||||
}}
|
||||
>
|
||||
Block txs
|
||||
</Button>
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={() => {
|
||||
onOk("name");
|
||||
}}
|
||||
>
|
||||
Block QDN data
|
||||
</Button>
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={() => {
|
||||
onOk("both");
|
||||
}}
|
||||
>
|
||||
Block All
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
@ -75,9 +75,9 @@ import { MessagingIcon } from "../../assets/Icons/MessagingIcon";
|
||||
import { formatEmailDate } from "./QMailMessages";
|
||||
import { AdminSpace } from "../Chat/AdminSpace";
|
||||
import { useRecoilState, useSetRecoilState } from "recoil";
|
||||
import { addressInfoControllerAtom, groupsPropertiesAtom, selectedGroupIdAtom } from "../../atoms/global";
|
||||
import { addressInfoControllerAtom, groupsPropertiesAtom, isOpenBlockedModalAtom, selectedGroupIdAtom } from "../../atoms/global";
|
||||
import { sortArrayByTimestampAndGroupName } from "../../utils/time";
|
||||
import BlockIcon from '@mui/icons-material/Block';
|
||||
import PersonOffIcon from '@mui/icons-material/PersonOff';
|
||||
import LockIcon from '@mui/icons-material/Lock';
|
||||
import NoEncryptionGmailerrorredIcon from '@mui/icons-material/NoEncryptionGmailerrorred';
|
||||
import { BlockedUsersModal } from "./BlockedUsersModal";
|
||||
@ -421,7 +421,7 @@ export const Group = ({
|
||||
const [groupAnnouncements, setGroupAnnouncements] = React.useState({});
|
||||
const [defaultThread, setDefaultThread] = React.useState(null);
|
||||
const [isOpenDrawer, setIsOpenDrawer] = React.useState(false);
|
||||
const [isOpenBlockedUserModal, setIsOpenBlockedUserModal] = React.useState(false);
|
||||
const setIsOpenBlockedUserModal = useSetRecoilState(isOpenBlockedModalAtom)
|
||||
|
||||
const [hideCommonKeyPopup, setHideCommonKeyPopup] = React.useState(false);
|
||||
const [isLoadingGroupMessage, setIsLoadingGroupMessage] = React.useState("");
|
||||
@ -704,11 +704,12 @@ export const Group = ({
|
||||
if (dataFromStorage) {
|
||||
data = dataFromStorage;
|
||||
} else {
|
||||
// const shouldRebuild = !secretKeyPublishDate || (publish?.update && publish?.updated > secretKeyPublishDate)
|
||||
setIsLoadingGroupMessage("Downloading encryption keys");
|
||||
const res = await fetch(
|
||||
`${getBaseApiReact()}/arbitrary/DOCUMENT_PRIVATE/${publish.name}/${
|
||||
publish.identifier
|
||||
}?encoding=base64`
|
||||
}?encoding=base64&rebuild=true`
|
||||
);
|
||||
data = await res.text();
|
||||
}
|
||||
@ -2034,7 +2035,7 @@ export const Group = ({
|
||||
padding: '10px'
|
||||
}}
|
||||
>
|
||||
<BlockIcon
|
||||
<PersonOffIcon
|
||||
sx={{
|
||||
color: "white",
|
||||
}}
|
||||
@ -2468,11 +2469,8 @@ export const Group = ({
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
{isOpenBlockedUserModal && (
|
||||
<BlockedUsersModal close={()=> {
|
||||
setIsOpenBlockedUserModal(false)
|
||||
}} />
|
||||
)}
|
||||
<BlockedUsersModal />
|
||||
|
||||
|
||||
{selectedDirect && !newChat && (
|
||||
<>
|
||||
|
@ -19,7 +19,7 @@ export const useBlockedAddresses = () => {
|
||||
const isUserBlocked = useCallback((address, name)=> {
|
||||
try {
|
||||
if(!address) return false
|
||||
if(userBlockedRef.current[address] || userNamesBlockedRef.current[name]) return true
|
||||
if(userBlockedRef.current[address]) return true
|
||||
return false
|
||||
|
||||
|
||||
@ -90,43 +90,13 @@ export const useBlockedAddresses = () => {
|
||||
}, [])
|
||||
|
||||
const removeBlockFromList = useCallback(async (address, name)=> {
|
||||
await new Promise((res, rej) => {
|
||||
window.sendMessage("listActions", {
|
||||
|
||||
type: 'remove',
|
||||
items: name ? [name] : [address],
|
||||
listName: name ? 'blockedNames' : 'blockedAddresses'
|
||||
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.error) {
|
||||
rej(response?.message);
|
||||
return;
|
||||
} else {
|
||||
if(!name){
|
||||
const copyObject = {...userBlockedRef.current}
|
||||
delete copyObject[address]
|
||||
userBlockedRef.current = copyObject
|
||||
} else {
|
||||
const copyObject = {...userNamesBlockedRef.current}
|
||||
delete copyObject[name]
|
||||
userNamesBlockedRef.current = copyObject
|
||||
}
|
||||
|
||||
res(response);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Failed qortalRequest", error);
|
||||
});
|
||||
})
|
||||
if(name && userBlockedRef.current[address]){
|
||||
if(name){
|
||||
await new Promise((res, rej) => {
|
||||
window.sendMessage("listActions", {
|
||||
|
||||
type: 'remove',
|
||||
items: !name ? [name] : [address],
|
||||
listName: !name ? 'blockedNames' : 'blockedAddresses'
|
||||
items: [name] ,
|
||||
listName: 'blockedNames'
|
||||
|
||||
})
|
||||
.then((response) => {
|
||||
@ -134,9 +104,12 @@ export const useBlockedAddresses = () => {
|
||||
rej(response?.message);
|
||||
return;
|
||||
} else {
|
||||
const copyObject = {...userBlockedRef.current}
|
||||
delete copyObject[address]
|
||||
userBlockedRef.current = copyObject
|
||||
|
||||
const copyObject = {...userNamesBlockedRef.current}
|
||||
delete copyObject[name]
|
||||
userNamesBlockedRef.current = copyObject
|
||||
|
||||
|
||||
res(response);
|
||||
}
|
||||
})
|
||||
@ -145,42 +118,95 @@ export const useBlockedAddresses = () => {
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
if(address){
|
||||
await new Promise((res, rej) => {
|
||||
window.sendMessage("listActions", {
|
||||
|
||||
type: 'remove',
|
||||
items: [address],
|
||||
listName: 'blockedAddresses'
|
||||
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.error) {
|
||||
rej(response?.message);
|
||||
return;
|
||||
} else {
|
||||
|
||||
const copyObject = {...userBlockedRef.current}
|
||||
delete copyObject[address]
|
||||
userBlockedRef.current = copyObject
|
||||
|
||||
|
||||
res(response);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Failed qortalRequest", error);
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}, [])
|
||||
|
||||
const addToBlockList = useCallback(async (address, name)=> {
|
||||
await new Promise((res, rej) => {
|
||||
window.sendMessage("listActions", {
|
||||
|
||||
type: 'add',
|
||||
items: name ? [name] : [address],
|
||||
listName: name ? 'blockedNames' : 'blockedAddresses'
|
||||
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.error) {
|
||||
rej(response?.message);
|
||||
return;
|
||||
} else {
|
||||
if(name){
|
||||
|
||||
const copyObject = {...userNamesBlockedRef.current}
|
||||
copyObject[name] = true
|
||||
userNamesBlockedRef.current = copyObject
|
||||
}else {
|
||||
const copyObject = {...userBlockedRef.current}
|
||||
copyObject[address] = true
|
||||
userBlockedRef.current = copyObject
|
||||
|
||||
}
|
||||
if(name){
|
||||
await new Promise((res, rej) => {
|
||||
window.sendMessage("listActions", {
|
||||
|
||||
res(response);
|
||||
}
|
||||
type: 'add',
|
||||
items: [name],
|
||||
listName: 'blockedNames'
|
||||
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.error) {
|
||||
rej(response?.message);
|
||||
return;
|
||||
} else {
|
||||
const copyObject = {...userNamesBlockedRef.current}
|
||||
copyObject[name] = true
|
||||
userNamesBlockedRef.current = copyObject
|
||||
|
||||
|
||||
res(response);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Failed qortalRequest", error);
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Failed qortalRequest", error);
|
||||
});
|
||||
})
|
||||
}
|
||||
if(address){
|
||||
await new Promise((res, rej) => {
|
||||
window.sendMessage("listActions", {
|
||||
|
||||
type: 'add',
|
||||
items: [address],
|
||||
listName: 'blockedAddresses'
|
||||
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.error) {
|
||||
rej(response?.message);
|
||||
return;
|
||||
} else {
|
||||
|
||||
const copyObject = {...userBlockedRef.current}
|
||||
copyObject[address] = true
|
||||
userBlockedRef.current = copyObject
|
||||
|
||||
res(response);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Failed qortalRequest", error);
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
}, [])
|
||||
|
||||
return {
|
||||
|
@ -169,12 +169,15 @@ useEffect(()=> {
|
||||
onClick={async () => {
|
||||
try {
|
||||
setIsLoading(true)
|
||||
if(isAlreadyBlocked === true){
|
||||
await removeBlockFromList(address, name)
|
||||
} else if(isAlreadyBlocked === false) {
|
||||
await addToBlockList(address, name)
|
||||
}
|
||||
executeEvent('updateChatMessagesWithBlocks', true)
|
||||
executeEvent("blockUserFromOutside", {
|
||||
user: address
|
||||
})
|
||||
// if(isAlreadyBlocked === true){
|
||||
// await removeBlockFromList(address, name)
|
||||
// } else if(isAlreadyBlocked === false) {
|
||||
// await addToBlockList(address, name)
|
||||
// }
|
||||
// executeEvent('updateChatMessagesWithBlocks', true)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
|
@ -24,7 +24,7 @@ window.addEventListener("message", (event) => {
|
||||
}
|
||||
});
|
||||
|
||||
export const sendMessageBackground = (action, data = {}, timeout = 180000, isExtension, appInfo, skipAuth) => {
|
||||
export const sendMessageBackground = (action, data = {}, timeout = 240000, isExtension, appInfo, skipAuth) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const requestId = generateRequestId(); // Unique ID for each request
|
||||
callbackMap.set(requestId, { resolve, reject }); // Store both resolve and reject callbacks
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { gateways, getApiKeyFromStorage } from "./background";
|
||||
import { gateways, getApiKeyFromStorage } from "./background";
|
||||
import { listOfAllQortalRequests } from "./components/Apps/useQortalMessageListener";
|
||||
import { addForeignServer, addGroupAdminRequest, addListItems, adminAction, banFromGroupRequest, cancelGroupBanRequest, cancelGroupInviteRequest, cancelSellOrder, createAndCopyEmbedLink, createBuyOrder, createGroupRequest, createPoll, createSellOrder, decryptAESGCMRequest, decryptData, decryptDataWithSharingKey, decryptQortalGroupData, deleteHostedData, deleteListItems, deployAt, encryptData, encryptDataWithSharingKey, encryptQortalGroupData, getCrossChainServerInfo, getDaySummary, getNodeInfo, getNodeStatus, getForeignFee, getHostedData, getListItems, getServerConnectionHistory, getTxActivitySummary, getUserAccount, getUserWallet, getUserWalletInfo, getUserWalletTransactions, getWalletBalance, inviteToGroupRequest, joinGroup, kickFromGroupRequest, leaveGroupRequest, openNewTab, publishMultipleQDNResources, publishQDNResource, registerNameRequest, removeForeignServer, removeGroupAdminRequest, saveFile, sendChatMessage, sendCoin, setCurrentForeignServer, signTransaction, updateForeignFee, updateNameRequest, voteOnPoll, getArrrSyncStatus } from "./qortalRequests/get";
|
||||
import { addForeignServer, addGroupAdminRequest, addListItems, adminAction, banFromGroupRequest, cancelGroupBanRequest, cancelGroupInviteRequest, cancelSellOrder, createAndCopyEmbedLink, createBuyOrder, createGroupRequest, createPoll, createSellOrder, decryptAESGCMRequest, decryptData, decryptDataWithSharingKey, decryptQortalGroupData, deleteHostedData, deleteListItems, deployAt, encryptData, encryptDataWithSharingKey, encryptQortalGroupData, getCrossChainServerInfo, getDaySummary, getNodeInfo, getNodeStatus, getForeignFee, getHostedData, getListItems, getServerConnectionHistory, getTxActivitySummary, getUserAccount, getUserWallet, getUserWalletInfo, getUserWalletTransactions, getWalletBalance, inviteToGroupRequest, joinGroup, kickFromGroupRequest, leaveGroupRequest, openNewTab, publishMultipleQDNResources, publishQDNResource, registerNameRequest, removeForeignServer, removeGroupAdminRequest, saveFile, sendChatMessage, sendCoin, setCurrentForeignServer, signTransaction, updateForeignFee, updateNameRequest, voteOnPoll, getArrrSyncStatus, updateGroupRequest, buyNameRequest, sellNameRequest, cancelSellNameRequest } from "./qortalRequests/get";
|
||||
import { getData, storeData } from "./utils/chromeStorage";
|
||||
import { executeEvent } from "./utils/events";
|
||||
|
||||
@ -1195,6 +1195,25 @@ export const isRunningGateway = async ()=> {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "UPDATE_GROUP" : {
|
||||
try {
|
||||
const res = await updateGroupRequest(request.payload, isFromExtension)
|
||||
event.source.postMessage({
|
||||
requestId: request.requestId,
|
||||
action: request.action,
|
||||
payload: res,
|
||||
type: "backgroundMessageResponse",
|
||||
}, event.origin);
|
||||
} catch (error) {
|
||||
event.source.postMessage({
|
||||
requestId: request.requestId,
|
||||
action: request.action,
|
||||
error: error?.message,
|
||||
type: "backgroundMessageResponse",
|
||||
}, event.origin);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "GET_ARRR_SYNC_STATUS": {
|
||||
try {
|
||||
@ -1238,6 +1257,63 @@ export const isRunningGateway = async ()=> {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "BUY_NAME": {
|
||||
try {
|
||||
const res = await buyNameRequest(request.payload, isFromExtension);
|
||||
event.source.postMessage({
|
||||
requestId: request.requestId,
|
||||
action: request.action,
|
||||
payload: res,
|
||||
type: "backgroundMessageResponse",
|
||||
}, event.origin);
|
||||
} catch (error) {
|
||||
event.source.postMessage({
|
||||
requestId: request.requestId,
|
||||
action: request.action,
|
||||
error: error.message,
|
||||
type: "backgroundMessageResponse",
|
||||
}, event.origin);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "SELL_NAME": {
|
||||
try {
|
||||
const res = await sellNameRequest(request.payload, isFromExtension);
|
||||
event.source.postMessage({
|
||||
requestId: request.requestId,
|
||||
action: request.action,
|
||||
payload: res,
|
||||
type: "backgroundMessageResponse",
|
||||
}, event.origin);
|
||||
} catch (error) {
|
||||
event.source.postMessage({
|
||||
requestId: request.requestId,
|
||||
action: request.action,
|
||||
error: error.message,
|
||||
type: "backgroundMessageResponse",
|
||||
}, event.origin);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "CANCEL_SELL_NAME": {
|
||||
try {
|
||||
const res = await cancelSellNameRequest(request.payload, isFromExtension);
|
||||
event.source.postMessage({
|
||||
requestId: request.requestId,
|
||||
action: request.action,
|
||||
payload: res,
|
||||
type: "backgroundMessageResponse",
|
||||
}, event.origin);
|
||||
} catch (error) {
|
||||
event.source.postMessage({
|
||||
requestId: request.requestId,
|
||||
action: request.action,
|
||||
error: error.message,
|
||||
type: "backgroundMessageResponse",
|
||||
}, event.origin);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -30,6 +30,11 @@ import {
|
||||
removeAdmin,
|
||||
cancelInvitationToGroup,
|
||||
createGroup,
|
||||
updateGroup,
|
||||
sellName,
|
||||
cancelSellName,
|
||||
buyName,
|
||||
getBaseApi,
|
||||
} from "../background";
|
||||
import { getNameInfo, uint8ArrayToObject } from "../backgroundFunctions/encryption";
|
||||
import { showSaveFilePicker } from "../components/Apps/useQortalMessageListener";
|
||||
@ -122,7 +127,7 @@ export async function retryTransaction(fn, args, throwError, retries = MAX_RETRI
|
||||
if(throwError){
|
||||
throw new Error(error?.message || "Unable to process transaction")
|
||||
} else {
|
||||
return null
|
||||
throw new Error(error?.message || "Unable to process transaction")
|
||||
}
|
||||
}
|
||||
await new Promise(res => setTimeout(res, 10000));
|
||||
@ -391,7 +396,7 @@ async function getUserPermission(payload, isFromExtension) {
|
||||
responseResolvers.get(requestId)(false); // Resolve with `false` if no response
|
||||
responseResolvers.delete(requestId);
|
||||
}
|
||||
}, 30000); // 30-second timeout
|
||||
}, 60000); // 30-second timeout
|
||||
});
|
||||
}
|
||||
|
||||
@ -497,7 +502,7 @@ export const encryptQortalGroupData = async (data, sender) => {
|
||||
if(publish === false) throw new Error('No group key found.')
|
||||
const url = await createEndpoint(`/arbitrary/DOCUMENT_PRIVATE/${publish.name}/${
|
||||
publish.identifier
|
||||
}?encoding=base64`);
|
||||
}?encoding=base64&rebuild=true`);
|
||||
|
||||
const res = await fetch(
|
||||
url
|
||||
@ -532,7 +537,7 @@ url
|
||||
if(publish === false) throw new Error('No group key found.')
|
||||
const url = await createEndpoint(`/arbitrary/DOCUMENT_PRIVATE/${publish.name}/${
|
||||
publish.identifier
|
||||
}?encoding=base64`);
|
||||
}?encoding=base64&rebuild=true`);
|
||||
|
||||
const res = await fetch(
|
||||
url
|
||||
@ -592,7 +597,7 @@ export const decryptQortalGroupData = async (data, sender) => {
|
||||
if(publish === false) throw new Error('No group key found.')
|
||||
const url = await createEndpoint(`/arbitrary/DOCUMENT_PRIVATE/${publish.name}/${
|
||||
publish.identifier
|
||||
}?encoding=base64`);
|
||||
}?encoding=base64&rebuild=true`);
|
||||
|
||||
const res = await fetch(
|
||||
url
|
||||
@ -623,7 +628,7 @@ url
|
||||
if(publish === false) throw new Error('No group key found.')
|
||||
const url = await createEndpoint(`/arbitrary/DOCUMENT_PRIVATE/${publish.name}/${
|
||||
publish.identifier
|
||||
}?encoding=base64`);
|
||||
}?encoding=base64&rebuild=true`);
|
||||
|
||||
const res = await fetch(
|
||||
url
|
||||
@ -1349,6 +1354,7 @@ export const publishMultipleQDNResources = async (
|
||||
failedPublishesIdentifiers.push({
|
||||
reason: errorMsg,
|
||||
identifier: resource.identifier,
|
||||
service: resource.service,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
@ -1357,6 +1363,7 @@ export const publishMultipleQDNResources = async (
|
||||
failedPublishesIdentifiers.push({
|
||||
reason: errorMsg,
|
||||
identifier: resource.identifier,
|
||||
service: resource.service,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
@ -1386,6 +1393,7 @@ export const publishMultipleQDNResources = async (
|
||||
failedPublishesIdentifiers.push({
|
||||
reason: errorMsg,
|
||||
identifier: resource.identifier,
|
||||
service: resource.service,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
@ -1413,6 +1421,7 @@ export const publishMultipleQDNResources = async (
|
||||
failedPublishesIdentifiers.push({
|
||||
reason: errorMsg,
|
||||
identifier: resource.identifier,
|
||||
service: resource.service,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
@ -1439,7 +1448,7 @@ export const publishMultipleQDNResources = async (
|
||||
apiVersion: 2,
|
||||
withFee: true,
|
||||
},
|
||||
], false);
|
||||
], true);
|
||||
await new Promise((res) => {
|
||||
setTimeout(() => {
|
||||
res();
|
||||
@ -1450,17 +1459,21 @@ export const publishMultipleQDNResources = async (
|
||||
failedPublishesIdentifiers.push({
|
||||
reason: errorMsg,
|
||||
identifier: resource.identifier,
|
||||
service: resource.service,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
failedPublishesIdentifiers.push({
|
||||
reason: error?.message || "Unknown error",
|
||||
identifier: resource.identifier,
|
||||
service: resource.service,
|
||||
});
|
||||
}
|
||||
}
|
||||
if (failedPublishesIdentifiers.length > 0) {
|
||||
const obj = {};
|
||||
const obj = {
|
||||
message: "Some resources have failed to publish.",
|
||||
};
|
||||
obj["error"] = {
|
||||
unsuccessfulPublishes: failedPublishesIdentifiers,
|
||||
};
|
||||
@ -3078,6 +3091,7 @@ export const sendCoin = async (data, isFromExtension) => {
|
||||
text2: `To: ${recipient}`,
|
||||
highlightedText: `${amount} ${checkCoin}`,
|
||||
fee: fee,
|
||||
confirmCheckbox: true
|
||||
},
|
||||
isFromExtension
|
||||
);
|
||||
@ -3088,7 +3102,7 @@ export const sendCoin = async (data, isFromExtension) => {
|
||||
{ amount, password: null, receiver: recipient },
|
||||
true
|
||||
);
|
||||
return makePayment.res;
|
||||
return makePayment.res?.data;
|
||||
} else {
|
||||
throw new Error("User declined request");
|
||||
}
|
||||
@ -4091,6 +4105,12 @@ export const registerNameRequest = async (data, isFromExtension) => {
|
||||
missingFields.push(field);
|
||||
}
|
||||
});
|
||||
|
||||
if (missingFields.length > 0) {
|
||||
const missingFieldsString = missingFields.join(", ");
|
||||
const errorMsg = `Missing fields: ${missingFieldsString}`;
|
||||
throw new Error(errorMsg);
|
||||
}
|
||||
const fee = await getFee("REGISTER_NAME");
|
||||
const resPermission = await getUserPermission(
|
||||
{
|
||||
@ -4104,7 +4124,7 @@ export const registerNameRequest = async (data, isFromExtension) => {
|
||||
const { accepted } = resPermission;
|
||||
if (accepted) {
|
||||
const name = data.name
|
||||
const description = data?.description
|
||||
const description = data?.description || ""
|
||||
const response = await registerName({ name, description });
|
||||
return response
|
||||
|
||||
@ -4121,9 +4141,14 @@ export const updateNameRequest = async (data, isFromExtension) => {
|
||||
missingFields.push(field);
|
||||
}
|
||||
});
|
||||
if (missingFields.length > 0) {
|
||||
const missingFieldsString = missingFields.join(", ");
|
||||
const errorMsg = `Missing fields: ${missingFieldsString}`;
|
||||
throw new Error(errorMsg);
|
||||
}
|
||||
const oldName = data.oldName
|
||||
const newName = data.newName
|
||||
const description = data?.description
|
||||
const description = data?.description || ""
|
||||
const fee = await getFee("UPDATE_NAME");
|
||||
const resPermission = await getUserPermission(
|
||||
{
|
||||
@ -4152,6 +4177,11 @@ export const leaveGroupRequest = async (data, isFromExtension) => {
|
||||
missingFields.push(field);
|
||||
}
|
||||
});
|
||||
if (missingFields.length > 0) {
|
||||
const missingFieldsString = missingFields.join(", ");
|
||||
const errorMsg = `Missing fields: ${missingFieldsString}`;
|
||||
throw new Error(errorMsg);
|
||||
}
|
||||
const groupId = data.groupId
|
||||
let groupInfo = null;
|
||||
try {
|
||||
@ -4192,6 +4222,11 @@ export const inviteToGroupRequest = async (data, isFromExtension) => {
|
||||
missingFields.push(field);
|
||||
}
|
||||
});
|
||||
if (missingFields.length > 0) {
|
||||
const missingFieldsString = missingFields.join(", ");
|
||||
const errorMsg = `Missing fields: ${missingFieldsString}`;
|
||||
throw new Error(errorMsg);
|
||||
}
|
||||
const groupId = data.groupId
|
||||
const qortalAddress = data?.inviteeAddress
|
||||
const inviteTime = data?.inviteTime
|
||||
@ -4241,6 +4276,11 @@ export const kickFromGroupRequest = async (data, isFromExtension) => {
|
||||
missingFields.push(field);
|
||||
}
|
||||
});
|
||||
if (missingFields.length > 0) {
|
||||
const missingFieldsString = missingFields.join(", ");
|
||||
const errorMsg = `Missing fields: ${missingFieldsString}`;
|
||||
throw new Error(errorMsg);
|
||||
}
|
||||
const groupId = data.groupId
|
||||
const qortalAddress = data?.qortalAddress
|
||||
const reason = data?.reason
|
||||
@ -4290,6 +4330,11 @@ export const banFromGroupRequest = async (data, isFromExtension) => {
|
||||
missingFields.push(field);
|
||||
}
|
||||
});
|
||||
if (missingFields.length > 0) {
|
||||
const missingFieldsString = missingFields.join(", ");
|
||||
const errorMsg = `Missing fields: ${missingFieldsString}`;
|
||||
throw new Error(errorMsg);
|
||||
}
|
||||
const groupId = data.groupId
|
||||
const qortalAddress = data?.qortalAddress
|
||||
const rBanTime = data?.banTime
|
||||
@ -4340,6 +4385,11 @@ export const cancelGroupBanRequest = async (data, isFromExtension) => {
|
||||
missingFields.push(field);
|
||||
}
|
||||
});
|
||||
if (missingFields.length > 0) {
|
||||
const missingFieldsString = missingFields.join(", ");
|
||||
const errorMsg = `Missing fields: ${missingFieldsString}`;
|
||||
throw new Error(errorMsg);
|
||||
}
|
||||
const groupId = data.groupId
|
||||
const qortalAddress = data?.qortalAddress
|
||||
|
||||
@ -4387,6 +4437,11 @@ export const addGroupAdminRequest = async (data, isFromExtension) => {
|
||||
missingFields.push(field);
|
||||
}
|
||||
});
|
||||
if (missingFields.length > 0) {
|
||||
const missingFieldsString = missingFields.join(", ");
|
||||
const errorMsg = `Missing fields: ${missingFieldsString}`;
|
||||
throw new Error(errorMsg);
|
||||
}
|
||||
const groupId = data.groupId
|
||||
const qortalAddress = data?.qortalAddress
|
||||
|
||||
@ -4434,6 +4489,11 @@ export const removeGroupAdminRequest = async (data, isFromExtension) => {
|
||||
missingFields.push(field);
|
||||
}
|
||||
});
|
||||
if (missingFields.length > 0) {
|
||||
const missingFieldsString = missingFields.join(", ");
|
||||
const errorMsg = `Missing fields: ${missingFieldsString}`;
|
||||
throw new Error(errorMsg);
|
||||
}
|
||||
const groupId = data.groupId
|
||||
const qortalAddress = data?.qortalAddress
|
||||
|
||||
@ -4481,6 +4541,11 @@ export const cancelGroupInviteRequest = async (data, isFromExtension) => {
|
||||
missingFields.push(field);
|
||||
}
|
||||
});
|
||||
if (missingFields.length > 0) {
|
||||
const missingFieldsString = missingFields.join(", ");
|
||||
const errorMsg = `Missing fields: ${missingFieldsString}`;
|
||||
throw new Error(errorMsg);
|
||||
}
|
||||
const groupId = data.groupId
|
||||
const qortalAddress = data?.qortalAddress
|
||||
|
||||
@ -4522,15 +4587,20 @@ export const cancelGroupInviteRequest = async (data, isFromExtension) => {
|
||||
|
||||
|
||||
export const createGroupRequest = async (data, isFromExtension) => {
|
||||
const requiredFields = ["groupId", "qortalAddress"];
|
||||
const requiredFields = ["groupId", "qortalAddress", "groupName", "type", "approvalThreshold", "minBlock", "maxBlock"];
|
||||
const missingFields: string[] = [];
|
||||
requiredFields.forEach((field) => {
|
||||
if (!data[field]) {
|
||||
if (data[field] !== undefined && data[field] !== null) {
|
||||
missingFields.push(field);
|
||||
}
|
||||
});
|
||||
if (missingFields.length > 0) {
|
||||
const missingFieldsString = missingFields.join(", ");
|
||||
const errorMsg = `Missing fields: ${missingFieldsString}`;
|
||||
throw new Error(errorMsg);
|
||||
}
|
||||
const groupName = data.groupName
|
||||
const description = data?.description
|
||||
const description = data?.description || ""
|
||||
const type = +data.type
|
||||
const approvalThreshold = +data?.approvalThreshold
|
||||
const minBlock = +data?.minBlock
|
||||
@ -4563,6 +4633,70 @@ export const createGroupRequest = async (data, isFromExtension) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const updateGroupRequest = async (data, isFromExtension) => {
|
||||
const requiredFields = ["groupId", "newOwner", "type", "approvalThreshold", "minBlock", "maxBlock"];
|
||||
const missingFields: string[] = [];
|
||||
requiredFields.forEach((field) => {
|
||||
if (data[field] !== undefined && data[field] !== null) {
|
||||
missingFields.push(field);
|
||||
}
|
||||
});
|
||||
if (missingFields.length > 0) {
|
||||
const missingFieldsString = missingFields.join(", ");
|
||||
const errorMsg = `Missing fields: ${missingFieldsString}`;
|
||||
throw new Error(errorMsg);
|
||||
}
|
||||
const groupId = +data.groupId
|
||||
const newOwner = data.newOwner
|
||||
const description = data?.description || ""
|
||||
const type = +data.type
|
||||
const approvalThreshold = +data?.approvalThreshold
|
||||
const minBlock = +data?.minBlock
|
||||
const maxBlock = +data.maxBlock
|
||||
|
||||
let groupInfo = null;
|
||||
try {
|
||||
const url = await createEndpoint(`/groups/${groupId}`);
|
||||
const response = await fetch(url);
|
||||
if (!response.ok) throw new Error("Failed to fetch group");
|
||||
|
||||
groupInfo = await response.json();
|
||||
} catch (error) {
|
||||
const errorMsg = (error && error.message) || "Group not found";
|
||||
throw new Error(errorMsg);
|
||||
}
|
||||
|
||||
const displayInvitee = await getNameInfoForOthers(newOwner)
|
||||
|
||||
|
||||
const fee = await getFee("CREATE_GROUP");
|
||||
const resPermission = await getUserPermission(
|
||||
{
|
||||
text1: `Do you give this application permission to update this group?`,
|
||||
text2: `New owner: ${displayInvitee || newOwner}`,
|
||||
highlightedText: `Group: ${groupInfo.groupName}`,
|
||||
fee: fee.fee,
|
||||
},
|
||||
isFromExtension
|
||||
);
|
||||
const { accepted } = resPermission;
|
||||
if (accepted) {
|
||||
const response = await updateGroup({
|
||||
groupId,
|
||||
newOwner,
|
||||
newIsOpen: type,
|
||||
newDescription: description,
|
||||
newApprovalThreshold: approvalThreshold,
|
||||
newMinimumBlockDelay: minBlock,
|
||||
newMaximumBlockDelay: maxBlock
|
||||
})
|
||||
return response
|
||||
|
||||
} else {
|
||||
throw new Error("User declined request");
|
||||
}
|
||||
};
|
||||
|
||||
export const decryptAESGCMRequest = async (data, isFromExtension) => {
|
||||
const requiredFields = ["encryptedData", "iv", "senderPublicKey"];
|
||||
requiredFields.forEach((field) => {
|
||||
@ -4571,6 +4705,8 @@ export const decryptAESGCMRequest = async (data, isFromExtension) => {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
const encryptedData = data.encryptedData;
|
||||
const iv = data.iv;
|
||||
const senderPublicKeyBase58 = data.senderPublicKey;
|
||||
@ -4617,3 +4753,137 @@ export const decryptAESGCMRequest = async (data, isFromExtension) => {
|
||||
throw new Error("Failed to decrypt the message. Ensure the data and keys are correct.");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const sellNameRequest = async (data, isFromExtension) => {
|
||||
const requiredFields = ["salePrice", "nameForSale"];
|
||||
const missingFields: string[] = [];
|
||||
requiredFields.forEach((field) => {
|
||||
if (data[field] !== undefined && data[field] !== null) {
|
||||
missingFields.push(field);
|
||||
}
|
||||
});
|
||||
if (missingFields.length > 0) {
|
||||
const missingFieldsString = missingFields.join(", ");
|
||||
const errorMsg = `Missing fields: ${missingFieldsString}`;
|
||||
throw new Error(errorMsg);
|
||||
}
|
||||
const name = data.nameForSale
|
||||
const sellPrice = +data.salePrice
|
||||
|
||||
const validApi = await getBaseApi();
|
||||
|
||||
const response = await fetch(validApi + "/names/" + name);
|
||||
const nameData = await response.json();
|
||||
if(!nameData) throw new Error("This name does not exist")
|
||||
|
||||
if(nameData?.isForSale) throw new Error("This name is already for sale")
|
||||
const fee = await getFee("SELL_NAME");
|
||||
const resPermission = await getUserPermission(
|
||||
{
|
||||
text1: `Do you give this application permission to create a sell name transaction?`,
|
||||
highlightedText: `Sell ${name} for ${sellPrice} QORT`,
|
||||
fee: fee.fee,
|
||||
},
|
||||
isFromExtension
|
||||
);
|
||||
const { accepted } = resPermission;
|
||||
if (accepted) {
|
||||
const response = await sellName({
|
||||
name,
|
||||
sellPrice
|
||||
})
|
||||
return response
|
||||
|
||||
} else {
|
||||
throw new Error("User declined request");
|
||||
}
|
||||
};
|
||||
|
||||
export const cancelSellNameRequest = async (data, isFromExtension) => {
|
||||
const requiredFields = ["nameForSale"];
|
||||
const missingFields: string[] = [];
|
||||
requiredFields.forEach((field) => {
|
||||
if (data[field] !== undefined && data[field] !== null) {
|
||||
missingFields.push(field);
|
||||
}
|
||||
});
|
||||
if (missingFields.length > 0) {
|
||||
const missingFieldsString = missingFields.join(", ");
|
||||
const errorMsg = `Missing fields: ${missingFieldsString}`;
|
||||
throw new Error(errorMsg);
|
||||
}
|
||||
const name = data.nameForSale
|
||||
const validApi = await getBaseApi();
|
||||
|
||||
const response = await fetch(validApi + "/names/" + name);
|
||||
const nameData = await response.json();
|
||||
if(!nameData?.isForSale) throw new Error("This name is not for sale")
|
||||
|
||||
const fee = await getFee("CANCEL_SELL_NAME");
|
||||
const resPermission = await getUserPermission(
|
||||
{
|
||||
text1: `Do you give this application permission to cancel the selling of a name?`,
|
||||
highlightedText: `Name: ${name}`,
|
||||
fee: fee.fee,
|
||||
},
|
||||
isFromExtension
|
||||
);
|
||||
const { accepted } = resPermission;
|
||||
if (accepted) {
|
||||
const response = await cancelSellName({
|
||||
name
|
||||
})
|
||||
return response
|
||||
|
||||
} else {
|
||||
throw new Error("User declined request");
|
||||
}
|
||||
};
|
||||
|
||||
export const buyNameRequest = async (data, isFromExtension) => {
|
||||
const requiredFields = ["nameForSale"];
|
||||
const missingFields: string[] = [];
|
||||
requiredFields.forEach((field) => {
|
||||
if (data[field] !== undefined && data[field] !== null) {
|
||||
missingFields.push(field);
|
||||
}
|
||||
});
|
||||
if (missingFields.length > 0) {
|
||||
const missingFieldsString = missingFields.join(", ");
|
||||
const errorMsg = `Missing fields: ${missingFieldsString}`;
|
||||
throw new Error(errorMsg);
|
||||
}
|
||||
const name = data.nameForSale
|
||||
|
||||
const validApi = await getBaseApi();
|
||||
|
||||
const response = await fetch(validApi + "/names/" + name);
|
||||
const nameData = await response.json();
|
||||
if(!nameData?.isForSale) throw new Error("This name is not for sale")
|
||||
const sellerAddress = nameData.owner
|
||||
const sellPrice = +nameData.salePrice
|
||||
|
||||
|
||||
const fee = await getFee("BUY_NAME");
|
||||
const resPermission = await getUserPermission(
|
||||
{
|
||||
text1: `Do you give this application permission to buy a name?`,
|
||||
highlightedText: `Buying ${name} for ${sellPrice} QORT`,
|
||||
fee: fee.fee,
|
||||
},
|
||||
isFromExtension
|
||||
);
|
||||
const { accepted } = resPermission;
|
||||
if (accepted) {
|
||||
const response = await buyName({
|
||||
name,
|
||||
sellerAddress,
|
||||
sellPrice
|
||||
})
|
||||
return response
|
||||
|
||||
} else {
|
||||
throw new Error("User declined request");
|
||||
}
|
||||
};
|
45
src/transactions/BuyNameTransacion.ts
Normal file
45
src/transactions/BuyNameTransacion.ts
Normal file
@ -0,0 +1,45 @@
|
||||
// @ts-nocheck
|
||||
|
||||
import { QORT_DECIMALS } from "../constants/constants"
|
||||
import TransactionBase from "./TransactionBase"
|
||||
|
||||
|
||||
export default class BuyNameTransacion extends TransactionBase {
|
||||
constructor() {
|
||||
super()
|
||||
this.type = 7
|
||||
}
|
||||
|
||||
set fee(fee) {
|
||||
this._fee = fee * QORT_DECIMALS
|
||||
this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
|
||||
}
|
||||
|
||||
set name(name) {
|
||||
this.nameText = name
|
||||
this._nameBytes = this.constructor.utils.stringtoUTF8Array(name)
|
||||
this._nameLength = this.constructor.utils.int32ToBytes(this._nameBytes.length)
|
||||
}
|
||||
|
||||
set sellPrice(sellPrice) {
|
||||
this._sellPrice = sellPrice * QORT_DECIMALS
|
||||
this._sellPriceBytes = this.constructor.utils.int64ToBytes(this._sellPrice)
|
||||
}
|
||||
|
||||
set recipient(recipient) {
|
||||
this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient)
|
||||
this.theRecipient = recipient
|
||||
}
|
||||
|
||||
get params() {
|
||||
const params = super.params
|
||||
params.push(
|
||||
this._nameLength,
|
||||
this._nameBytes,
|
||||
this._sellPriceBytes,
|
||||
this._recipient,
|
||||
this._feeBytes
|
||||
)
|
||||
return params
|
||||
}
|
||||
}
|
33
src/transactions/CancelSellNameTransacion.ts
Normal file
33
src/transactions/CancelSellNameTransacion.ts
Normal file
@ -0,0 +1,33 @@
|
||||
// @ts-nocheck
|
||||
|
||||
import { QORT_DECIMALS } from "../constants/constants"
|
||||
import TransactionBase from "./TransactionBase"
|
||||
|
||||
|
||||
export default class CancelSellNameTransacion extends TransactionBase {
|
||||
constructor() {
|
||||
super()
|
||||
this.type = 6
|
||||
}
|
||||
|
||||
set fee(fee) {
|
||||
this._fee = fee * QORT_DECIMALS
|
||||
this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
|
||||
}
|
||||
|
||||
set name(name) {
|
||||
this.nameText = name
|
||||
this._nameBytes = this.constructor.utils.stringtoUTF8Array(name)
|
||||
this._nameLength = this.constructor.utils.int32ToBytes(this._nameBytes.length)
|
||||
}
|
||||
|
||||
get params() {
|
||||
const params = super.params
|
||||
params.push(
|
||||
this._nameLength,
|
||||
this._nameBytes,
|
||||
this._feeBytes
|
||||
)
|
||||
return params
|
||||
}
|
||||
}
|
40
src/transactions/SellNameTransacion.ts
Normal file
40
src/transactions/SellNameTransacion.ts
Normal file
@ -0,0 +1,40 @@
|
||||
// @ts-nocheck
|
||||
|
||||
import { QORT_DECIMALS } from "../constants/constants"
|
||||
import TransactionBase from "./TransactionBase"
|
||||
|
||||
|
||||
export default class SellNameTransacion extends TransactionBase {
|
||||
constructor() {
|
||||
super()
|
||||
this.type = 5
|
||||
}
|
||||
|
||||
set fee(fee) {
|
||||
this._fee = fee * QORT_DECIMALS
|
||||
this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
|
||||
}
|
||||
|
||||
set name(name) {
|
||||
this.nameText = name
|
||||
this._nameBytes = this.constructor.utils.stringtoUTF8Array(name)
|
||||
this._nameLength = this.constructor.utils.int32ToBytes(this._nameBytes.length)
|
||||
}
|
||||
|
||||
set sellPrice(sellPrice) {
|
||||
this.showSellPrice = sellPrice
|
||||
this._sellPrice = sellPrice * QORT_DECIMALS
|
||||
this._sellPriceBytes = this.constructor.utils.int64ToBytes(this._sellPrice)
|
||||
}
|
||||
|
||||
get params() {
|
||||
const params = super.params
|
||||
params.push(
|
||||
this._nameLength,
|
||||
this._nameBytes,
|
||||
this._sellPriceBytes,
|
||||
this._feeBytes
|
||||
)
|
||||
return params
|
||||
}
|
||||
}
|
62
src/transactions/UpdateGroupTransaction.ts
Normal file
62
src/transactions/UpdateGroupTransaction.ts
Normal file
@ -0,0 +1,62 @@
|
||||
// @ts-nocheck
|
||||
|
||||
|
||||
import { QORT_DECIMALS } from "../constants/constants";
|
||||
import TransactionBase from "./TransactionBase";
|
||||
|
||||
export default class UpdateGroupTransaction extends TransactionBase {
|
||||
constructor() {
|
||||
super()
|
||||
this.type = 23
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
set fee(fee) {
|
||||
this._fee = fee * QORT_DECIMALS
|
||||
this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
|
||||
}
|
||||
set newOwner(newOwner) {
|
||||
this._newOwner = newOwner instanceof Uint8Array ? newOwner : this.constructor.Base58.decode(newOwner)
|
||||
}
|
||||
set newIsOpen(newIsOpen) {
|
||||
|
||||
this._rGroupType = new Uint8Array(1)
|
||||
this._rGroupType[0] = newIsOpen
|
||||
}
|
||||
set newDescription(newDescription) {
|
||||
this._rGroupDescBytes = this.constructor.utils.stringtoUTF8Array(newDescription.toLocaleLowerCase())
|
||||
this._rGroupDescLength = this.constructor.utils.int32ToBytes(this._rGroupDescBytes.length)
|
||||
}
|
||||
set newApprovalThreshold(newApprovalThreshold) {
|
||||
this._rGroupApprovalThreshold = new Uint8Array(1)
|
||||
this._rGroupApprovalThreshold[0] = newApprovalThreshold;
|
||||
}
|
||||
set newMinimumBlockDelay(newMinimumBlockDelay) {
|
||||
this._rGroupMinimumBlockDelayBytes = this.constructor.utils.int32ToBytes(newMinimumBlockDelay)
|
||||
}
|
||||
set newMaximumBlockDelay(newMaximumBlockDelay) {
|
||||
|
||||
this._rGroupMaximumBlockDelayBytes = this.constructor.utils.int32ToBytes(newMaximumBlockDelay)
|
||||
}
|
||||
|
||||
set _groupId(_groupId){
|
||||
this._groupBytes = this.constructor.utils.int32ToBytes(_groupId)
|
||||
}
|
||||
get params() {
|
||||
const params = super.params
|
||||
params.push(
|
||||
this._groupBytes,
|
||||
this._newOwner,
|
||||
this._rGroupDescLength,
|
||||
this._rGroupDescBytes,
|
||||
this._rGroupType,
|
||||
this._rGroupApprovalThreshold,
|
||||
this._rGroupMinimumBlockDelayBytes,
|
||||
this._rGroupMaximumBlockDelayBytes,
|
||||
this._feeBytes
|
||||
)
|
||||
return params
|
||||
}
|
||||
}
|
@ -20,18 +20,26 @@ import DeployAtTransaction from './DeployAtTransaction.js'
|
||||
import RewardShareTransaction from './RewardShareTransaction.js'
|
||||
import RemoveRewardShareTransaction from './RemoveRewardShareTransaction.js'
|
||||
import UpdateNameTransaction from './UpdateNameTransaction.js'
|
||||
import UpdateGroupTransaction from './UpdateGroupTransaction.js'
|
||||
import SellNameTransacion from './SellNameTransacion.js'
|
||||
import CancelSellNameTransacion from './CancelSellNameTransacion.js'
|
||||
import BuyNameTransacion from './BuyNameTransacion.js'
|
||||
|
||||
|
||||
export const transactionTypes = {
|
||||
2: PaymentTransaction,
|
||||
3: RegisterNameTransaction,
|
||||
4: UpdateNameTransaction,
|
||||
2: PaymentTransaction,
|
||||
5: SellNameTransacion,
|
||||
6: CancelSellNameTransacion,
|
||||
7: BuyNameTransacion,
|
||||
8: CreatePollTransaction,
|
||||
9: VoteOnPollTransaction,
|
||||
16: DeployAtTransaction,
|
||||
18: ChatTransaction,
|
||||
181: GroupChatTransaction,
|
||||
22: CreateGroupTransaction,
|
||||
23: UpdateGroupTransaction,
|
||||
24: AddGroupAdminTransaction,
|
||||
25: RemoveGroupAdminTransaction,
|
||||
26: GroupBanTransaction,
|
||||
|
Loading…
x
Reference in New Issue
Block a user