Skip to content

Commit

Permalink
namespace proxies working
Browse files Browse the repository at this point in the history
  • Loading branch information
cblanquera committed Mar 11, 2022
1 parent 2e028df commit ee2b37f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ yarn-error.log*
#Hardhat files
cache
artifacts
.openzeppelin
17 changes: 12 additions & 5 deletions scripts/deploy-gns.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@

const hardhat = require('hardhat')

const { getImplementationAddress } = require('@openzeppelin/upgrades-core')

const uri = 'https://ipfs.io/ipfs/bafkreicw32mefimobvabviirb7rao45r3kpy5zdudiputyubcmp2gag4xa'

async function main() {
await hre.run('compile')
const NFT = await hardhat.ethers.getContractFactory('GryphNamespaces')
const nft = await hardhat.upgrades.deployProxy(NFT, [uri], { initializer: 'initialize'})
await nft.deployed()
console.log('NFT contract deployed to (update .env):', nft.address)
console.log('npx hardhat verify --network', hardhat.config.defaultNetwork, nft.address, `"${uri}"`)
const Upgradeable = await hardhat.ethers.getContractFactory('GryphNamespaces')
const proxy = await hardhat.upgrades.deployProxy(Upgradeable, [uri], { initializer: 'initialize'})
await proxy.deployed()

const network = hardhat.config.networks[hardhat.config.defaultNetwork]
const provider = new hardhat.ethers.providers.JsonRpcProvider(network.url)
const implementation = await getImplementationAddress(provider, proxy.address);

console.log('Proxy contract deployed to (update .env):', proxy.address)
console.log('npx hardhat verify --network', hardhat.config.defaultNetwork, implementation, `"${uri}"`)
}

// We recommend this pattern to be able to use async/await everywhere
Expand Down
23 changes: 23 additions & 0 deletions scripts/upgrade-gns.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//to run this on testnet:
// $ npx hardhat run scripts/deploy-gns.js

const hardhat = require('hardhat')

async function main() {
await hre.run('compile')
const network = hardhat.config.networks[hardhat.config.defaultNetwork]
const NFT = await hardhat.ethers.getContractFactory('GryphNamespaces')
const nft = await hardhat.upgrades.UpgradeProxy(network.contracts.namespaces, NFT)
await nft.deployed()
console.log('Proxy contract updated to (update .env):', nft.address)
}

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().then(() => process.exit(0)).catch(error => {
console.error(error)
process.exit(1)
});

//$ npx hardhat verify --network testnet 0xCFe522301C7246401387003156dFb7cd4826Bd3b "https://ipfs.io/ipfs/bafkreicw32mefimobvabviirb7rao45r3kpy5zdudiputyubcmp2gag4xa"
//$ npx hardhat verify --network mainnet

0 comments on commit ee2b37f

Please sign in to comment.