@@ -17,19 +17,6 @@ const platformFee = ethers.parseEther(config.platformFee);
1717
1818const 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
0 commit comments