Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement uups proxy method #10

Merged
merged 9 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 45 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,35 @@ ____

## Current Deployments

(CNFT V5: Finalized Implementation // CODENAME: "CATALOGV1")
(CNFT V6: Finalized Implementation // CODENAME: "CATALOGV1")

Rinkeby Deployer Address: `0x43C4D51dE4b7bf046d92c324678a1a3969703632`


| Contract | Address | Etherscan |
| ----------------- |:------------------------------------------:| ---------------------------------------------------------------------------------------------:|
| Catalog Proxy | 0x232Dd4a3AB377C9225E49c5932Ae8A694aa7c0b5 | [link](https://rinkeby.etherscan.io/address/0x232Dd4a3AB377C9225E49c5932Ae8A694aa7c0b5) |
| V1 Implementation | 0xd25E883Ba97a851252b2459827503b829d1c4b40 | [link](https://rinkeby.etherscan.io/address/0xd25E883Ba97a851252b2459827503b829d1c4b40) |



Gas Stats (measured at 130 gwei/gas):

- `burn` (39905 avg)
- `mint` (200089 avg) ***ohhhh yeahhhh***
- `updateContentURI` (32810 avg)
- `updateCreator` (35680 avg)
- `updateMetadataURI` (46477 avg)
- `updateRoot` (35052 avg)
- `updateRoyaltyInfo` (35660 avg)
- `transferFrom` (62538 avg)


____

## Past Deployments

(nullified) Final implementation (TRANSPARENT PROXY)
| Contract | Address | Etherscan |
| ----------------- |:------------------------------------------:| ---------------------------------------------------------------------------------------------:|
| Catalog Proxy | 0x86e9dA93658807F8343A8D7B6ABc405d200e566F | [link](https://rinkeby.etherscan.io/address/0x86e9dA93658807F8343A8D7B6ABc405d200e566F) |
Expand All @@ -63,10 +87,6 @@ Gas Stats (measured at 130 gwei/gas):
- `transferFrom` (62737 avg)


____

## Past Deployments

Proposed Final Implementation
(CNFT V4: CODENAME "CFR")

Expand Down Expand Up @@ -271,6 +291,26 @@ ____

Repo is setup with ESLint/Prettier/Solhint

Running Prettier:

```bash
yarn format
```

```bash
yarn format:fix
```

Running ESLint/Solhint:

```bash
yarn lint
```

```bash
yarn lint:fix
```

____


Expand Down
2 changes: 1 addition & 1 deletion addresses/4.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"catalog": "0x86e9dA93658807F8343A8D7B6ABc405d200e566F"
"catalog": "0x232Dd4a3AB377C9225E49c5932Ae8A694aa7c0b5"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
67 changes: 67 additions & 0 deletions archive/old-deployments/008_deploy_cataloguups.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// // deploy script for CatalogUUPS

// // Uses OZ Hardhat Upgrades, saves deployment for hardhat-deploy

// import {HardhatRuntimeEnvironment} from 'hardhat/types';
// import {DeployFunction} from 'hardhat-deploy/types';
// import {ethers, upgrades} from 'hardhat';

// const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
// const {deployments, getNamedAccounts} = hre;
// const {deploy, log, catchUnknownSigner, save} = deployments;

// // Get accounts
// const {deployer, tokenOwner, multisig} = await getNamedAccounts();

// const CatalogUUPS = await ethers.getContractFactory('CatalogUUPS');

// // Deploy UUPS Proxy
// const proxy = await upgrades.deployProxy(CatalogUUPS, ['Catalog', 'cNFT'], {
// kind: 'uups',
// });
// console.log(
// '\x1b[36m%s\x1b[0m',
// 'Deployed CatalogUUPS Proxy to:',
// proxy.address
// );
// // wait for confirmation
// await proxy.deployed();

// // Deploy implementation
// // Modify this for upgrades
// const implementation = await upgrades.upgradeProxy(proxy, CatalogUUPS);

// const implementationAddress = await upgrades.erc1967.getImplementationAddress(proxy.address);
// console.log(
// '\x1b[36m%s\x1b[0m',
// 'Deploy CatalogUUPS implementation to:',
// implementationAddress
// );

// const artifact = await deployments.getExtendedArtifact('CatalogUUPS');

// const proxyDeployments = {
// address: proxy.address,
// ...artifact,
// };

// if (proxy.address && implementation.address) {
// log(
// '\x1b[36m%s\x1b[0m',
// `
// contract: CatalogUUPS deployed at ${proxy.address}
// using ${proxy.receipt?.gasUsed} gas.
// Owner (to): ${proxy.receipt?.to}
// implementation: ${implementationAddress}
// Signed from : ${proxy.receipt?.from}
// `
// );
// }

// await save('CatalogUUPS', proxyDeployments);
// };

// export default func;

// // Deployment tags
// func.tags = ['CatalogUUPS'];
File renamed without changes.
File renamed without changes.
18 changes: 17 additions & 1 deletion contracts/catalog/Catalog.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {IERC2981Upgradeable, IERC165Upgradeable} from "@openzeppelin/contracts-u
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import {CountersUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol";
import {MerkleProofUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/cryptography/MerkleProofUpgradeable.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";

/**
--------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -38,7 +39,7 @@ https://catalog.works/terms

---------------------------------------------------------------------------------------------------------------------
*/
contract Catalog is ERC721Upgradeable, IERC2981Upgradeable, OwnableUpgradeable {
contract Catalog is ERC721Upgradeable, IERC2981Upgradeable, OwnableUpgradeable, UUPSUpgradeable {
using CountersUpgradeable for CountersUpgradeable.Counter;

/// Events
Expand Down Expand Up @@ -68,6 +69,9 @@ contract Catalog is ERC721Upgradeable, IERC2981Upgradeable, OwnableUpgradeable {
/// Merkle Root
bytes32 public merkleRoot;

/// @custom:oz-upgrades-unsafe-allow constructor
constructor() initializer {}

/**
initialize Function
@notice Initializes contract with default values, acts as a constructor
Expand All @@ -78,6 +82,7 @@ contract Catalog is ERC721Upgradeable, IERC2981Upgradeable, OwnableUpgradeable {
function initialize(string memory _name, string memory _symbol) public initializer {
__ERC721_init(_name, _symbol);
__Ownable_init();
__UUPSUpgradeable_init();

/// Start tokenId @ 1
_tokenIdCounter.increment();
Expand Down Expand Up @@ -218,6 +223,17 @@ contract Catalog is ERC721Upgradeable, IERC2981Upgradeable, OwnableUpgradeable {
tokenData[_tokenId].royaltyPayout = _royaltyPayoutAddress;
}

/// ----- OVERRIDES --- ///

/**
_authorizeUpgrade Function
@notice override of UUPSUpgradeable authorizeUpgrade function.
Can be modified to supportv different authorization schemes.
@param newImplementation address of the new implementation contract
@dev access controlled to owner only, issues upgrade.
*/
function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}

/**
tokenURI Function
@notice override function to get the URI of a token. returns stored metadataURI
Expand Down
Loading