mirror of
https://github.com/Qortal/chrome-extension.git
synced 2025-04-25 04:17:53 +00:00
fixes and added qortal request
This commit is contained in:
parent
ad5a76b8bc
commit
856cff0d4d
@ -14,6 +14,7 @@ import {
|
|||||||
Input,
|
Input,
|
||||||
styled,
|
styled,
|
||||||
Switch,
|
Switch,
|
||||||
|
TextField,
|
||||||
Typography,
|
Typography,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import Logo1 from "../assets/svgs/Logo1.svg";
|
import Logo1 from "../assets/svgs/Logo1.svg";
|
||||||
@ -76,6 +77,8 @@ export const NotAuthenticated = ({
|
|||||||
//add and edit states
|
//add and edit states
|
||||||
const [url, setUrl] = React.useState("https://");
|
const [url, setUrl] = React.useState("https://");
|
||||||
const [customApikey, setCustomApiKey] = React.useState("");
|
const [customApikey, setCustomApiKey] = React.useState("");
|
||||||
|
const [showSelectApiKey, setShowSelectApiKey] = useState(false)
|
||||||
|
const [enteredApiKey, setEnteredApiKey] = useState('')
|
||||||
const [customNodeToSaveIndex, setCustomNodeToSaveIndex] =
|
const [customNodeToSaveIndex, setCustomNodeToSaveIndex] =
|
||||||
React.useState(null);
|
React.useState(null);
|
||||||
const { showTutorial, hasSeenGettingStarted } = useContext(GlobalContext);
|
const { showTutorial, hasSeenGettingStarted } = useContext(GlobalContext);
|
||||||
@ -85,6 +88,7 @@ export const NotAuthenticated = ({
|
|||||||
const hasLocalNodeRef = useRef(null);
|
const hasLocalNodeRef = useRef(null);
|
||||||
const isLocal = cleanUrl(currentNode?.url) === "127.0.0.1:12391";
|
const isLocal = cleanUrl(currentNode?.url) === "127.0.0.1:12391";
|
||||||
const handleFileChangeApiKey = (event) => {
|
const handleFileChangeApiKey = (event) => {
|
||||||
|
setShowSelectApiKey(false)
|
||||||
const file = event.target.files[0]; // Get the selected file
|
const file = event.target.files[0]; // Get the selected file
|
||||||
if (file) {
|
if (file) {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
@ -238,6 +242,55 @@ export const NotAuthenticated = ({
|
|||||||
apikey: importedApiKeyRef.current || key?.apikey,
|
apikey: importedApiKeyRef.current || key?.apikey,
|
||||||
url: currentNodeRef.current?.url,
|
url: currentNodeRef.current?.url,
|
||||||
};
|
};
|
||||||
|
if(!payload?.apikey){
|
||||||
|
try {
|
||||||
|
const generateUrl = "http://127.0.0.1:12391/admin/apikey/generate";
|
||||||
|
const generateRes = await fetch(generateUrl, {
|
||||||
|
method: "POST",
|
||||||
|
})
|
||||||
|
let res;
|
||||||
|
try {
|
||||||
|
res = await generateRes.clone().json();
|
||||||
|
} catch (e) {
|
||||||
|
res = await generateRes.text();
|
||||||
|
}
|
||||||
|
if (res != null && !res.error && res.length >= 8) {
|
||||||
|
payload = {
|
||||||
|
apikey: res,
|
||||||
|
url: currentNodeRef.current?.url,
|
||||||
|
};
|
||||||
|
|
||||||
|
setImportedApiKey(res); // Store the file content in the state
|
||||||
|
|
||||||
|
|
||||||
|
setCustomNodes((prev)=> {
|
||||||
|
const copyPrev = [...prev]
|
||||||
|
const findLocalIndex = copyPrev?.findIndex((item)=> item?.url === 'http://127.0.0.1:12391')
|
||||||
|
if(findLocalIndex === -1){
|
||||||
|
copyPrev.unshift({
|
||||||
|
url: "http://127.0.0.1:12391",
|
||||||
|
apikey: res
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
copyPrev[findLocalIndex] = {
|
||||||
|
url: "http://127.0.0.1:12391",
|
||||||
|
apikey: res
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chrome?.runtime?.sendMessage(
|
||||||
|
{ action: "setCustomNodes", copyPrev }
|
||||||
|
);
|
||||||
|
return copyPrev
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (currentNodeRef.current) {
|
} else if (currentNodeRef.current) {
|
||||||
payload = currentNodeRef.current;
|
payload = currentNodeRef.current;
|
||||||
}
|
}
|
||||||
@ -540,14 +593,8 @@ export const NotAuthenticated = ({
|
|||||||
</Box>
|
</Box>
|
||||||
{currentNode?.url === "http://127.0.0.1:12391" && (
|
{currentNode?.url === "http://127.0.0.1:12391" && (
|
||||||
<>
|
<>
|
||||||
<Button size="small" variant="contained" component="label">
|
<Button onClick={()=> setShowSelectApiKey(true)} size="small" variant="contained" component="label">
|
||||||
{apiKey ? "Change " : "Import "} apiKey.txt
|
{apiKey ? "Change " : "Import "} apikey
|
||||||
<input
|
|
||||||
type="file"
|
|
||||||
accept=".txt"
|
|
||||||
hidden
|
|
||||||
onChange={handleFileChangeApiKey} // File input handler
|
|
||||||
/>
|
|
||||||
</Button>
|
</Button>
|
||||||
<Typography
|
<Typography
|
||||||
sx={{
|
sx={{
|
||||||
@ -814,6 +861,90 @@ export const NotAuthenticated = ({
|
|||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{showSelectApiKey && (
|
||||||
|
<Dialog
|
||||||
|
open={showSelectApiKey}
|
||||||
|
aria-labelledby="alert-dialog-title"
|
||||||
|
aria-describedby="alert-dialog-description"
|
||||||
|
|
||||||
|
>
|
||||||
|
<DialogTitle id="alert-dialog-title">{"Enter apikey"}</DialogTitle>
|
||||||
|
<DialogContent>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
gap: '20px'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TextField value={enteredApiKey} onChange={(e)=> setEnteredApiKey(e.target.value)}/>
|
||||||
|
<Button disabled={!!enteredApiKey} variant="contained" component="label">Alternative: File select
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
accept=".txt"
|
||||||
|
hidden
|
||||||
|
onChange={handleFileChangeApiKey} // File input handler
|
||||||
|
/>
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
onClick={() => {
|
||||||
|
setEnteredApiKey("")
|
||||||
|
setShowSelectApiKey(false)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Close
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
disabled={!enteredApiKey}
|
||||||
|
onClick={() => {
|
||||||
|
try {
|
||||||
|
setImportedApiKey(enteredApiKey); // Store the file content in the state
|
||||||
|
if(customNodes){
|
||||||
|
setCustomNodes((prev)=> {
|
||||||
|
const copyPrev = [...prev]
|
||||||
|
const findLocalIndex = copyPrev?.findIndex((item)=> item?.url === 'http://127.0.0.1:12391')
|
||||||
|
if(findLocalIndex === -1){
|
||||||
|
copyPrev.unshift({
|
||||||
|
url: "http://127.0.0.1:12391",
|
||||||
|
apikey: enteredApiKey
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
copyPrev[findLocalIndex] = {
|
||||||
|
url: "http://127.0.0.1:12391",
|
||||||
|
apikey: enteredApiKey
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chrome?.runtime?.sendMessage(
|
||||||
|
{ action: "setCustomNodes", copyPrev }
|
||||||
|
);
|
||||||
|
return copyPrev
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
setUseLocalNode(false);
|
||||||
|
setShowSelectApiKey(false)
|
||||||
|
setEnteredApiKey("")
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
autoFocus
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
|
)}
|
||||||
<ButtonBase onClick={()=> {
|
<ButtonBase onClick={()=> {
|
||||||
showTutorial('create-account', true)
|
showTutorial('create-account', true)
|
||||||
}} sx={{
|
}} sx={{
|
||||||
|
@ -35,7 +35,8 @@ const AppViewerContainer = React.forwardRef(({ app, isSelected, hide, isDevMode,
|
|||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
style={{
|
style={{
|
||||||
display: (!isSelected || hide) && 'none',
|
position: (!isSelected || hide) && 'absolute',
|
||||||
|
left: (!isSelected || hide) && '10000000px',
|
||||||
height: customHeight ? customHeight : !isMobile ? '100vh' : `calc(${rootHeight} - 60px - 45px)`,
|
height: customHeight ? customHeight : !isMobile ? '100vh' : `calc(${rootHeight} - 60px - 45px)`,
|
||||||
border: 'none',
|
border: 'none',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
|
@ -309,7 +309,8 @@ export const AppsDesktop = ({ mode, setMode, show , myName, goToHome, setDesktop
|
|||||||
return (
|
return (
|
||||||
<AppsParent
|
<AppsParent
|
||||||
sx={{
|
sx={{
|
||||||
display: !show && "none",
|
position: !show && 'absolute',
|
||||||
|
left: !show && '10000000px',
|
||||||
flexDirection: 'row'
|
flexDirection: 'row'
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@ -247,7 +247,7 @@ const UIQortalRequests = [
|
|||||||
'GET_SERVER_CONNECTION_HISTORY', 'SET_CURRENT_FOREIGN_SERVER',
|
'GET_SERVER_CONNECTION_HISTORY', 'SET_CURRENT_FOREIGN_SERVER',
|
||||||
'ADD_FOREIGN_SERVER', 'REMOVE_FOREIGN_SERVER', 'GET_DAY_SUMMARY', 'CREATE_TRADE_BUY_ORDER',
|
'ADD_FOREIGN_SERVER', 'REMOVE_FOREIGN_SERVER', 'GET_DAY_SUMMARY', 'CREATE_TRADE_BUY_ORDER',
|
||||||
'CREATE_TRADE_SELL_ORDER', 'CANCEL_TRADE_SELL_ORDER', 'IS_USING_PUBLIC_NODE', 'ADMIN_ACTION', 'SIGN_TRANSACTION', 'DECRYPT_QORTAL_GROUP_DATA', 'DELETE_HOSTED_DATA', 'GET_HOSTED_DATA', 'DECRYPT_DATA_WITH_SHARING_KEY', 'SHOW_ACTIONS', 'REGISTER_NAME', 'UPDATE_NAME', 'LEAVE_GROUP', 'INVITE_TO_GROUP', 'KICK_FROM_GROUP', 'BAN_FROM_GROUP', 'CANCEL_GROUP_BAN', 'ADD_GROUP_ADMIN','REMOVE_GROUP_ADMIN','DECRYPT_AESGCM', 'CANCEL_GROUP_INVITE', 'CREATE_GROUP', 'GET_USER_WALLET_TRANSACTIONS', 'GET_NODE_INFO',
|
'CREATE_TRADE_SELL_ORDER', 'CANCEL_TRADE_SELL_ORDER', 'IS_USING_PUBLIC_NODE', 'ADMIN_ACTION', 'SIGN_TRANSACTION', 'DECRYPT_QORTAL_GROUP_DATA', 'DELETE_HOSTED_DATA', 'GET_HOSTED_DATA', 'DECRYPT_DATA_WITH_SHARING_KEY', 'SHOW_ACTIONS', 'REGISTER_NAME', 'UPDATE_NAME', 'LEAVE_GROUP', 'INVITE_TO_GROUP', 'KICK_FROM_GROUP', 'BAN_FROM_GROUP', 'CANCEL_GROUP_BAN', 'ADD_GROUP_ADMIN','REMOVE_GROUP_ADMIN','DECRYPT_AESGCM', 'CANCEL_GROUP_INVITE', 'CREATE_GROUP', 'GET_USER_WALLET_TRANSACTIONS', 'GET_NODE_INFO',
|
||||||
'GET_NODE_STATUS'
|
'GET_NODE_STATUS', 'GET_ARRR_SYNC_STATUS'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { banFromGroup, gateways, getApiKeyFromStorage } from "./background";
|
import { banFromGroup, gateways, getApiKeyFromStorage } from "./background";
|
||||||
import { addForeignServer, addGroupAdminRequest, addListItems, adminAction, banFromGroupRequest, cancelGroupBanRequest, cancelGroupInviteRequest, cancelSellOrder, createBuyOrder, createGroupRequest, createPoll, createSellOrder, decryptAESGCMRequest, decryptData, decryptDataWithSharingKey, decryptQortalGroupData, deleteHostedData, deleteListItems, deployAt, encryptData, encryptDataWithSharingKey, encryptQortalGroupData, getCrossChainServerInfo, getDaySummary, getForeignFee, getHostedData, getListItems, getNodeInfo, getNodeStatus, getServerConnectionHistory, getTxActivitySummary, getUserAccount, getUserWallet, getUserWalletInfo, getUserWalletTransactions, getWalletBalance, inviteToGroupRequest, joinGroup, kickFromGroupRequest, leaveGroupRequest, publishMultipleQDNResources, publishQDNResource, registerNameRequest, removeForeignServer, removeGroupAdminRequest, saveFile, sendChatMessage, sendCoin, setCurrentForeignServer, signTransaction, updateForeignFee, updateNameRequest, voteOnPoll } from "./qortalRequests/get";
|
import { addForeignServer, addGroupAdminRequest, addListItems, adminAction, banFromGroupRequest, cancelGroupBanRequest, cancelGroupInviteRequest, cancelSellOrder, createBuyOrder, createGroupRequest, createPoll, createSellOrder, decryptAESGCMRequest, decryptData, decryptDataWithSharingKey, decryptQortalGroupData, deleteHostedData, deleteListItems, deployAt, encryptData, encryptDataWithSharingKey, encryptQortalGroupData, getArrrSyncStatus, getCrossChainServerInfo, getDaySummary, getForeignFee, getHostedData, getListItems, getNodeInfo, getNodeStatus, getServerConnectionHistory, getTxActivitySummary, getUserAccount, getUserWallet, getUserWalletInfo, getUserWalletTransactions, getWalletBalance, inviteToGroupRequest, joinGroup, kickFromGroupRequest, leaveGroupRequest, publishMultipleQDNResources, publishQDNResource, registerNameRequest, removeForeignServer, removeGroupAdminRequest, saveFile, sendChatMessage, sendCoin, setCurrentForeignServer, signTransaction, updateForeignFee, updateNameRequest, voteOnPoll } from "./qortalRequests/get";
|
||||||
|
|
||||||
export const listOfAllQortalRequests = [
|
export const listOfAllQortalRequests = [
|
||||||
'GET_USER_ACCOUNT',
|
'GET_USER_ACCOUNT',
|
||||||
@ -80,7 +80,8 @@ import { addForeignServer, addGroupAdminRequest, addListItems, adminAction, banF
|
|||||||
'CREATE_GROUP',
|
'CREATE_GROUP',
|
||||||
'GET_USER_WALLET_TRANSACTIONS',
|
'GET_USER_WALLET_TRANSACTIONS',
|
||||||
'GET_NODE_INFO',
|
'GET_NODE_INFO',
|
||||||
'GET_NODE_STATUS'
|
'GET_NODE_STATUS',
|
||||||
|
'GET_ARRR_SYNC_STATUS'
|
||||||
]
|
]
|
||||||
|
|
||||||
// Promisify chrome.storage.local.get
|
// Promisify chrome.storage.local.get
|
||||||
@ -837,6 +838,17 @@ chrome?.runtime?.onMessage.addListener((request, sender, sendResponse) => {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "GET_ARRR_SYNC_STATUS" : {
|
||||||
|
|
||||||
|
getArrrSyncStatus()
|
||||||
|
.then((res) => {
|
||||||
|
sendResponse(res);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
sendResponse({ error: error.message });
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4539,3 +4539,33 @@ export const getNodeStatus = async () => {
|
|||||||
throw new Error(error?.message || "Error in retrieving node status");
|
throw new Error(error?.message || "Error in retrieving node status");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getArrrSyncStatus = async () => {
|
||||||
|
const resKeyPair = await getKeyPair();
|
||||||
|
const parsedData = resKeyPair;
|
||||||
|
const arrrSeed = parsedData.arrrSeed58;
|
||||||
|
const url = `/crosschain/arrr/syncstatus`; // Simplified endpoint URL
|
||||||
|
|
||||||
|
try {
|
||||||
|
const endpoint = await createEndpoint(url); // Assuming createEndpoint is available for constructing the full URL
|
||||||
|
const response = await fetch(endpoint, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
Accept: "*/*",
|
||||||
|
},
|
||||||
|
body: arrrSeed
|
||||||
|
});
|
||||||
|
|
||||||
|
let res;
|
||||||
|
|
||||||
|
try {
|
||||||
|
res = await response.clone().json();
|
||||||
|
} catch (e) {
|
||||||
|
res = await response.text();
|
||||||
|
}
|
||||||
|
|
||||||
|
return res; // Return the full response
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error(error?.message || "Error in retrieving arrr sync status");
|
||||||
|
}
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user