-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merged feat/deployment into scripts. data loading from json.
- Loading branch information
1 parent
40ae302
commit 0a2c882
Showing
6 changed files
with
69 additions
and
27 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 |
---|---|---|
@@ -1,51 +1,87 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
|
||
import {Script, console} from "forge-std/Script.sol"; | ||
import {BaseData} from "./BaseData.sol"; | ||
import {ImmutableMultiChainDeployer} from "@factory/ImmutableMultiChainDeployer.sol"; | ||
import {RateLimiter} from "@layerzerolabs/lz-evm-oapp-v2/contracts/oapp/utils/RateLimiter.sol"; | ||
import {EndpointV2} from "@layerzerolabs/lz-evm-protocol-v2/contracts/EndpointV2.sol"; | ||
|
||
struct YnOFTAdapterInput { | ||
address erc20Address; | ||
address lzEndpoint; | ||
address adapterImplementation; | ||
RateLimiterConfig[] rateLimitConfigs; | ||
uint256 chainId; | ||
address erc20Address; | ||
RateLimitConfig[] rateLimitConfigs; | ||
} | ||
|
||
struct RateLimitConfig { | ||
uint32 dstEid; | ||
uint256 limit; | ||
uint256 window; | ||
} | ||
|
||
struct YnERC20Input { | ||
uint256 chainId; | ||
address erc20Address; | ||
string name; | ||
string symbol; | ||
} | ||
//forge script script/DeployMainnetImplementations.s.sol:DeployMainnetImplementations --rpc-url ${rpc} --account ${deployerAccountName} --sender ${deployer} --broadcast --etherscan-api-key ${api} --verify | ||
|
||
contract BaseScript is Script { | ||
contract BaseScript is BaseData { | ||
// TODO: parse token address from json or as input from user | ||
// TODO: setup forks based on if testnet or mainnet deployment as per json | ||
// TODO: setup saving of deployment data in deployments json file | ||
uint256 _chainId; | ||
bytes public data; | ||
YnOFTAdapterInput public _ynOFTAdapterInputs; | ||
YnERC20Input public _ynERC20Inputs; | ||
RateLimiter.RateLimitConfig[] public _rateLimitConfigs; | ||
|
||
function _loadERC20(string memory _inputPath) internal { | ||
_loadJson(_inputPath); | ||
_loadYnERC20Inputs(); | ||
isSupportedChainId(_chainId); | ||
} | ||
|
||
function _loadOFTAdapter(string memory _inputPath) internal { | ||
_loadJson(_inputPath); | ||
_loadYnOFTAdapterInputs(); | ||
_getRateLimiterConfigs(); | ||
isSupportedChainId(_chainId); | ||
} | ||
|
||
function _loadJson(string memory _path) internal { | ||
string memory path = string(abi.encodePacked(vm.projectRoot(), "/", _path)); | ||
string memory json = vm.readFile(path); | ||
data = vm.parseJson(json); | ||
} | ||
|
||
function _loadYnOFTAdapterInputs() internal { | ||
YnOFTAdapterInput memory _inputs = abi.decode(data, (YnOFTAdapterInput)); | ||
YnOFTAdapterInput memory ynOFTAdapterInputs = abi.decode(data, (YnOFTAdapterInput)); | ||
_chainId = _ynOFTAdapterInputs.chainId; | ||
this.loadAdapterInputs(ynOFTAdapterInputs); | ||
} | ||
|
||
function loadAdapterInputs(YnOFTAdapterInput calldata _ynInput) external { | ||
_ynOFTAdapterInputs = _ynInput; | ||
} | ||
|
||
function _loadYnERC20Inputs() internal { | ||
_ynERC20Inputs = abi.decode(data, (YnERC20Input)); | ||
_chainId = _ynERC20Inputs.chainId; | ||
} | ||
|
||
function _getRateLimiterConfigs() internal { | ||
RateLimiter.RateLimitConfig memory _tempConfig; | ||
uint32 tempDstEid = EndpointV2(_ynOFTAdapterInputs.lzEndpoint).eid(); | ||
uint32 tempDstEid = EndpointV2(addresses[_chainId].lzEndpoint).eid(); | ||
for (uint256 i; i < _ynOFTAdapterInputs.rateLimitConfigs.length; i++) { | ||
_tempConfig.dstEid = tempDstEid; | ||
_tempConfig.limit = _ynOFTAdapterInputs.rateLimitConfigs[i].limit; | ||
_tempConfig.window = _ynOFTAdapterInputs.rateLimitConfigs[i].window; | ||
_rateLimitConfigs.push(_tempConfig); | ||
} | ||
} | ||
|
||
function _serializeOutputs(string memory objectKey) internal virtual { | ||
// left blank on purpose | ||
} | ||
} |
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 |
---|---|---|
@@ -1,24 +1,27 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
|
||
import {Script, console} from "forge-std/Script.sol"; | ||
import {BaseScript} from "./BaseScript.s.sol"; | ||
import {ImmutableMultiChainDeployer} from "@factory/ImmutableMultiChainDeployer.sol"; | ||
import {RateLimiter} from "@layerzerolabs/lz-evm-oapp-v2/contracts/oapp/utils/RateLimiter.sol"; | ||
import {L1YnOFTAdapterUpgradeable} from "@/L1YnOFTAdapterUpgradeable.sol"; | ||
import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; | ||
|
||
//forge script script/DeployMainnetImplementations.s.sol:DeployMainnetImplementations --rpc-url ${rpc} --account ${deployerAccountName} --sender ${deployer} --broadcast --etherscan-api-key ${api} --verify | ||
contract DeployMainnetImplementations is Script { | ||
RateLimiter.RateLimitConfig[] public _rateLimitConfigs; | ||
|
||
function setUp() public {} | ||
contract DeployMainnetImplementations is BaseScript { | ||
address public mainnetOFTAdapterImpl; | ||
L1YnOFTAdapterUpgradeable public mainnetOFTAdapter; | ||
|
||
function run(string memory __path) public { | ||
loadOFTAdapter(__path); | ||
|
||
vm.broadcast(); | ||
|
||
mainnetOFTAdapterImpl = address( | ||
new L1YnOFTAdapterUpgradeable(address(vm.envAddress("YnERC20_ADDRESS")), address("MIANNET_LZ_ENDPOINT")) | ||
); | ||
mainnetOFTAdapterImpl = | ||
address(new L1YnOFTAdapterUpgradeable(_ynOFTAdapterInputs.erc20Address, addresses[_chainId].lzEndpoint)); | ||
mainnetOFTAdapter = | ||
L1YnOFTAdapterUpgradeable(address(new TransparentUpgradeableProxy(mainnetOFTAdapterImpl, msg.sender, ""))); | ||
|
||
mainnetOFTAdapter.initialize(msg.sender, _rateLimitConfigs); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
{ | ||
"chainId": 1, | ||
"erc20Address": "0x0000000000000000000000000000000000000000", | ||
"lzEndpoint": "0x0000000000000000000000000000000000000000" | ||
"lzEndpoint": "0x0000000000000000000000000000000000000000", | ||
"name": "name", | ||
"symbol": "symbol" | ||
} |
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 |
---|---|---|
@@ -1,12 +1,14 @@ | ||
{ | ||
"chainId": 1, | ||
"erc20Address": "0x0000000000000000000000000000000000000000", | ||
"lzEndpoint": "0x0000000000000000000000000000000000000000", | ||
"adapterImplementation": "0x0000000000000000000000000000000000000000", | ||
"rateLimiterConfigs": [ | ||
{ | ||
"limit": "100000000000000000000", | ||
"window": "86400" | ||
} | ||
] | ||
], | ||
"TOKEN_ADMIN": "0x0000000000000000000000000000000000000000", | ||
"PROXY_ADMIN": "0x0000000000000000000000000000000000000000", | ||
"OFT_DELEGATE": "0x0000000000000000000000000000000000000000" | ||
} |