diff --git a/.gitignore b/.gitignore index 1437c53..99e47bf 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,9 @@ /.pnp .pnp.js +# artifacts +/artifacts + # testing /coverage @@ -29,6 +32,7 @@ yarn-error.log* .env.development.local .env.test.local .env.production.local +.env # vercel .vercel diff --git a/cache/solidity-files-cache.json b/cache/solidity-files-cache.json index aa00364..27f2485 100644 --- a/cache/solidity-files-cache.json +++ b/cache/solidity-files-cache.json @@ -21,7 +21,9 @@ "evm.methodIdentifiers", "metadata" ], - "": ["ast"] + "": [ + "ast" + ] } } } @@ -33,8 +35,12 @@ "../node_modules/@openzeppelin/contracts/utils/Counters.sol", "../node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol" ], - "versionPragmas": ["0.8.10"], - "artifacts": ["InstrumentDeedToken"] + "versionPragmas": [ + "0.8.10" + ], + "artifacts": [ + "InstrumentDeedToken" + ] }, "/Users/peter/Development/trackyouraxe.v2/node_modules/@openzeppelin/contracts/token/ERC721/ERC721.sol": { "lastModificationDate": 1652716966146, @@ -56,7 +62,9 @@ "evm.methodIdentifiers", "metadata" ], - "": ["ast"] + "": [ + "ast" + ] } } } @@ -70,8 +78,12 @@ "../../utils/Strings.sol", "../../utils/introspection/ERC165.sol" ], - "versionPragmas": ["^0.8.0"], - "artifacts": ["ERC721"] + "versionPragmas": [ + "^0.8.0" + ], + "artifacts": [ + "ERC721" + ] }, "/Users/peter/Development/trackyouraxe.v2/node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol": { "lastModificationDate": 1652716973214, @@ -93,14 +105,22 @@ "evm.methodIdentifiers", "metadata" ], - "": ["ast"] + "": [ + "ast" + ] } } } }, - "imports": ["../ERC721.sol"], - "versionPragmas": ["^0.8.0"], - "artifacts": ["ERC721URIStorage"] + "imports": [ + "../ERC721.sol" + ], + "versionPragmas": [ + "^0.8.0" + ], + "artifacts": [ + "ERC721URIStorage" + ] }, "/Users/peter/Development/trackyouraxe.v2/node_modules/@openzeppelin/contracts/access/Ownable.sol": { "lastModificationDate": 1652716955599, @@ -122,14 +142,22 @@ "evm.methodIdentifiers", "metadata" ], - "": ["ast"] + "": [ + "ast" + ] } } } }, - "imports": ["../utils/Context.sol"], - "versionPragmas": ["^0.8.0"], - "artifacts": ["Ownable"] + "imports": [ + "../utils/Context.sol" + ], + "versionPragmas": [ + "^0.8.0" + ], + "artifacts": [ + "Ownable" + ] }, "/Users/peter/Development/trackyouraxe.v2/node_modules/@openzeppelin/contracts/utils/Counters.sol": { "lastModificationDate": 1652716955615, @@ -151,14 +179,20 @@ "evm.methodIdentifiers", "metadata" ], - "": ["ast"] + "": [ + "ast" + ] } } } }, "imports": [], - "versionPragmas": ["^0.8.0"], - "artifacts": ["Counters"] + "versionPragmas": [ + "^0.8.0" + ], + "artifacts": [ + "Counters" + ] }, "/Users/peter/Development/trackyouraxe.v2/node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol": { "lastModificationDate": 1652716973213, @@ -180,14 +214,23 @@ "evm.methodIdentifiers", "metadata" ], - "": ["ast"] + "": [ + "ast" + ] } } } }, - "imports": ["../ERC721.sol", "./IERC721Enumerable.sol"], - "versionPragmas": ["^0.8.0"], - "artifacts": ["ERC721Enumerable"] + "imports": [ + "../ERC721.sol", + "./IERC721Enumerable.sol" + ], + "versionPragmas": [ + "^0.8.0" + ], + "artifacts": [ + "ERC721Enumerable" + ] }, "/Users/peter/Development/trackyouraxe.v2/node_modules/@openzeppelin/contracts/token/ERC721/IERC721.sol": { "lastModificationDate": 1652716966145, @@ -209,14 +252,22 @@ "evm.methodIdentifiers", "metadata" ], - "": ["ast"] + "": [ + "ast" + ] } } } }, - "imports": ["../../utils/introspection/IERC165.sol"], - "versionPragmas": ["^0.8.0"], - "artifacts": ["IERC721"] + "imports": [ + "../../utils/introspection/IERC165.sol" + ], + "versionPragmas": [ + "^0.8.0" + ], + "artifacts": [ + "IERC721" + ] }, "/Users/peter/Development/trackyouraxe.v2/node_modules/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": { "lastModificationDate": 1652716966146, @@ -238,14 +289,20 @@ "evm.methodIdentifiers", "metadata" ], - "": ["ast"] + "": [ + "ast" + ] } } } }, "imports": [], - "versionPragmas": ["^0.8.0"], - "artifacts": ["IERC721Receiver"] + "versionPragmas": [ + "^0.8.0" + ], + "artifacts": [ + "IERC721Receiver" + ] }, "/Users/peter/Development/trackyouraxe.v2/node_modules/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": { "lastModificationDate": 1652716973214, @@ -267,14 +324,22 @@ "evm.methodIdentifiers", "metadata" ], - "": ["ast"] + "": [ + "ast" + ] } } } }, - "imports": ["../IERC721.sol"], - "versionPragmas": ["^0.8.0"], - "artifacts": ["IERC721Metadata"] + "imports": [ + "../IERC721.sol" + ], + "versionPragmas": [ + "^0.8.0" + ], + "artifacts": [ + "IERC721Metadata" + ] }, "/Users/peter/Development/trackyouraxe.v2/node_modules/@openzeppelin/contracts/utils/Address.sol": { "lastModificationDate": 1652716955615, @@ -296,14 +361,20 @@ "evm.methodIdentifiers", "metadata" ], - "": ["ast"] + "": [ + "ast" + ] } } } }, "imports": [], - "versionPragmas": ["^0.8.1"], - "artifacts": ["Address"] + "versionPragmas": [ + "^0.8.1" + ], + "artifacts": [ + "Address" + ] }, "/Users/peter/Development/trackyouraxe.v2/node_modules/@openzeppelin/contracts/utils/Context.sol": { "lastModificationDate": 1652716955615, @@ -325,14 +396,20 @@ "evm.methodIdentifiers", "metadata" ], - "": ["ast"] + "": [ + "ast" + ] } } } }, "imports": [], - "versionPragmas": ["^0.8.0"], - "artifacts": ["Context"] + "versionPragmas": [ + "^0.8.0" + ], + "artifacts": [ + "Context" + ] }, "/Users/peter/Development/trackyouraxe.v2/node_modules/@openzeppelin/contracts/utils/Strings.sol": { "lastModificationDate": 1652716955616, @@ -354,14 +431,20 @@ "evm.methodIdentifiers", "metadata" ], - "": ["ast"] + "": [ + "ast" + ] } } } }, "imports": [], - "versionPragmas": ["^0.8.0"], - "artifacts": ["Strings"] + "versionPragmas": [ + "^0.8.0" + ], + "artifacts": [ + "Strings" + ] }, "/Users/peter/Development/trackyouraxe.v2/node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol": { "lastModificationDate": 1652716966153, @@ -383,14 +466,22 @@ "evm.methodIdentifiers", "metadata" ], - "": ["ast"] + "": [ + "ast" + ] } } } }, - "imports": ["./IERC165.sol"], - "versionPragmas": ["^0.8.0"], - "artifacts": ["ERC165"] + "imports": [ + "./IERC165.sol" + ], + "versionPragmas": [ + "^0.8.0" + ], + "artifacts": [ + "ERC165" + ] }, "/Users/peter/Development/trackyouraxe.v2/node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol": { "lastModificationDate": 1652716966154, @@ -412,14 +503,20 @@ "evm.methodIdentifiers", "metadata" ], - "": ["ast"] + "": [ + "ast" + ] } } } }, "imports": [], - "versionPragmas": ["^0.8.0"], - "artifacts": ["IERC165"] + "versionPragmas": [ + "^0.8.0" + ], + "artifacts": [ + "IERC165" + ] }, "/Users/peter/Development/trackyouraxe.v2/node_modules/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol": { "lastModificationDate": 1652716973213, @@ -441,14 +538,22 @@ "evm.methodIdentifiers", "metadata" ], - "": ["ast"] + "": [ + "ast" + ] } } } }, - "imports": ["../IERC721.sol"], - "versionPragmas": ["^0.8.0"], - "artifacts": ["IERC721Enumerable"] + "imports": [ + "../IERC721.sol" + ], + "versionPragmas": [ + "^0.8.0" + ], + "artifacts": [ + "IERC721Enumerable" + ] }, "/Users/peter/Development/trackyouraxe.v2/contracts/Provenance.sol": { "lastModificationDate": 1651602338123, @@ -470,7 +575,9 @@ "evm.methodIdentifiers", "metadata" ], - "": ["ast"] + "": [ + "ast" + ] } } } @@ -481,8 +588,12 @@ "./Mothership.sol", "./InstrumentDeedToken.sol" ], - "versionPragmas": ["0.8.10"], - "artifacts": ["Provenance"] + "versionPragmas": [ + "0.8.10" + ], + "artifacts": [ + "Provenance" + ] }, "/Users/peter/Development/trackyouraxe.v2/node_modules/hardhat/console.sol": { "lastModificationDate": 1652716951596, @@ -504,14 +615,20 @@ "evm.methodIdentifiers", "metadata" ], - "": ["ast"] + "": [ + "ast" + ] } } } }, "imports": [], - "versionPragmas": [">=0.4.22 <0.9.0"], - "artifacts": ["console"] + "versionPragmas": [ + ">=0.4.22 <0.9.0" + ], + "artifacts": [ + "console" + ] }, "/Users/peter/Development/trackyouraxe.v2/contracts/Mothership.sol": { "lastModificationDate": 1651602457710, @@ -533,7 +650,9 @@ "evm.methodIdentifiers", "metadata" ], - "": ["ast"] + "": [ + "ast" + ] } } } @@ -544,8 +663,12 @@ "./Provenance.sol", "./InstrumentDeedToken.sol" ], - "versionPragmas": ["0.8.10"], - "artifacts": ["Mothership"] + "versionPragmas": [ + "0.8.10" + ], + "artifacts": [ + "Mothership" + ] } } } diff --git a/hardhat.config.js b/hardhat.config.js index afb0ed8..99e161c 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -23,16 +23,14 @@ module.exports = { hardhat: { chainId: 31337, }, - /* - kovan: { - url: `${process.env.REACT_APP_KOVAN_INFURA_URL}`, - accounts:[`${process.env.REACT_APP_PRIVATE_KEY}`], + sepolia: { + url: `${process.env.KOVAN_INFURA_URL}`, + accounts:[`${process.env.PRIVATE_KEY}`], + }, + mumbai: { + url: `${process.env.MUMBAI_INFURA_URL}`, + accounts:[`${process.env.PRIVATE_KEY}`], }, - rinkeby: { - url: `${process.env.REACT_APP_RINKEBY_INFURA_URL}`, - accounts:[`${process.env.REACT_APP_PRIVATE_KEY}`], - } - */ }, solidity: { version: "0.8.10", diff --git a/lib/getPathsAndProps.js b/lib/getPathsAndProps.js deleted file mode 100644 index 6c3672f..0000000 --- a/lib/getPathsAndProps.js +++ /dev/null @@ -1,41 +0,0 @@ -import { useItemContext } from "../src/context/ItemContext"; -//ethers -import { ethers } from "ethers"; - -//abi -import Provenance from "../artifacts/contracts/Provenance.sol/Provenance.json"; - -// this needs to be rewritten for non-user specific data only - -export async function getProvenanceAddresses() { - const { MothershipContract } = useContractObjectRepo(); - // const {mainAccount, setMainAccount, signer, provider} = useHandleEthereum(); - - const addressArray = await MothershipContract.getOwnersInstruments(); - - const paths = addressArray.map((address) => ({ - params: { provenanceAddress: address.toString() }, - })); - - return { paths, fallback: false }; -} - -export function getProvenanceProps(context) { - const { provenanceObjects } = useItemContext(); - - const ProvenanceFullProps = []; - - provenanceObjects.map((array, index) => { - const { ProvenanceContract, ProvenanceProps, ProvenanceOwnerInfo } = array; - ProvenanceFullProps.push({ - ProvenanceContract, - ProvenanceProps, - ProvenanceOwnerInfo, - }); - }); - - return { - provAddress, - ProvenanceFullProps, - }; -} diff --git a/oldContracts/Mothership.sol b/oldContracts/Mothership.sol deleted file mode 100644 index 47b5935..0000000 --- a/oldContracts/Mothership.sol +++ /dev/null @@ -1,302 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.10; - -import "../node_modules/@openzeppelin/contracts/access/Ownable.sol"; -import "hardhat/console.sol"; -import "./Provenance.sol"; -import "./InstrumentDeedToken.sol"; - - - -// With Ownable it's currently over byte limit. Can get around with optimization or not using Ownable -contract Mothership { - - //maybe don't need Ownable if it bloats code too much? pushes it over limit without optimizer - - //Current Owner of Provenances. - mapping(address => Provenance[]) public ownersToAxes; - - mapping(address => bool) public provenanceVerify; - - mapping(address => address[]) public pendingTransfers; - - //To enable a loop that will return all provenances on frontend - address[] public ownerArray; - - Provenance[] public allProvenanceArray; - - - InstrumentDeedToken public instrumentDeedTokenContract; - - - //add modifier that confirms tokenOwner is caller - //constructor can also be removed and tokenAddress hardcoded - - constructor (address _tokenAddress) { - instrumentDeedTokenContract = InstrumentDeedToken(_tokenAddress); - } - - - event ProvenanceCreated( - Provenance.Types _enumType, - address childAddress, - string serial, - string brand, - string model, - uint16 year, - uint instrumentDeedToken, - string date, - string verificationPhotoHash, - string[] instrumentPhotoHashes); - - event ProvenanceSale( - address seller, - address buyer, - address provenanaceAddress, - string date - ); - - // SETTERS - - //this function needs to check that an existing provenance doesn't already exist for this instrument - function createNewProvenance( - Provenance.Types _enumType, - string memory _serial, - string memory _brand, - string memory _model, - uint16 _year, - uint _instrumentDeedToken, - string memory _date, - string memory _verificationPhotoHash, - string[] memory _instrumentPhotoHashes - ) external returns(address) { - //might need to check for dupes on frontend - require(msg.sender == instrumentDeedTokenContract.ownerOf(_instrumentDeedToken), "You are not the owner of the Deed Token for this instrument"); - Provenance provenance = new Provenance( - _enumType, - _serial, - _brand, - _model, - _year, - _instrumentDeedToken, - _date, - _verificationPhotoHash, - _instrumentPhotoHashes, - address(this), - address(instrumentDeedTokenContract)); - - if ((ownersToAxes[msg.sender]).length == 0) ownerArray.push(msg.sender); - ownersToAxes[msg.sender].push(provenance); - allProvenanceArray.push(provenance); - // ownerArray.push(msg.sender); - provenanceVerify[address(provenance)] = true; - - emit ProvenanceCreated( - _enumType, - address(provenance), - _serial, - _brand, - _model, - _year, - _instrumentDeedToken, - _date, - _verificationPhotoHash, - _instrumentPhotoHashes); - - return(address(provenance)); - - - } - - - // FUNCTIONS FOR TESTING ONLY!!!!!!!!!!!!! - function createPracticeProvenance( - Provenance.Types _enumType, - string memory _serial, - string memory _brand, - string memory _model, - uint16 _year, - uint _instrumentDeedToken, - string memory _date, - string memory _verificationPhotoHash, - string[] memory _instrumentPhotoHashes - ) public returns(address) { - //might need to check for dupes on frontend - Provenance provenance = new Provenance( - _enumType, - _serial, - _brand, - _model, - _year, - _instrumentDeedToken, - _date, - _verificationPhotoHash, - _instrumentPhotoHashes, - address(this), - address(instrumentDeedTokenContract)); - - - //ownerUpdates - if ((ownersToAxes[msg.sender]).length == 0) ownerArray.push(msg.sender); - ownersToAxes[msg.sender].push(provenance); - allProvenanceArray.push(provenance); - // ownerArray.push(msg.sender); - provenanceVerify[address(provenance)] = true; - - emit ProvenanceCreated( - _enumType, - address(provenance), - _serial, - _brand, - _model, - _year, - _instrumentDeedToken, - _date, - _verificationPhotoHash, - _instrumentPhotoHashes); - - return(address(provenance)); - - - } - - - function createBatchProvenances( - Provenance.Types _enumType, - string memory _serial, - string memory _brand, - string memory _model, - uint16 _year, - uint _instrumentDeedToken, - string memory _date, - string memory _verificationPhotoHash, - string[] memory _instrumentPhotoHashes - ) public { - for(uint i = 0; i<= 10; i++){ - createPracticeProvenance(_enumType, _serial, _brand, _model, _year, _instrumentDeedToken, _date, _verificationPhotoHash, _instrumentPhotoHashes); - } - } - // ************* - - function setPendingTransfer(address buyer, address provenanceAddress) external { - pendingTransfers[buyer].push(provenanceAddress); - } - - // these functions should be combined with the other ones below. the differing arrays can go in the arguments - function _findArrayIndex(address[] memory array, address provenance) pure internal returns(uint) { - uint index; - for (uint i = 0; i < array.length; i++) { - if (array[i] == provenance) { - index = i; - } - } - return index; - } - - - - function _burnTransferIndex(address buyer, uint index) internal { - require(index < pendingTransfers[buyer].length, "burn failed in require"); - pendingTransfers[buyer][index] = pendingTransfers[buyer][pendingTransfers[buyer].length-1]; - pendingTransfers[buyer].pop(); - } - - function removePendingTransfer(address buyer, address provenance) external { - uint index = _findArrayIndex(pendingTransfers[buyer], provenance); - - _burnTransferIndex(buyer, index); - - } - - - - - function getPendingTransfersOfBuyer(address buyer) public view returns(address[] memory){ - return pendingTransfers[buyer]; - } - - - // ************************ - // INTERNAL FUNCTIONS FOR updateOnProvenanceSale - // ************************ - - - function _findProvenanceIndex(address seller, Provenance provenanceForIndex) view internal returns(uint) { - uint index; - for (uint i = 0; i < ownersToAxes[seller].length; i++) { - if (ownersToAxes[seller][i] == provenanceForIndex) { - index = i; - } - } - return index; - } - - function _burnSoldProvenance(address seller, uint index) internal { - require(index < ownersToAxes[seller].length, "burn failed in require"); - ownersToAxes[seller][index] = ownersToAxes[seller][ownersToAxes[seller].length-1]; - ownersToAxes[seller].pop(); - } - - - //called from Provenance to update mothership state. needs tokenOwner modifier for security - function updateOnProvenanceSale(address seller, address buyer, Provenance provenanceSold, string memory date) external { - //update ownership - ownersToAxes[buyer].push(provenanceSold); - if ((ownersToAxes[msg.sender]).length == 0) ownerArray.push(msg.sender); - - uint index = _findProvenanceIndex(seller, provenanceSold); - - _burnSoldProvenance(seller, index); - - emit ProvenanceSale(msg.sender, buyer, address(provenanceSold), date); - - } - - - // ******** - // GETTERS - // ******** - - //dupes, figure which is needed and get rid of other - function getOwners() external view returns(address[] memory){ - return ownerArray; - } - - function getOwnersToAxesOwner(address owner) public view returns(Provenance[] memory) { - return ownersToAxes[owner]; - } - - //works - function getOwnersInstruments() public view returns(Provenance[] memory) { - return ownersToAxes[msg.sender]; - } - - //can also take this out and iterate through ownersToAxes with ownerArray on frontend as well - function getAllProvenances() external view returns(Provenance[] memory) { - return allProvenanceArray; - } - - - - - - /* - function disable(Provenance provenance) external { - children[child.index()].disable(); - disabledCount++; - } - */ - - //FOR OWNER ONLY functions - - // function setExistingProvenance() public onlyOwner { - - // } - - // function removeDuplicateProvenance() public onlyOwner { - - // } - -} - - diff --git a/oldContracts/Provenance.sol b/oldContracts/Provenance.sol deleted file mode 100644 index 5b65916..0000000 --- a/oldContracts/Provenance.sol +++ /dev/null @@ -1,241 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.10; - -import "../node_modules/@openzeppelin/contracts/access/Ownable.sol"; -import "hardhat/console.sol"; -import "./MothershipOptimization.sol"; -import "./InstrumentDeedToken.sol"; - - -/* To Dos: - more consistent naming - ipfs functions - token address (modifiable from third contract?) - updatale contract patterns? - */ - -contract Provenance is Ownable { - - //static instrument information - struct Instrument { - Types typeOfProvenance; - string serial; - string brand; - string model; - uint16 year; - uint instrumentDeedToken; - string[] photoHashes; - } - - struct Owner { - uint16 ownerCount; - address ownerAddress; - string verificationPhotoHash; - string date; - } - - struct Offer { - address buyer; - uint offer; - } - - Types public typeOfProvenance; - - Instrument public instrument; - - //For Buyer-Initated Transfer - - Offer public currentOffer; - - //For Seller-Initated Transfer - - address public pendingOwner; - - mapping(uint16 => Owner) public ownerProvenance; - - enum Types{Instrument, Gear, Accessory} - - uint8 public ownerCount; - - - - event OfferMade(address buyer, uint amount); - - //Contract Instances. Can hardcode Addresses for less gas(?) - InstrumentDeedToken public instrumentDeedTokenContract; - MothershipOptimization public mothershipContract; - - modifier onlyAuthorized() { - require(ownerProvenance[ownerCount].ownerAddress == msg.sender || owner() == msg.sender, "onlyAuthorized fail"); - _; - } - - //convert to bytes where possible for gas, shorten variable names - constructor( - Types enumType, - string memory _serial, - string memory _brand, - string memory _model, - uint16 _year, - uint _instrumentDeedToken, - string memory _date, - string memory _verificationPhotoHash, - string[] memory _instrumentPhotoHashes, - address _mothershipAddress, - address _deedTokenAddress) - { - - //set external contract addresses - mothershipContract = Mothership(_mothershipAddress); - instrumentDeedTokenContract = InstrumentDeedToken(_deedTokenAddress); - - //set Instrument Info - instrument.typeOfProvenance = enumType; - instrument.serial = _serial; - instrument.brand = _brand; - instrument.model = _model; - instrument.year = _year; - instrument.instrumentDeedToken = _instrumentDeedToken; - instrument.photoHashes = _instrumentPhotoHashes; - - //set Owner Info - - ownerCount = 1; - ownerProvenance[ownerCount] = Owner( - ownerCount, - instrumentDeedTokenContract.ownerOf(_instrumentDeedToken), - _verificationPhotoHash, - _date); - - - } - - - // ************************ - // Seller Initated Transfer - // ************************ - function setPendingOwner(address buyer) public onlyAuthorized { - pendingOwner = buyer; - - mothershipContract.setPendingTransfer(buyer, address(this)); - } - - //newOwner claims new Token on proof of ownership and updates all state - function claimOwnership(address _seller, string memory _verificationPhotoHash, string memory date) public { - require(msg.sender == pendingOwner, "You are not the pendingOwner of this item and therefore cannot claim it"); - - // mothership updates - mothershipContract.updateOnProvenanceSale(_seller, msg.sender, this, date); - mothershipContract.removePendingTransfer(msg.sender, address(this)); - - //remove pending owner - pendingOwner = address(0); - - //set new owner - ++ownerCount; - ownerProvenance[ownerCount] = Owner(ownerCount, msg.sender, _verificationPhotoHash, date); - - //transfer token - instrumentDeedTokenContract.safeTransferFrom(_seller, msg.sender, instrument.instrumentDeedToken); - } - - // ************************ - // Buyer Initated Transfer - // ************************ - - function makeOffer() public payable { - require(ownerProvenance[ownerCount].ownerAddress != msg.sender, "You cannot purchase your own Provenance"); - require(msg.value > 0, "Offer must be above 0 wei"); - require(msg.value > currentOffer.offer, "Offer must greater than current standing offer"); - - currentOffer.buyer = msg.sender; - currentOffer.offer = msg.value; - - emit OfferMade(msg.sender, msg.value); - - } - - - function cancelOffer() public { - require(msg.sender == currentOffer.buyer || msg.sender == ownerProvenance[ownerCount].ownerAddress); - uint declinedOffer = currentOffer.offer; - address declinedBuyer = currentOffer.buyer; - - currentOffer.buyer = address(0); - currentOffer.offer = 0; - (bool sent, ) = payable(declinedBuyer).call{value: declinedOffer}(""); - require(sent, "return transaction failed"); - - } - function uint2str(uint _i) internal pure returns (string memory _uintAsString) { - if (_i == 0) { - return "0"; - } - uint j = _i; - uint len; - while (j != 0) { - len++; - j /= 10; - } - bytes memory bstr = new bytes(len); - uint k = len; - while (_i != 0) { - k = k-1; - uint8 temp = (48 + uint8(_i - _i / 10 * 10)); - bytes1 b1 = bytes1(temp); - bstr[k] = b1; - _i /= 10; - } - return string(bstr); - } - - function acceptOffer() public payable { - require(msg.sender == ownerProvenance[ownerCount].ownerAddress); - require(currentOffer.offer > 0, "Offer is currently 0"); - - // mothership updates - mothershipContract.updateOnProvenanceSale(msg.sender, currentOffer.buyer, this, uint2str(block.timestamp)); - - //set new owner - ++ownerCount; - ownerProvenance[ownerCount] = Owner(ownerCount, currentOffer.buyer, "QmPhNm6hikNWTSX6AgHuf1BkbZbsXmKKEkDQRjRcdw7KZk", uint2str(block.timestamp)); - - - //transfer token - instrumentDeedTokenContract.safeTransferFrom(msg.sender, currentOffer.buyer, instrument.instrumentDeedToken); - - currentOffer.buyer = address(0); - currentOffer.offer = 0; - } - - // ******** - // Getters - // ******** - function getOwnershipHistory() public view returns(Owner[] memory) { - - Owner[] memory ownershipHistory = new Owner[](ownerCount+1); - - for (uint16 i = 1; i <= ownerCount; i++) { - - ownershipHistory[i] = ownerProvenance[i]; - console.log(i); - } - return ownershipHistory; - - } - - - function getItemPics() public view returns(string[] memory) { - return instrument.photoHashes; - } - - //publish new Instrument photo to Ipfs. Needs to replace old - function addNewInstrumentPhoto(string memory instrumentPhotoHash) public onlyOwner { - - } - - function setNewVerificationPhoto(string memory instrumentPhotoHash) public onlyOwner { - - } - -} \ No newline at end of file diff --git a/package.json b/package.json index 2d46481..8554cf1 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,8 @@ "lint": "next lint", "deploytoken": "hh run --network localhost scripts/deployInstrumentToken.js", "deploymothership": "hh run --network localhost scripts/deployMothership.js", + "deploytoken-mumbai": "hh run scripts/deployInstrumentToken.js --network mumbai", + "deploymothership-mumbai": "hh run scripts/deployMothership.js --network mumbai", "prettify": "yarn prettier --write ." }, "dependencies": { diff --git a/pages/_app.js b/pages/_app.js index 220d512..69b3f3c 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -3,7 +3,7 @@ import "../styles/global.css"; import { useEffect } from "react"; //temp style imports -import "../src/components/DragAndDrop.css"; +import "../src/components/DragAndDrop/DragAndDrop.css"; //component imports import NavBar from "../src/components/NavBar/NavBar"; diff --git a/pages/incoming-transfers/[incomingTransfer].js b/pages/incoming-transfers/[incomingTransfer].js index fe6f78c..18b5082 100644 --- a/pages/incoming-transfers/[incomingTransfer].js +++ b/pages/incoming-transfers/[incomingTransfer].js @@ -26,7 +26,7 @@ import { useUserContext } from "../../src/context/UserContext"; import { useTransferContext } from "../../src/context/TransferContext"; // component imports -import DragAndDrop from "../../src/components/DragAndDrop.js"; +import DragAndDrop from "../../src/components/DragAndDrop/DragAndDrop.js"; import PhotoPreviews from "../../src/components/PhotoPreviews.js"; // styles diff --git a/pages/provenances/index.jsx b/pages/provenances/index.jsx index feb1327..d17ab67 100644 --- a/pages/provenances/index.jsx +++ b/pages/provenances/index.jsx @@ -38,7 +38,7 @@ const OwnedProvenanceHub = () => { const router = useRouter(); // to rebuild page and add new item. can probably be optimized. - useEffect(async () => { + useEffect(() => { confirmAdded(); async function confirmAdded() { diff --git a/pages/register-item/RegisterItem.jsx b/pages/register-item/RegisterItem.jsx index 6212a56..f4ccb16 100644 --- a/pages/register-item/RegisterItem.jsx +++ b/pages/register-item/RegisterItem.jsx @@ -7,11 +7,11 @@ import Link from "next/link"; import { useRouter } from "next/router"; //component imports -import DragAndDrop from "../../src/components/DragAndDrop.js"; +import DragAndDrop from "../../src/components/DragAndDrop/DragAndDrop.js"; import PhotoPreviews from "../../src/components/PhotoPreviews.js"; // import { Modal } from '../../src/components/Modal.js'; -import { ConfirmationModal } from "../../src/components/ConfirmationModal.js"; +import { ConfirmationModal } from "../../src/components/ConfirmationModal/ConfirmationModal"; //context imports import { useUserContext } from "../../src/context/UserContext.js"; diff --git a/src/components/ConfirmationModal.js b/src/components/ConfirmationModal/ConfirmationModal.js similarity index 96% rename from src/components/ConfirmationModal.js rename to src/components/ConfirmationModal/ConfirmationModal.js index 5f69d3f..c238c62 100644 --- a/src/components/ConfirmationModal.js +++ b/src/components/ConfirmationModal/ConfirmationModal.js @@ -12,9 +12,7 @@ import { //import './ConfirmationModal.css'; -import waitingkitten from "../../public/images/waitingkitten.jpeg"; - -import { useUserContext } from "../context/UserContext"; +import { useUserContext } from "../../context/UserContext"; import styles from "./ConfirmationModal.module.css"; diff --git a/src/components/ConfirmationModal.module.css b/src/components/ConfirmationModal/ConfirmationModal.module.css similarity index 100% rename from src/components/ConfirmationModal.module.css rename to src/components/ConfirmationModal/ConfirmationModal.module.css diff --git a/src/components/ConnectWalletButton.js b/src/components/ConnectWalletButton/ConnectWalletButton.js similarity index 92% rename from src/components/ConnectWalletButton.js rename to src/components/ConnectWalletButton/ConnectWalletButton.js index 975c29f..3d744b6 100644 --- a/src/components/ConnectWalletButton.js +++ b/src/components/ConnectWalletButton/ConnectWalletButton.js @@ -1,15 +1,15 @@ import { useState, React, useEffect } from "react"; import { ethers } from "ethers"; -import { useUserContext } from "../context/UserContext"; +import { useUserContext } from "../../context/UserContext"; // images -import greenCheckMark from "../../public/images/green_checkmark.png"; +import greenCheckMark from "../../../public/images/green_checkmark.png"; // styles import { Button, Image, Dropdown } from "react-bootstrap"; import styles from "./ConnectWalletButton.module.css"; -import { truncateAddress } from "../hooks/utils"; +import { truncateAddress } from "../../hooks/utils"; const ConnectWalletButton = () => { const { diff --git a/src/components/ConnectWalletButton.module.css b/src/components/ConnectWalletButton/ConnectWalletButton.module.css similarity index 100% rename from src/components/ConnectWalletButton.module.css rename to src/components/ConnectWalletButton/ConnectWalletButton.module.css diff --git a/src/components/DragAndDrop.css b/src/components/DragAndDrop/DragAndDrop.css similarity index 96% rename from src/components/DragAndDrop.css rename to src/components/DragAndDrop/DragAndDrop.css index f5de1dd..1d23d16 100644 --- a/src/components/DragAndDrop.css +++ b/src/components/DragAndDrop/DragAndDrop.css @@ -29,7 +29,7 @@ .upload-icon { width: 50px; height: 50px; - background: url(../../public/images/upload.png) no-repeat center center; + background: url(../../../public/images/upload.png) no-repeat center center; background-size: 100%; text-align: center; margin: 0 auto; @@ -123,7 +123,7 @@ .file-type-logo { width: 50px; height: 50px; - background: url(../../public/images/generic.png) no-repeat center center; + background: url(../../../public/images/generic.png) no-repeat center center; background-size: 100%; position: absolute; } diff --git a/src/components/DragAndDrop.js b/src/components/DragAndDrop/DragAndDrop.js similarity index 99% rename from src/components/DragAndDrop.js rename to src/components/DragAndDrop/DragAndDrop.js index 25426c3..aa09245 100644 --- a/src/components/DragAndDrop.js +++ b/src/components/DragAndDrop/DragAndDrop.js @@ -4,7 +4,7 @@ import { Spinner, Button } from "react-bootstrap"; import Image from "next/image"; -import waitingkitten from "../../public/images/waitingkitten.jpeg"; +import waitingkitten from "../../../public/images/waitingkitten.jpeg"; //import './DragAndDrop.css'; diff --git a/src/components/NavBar/NavBar.js b/src/components/NavBar/NavBar.js index e4a73ee..8d2fd5c 100644 --- a/src/components/NavBar/NavBar.js +++ b/src/components/NavBar/NavBar.js @@ -1,7 +1,7 @@ import { useState, useEffect } from "react"; // component imports -import ConnectWalletButton from "../ConnectWalletButton"; +import ConnectWalletButton from "../ConnectWalletButton/ConnectWalletButton"; // context imports import { useUserContext } from "../../context/UserContext"; diff --git a/src/deployedContractAddresses/instrumenttokenaddress.json b/src/deployedContractAddresses/instrumenttokenaddress.json index 06c6404..3c945a4 100644 --- a/src/deployedContractAddresses/instrumenttokenaddress.json +++ b/src/deployedContractAddresses/instrumenttokenaddress.json @@ -1 +1 @@ -{ "address": "0x5FbDB2315678afecb367f032d93F642f64180aa3" } +{ "address": "0x5FbDB2315678afecb367f032d93F642f64180aa3" } \ No newline at end of file diff --git a/src/deployedContractAddresses/mothershipaddress.json b/src/deployedContractAddresses/mothershipaddress.json index 5338401..9a49500 100644 --- a/src/deployedContractAddresses/mothershipaddress.json +++ b/src/deployedContractAddresses/mothershipaddress.json @@ -1 +1 @@ -{ "address": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512" } +{ "address": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512" } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 84d2a7e..7ee5a6f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5519,9 +5519,9 @@ caniuse-api@^3.0.0: lodash.uniq "^4.5.0" caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000844, caniuse-lite@^1.0.30001283, caniuse-lite@^1.0.30001332, caniuse-lite@^1.0.30001335: - version "1.0.30001341" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001341.tgz#59590c8ffa8b5939cf4161f00827b8873ad72498" - integrity sha512-2SodVrFFtvGENGCv0ChVJIDQ0KPaS1cg7/qtfMaICgeMolDdo/Z2OD32F0Aq9yl6F4YFwGPBS5AaPqNYiW4PoA== + version "1.0.30001445" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001445.tgz" + integrity sha512-8sdQIdMztYmzfTMO6KfLny878Ln9c2M0fc7EH60IjlP4Dc4PiCy7K2Vl3ITmWgOyPgVQKa5x+UP/KqFsxj4mBg== case-sensitive-paths-webpack-plugin@^2.4.0: version "2.4.0"