Skip to content

Commit

Permalink
Merge pull request #138 from G7DAO/SUM-209-update-openzeppelin-contra…
Browse files Browse the repository at this point in the history
…cts-to-latest-stable-version-new-branch

Sum 209 update openzeppelin contracts to latest stable version new branch
  • Loading branch information
vasinl124 authored Jun 28, 2024
2 parents c5608cb + 8aa1a5a commit 1d04c76
Show file tree
Hide file tree
Showing 102 changed files with 2,717 additions and 4,861 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# TESTNET - MAINNET
#PRIVATE_KEY="0xYourKey"

# DEV - ZKSYNC - LOCAL

PRIVATE_KEY="0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110"
POLYGON_PROVIDER_URL="https://endpoints.omniatech.io/v1/matic/mumbai/public"
POLYGONSCAN_API_KEY="YOUR_API_KEY"
Expand Down
14 changes: 0 additions & 14 deletions .run/deployERC20Paymaster_ZkSync_testnet --force.run.xml

This file was deleted.

143 changes: 25 additions & 118 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<p align="center">
<br />
<a href="https://achievo.xyz"><img src="https://docs.achievo.xyz/assets/images/achievo_hero-c6f48974170f838b624d0b30ef52735f.png" width="200" alt=""/></a>
Expand All @@ -11,135 +10,43 @@
</p>
<br />


## Requirements

1. NodeJs >= 18 (use nvm pls)
2. Fill the .env file with the correct values(see .env.example)
3. Install dependencies

```shell
npm install
```

To deploy the current diamond to the zkSync testnet network, run the following command

4. `npm run compile`
5. `npm run deployDiamond:localhost`

This command will run the script of

**/deploy/zk/deployDiamond.ts**

```shell
npm run deployDiamond:ZkSync
```

You can also try the achievements erc1155 smart contract
**/deploy/zk/deployAvatar.ts**

```shell
npm run deployAvatar:ZkSync
```

## Commands

1. This command will setup a hardhat node for you, could be used for testing as Ganache

```shell
npm run localChain
```

2. This command will run a diamond deployment for Mantle on:

```shell
npm run deployDiamond:mantle
```

3. This command will run a diamond deployment for Polygon mumbai on:

```shell
npm run deployDiamond:mumbai
```

Check the rest of the scripts in the package.json file

4. Run the unit tests

```shell
npm test
```

5. Flat smart contracts

```shell
npx hardhat flatten contracts/GameSummary.sol > .flat/GameSummary.sol
pnpm install
```

## Scripts

```json
{
"deployBridge:polygon:mainnet": "pnpm deploy:polygon:mainnet --name BridgePolygon",
"deployBridge:ZkSync:mainnet": "pnpm deploy:ZkSync:mainnet --name BridgeZkSync",
"deployERC20StakeUpgradeable:ZkSync:mainnet": "pnpm deploy:ZkSync:mainnet --name ERC20StakeV1",
"deployWhitelist:ZkSync:mainnet": "pnpm deploy:ZkSync:mainnet --name Whitelist",
"deployBridgeUpgradeable:polygon:mainnet": "pnpm deploy:polygon:mainnet --name BridgeUpgradeablePolygon",
"deployBridgeUpgradeable:zksync:mainnet": "pnpm deploy:ZkSync:mainnet --name BridgeUpgradeableZkSync",
"deployBurnableToken:ZkSync:mainnet": "pnpm deploy:ZkSync:mainnet --name ZkSpork",
"deployFreeMint:ZkSync:mainnet": "pnpm deploy:ZkSync:mainnet --name FreeMint",
"deployFreeMint:ZkSync:sepolia": "pnpm deploy:ZkSync:sepolia --name FreeMint",
"deployAvatars:ZkSync:mainnet": "pnpm deploy:ZkSync:mainnet --name Avatars",
"deployAvatars:ZkSync:sepolia": "pnpm deploy:ZkSync:sepolia --name Avatars",
"deployAvatarsUpgradeable:ZkSync:mainnet": "pnpm deploy:ZkSync:mainnet --name AvatarsUpgradeable",
"deployAvatarsUpgradeable:ZkSync:sepolia": "pnpm deploy:ZkSync:sepolia --name AvatarsUpgradeable",
"upgradeAvatars:ZkSync:mainnet": "pnpm compile:zkSync && hardhat run deploy/upgrades/upgradeAvatars.mainnet.ts --config zkSync.config.ts --network zkSync",
"upgradeAvatars:ZkSync:sepolia": "pnpm compile:zkSync && hardhat run deploy/upgrades/upgradeAvatars.testnet.ts --config zkSync.config.ts --network zkSyncSepolia",
"deployItems:arbitrum:one": "pnpm deploy:arbitrum:one --name Items",
"deployItems:arbitrum:sepolia": "pnpm deploy:arbitrum:sepolia --name Items",
"deployItems:polygon:mainnet": "pnpm deploy:polygon:mainnet --name Items",
"deployItems:polygon:mumbai": "pnpm deploy:polygon:mumbai --name Items",
"deployItems:ZkSync:mainnet": "pnpm deploy:ZkSync:mainnet --name Items",
"deployItems:ZkSync:sepolia": "pnpm deploy:ZkSync:sepolia --name Items",
"deployItemsUpgradeable:arbitrum:one": "pnpm deploy:arbitrum:one --name ItemsUpgradeable",
"deployItemsUpgradeable:arbitrum:sepolia": "pnpm deploy:arbitrum:sepolia --name ItemsUpgradeable",
"deployItemsUpgradeable:ZkSync:mainnet": "pnpm deploy:ZkSync:mainnet --name ItemsUpgradeable",
"deployItemsUpgradeable:ZkSync:sepolia": "pnpm deploy:ZkSync:sepolia --name ItemsUpgradeable",
"upgradeItem:ZkSync:mainnet": "pnpm compile:zkSync && hardhat run deploy/upgrades/upgradeItem.mainnet.ts --config zkSync.config.ts --network zkSync",
"upgradeItem:ZkSync:sepolia": "pnpm compile:zkSync && hardhat run deploy/upgrades/upgradeItem.testnet.ts --config zkSync.config.ts --network zkSyncSepolia",
"deployItemsReward:ZkSync:mainnet": "pnpm deploy:ZkSync:mainnet --name RewardItems",
"deployItemsReward:ZkSync:sepolia": "pnpm deploy:ZkSync:sepolia --name RewardItems",
"deployLevelsOnChain:ZkSync:mainnet": "pnpm deploy:ZkSync:mainnet --name Levels",
"deployLevelsOnChain:ZkSync:sepolia": "pnpm deploy:ZkSync:sepolia --name Levels",
"deployLevelsOnChainUpgradable:ZkSync:mainnet": "pnpm deploy:ZkSync:mainnet --name LevelsUpgradable",
"deployLevelsOnChainUpgradable:ZkSync:sepolia": "pnpm deploy:ZkSync:sepolia --name LevelsUpgradable",
"upgradeLevels:ZkSync:mainnet": "pnpm compile:zkSync && hardhat run deploy/upgrades/upgradeLevels.mainnet.ts --config zkSync.config.ts --network zkSync",
"upgradeLevels:ZkSync:sepolia": "pnpm compile:zkSync && hardhat run deploy/upgrades/upgradeLevels.testnet.ts --config zkSync.config.ts --network zkSyncSepolia",
"mintItemsReward:ZkSync:mainnet": "pnpm compile:zkSync && hardhat --config zkSync.config.ts deploy-zksync --network zkSync --script mints/mintRewardItems.ts",
"mintItemsReward:ZkSync:sepolia": "pnpm compile:zkSync && hardhat --config zkSync.config.ts deploy-zksync --network zkSyncSepolia --script mints/mintRewardItems.ts",
"deployMockERC20:ZkSync:sepolia": "pnpm compile:zkSync && hardhat run deploy/deployMockERC20.testnet.ts --network zkSyncSepolia --config zkSync.config.ts",
"deployNftGating:ZkSync:mainnet": "pnpm compile:zkSync && hardhat --config zkSync.config.ts deploy-zksync --network zkSync --script deployNFTGating.mainnet.ts",
"deployNftGating:ZkSync:sepolia": "pnpm compile:zkSync && hardhat --config zkSync.config.ts deploy-zksync --network zkSyncSepolia --script deployNFTGating.testnet.ts",
"deployERC20PythPaymaster:ZkSync:mainnet": "pnpm deploy:ZkSync:mainnet --name PaymasterPyth",
"deployERC20PythPaymaster:ZkSync:sepolia": "pnpm deploy:ZkSync:sepolia --name PaymasterPyth",
"deployERC20ChainlinkPaymaster:ZkSync:mainnet": "pnpm deploy:ZkSync:mainnet --name PaymasterChainlink",
"deployERC20ChainlinkPaymaster:ZkSync:sepolia": "pnpm deploy:ZkSync:sepolia --name PaymasterChainlink",
"deployERC20ChainlinkUpgradeablePaymaster:ZkSync:mainnet": "pnpm deploy:ZkSync:mainnet --name PaymasterChainlinkUpgradable",
"deployERC20ChainlinkUpgradeablePaymaster:ZkSync:sepolia": "pnpm deploy:ZkSync:sepolia --name PaymasterChainlinkUpgradable",
"upgradeERC20ChainlinkPaymaster:ZkSync:mainnet": "pnpm compile:zkSync && hardhat run deploy/upgrades/upgradeERC20ChainlinkPaymaster.mainnet.ts --config zkSync.config.ts --network zkSync",
"deployGameSummary:mantle:mainnet": "pnpm deploy:mantle:mainnet --name GameSummary",
"deployGameSummary:mantle:wadsley": "pnpm deploy:mantle:wadsley --name GameSummary",
"deployBadge:ZkSync:mainnet": "pnpm deploy:ZkSync:mainnet --name Badge",
"deployBadge:ZkSync:sepolia": "pnpm deploy:ZkSync:sepolia --name Badge",
"deployBadgeUpgradeable:ZkSync:mainnet": "pnpm deploy:ZkSync:mainnet --name BadgeUpgradable",
"deployBadgeUpgradeable:ZkSync:sepolia": "pnpm deploy:ZkSync:sepolia --name BadgeUpgradable",
"upgradeBadge:ZkSync:mainnet": "pnpm compile:zkSync && hardhat run deploy/upgrades/upgradeBadge.mainnet.ts --config zkSync.config.ts --network zkSync",
"upgradeBadge:ZkSync:sepolia": "pnpm compile:zkSync && hardhat run deploy/upgrades/upgradeBadge.testnet.ts --config zkSync.config.ts --network zkSyncSepolia",
"deploySkillTreeUpgradable:ZkSync:mainnet": "pnpm deploy:ZkSync:mainnet --name SkillTreeUpgradable",
"deploySkillTreeUpgradable:ZkSync:sepolia": "pnpm deploy:ZkSync:sepolia --name SkillTreeUpgradable",
"deployMarketplace:g7:base:sepolia": "pnpm deploy:g7:sepolia:base --name Marketplace",
"upgradeLegacyAvatars:ZkSync:mainnet": "pnpm compile:zkSync && hardhat run deploy/upgrades/upgradeLegacyAvatarBound.mainnet.ts --config zkSync.config.ts --network zkSync",
"upgradeLegacyAvatars:ZkSync:sepolia": "pnpm compile:zkSync && hardhat run deploy/upgrades/upgradeLegacyAvatarBound.testnet.ts --config zkSync.config.ts --network zkSyncSepolia",
"deployMarketplace:g7:arb:sepolia": "pnpm compile && hardhat --config g7.config.ts deploy-proxy --name Marketplace --network game7OrbitArbSepolia"
"deploy:create2": "pnpm compile && hardhat --config hardhat.config.ts deploy-create2",
"deploy:nonce": "pnpm compile && hardhat --config hardhat.config.ts deploy-nonce",
"deploy:proxy": "pnpm compile && hardhat --config hardhat.config.ts deploy-proxy",
"deploy:sepolia": "pnpm compile && hardhat --config hardhat.config.ts deploy --network sepolia",
"deploy:arbitrum:one": "pnpm compile && hardhat --config arbitrum.config.ts deploy --network arbitrumOne",
"deploy:arbitrum:sepolia": "pnpm compile && hardhat --config arbitrum.config.ts deploy --network arbitrumSepolia",
"deploy:base:mainnet": "pnpm compile && hardhat --config base.config.ts deploy --network base",
"deploy:base:sepolia": "pnpm compile && hardhat --config base.config.ts deploy --network baseSepolia",
"deploy:mantle:mainnet": "pnpm compile && hardhat --config mantle.config.ts deploy --network mantle",
"deploy:mantle:sepolia": "pnpm compile && hardhat --config mantle.config.ts deploy --network mantleSepolia",
"deploy:polygon:mainnet": "pnpm compile && hardhat --config polygon.config.ts deploy --network polygon",
"deploy:polygon:mumbai": "pnpm compile && hardhat --config polygon.config.ts deploy --network polygonMumbai",
"deploy:g7:arb:sepolia": "pnpm compile && hardhat --config g7.config.ts deploy --network game7OrbitArbSepolia",
"deploy:g7:base:sepolia": "pnpm compile && hardhat --config g7.config.ts deploy --network game7OrbitBaseSepolia",
"test:foundry": "forge test -vvv",
"test": "REPORT_GAS=true hardhat --config hardhat.config.ts test test/hardhatTests/*.ts --network hardhat",
"test:ci": "hardhat --config hardhat.config.ts test test/hardhatTests/*.ts --network hardhat",
"lint": "eslint --config ./.eslintrc.js --ignore-path ./.eslintignore ./test/**/*.ts",
"solhint": "solhint ./contracts/**/*.sol",
"format": "yarn prettier -w ./deploy/**/*.ts ./tasks/**/*.ts ./tests/**/*.ts ./helpers/**/*.ts contracts/**/*.sol ",
"format:check": "yarn prettier -c ./deploy/**/*.ts ./tasks/**/*.ts ./tests/**/*.ts ./helpers/**/*.ts ./contracts/**/*.sol ",
"coverage": "TS_NODE_TRANSPILE_ONLY=true SOLIDITY_COVERAGE=true hardhat coverage --solcoverjs .solcover.ts",
"coverage:foundry": "forge coverage --report lcov && genhtml lcov.info --branch-coverage --output-dir coverage",
"generate:types": "pnpm dlx hardhat typechain"
}
```
68 changes: 4 additions & 64 deletions constants/constructor-args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,6 @@ import { ChainId } from './network';
const MAR20_G7_TESTNET = '0x9BcdFD72F0434B1cA3b2E8BB96592ceEc22A85e7';
const IRON_G7_ARB_SEPOLIA_NATIVE_TOKEN = '0x4EdD6ddeAf8f259dba75AC8C5C89ee7564201170';

const PYTH_USDC_PRICE_ID_TESTNET = '0x41f3625971ca2ed2263e78573fe5ce23e13d2558ed3f2e47ab0f84fb9e7ae722';
const PYTH_ETH_PRICE_ID_TESTNET = '0xca80ba6dc32e08d06f1aa886011eed1d77c77be9eb761cc10d72b7d0a2fd57a6';
const PYTH_ORACLE_ADDRESS_TESTNET = '0x8739d5024B5143278E2b15Bd9e7C26f6CEc658F1';

const PYTH_USDC_PRICE_ID_MAINNET = '0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a';
const PYTH_ETH_PRICE_ID_MAINNET = '0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace';
const PYTH_ORACLE_ADDRESS_MAINNET = '0xf087c864AEccFb6A2Bf1Af6A0382B0d0f6c5D834';

const CHAINLINK_USDC_PRICE_ID_TESTNET = '0x1844478CA634f3a762a2E71E3386837Bd50C947F';
const CHAINLINK_ETH_PRICE_ID_TESTNET = '0xfEefF7c3fB57d18C5C6Cdd71e45D2D0b4F9377bF';

const CHAINLINK_USDC_PRICE_ID_MAINNET = '0x1824D297C6d6D311A204495277B63e943C2D376E';
const CHAINLINK_ETH_PRICE_ID_MAINNET = '0x6D41d1dc818112880b40e26BD6FD347E41008eDA';

const ZKSYNC_MAINNET_ERC20_USDC = '0x1d17CBcF0D6D143135aE902365D2E5e2A16538D4';
const ZKSYNC_TESTNET_ERC20_OUSDC = '0x4b6021A15cB4E76DD40dE7B0d316A6a7fb613C05';

export interface ConstructorArgs {
name: string;
symbol: string;
Expand Down Expand Up @@ -207,38 +190,6 @@ export const OpenMintArgs = {
},
};

export const ERC20PythPaymasterArgs = {
MAINNET: {
erc20Address: ZKSYNC_MAINNET_ERC20_USDC,
usdcPriceId: PYTH_USDC_PRICE_ID_MAINNET,
ethPriceId: PYTH_ETH_PRICE_ID_MAINNET,
pythOracleAddress: PYTH_ORACLE_ADDRESS_MAINNET,
},
TESTNET: {
erc20Address: ZKSYNC_TESTNET_ERC20_OUSDC,
usdcPriceId: PYTH_USDC_PRICE_ID_TESTNET,
ethPriceId: PYTH_ETH_PRICE_ID_TESTNET,
pythOracleAddress: PYTH_ORACLE_ADDRESS_TESTNET,
},
};

export const ERC20ChainlinkPaymasterArgs = {
MAINNET: {
erc20Address: ZKSYNC_MAINNET_ERC20_USDC,
erc20FeedId: CHAINLINK_USDC_PRICE_ID_MAINNET,
ethFeedId: CHAINLINK_ETH_PRICE_ID_MAINNET,
fixedPrice: 1,
useChainLink: true,
},
TESTNET: {
erc20Address: ZKSYNC_TESTNET_ERC20_OUSDC,
erc20FeedId: CHAINLINK_USDC_PRICE_ID_TESTNET,
ethFeedId: CHAINLINK_ETH_PRICE_ID_TESTNET,
fixedPrice: 1,
useChainLink: true,
},
};

export const GameSummaryArgs = {
MAINNET: {
_name: 'GameSummary',
Expand Down Expand Up @@ -283,25 +234,12 @@ export const BridgePolygonV1Args = {
MAINNET: {
developerAdmin: 'DEPLOYER_WALLET',
chainIdFrom: ChainId.Polygon,
chainIdTo: ChainId.ZkSync,
chainIdTo: ChainId.Game7OrbitArbSepolia, // TODO * chain to mainnet
},
TESTNET: {
developerAdmin: 'DEPLOYER_WALLET',
chainIdFrom: ChainId.PolygonMumbai,
chainIdTo: ChainId.ZkSyncSepolia,
},
};

export const BridgeZkSyncV1Args = {
MAINNET: {
developerAdmin: 'DEPLOYER_WALLET',
chainIdFrom: ChainId.ZkSync,
chainIdTo: ChainId.Polygon,
},
TESTNET: {
developerAdmin: 'DEPLOYER_WALLET',
chainIdFrom: ChainId.ZkSyncSepolia,
chainIdTo: ChainId.PolygonMumbai,
chainIdTo: ChainId.Game7OrbitArbSepolia,
},
};

Expand Down Expand Up @@ -440,13 +378,15 @@ export const RewardTokenArgs = {
_defaultTokenURI: 'FILL_ME',
_contractURI: 'FILL_ME',
_devWallet: 'DEPLOYER_WALLET',
_lootDropAddress: `CONTRACT_${CONTRACT_NAME.LootDrop}`,
},
TESTNET: {
_name: 'RainToken',
_symbol: 'RT',
_defaultTokenURI: 'FILL_ME',
_contractURI: 'FILL_ME',
_devWallet: 'DEPLOYER_WALLET',
_lootDropAddress: `CONTRACT_${CONTRACT_NAME.LootDrop}`,
},
};

Expand Down
7 changes: 0 additions & 7 deletions constants/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export enum CONTRACT_TYPE {
Items = 'Items',
Levels = 'Levels',
FreeMint = 'FreeMint',
Paymaster = 'Paymaster',
GameSummary = 'GameSummary',
ERC20 = 'ERC20',
Staker = 'Staker',
Expand Down Expand Up @@ -47,7 +46,6 @@ export enum CONTRACT_FILE_NAME {
ERC1155RoyaltiesSoulbound = 'ERC1155RoyaltiesSoulbound',
Levels = 'LevelsBound',
FreeMint = 'FreeMint',
ERC20ChainlinkPaymaster = 'ERC20ChainlinkPaymaster',
ERC1155Soulbound = 'ERC1155Soulbound',
Bridge = 'ERC20Bridge',
Whitelist = 'Whitelist',
Expand All @@ -68,7 +66,6 @@ export enum CONTRACT_UPGRADABLE_FILE_NAME {
Avatars = 'AvatarBoundV1',
ERC1155RoyaltiesSoulbound = 'ERC1155RoyaltiesSoulboundV2',
Levels = 'LevelsBoundV1',
ERC20ChainlinkPaymaster = 'ERC20ChainlinkPaymasterV2',
ERC1155Soulbound = 'ERC1155SoulboundV1',
Staker = 'ERC20StakeV1',
Bridge = 'ERC20BridgeV1',
Expand All @@ -80,7 +77,6 @@ export enum CONTRACT_UPGRADABLE_FILE_NAME_V2 {
Avatars = 'AvatarBoundV2',
ERC1155RoyaltiesSoulbound = 'ERC1155RoyaltiesSoulboundV2',
Levels = 'LevelsBoundV2',
ERC20ChainlinkPaymaster = 'ERC20ChainlinkPaymasterV3',
ERC1155Soulbound = 'ERC1155SoulboundV2',
}

Expand All @@ -89,7 +85,6 @@ export enum CONTRACT_NAME {
Items = 'Items',
Levels = 'Levels',
FreeMint = 'FreeMint',
PaymasterChainlink = 'PaymasterChainlink',
GameSummary = 'GameSummary',
ERC20 = 'ERC20',
Badge = 'Badge',
Expand All @@ -116,12 +111,10 @@ export enum CONTRACT_UPGRADABLE_NAME {
Items = 'ItemsUpgradeable',
ItemsRoyaltiesV2 = 'ItemsRoyaltiesV2',
Levels = 'LevelsUpgradable',
PaymasterChainlink = 'PaymasterChainlinkUpgradable',
ERC20 = 'BurnableTokenV1',
Staker = 'ERC20StakeV1',
Badge = 'BadgeUpgradable',
BridgePolygon = 'BridgeUpgradeablePolygon',
BridgeZkSync = 'BridgeUpgradeableZkSync',
ZkSpork = 'ZkSpork',
SkillTree = 'SkillTreeUpgradable',
Marketplace = 'Marketplace',
Expand Down
2 changes: 1 addition & 1 deletion constants/deployments/deployments-g7-sepolia-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { TENANT } from '@constants/tenant';
import { DeploymentContract } from '../../types/deployment-type';
import { NETWORK_TYPE, NetworkName } from '../network';

const chain = NetworkName.ZkSyncSepolia;
const chain = NetworkName.Game7OrbitBaseSepolia;
const networkType = NETWORK_TYPE.TESTNET;

export const G7_SEPOLIA_BASE_CONTRACTS: DeploymentContract[] = [
Expand Down
Loading

0 comments on commit 1d04c76

Please sign in to comment.