Skip to content

Commit

Permalink
mumbai deployment and hook fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
psparacino committed Jan 15, 2023
1 parent fd19abd commit b98f4eb
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = {
accounts:[`${process.env.PRIVATE_KEY}`],
},
mumbai: {
url: `${process.env.MUMBAI_INFURA_URL}`,
url: `${process.env.MUMBAI_ENDPOINT}`,
accounts:[`${process.env.PRIVATE_KEY}`],
},
},
Expand Down
2 changes: 1 addition & 1 deletion pages/provenances/[provenance]/release-provenance.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ const ReleaseProvenance = () => {
<h2>
Step 1: Approve This Token For Transfer{" "}
{tokenApproved ? (
<Image src={greenCheckMark.src} height="20px" />
<Image alt="green checkmark" src={greenCheckMark.src} height="20px" />
) : null}
</h2>
</Row>
Expand Down
5 changes: 3 additions & 2 deletions pages/register-item/RegisterItem.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect, useReducer } from "react";
import { useState, useEffect, useReducer, useMemo } from "react";
//import { Routes, Route, Link, useNavigate } from "react-router-dom";
import { ethers } from "ethers";

Expand Down Expand Up @@ -81,6 +81,7 @@ const RegisterItem = () => {
const { MothershipContract, TokenContract } = useContractContext();
const { stringToBytes32 } = useItemContext();


const {
items,
setItems,
Expand Down Expand Up @@ -211,7 +212,7 @@ const RegisterItem = () => {

//check if token has been used in a Provenance
const UserTokens = () => {
let provenanceTokens = [];
const provenanceTokens = useMemo(() => [], []);
let unusedTokens = [];

useEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/context/ContractContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ export function ContractContextProvider({ children }) {
// const { MothershipContract, TokenContract } = useContractObjectRepo()

const { provider, modalProvider, signer } = useUserContext();
// console.log(signer, "top signer check")


const [MothershipContract, setMothershipContract] = useState("");
const [TokenContract, setTokenContract] = useState("");

//need to adjust this hook for non-Ethereum
useEffect(async () => {
useEffect(() => {
contractObjects();

async function contractObjects() {
Expand Down
4 changes: 2 additions & 2 deletions src/context/TransferContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function TransferContextProvider({ children }) {
const [pendingTransferContracts, setPendingTransferContracts] = useState();

//load all pending transfers
useEffect(async () => {
useEffect(() => {
if (MothershipContract) {
populateTransfers()
.then((result) => console.log(result, "transfer populate result"))
Expand Down Expand Up @@ -56,7 +56,7 @@ export function TransferContextProvider({ children }) {
setPendingTransferContracts(transferArray);
// setTransferInitiated(false)
}
}, [MothershipContract, mainAccount]);
}, [MothershipContract, mainAccount, signer]);

const state = {
pendingTransferContracts,
Expand Down
30 changes: 16 additions & 14 deletions src/context/UserContext.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// src/context/state.js
import { createContext, useContext, useEffect, useState } from "react";
import { createContext, useContext, useEffect, useState, useCallback } from "react";
// import { networkParams } from "./networks";
import { toHex, truncateAddress } from "../hooks/utils";
import { ethers } from "ethers";
Expand All @@ -25,7 +25,7 @@ export function UserContextProvider({ children }) {

//set web3Modal instance

useEffect(async () => {
useEffect(() => {
loadModal();
// console.log("load modal firing")

Expand All @@ -38,14 +38,7 @@ export function UserContextProvider({ children }) {
}
}, []);

//connect page on reload
useEffect(async () => {
if (web3Modal && web3Modal.cachedProvider) {
connectWallet();
}
}, [web3Modal]);

const connectWallet = async () => {
const connectWallet = useCallback(async() => {
try {
const modalProvider = await web3Modal.connect();
const provider = new ethers.providers.Web3Provider(modalProvider);
Expand All @@ -67,7 +60,16 @@ export function UserContextProvider({ children }) {
);
console.error(error, "connect error");
}
};
},[web3Modal]);

//connect page on reload
useEffect(() => {
if (web3Modal && web3Modal.cachedProvider) {
connectWallet();
}
}, [web3Modal, connectWallet]);



const handleNetwork = (e) => {
const id = e.target.value;
Expand Down Expand Up @@ -108,11 +110,11 @@ export function UserContextProvider({ children }) {
setNetwork("");
};

const disconnect = async () => {
const disconnect = useCallback(async () => {
await web3Modal.clearCachedProvider();
refreshState();
console.log("disconnect");
};
},[web3Modal]);

//EVENT LISTENERS

Expand Down Expand Up @@ -148,7 +150,7 @@ export function UserContextProvider({ children }) {
}
};
}
}, [modalProvider]);
}, [modalProvider, disconnect, error]);

const ipfsGetterRootURL = "https://gateway.pinata.cloud/ipfs/";
const date = new Date();
Expand Down
2 changes: 2 additions & 0 deletions src/deployedContractAddresses/deployed.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#mumbai
token=0x62737d2A21aAc79826AEf1CBd52B3Ae2641d8bF1
2 changes: 1 addition & 1 deletion src/deployedContractAddresses/instrumenttokenaddress.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "address": "0x5FbDB2315678afecb367f032d93F642f64180aa3" }
{ "address": "0x62737d2A21aAc79826AEf1CBd52B3Ae2641d8bF1" }
2 changes: 1 addition & 1 deletion src/deployedContractAddresses/mothershipaddress.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "address": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512" }
{ "address": "0x88550a5d951f5717Ec259659Ed9A6D18544eA9B5" }

0 comments on commit b98f4eb

Please sign in to comment.