Skip to content

Commit 728f99a

Browse files
WIP
1 parent 5fb32a7 commit 728f99a

File tree

3 files changed

+11
-40
lines changed

3 files changed

+11
-40
lines changed

src/components/App.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,11 @@ const App: React.FC = () => {
9696
description,
9797
artistName
9898
);
99-
console.log("xx", ipfsHashMD);
10099
// Check if MetaMask is installed, if not throw error
101100
checkMetaMaskInstall();
102-
console.log("22", ipfsHashMD);
103101
// Get the users account
104102
const account = await requestAccounts();
105103
setAccount(account);
106-
console.log("333", ipfsHashMD);
107104
await mintNFT(`ipfs://${ipfsHashMD}`);
108105
} catch (error: any) {
109106
setMintingError(`Minting Error: ${error.message}`);

src/mintNFT.ts

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,6 @@ const platformFee = ethers.parseEther(config.platformFee);
1717

1818
const mintNFT = async (ipfsTokenURI: string) => {
1919
try {
20-
// setLoading(true);
21-
// // Check if MetaMask is available
22-
// if (typeof window.ethereum === "undefined") {
23-
// throw new Error(errorMessages.notInstalled);
24-
// }
25-
// Request account access if needed
26-
// TODO check if account access exists before requesting, set error
27-
// setError(errorMessages.accountAccess);
28-
// const userAccount = await window.ethereum.request({
29-
// method: "eth_requestAccounts",
30-
// });
31-
//setAccount(userAccount);
32-
// setError("");
3320
// Create a provider and signer from MetaMask
3421
const provider = new ethers.BrowserProvider(window.ethereum);
3522
const signer = await provider.getSigner();
@@ -38,17 +25,13 @@ const mintNFT = async (ipfsTokenURI: string) => {
3825
// Ensure the user is connected to correct chain
3926
if (chainId !== config.chainIDBigInt) {
4027
try {
41-
// setError(errorMessages.attemptSwitch);
4228
// attempt switch to correct chain
4329
await window.ethereum.request({
4430
method: "wallet_switchEthereumChain",
4531
params: [{ chainId: config.chainIDHex }],
4632
});
4733
// setError("");
4834
} catch (e: unknown) {
49-
console.log('abcdef', e)
50-
51-
// setError(errorMessages.attemptAdd);
5235
// This error code 4902 indicates that the requested chain
5336
// has not been switched in MetaMask therefore call wallet_addEthereumChain
5437
if (e instanceof Error && "code" in e && e.code === 4902) {
@@ -68,33 +51,24 @@ const mintNFT = async (ipfsTokenURI: string) => {
6851
// Get the signers' address
6952
const userAddress = await signer.getAddress();
7053
// Call the contracts' preSafeMint function
71-
const txResponse: TransactionResponse = await AaartoNFTContract.preSafeMint(
72-
userAddress,
73-
ipfsTokenURI,
74-
{
75-
value: platformFee, // Set msg.value(in contract) to the platform fee
76-
}
77-
);
78-
//setTransactionHash(txResponse.hash);
54+
// const txResponse: TransactionResponse = await AaartoNFTContract.preSafeMint(
55+
// userAddress,
56+
// ipfsTokenURI,
57+
// {
58+
// value: platformFee, // Set msg.value(in contract) to the platform fee
59+
// }
60+
// );
7961
// Wait for the transaction to be mined
80-
const receipt = await txResponse.wait();
81-
//setTransactionReceipt(receipt);
62+
// const receipt = await txResponse.wait();
63+
return "xxx";
8264
} catch (error: unknown) {
83-
console.log('2222222', error)
84-
85-
// If MetaMask is processing a request and remains hidden, can throw this error if MM is processing and hidden
86-
// Already processing eth_requestAccounts. Please wait.', stack: '{\n "code": -32002,\n
8765
if (error instanceof Error) {
88-
if (error.message.includes("Already processing eth_requestAccounts")) {
89-
throw new Error(errorMessages.alreadyProcessing);
90-
} else if (error.message.includes("user rejected action")) {
66+
if (error.message.includes("user rejected action")) {
9167
throw new Error(errorMessages.userCancel);
9268
} else {
9369
throw new Error(errorMessages.general);
9470
}
9571
}
96-
} finally {
97-
//setLoading(false);
9872
}
9973
};
10074

src/requestAccounts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const requestAccounts = async () => {
1010
method: "eth_requestAccounts",
1111
});
1212
} catch (error: any) {
13-
if (error.message.includes("Already processing eth_requestAccounts")) {
13+
if (error.message?.includes("Already processing eth_requestAccounts")) {
1414
throw new Error(errorMessages.alreadyProcessing);
1515
}
1616
throw error;

0 commit comments

Comments
 (0)