Skip to content

Commit

Permalink
mainnet deploy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
princetonbishop committed Oct 6, 2023
1 parent 171357e commit 757c3d6
Show file tree
Hide file tree
Showing 12 changed files with 226 additions and 18 deletions.
2 changes: 1 addition & 1 deletion protocol/contracts/fakes/nexus/TestnetRelic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { CommonEventsAndErrors } from "../../common/CommonEventsAndErrors.sol";
import { IShard } from "../../interfaces/nexus/IShard.sol";


contract Relic is ERC721ACustom, ERC1155Receiver {
contract TestnetRelic is ERC721ACustom, ERC1155Receiver {
using SafeERC20 for IERC20;
using EnumerableSet for EnumerableSet.UintSet;

Expand Down
3 changes: 2 additions & 1 deletion protocol/contracts/fakes/nexus/TestnetShard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ERC1155Burnable } from "@openzeppelin/contracts/token/ERC1155/extension
import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import { CommonEventsAndErrors } from "../../common/CommonEventsAndErrors.sol";

contract Shard is ERC1155, ERC1155Burnable {
contract TestnetShard is ERC1155, ERC1155Burnable {
using EnumerableSet for EnumerableSet.UintSet;
/// @notice Relic NFT contract
IRelic public relic;
Expand Down Expand Up @@ -90,6 +90,7 @@ contract Shard is ERC1155, ERC1155Burnable {
) ERC1155(_uri) {
relic = IRelic(_relic);
_currentIndex = _currentRecipeIndex = _startTokenId();
operators[msg.sender] = true;
}

function setOperator(address operator, bool allow) external onlyOperator {
Expand Down
2 changes: 1 addition & 1 deletion protocol/contracts/fakes/nexus/TestnetTempleSacrifice.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ITempleERC20Token } from "../../interfaces/core/ITempleERC20Token.sol";
import { CommonEventsAndErrors } from "../../common/CommonEventsAndErrors.sol";
import { mulDiv } from "@prb/math/src/Common.sol";

contract TempleSacrifice is Ownable {
contract TestnetTempleSacrifice is Ownable {
using SafeERC20 for ITempleERC20Token;

/// @notice the Relic ERC721A token
Expand Down
2 changes: 0 additions & 2 deletions protocol/scripts/deploys/arbitrumGoerli/nexus/01-relic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import {
deployAndMine,
ensureExpectedEnvvars,
} from '../../helpers';
import { getDeployedContracts } from '../../v2/sepolia/contract-addresses';

async function main() {
ensureExpectedEnvvars();
const [owner] = await ethers.getSigners();

const ownerAddress = await owner.getAddress();
const relicFactory= new TestnetRelic__factory(owner);
await deployAndMine(
'RELIC',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ async function main() {

const ownerAddress = await owner.getAddress();

// TESTNET ONLY -- Allow msig & owner to mint Testnet Temple
{
// await mine(templeV2contracts.templeToken.addMinter(TEMPLE_V2_DEPLOYED.CORE.EXECUTOR_MSIG));
// TESTNET ONLY -- Allow owner to mint Testnet Temple
{
await mine(temple.addMinter(ownerAddress));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ async function main() {
ensureExpectedEnvvars();

const [owner] = await ethers.getSigners();
const ownerAddress = await owner.getAddress();
const deployedContracts = DEPLOYED_CONTRACTS[network.name];
const shardId1 = 123;
const shardId2 = 456;
Expand All @@ -22,13 +21,6 @@ async function main() {
const uri4 = "http://example4.com";
const shard = TestnetShard__factory.connect(deployedContracts.SHARD, owner);

// minters and partners
{
const shardIds = [shardId4];
const allowed = [true];
await mine(shard.setPartnerAllowedShardIds(ownerAddress, shardIds, allowed));
await mine(shard.setPartnerAllowedShardCaps(ownerAddress, shardIds, [99999]));
}
// uri and recipe
{
const recipe = {
Expand All @@ -37,8 +29,7 @@ async function main() {
outputShardIds: [shardId3],
outputShardAmounts: [1]
};
const recipeId = 1;
await mine(shard.setRecipe(recipeId, recipe));
await mine(shard.setRecipe(recipe));
await mine(shard.setShardUri(shardId1, uri1));
await mine(shard.setShardUri(shardId2, uri2));
await mine(shard.setShardUri(shardId3, uri3));
Expand Down
36 changes: 36 additions & 0 deletions protocol/scripts/deploys/mainnet/nexus/01-relic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import '@nomiclabs/hardhat-ethers';
import { ethers } from 'hardhat';
import { Relic__factory } from '../../../../typechain';
import {
deployAndMine,
ensureExpectedEnvvars,
} from '../../helpers';


async function main() {
ensureExpectedEnvvars();
const [owner] = await ethers.getSigners();
const initialRescuer = "";
const initialExecutor = "";

const relicFactory = new Relic__factory(owner);
await deployAndMine(
'RELIC',
relicFactory,
relicFactory.deploy,
'RELIC',
'REL',
initialRescuer,
initialExecutor
);
}

// 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);
});

37 changes: 37 additions & 0 deletions protocol/scripts/deploys/mainnet/nexus/02-shard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import '@nomiclabs/hardhat-ethers';
import { ethers, network } from 'hardhat';
import { Shard__factory } from '../../../../typechain';
import {
deployAndMine,
ensureExpectedEnvvars,
DEPLOYED_CONTRACTS
} from '../../helpers';

async function main() {
ensureExpectedEnvvars();
const [owner] = await ethers.getSigners();
const initialRescuer = "";
const initialExecutor = "";
const relicAddress = DEPLOYED_CONTRACTS[network.name].RELIC;;
const uri = "";

const shardFactory = new Shard__factory(owner);
await deployAndMine(
'SHARD',
shardFactory,
shardFactory.deploy,
relicAddress,
initialRescuer,
initialExecutor,
uri
);
}

// 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);
});
35 changes: 35 additions & 0 deletions protocol/scripts/deploys/mainnet/nexus/03-temple-sacrifice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import '@nomiclabs/hardhat-ethers';
import { ethers, network } from 'hardhat';
import { TempleSacrifice__factory } from '../../../../typechain';
import {
deployAndMine,
ensureExpectedEnvvars,
DEPLOYED_CONTRACTS
} from '../../helpers';

async function main() {
ensureExpectedEnvvars();
const [owner] = await ethers.getSigners();

const relicAddress = DEPLOYED_CONTRACTS[network.name].RELIC;
const templeTokenAddress = DEPLOYED_CONTRACTS[network.name].TEMPLE;;

const templeSacrificeFactory = new TempleSacrifice__factory(owner);
await deployAndMine(
'TEMPLE_SACRIFICE',
templeSacrificeFactory,
templeSacrificeFactory.deploy,
relicAddress,
templeTokenAddress
);
}


// 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);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { ethers, network } from 'hardhat';
import {
ensureExpectedEnvvars,
mine
} from '../../helpers';
import { Relic__factory } from '../../../../typechain';
import { DEPLOYED_CONTRACTS } from '../../helpers';


async function main() {
ensureExpectedEnvvars();

const [owner] = await ethers.getSigners();
const deployedContracts = DEPLOYED_CONTRACTS[network.name];
const relic = Relic__factory.connect(deployedContracts.RELIC, owner);

// set shard
const shardAddress = deployedContracts.SHARD;
{
await mine(relic.setShard(shardAddress));
}
// set relic minter (temple sacrifice)
const templeSacrificeAddress = deployedContracts.TEMPLE_SACRIFICE;
{
await mine(relic.setRelicMinter(templeSacrificeAddress, true));
}
// set xp controller
{

}
}

// 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);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { ethers, network } from 'hardhat';
import {
ensureExpectedEnvvars,
mine
} from '../../helpers';
import { TempleERC20Token__factory, Shard__factory } from '../../../../typechain';
import { DEPLOYED_CONTRACTS } from '../../helpers';


async function main() {
ensureExpectedEnvvars();

const [owner] = await ethers.getSigners();
const deployedContracts = DEPLOYED_CONTRACTS[network.name];
const shard = Shard__factory.connect(deployedContracts.SHARD, owner);


}

// 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);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { ethers, network } from 'hardhat';
import {
ensureExpectedEnvvars,
mine,
toAtto
} from '../../helpers';
import { TempleSacrifice__factory } from '../../../../typechain';
import { DEPLOYED_CONTRACTS } from '../../helpers';


async function main() {
ensureExpectedEnvvars();

const [owner] = await ethers.getSigners();
const deployedContracts = DEPLOYED_CONTRACTS[network.name];
const templeSacrifice = TempleSacrifice__factory.connect(deployedContracts.TEMPLE_SACRIFICE, owner);

// set sacrificed temple recipient
{
await mine(templeSacrifice.setSacrificedTempleRecipient(''));
}
// set price params
{
const priceParams = {
minimumPrice: toAtto(40),
maximumPrice: toAtto(100),
priceMaxPeriod: 365 * 24 * 60 * 60
}
await mine(templeSacrifice.setPriceParams(priceParams));
}
// set origin time
{

}
}

// 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);
});

0 comments on commit 757c3d6

Please sign in to comment.