-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathUpgradeTokenRouter.s.sol
60 lines (45 loc) · 2.21 KB
/
UpgradeTokenRouter.s.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// SPDX-License-Identifier: Apache 2
pragma solidity ^0.8.19;
import "forge-std/Script.sol";
import "forge-std/console2.sol";
import {ICircleIntegration} from "wormhole-solidity/ICircleIntegration.sol";
import {ITokenBridge} from "wormhole-solidity/ITokenBridge.sol";
import {TokenRouterImplementation} from "../../src/TokenRouter/TokenRouterImplementation.sol";
import {ITokenRouter} from "../../src/interfaces/ITokenRouter.sol";
import {CheckWormholeContracts} from "./helpers/CheckWormholeContracts.sol";
import {Utils} from "../../src/shared/Utils.sol";
contract UpgradeTokenRouter is CheckWormholeContracts, Script {
using Utils for address;
uint16 immutable _chainId = uint16(vm.envUint("RELEASE_CHAIN_ID"));
address immutable _tokenRouterAddress = vm.envAddress("RELEASE_TOKEN_ROUTER_ADDRESS");
address immutable _token = vm.envAddress("RELEASE_TOKEN_ADDRESS");
address immutable _wormhole = vm.envAddress("RELEASE_WORMHOLE_ADDRESS");
address immutable _cctpTokenMessenger = vm.envAddress("RELEASE_TOKEN_MESSENGER_ADDRESS");
address immutable _ownerAssistantAddress = vm.envAddress("RELEASE_OWNER_ASSISTANT_ADDRESS");
bytes32 immutable _matchingEngineAddress = vm.envBytes32("RELEASE_MATCHING_ENGINE_ADDRESS");
bytes32 immutable _matchingEngineMintRecipient =
vm.envBytes32("RELEASE_MATCHING_ENGINE_MINT_RECIPIENT");
uint16 immutable _matchingEngineChain = uint16(vm.envUint("RELEASE_MATCHING_ENGINE_CHAIN"));
uint32 immutable _matchingEngineDomain = uint32(vm.envUint("RELEASE_MATCHING_ENGINE_DOMAIN"));
function upgrade() public {
requireValidChain(_chainId, _wormhole);
TokenRouterImplementation implementation = new TokenRouterImplementation(
_token,
_wormhole,
_cctpTokenMessenger,
_matchingEngineChain,
_matchingEngineAddress,
_matchingEngineMintRecipient,
_matchingEngineDomain
);
ITokenRouter(_tokenRouterAddress).upgradeContract(address(implementation));
}
function run() public {
// Begin sending transactions.
vm.startBroadcast();
// Perform upgrade.
upgrade();
// Done.
vm.stopBroadcast();
}
}