-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from 0xPolygon/feat/deployment-scripts
Deployment scripts
- Loading branch information
Showing
5 changed files
with
84 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.21; | ||
|
||
import {Script, stdJson, console2 as console} from "forge-std/Script.sol"; | ||
|
||
import {ProxyAdmin, TransparentUpgradeableProxy} from "openzeppelin-contracts/contracts/proxy/transparent/ProxyAdmin.sol"; | ||
import {PolygonEcosystemToken} from "../../src/PolygonEcosystemToken.sol"; | ||
import {DefaultEmissionManager} from "../../src/DefaultEmissionManager.sol"; | ||
import {PolygonMigration} from "../../src/PolygonMigration.sol"; | ||
|
||
contract Deploy is Script { | ||
using stdJson for string; | ||
|
||
function run() public { | ||
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); | ||
string memory input = vm.readFile("scripts/1.0.0/input.json"); | ||
string memory chainIdSlug = string(abi.encodePacked('["', vm.toString(block.chainid), '"]')); | ||
address matic = input.readAddress(string.concat(chainIdSlug, ".matic")); | ||
address governance = input.readAddress(string.concat(chainIdSlug, ".governance")); | ||
address treasury = input.readAddress(string.concat(chainIdSlug, ".treasury")); | ||
address stakeManager = input.readAddress(string.concat(chainIdSlug, ".stakeManager")); | ||
address permit2revoker = input.readAddress(string.concat(chainIdSlug, ".permit2revoker")); | ||
|
||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
ProxyAdmin admin = new ProxyAdmin(); | ||
admin.transferOwnership(governance); | ||
|
||
address migrationImplementation = address(new PolygonMigration(matic)); | ||
|
||
address migrationProxy = address( | ||
new TransparentUpgradeableProxy( | ||
migrationImplementation, | ||
address(admin), | ||
abi.encodeWithSelector(PolygonMigration.initialize.selector) | ||
) | ||
); | ||
|
||
address emissionManagerImplementation = address( | ||
new DefaultEmissionManager(migrationProxy, stakeManager, treasury) | ||
); | ||
address emissionManagerProxy = address( | ||
new TransparentUpgradeableProxy(address(emissionManagerImplementation), address(admin), "") | ||
); | ||
|
||
PolygonEcosystemToken polygonToken = new PolygonEcosystemToken( | ||
migrationProxy, | ||
emissionManagerProxy, | ||
governance, | ||
permit2revoker | ||
); | ||
|
||
DefaultEmissionManager(emissionManagerProxy).initialize(address(polygonToken), governance); | ||
|
||
PolygonMigration(migrationProxy).setPolygonToken(address(polygonToken)); | ||
|
||
PolygonMigration(migrationProxy).transferOwnership(governance); // governance needs to accept the ownership transfer | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters