Fixed most of the new MUI problems. Missing /admin and other button disabled issues
This commit is contained in:
@@ -12,8 +12,6 @@ import {
|
||||
} from "@mui/material";
|
||||
import { useAlert } from "react-alert";
|
||||
|
||||
import detectEthereumProvider from "@metamask/detect-provider";
|
||||
|
||||
const Settings = (props) => {
|
||||
const { globalUrl, isLoaded, userdata, setUserData } = props;
|
||||
const alert = useAlert();
|
||||
@@ -814,65 +812,6 @@ const Settings = (props) => {
|
||||
) : null}
|
||||
</div>
|
||||
<div style={{ flex: 1, marginTop: 20 }}>
|
||||
{/*userdata !== undefined &&
|
||||
userdata.eth_info !== undefined &&
|
||||
userdata.eth_info.account !== undefined &&
|
||||
userdata.eth_info.account.length > 0 ? (
|
||||
<div style={{ width: "100%", textAlign: "left" }}>
|
||||
<Typography variant="body2">Network: TBD</Typography>
|
||||
<Typography variant="body2">
|
||||
Address: {userdata.eth_info.account}
|
||||
</Typography>
|
||||
{loadedWorkflowCollections.length > 0 ? (
|
||||
<Typography variant="body2">
|
||||
Collections:
|
||||
{loadedWorkflowCollections.map((data, index) => {
|
||||
var collectionname = data.toLowerCase();
|
||||
collectionname = collectionname.replaceAll("#", "");
|
||||
collectionname = collectionname.replaceAll(" ", "-");
|
||||
|
||||
return (
|
||||
<span key={index}>
|
||||
<a
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
href={`https://opensea.io/collection/${collectionname}`}
|
||||
style={{ textDecoration: "none", color: "#f85a3e" }}
|
||||
>
|
||||
{data}
|
||||
</a>
|
||||
|
||||
</span>
|
||||
);
|
||||
})}
|
||||
</Typography>
|
||||
) : null}
|
||||
<Button
|
||||
style={{ height: 40, marginTop: 10 }}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
fullWidth={true}
|
||||
onClick={() => {
|
||||
//handleEthereumTokenCreation()
|
||||
loadWorkflowOwnership();
|
||||
}}
|
||||
>
|
||||
Validate ownership
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
<Button
|
||||
style={{ height: 40, marginTop: 10 }}
|
||||
variant="outlined"
|
||||
color="primary"
|
||||
fullWidth={true}
|
||||
onClick={() => {
|
||||
handleEthereumConnection();
|
||||
}}
|
||||
>
|
||||
Authenticate Metamask Wallet
|
||||
</Button>
|
||||
)*/}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -986,137 +925,6 @@ const Settings = (props) => {
|
||||
//saveWorkflow(workflow);
|
||||
}
|
||||
|
||||
const handleEthereumTokenCreation = async () => {
|
||||
const provider = await detectEthereumProvider();
|
||||
if (!provider) {
|
||||
console.log("Please install MetaMask!");
|
||||
alert.error(
|
||||
"Please download the MetaMask browser extension to authenticate fully!"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!provider.isMetaMask) {
|
||||
alert.error("Only MetaMask is supported as of now.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!provider.isConnected()) {
|
||||
alert.error("Metamask is not connected.");
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("Should make a token");
|
||||
};
|
||||
|
||||
const handleEthereumConnection = async () => {
|
||||
const provider = await detectEthereumProvider();
|
||||
if (!provider) {
|
||||
console.log("Please install MetaMask!");
|
||||
alert.error(
|
||||
"Please download the MetaMask browser extension to authenticate fully!"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!provider.isMetaMask) {
|
||||
alert.error("Only MetaMask is supported as of now.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the ethereum network
|
||||
// Get the users' account(s)
|
||||
//alert.info("Connecting to MetaMask")
|
||||
//console.log("Connected: ", provider.isConnected())
|
||||
|
||||
if (!provider.isConnected()) {
|
||||
alert.error("Metamask is not connected.");
|
||||
return;
|
||||
}
|
||||
|
||||
provider.on("message", (event) => {
|
||||
alert.info("Ethereum message: ", event);
|
||||
});
|
||||
|
||||
/*
|
||||
params: [
|
||||
{
|
||||
from: '0xb60e8dd61c5d32be8058bb8eb970870f07233155',
|
||||
to: '0xd46e8dd67c5d32be8058bb8eb970870f07244567',
|
||||
gas: '0x76c0', // 30400
|
||||
gasPrice: '0x9184e72a000', // 10000000000000
|
||||
value: '0x9184e72a', // 2441406250
|
||||
data:
|
||||
'0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675',
|
||||
},
|
||||
]
|
||||
*/
|
||||
|
||||
// https://docs.metamask.io/guide/rpc-api.html
|
||||
// Gets accounts - requires previous permissions
|
||||
//const method = "eth_accounts"
|
||||
//const params = []
|
||||
//
|
||||
// Asks for permission, and gets the accounts
|
||||
var method = "eth_requestAccounts";
|
||||
var params = [];
|
||||
provider
|
||||
.request({
|
||||
method: method,
|
||||
params,
|
||||
})
|
||||
.then((result) => {
|
||||
if (result !== undefined && result !== null && result.length > 0) {
|
||||
userdata.eth_info.account = result[0];
|
||||
|
||||
// Getting and setting balance for the current user
|
||||
method = "eth_getBalance";
|
||||
params = [userdata.eth_info.account, "latest"];
|
||||
provider
|
||||
.request({
|
||||
method: method,
|
||||
params,
|
||||
})
|
||||
.then((result) => {
|
||||
if (
|
||||
result !== undefined &&
|
||||
result !== null &&
|
||||
result.length > 0
|
||||
) {
|
||||
userdata.eth_info.balance = result;
|
||||
userdata.eth_info.parsed_balance = result / 1000000000000000000;
|
||||
console.log(userdata.eth_info);
|
||||
setUserData(userdata.eth_info);
|
||||
|
||||
// Updating
|
||||
//if (userdata.eth_info !== userdata.userdata.eth_info) {
|
||||
//}
|
||||
|
||||
setUser(userdata.id, "eth_info", userdata.eth_info);
|
||||
userdata.userdata.eth_info = userdata.eth_info;
|
||||
} else {
|
||||
alert.error("Couldn't find balance: ", result);
|
||||
}
|
||||
// The result varies by RPC method.
|
||||
// For example, this method will return a transaction hash hexadecimal string on success.
|
||||
})
|
||||
.catch((error) => {
|
||||
// If the request fails, the Promise will reject with an error.
|
||||
//setEthInfo(userdata.eth_info)
|
||||
alert.error("Failed getting info from ethereum API: " + error);
|
||||
});
|
||||
} else {
|
||||
alert.error("Couldn't find any user: ", result);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
// If the request fails, the Promise will reject with an error.
|
||||
alert.error("Failed getting info from ethereum API: " + error);
|
||||
});
|
||||
|
||||
// Gets the users' balance in WEI (one quintilionth ETH)
|
||||
};
|
||||
|
||||
const loadedCheck =
|
||||
isLoaded && !firstrequest ? (
|
||||
<div style={bodyDivStyle}>{landingpageData}</div>
|
||||
|
||||
Reference in New Issue
Block a user