Skip to content

Commit

Permalink
feat: migrate deployment complete
Browse files Browse the repository at this point in the history
  • Loading branch information
RasenGUY committed Nov 25, 2023
1 parent 503c3e8 commit c697dad
Show file tree
Hide file tree
Showing 28 changed files with 92 additions and 250 deletions.
7 changes: 6 additions & 1 deletion contracts/WegaRandomizerController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ contract WegaRandomizerController is AccessControlErrors, WegaProtocolAdminRole,
_;
}

modifier onlyGameControllerOrAdmin {
require(hasRole(GAME_CONTROLLER_ROLE, _msgSender()) || hasRole(WEGA_PROTOCOL_ADMIN_ROLE, _msgSender()), CALLER_NOT_ALLOWED);
_;
}

function initialize(uint256[] memory randomNumbers) initializer public {
__UUPSUpgradeable_init();
__WegaProtocolAdminRole_init();
Expand All @@ -58,7 +63,7 @@ contract WegaRandomizerController is AccessControlErrors, WegaProtocolAdminRole,
return result;
}

function seedRandomizer(uint256[] memory randomNumbers) public override onlyRole(GAME_CONTROLLER_ROLE) {
function seedRandomizer(uint256[] memory randomNumbers) public override onlyGameControllerOrAdmin {
getRandomizer().seed(randomNumbers);
}

Expand Down
96 changes: 44 additions & 52 deletions deployed-addresses.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,102 +4,91 @@
"1337": {
"contracts": {
"WegaERC20Escrow": {
"address": "0x8ac87219a0F5639BC01b470F87BA2b26356CB2B9",
"address": "0xa82fF9aFd8f496c3d6ac40E2a0F282E47488CFc9",
"legacyAddresses": [
"0x5FC8d32690cc91D4c39d9d3abcBD16989F875707"
],
"deploymentBlock": "0x0130",
"implementation": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9"
"deploymentBlock": "130",
"implementation": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853"
},
"WegaERC20Dummy": {
"address": "0x572316aC11CB4bc5daf6BDae68f43EA3CCE3aE0e",
"address": "0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690",
"legacyAddresses": [],
"deploymentBlock": "0x012c"
"deploymentBlock": "12c"
},
"WegaGameController": {
"address": "0x742489F22807ebB4C36ca6cD95c3e1C044B7B6c8",
"address": "0x0E801D84Fa97b50751Dbf25036d067dCf18858bF",
"legacyAddresses": [
"0x5FC8d32690cc91D4c39d9d3abcBD16989F875707"
],
"deploymentBlock": "0x0138",
"implementation": "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1"
"deploymentBlock": "138",
"implementation": "0x09635F643e140090A9A8Dcd712eD6285858ceBef"
},
"WegaRandomNumberController": {
"address": "0xCa1D199b6F53Af7387ac543Af8e8a34455BBe5E0",
"WegaRandomizerController": {
"address": "0xf5059a5D33d5853360D16C683c16e67980206f36",
"legacyAddresses": [],
"deploymentBlock": "0x0132",
"implementation": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853"
"implementation": "0x851356ae760d987E095750cCeb3bC6014560891C"
},
"WegaDiceGame": {
"address": "0xB22C255250d74B0ADD1bfB936676D2a299BF48Bd",
"address": "0x4826533B4897376654Bb4d4AD88B7faFD0C98528",
"legacyAddresses": [],
"deploymentBlock": "0x0136",
"implementation": "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82"
"deploymentBlock": "136",
"implementation": "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f"
},
"WegaCoinFlipGame": {
"address": "0xf5c4a909455C00B99A90d93b48736F3196DB5621",
"address": "0x998abeb3E57409262aE5b751f60747921B33613E",
"legacyAddresses": [],
"deploymentBlock": "0x0134",
"implementation": "0x610178dA211FEF7D417bC0e6FeD39F05609AD788"
"deploymentBlock": "134",
"implementation": "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82"
},
"FeeManager": {
"address": "0x4593ed9CbE6003e687e5e77368534bb04b162503",
"address": "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB",
"legacyAddresses": [],
"deploymentBlock": "0x012e",
"implementation": "0x975Ab64F4901Af5f0C96636deA0b9de3419D0c2F"
"deploymentBlock": "12e",
"implementation": "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0"
},
"WegaRandomizer": {
"address": "0x0000000000000000000000000000000000000000"
},
"WegaChanceGame": {
"address": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9",
"legacyAddresses": [],
"deploymentBlock": "0x05",
"deploymentBlock": "5",
"implementation": "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9"
},
"WegaRandomNumberController": {
"address": "0xCa1D199b6F53Af7387ac543Af8e8a34455BBe5E0",
"legacyAddresses": [],
"deploymentBlock": "132",
"implementation": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853"
}
}
},
"80001": {
"contracts": {
"WegaERC20Escrow": {
"address": "0x08052EEaf0c3F42cd38331E1C3D188Cd108E0C10",
"legacyAddresses": [],
"deploymentBlock": "0x0263113a",
"implementation": "0xf731b996738AA8909Ca18f8954395Ff4b62B305d"
"address": "0x0000000000000000000000000000000000000000"
},
"WegaERC20Dummy": {
"address": "0x818120D7f6C1f96C3ddb45B1363752E6688F3a9C",
"legacyAddresses": [],
"deploymentBlock": "0x0263112e"
"address": "0x0000000000000000000000000000000000000000"
},
"WegaGameController": {
"address": "0xC69cD908504C554eaD8D24354e018e3a37e7F29b",
"legacyAddresses": [
"0x760D87Ce891F301d19F608044D42356De2D50D14",
"0x740e1416aE865E2bff8f95aa5776F5Fa0a3706e7",
"0x02D7EF0f678BCd9323f2FA88e7197528D113f24a",
"0x0000000000000000000000000000000000000000"
],
"deploymentBlock": "0x0272c37b",
"implementation": "0xAF0A650F026419776015fF248DFefC2768497C4C"
"address": "0x0000000000000000000000000000000000000000"
},
"WegaRandomNumberController": {
"address": "0xaBC8837A5756aF9a915a8cC77b80b06c1997e17e",
"legacyAddresses": [],
"deploymentBlock": "0x02631148",
"implementation": "0xCC6e334201974DF201EBb4bd84b97ac232fE7380"
"WegaRandomizerController": {
"address": "0x0000000000000000000000000000000000000000"
},
"WegaDiceGame": {
"address": "0x95c44B6F23D361c071667129F2A06Ae4275d7cC6",
"legacyAddresses": [],
"deploymentBlock": "0x0263116f",
"implementation": "0x18279b8235b84f68db39f76aF481DcD5aBa75218"
"address": "0x0000000000000000000000000000000000000000"
},
"WegaCoinFlipGame": {
"address": "0x80B0AC09f6c42c0010731186DCBfbeb9D1A1C76f",
"legacyAddresses": [],
"deploymentBlock": "0x02631158",
"implementation": "0x1d4A2C0Ce54525f555Bbe772f5b8132ECf2002BD"
"address": "0x0000000000000000000000000000000000000000"
},
"FeeManager": {
"address": "0x0000000000000000000000000000000000000000"
},
"WegaRandomizer": {
"address": "0x0000000000000000000000000000000000000000"
}
}
},
Expand All @@ -114,7 +103,7 @@
"WegaGameController": {
"address": "0x0000000000000000000000000000000000000000"
},
"WegaRandomNumberController": {
"WegaRandomizerController": {
"address": "0x0000000000000000000000000000000000000000"
},
"WegaDiceGame": {
Expand All @@ -125,6 +114,9 @@
},
"FeeManager": {
"address": "0x0000000000000000000000000000000000000000"
},
"WegaRandomizer": {
"address": "0x0000000000000000000000000000000000000000"
}
}
}
Expand Down
1 change: 0 additions & 1 deletion scripts/configure_protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { network } from 'hardhat';
import { getNetworkConfig } from '../src/config';
import { Deployer } from '../src/deployer';
import { unwrap } from '../src/helpers';
import { ArtifactName, ContractName } from '../src/types';

async function main () {
const deployer = await Deployer.create();
Expand Down
13 changes: 7 additions & 6 deletions scripts/crawl-random-numbers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getRandomNumbersConfig, mergeRandomNumConfig } from '../src/config';
import { utils, BigNumber } from 'ethers';
import { solidityPackedSha256, toBigInt } from 'ethers';
import { unwrap } from '../src/helpers';
import { network } from "hardhat";

Expand Down Expand Up @@ -36,11 +36,12 @@ async function getRandomNumber(
cache: 'no-cache' as RequestCache
}

const url = `https://api.drand.sh/${chainHash}/public/${round}`
const url = `https://api.drand.sh/dbd506d6ef76e5f386f41c651dcb808c5bcbd75471cc4eafa3f4df7ad4e4c493/public/4000`;
const ran = '0xea97d6b28d3a4111b1ed17a770ae473dff631b0fa0dc913d02245b7205a77ae6'
let fulfilled = false;
let result: { round: number, randomness: string, signature: string } = {
let result: { round: number, randomness: bigint, signature: string } = {
round: 0,
randomness: "",
randomness: 0n,
signature: "",
}
while (!fulfilled) {
Expand All @@ -60,8 +61,8 @@ async function getRandomNumber(
return result;
}

function convertBytesToNumber(bytes: string){
return BigNumber.from(String(utils.sha256(utils.arrayify("0x".concat(bytes))))).toString()
function convertBytesToNumber(bytes: string): bigint {
return toBigInt(solidityPackedSha256(['bytes'],["0x".concat(bytes)]));
}

main().then(() => console.log('DONE!')).catch(e => {
Expand Down
2 changes: 1 addition & 1 deletion scripts/deploy_coinflip-game.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ethers, network } from "hardhat";
import { network } from "hardhat";
import { getNetworkConfig, mergeNetworkConfig } from '../src/config';
import { Deployer } from '../src/deployer';
import { unwrap } from '../src/helpers';
Expand Down
2 changes: 1 addition & 1 deletion scripts/deploy_dice-game.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ethers, network } from "hardhat";
import { network } from "hardhat";
import { getNetworkConfig, mergeNetworkConfig } from '../src/config';
import { Deployer } from '../src/deployer';
import { unwrap } from '../src/helpers';
Expand Down
2 changes: 1 addition & 1 deletion scripts/deploy_erc20-dummy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ethers, network } from "hardhat";
import { network } from "hardhat";
import { getNetworkConfig, mergeNetworkConfig } from '../src/config';
import { Deployer } from '../src/deployer';
import { unwrap } from '../src/helpers';
Expand Down
2 changes: 1 addition & 1 deletion scripts/deploy_escrow.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ethers, network } from "hardhat";
import { network } from "hardhat";
import { getNetworkConfig, mergeNetworkConfig } from '../src/config';
import { Deployer } from '../src/deployer';
import { unwrap } from '../src/helpers';
Expand Down
7 changes: 3 additions & 4 deletions scripts/deploy_full.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '../src/config';
import { Deployer } from '../src/deployer';
import { unwrap } from '../src/helpers';
import { BigNumber } from 'ethers';
import { toBigInt } from 'ethers';

async function main() {
console.log('Network:', network.name);
Expand All @@ -22,8 +22,8 @@ async function main() {

const deployer = await Deployer.create();
const drandIndexesToAdd = 500;
const initialDrands = randomNumConfig[chainId].drands.map(({ randomness }) => BigNumber.from(randomness)).slice(0, 101);
const drands = randomNumConfig[chainId].drands.map(({ randomness }) => BigNumber.from(randomness)).slice(101, drandIndexesToAdd + 1);
const initialDrands = randomNumConfig[chainId].drands.map(({ randomness }) => toBigInt(randomness)).slice(0, 101);
const drands = randomNumConfig[chainId].drands.map(({ randomness }) => toBigInt(randomness)).slice(101, drandIndexesToAdd + 1);
const deployConfig = await deployer.execute(['full'], config, {
tokenReceivers: chainId == 1337 ? [
'0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
Expand Down Expand Up @@ -56,7 +56,6 @@ async function main() {
}

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
console.error(error);
process.exitCode = 1;
Expand Down
4 changes: 2 additions & 2 deletions scripts/deploy_game-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '../src/config';
import { Deployer } from '../src/deployer';
import { unwrap } from '../src/helpers';
import { BigNumber } from 'ethers';
import { toBigInt } from 'ethers';


async function main() {
Expand All @@ -25,7 +25,7 @@ async function main() {
const lastStoredIndex = randomNumConfig[chainId].lastStoredIndex ?? 0;
const startIndex = lastStoredIndex == 0 ? lastStoredIndex : lastStoredIndex + 1;
const stopIndex = lastStoredIndex > 0 ? lastStoredIndex + drandIndexesToAdd + 1 : drandIndexesToAdd
const drands = randomNumConfig[chainId].drands.map(({ randomness }) => BigNumber.from(randomness)).slice(startIndex, stopIndex);
const drands = randomNumConfig[chainId].drands.map(({ randomness }) => toBigInt(randomness)).slice(startIndex, stopIndex);

const deployConfig = await deployer.execute(['wega_game_controller'], config, { drands });

Expand Down
4 changes: 2 additions & 2 deletions scripts/deploy_random-number-controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ethers, network } from "hardhat";
import { getNetworkConfig, mergeNetworkConfig, getRandomNumbersConfig, mergeRandomNumConfig } from '../src/config';
import { BigNumber } from 'ethers';
import { toBigInt } from 'ethers';
import { Deployer } from '../src/deployer';
import { unwrap } from '../src/helpers';

Expand All @@ -17,7 +17,7 @@ async function main() {
}
const deployer = await Deployer.create();
const deployConfig = await deployer.execute(['wega_random_number_controller'], config, {
initialDrands: [ ...randomNumConfig[chainId].drands.map(({ randomness }) => BigNumber.from(randomness)).slice(0, 101) ]
initialDrands: [ ...randomNumConfig[chainId].drands.map(({ randomness }) => toBigInt(randomness)).slice(0, 101) ]
});
mergeNetworkConfig(deployConfig);
mergeRandomNumConfig({[chainId]: { ...randomNumConfig[chainId], lastStoredIndex: 100 } }, drandChainhash)
Expand Down
2 changes: 1 addition & 1 deletion scripts/upgrade_contract.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { network } from 'hardhat';
import { mergeNetworkConfig, getNetworkConfig } from '../src/config';
import { getNetworkConfig } from '../src/config';
import { Deployer } from '../src/deployer';
import { unwrap } from '../src/helpers';
import { ArtifactName, ContractName } from '../src/types';
Expand Down
1 change: 0 additions & 1 deletion scripts/upgrade_game-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
} from '../src/config';
import { Deployer } from '../src/deployer';
import { unwrap } from '../src/helpers';
import { BigNumber } from 'ethers';


async function main() {
Expand Down
Loading

0 comments on commit c697dad

Please sign in to comment.