Skip to content

Commit

Permalink
chore: Migrate Chainlink Local CCT guides to v1.5.1 (smartcontractkit…
Browse files Browse the repository at this point in the history
  • Loading branch information
andrejrakic authored Dec 16, 2024
1 parent ba12824 commit a76c17c
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@ contract CCIPv1_5BurnMintPoolFork is Test {
CCIPLocalSimulatorFork public ccipLocalSimulatorFork;
MockERC20BurnAndMintToken public mockERC20TokenEthSepolia;
MockERC20BurnAndMintToken public mockERC20TokenBaseSepolia;
BurnMintTokenPool public burnMintTokenPoolEthSepolia;
BurnMintTokenPool public burnMintTokenPoolBaseSepolia;
Register.NetworkDetails ethSepoliaNetworkDetails;
Register.NetworkDetails baseSepoliaNetworkDetails;
uint256 ethSepoliaFork;
Expand Down Expand Up @@ -230,12 +233,14 @@ contract CCIPv1_5BurnMintPoolFork is Test {
function test_forkSupportNewCCIPToken() public {
// Step 3) Deploy BurnMintTokenPool on Ethereum Sepolia
vm.selectFork(ethSepoliaFork);
Register.NetworkDetails memory ethSepoliaNetworkDetails = ccipLocalSimulatorFork.getNetworkDetails(block.chainid);
ethSepoliaNetworkDetails = ccipLocalSimulatorFork.getNetworkDetails(block.chainid);
address[] memory allowlist = new address[](0);
uint8 localTokenDecimals = 18;
vm.startPrank(alice);
BurnMintTokenPool burnMintTokenPoolEthSepolia = new BurnMintTokenPool(
burnMintTokenPoolEthSepolia = new BurnMintTokenPool(
IBurnMintERC20(address(mockERC20TokenEthSepolia)),
localTokenDecimals,
allowlist,
ethSepoliaNetworkDetails.rmnProxyAddress,
ethSepoliaNetworkDetails.routerAddress
Expand All @@ -257,8 +262,9 @@ contract CCIPv1_5BurnMintPoolFork is Test {
baseSepoliaNetworkDetails = ccipLocalSimulatorFork.getNetworkDetails(block.chainid);
vm.startPrank(alice);
BurnMintTokenPool burnMintTokenPoolBaseSepolia = new BurnMintTokenPool(
burnMintTokenPoolBaseSepolia = new BurnMintTokenPool(
IBurnMintERC20(address(mockERC20TokenBaseSepolia)),
localTokenDecimals,
allowlist,
baseSepoliaNetworkDetails.rmnProxyAddress,
baseSepoliaNetworkDetails.routerAddress
Expand Down Expand Up @@ -434,15 +440,17 @@ contract CCIPv1_5BurnMintPoolFork is Test {
vm.startPrank(alice);
TokenPool.ChainUpdate[] memory chains = new TokenPool.ChainUpdate[](1);
bytes[] memory remotePoolAddressesEthSepolia = new bytes[](1);
remotePoolAddressesEthSepolia[0] = abi.encode(address(burnMintTokenPoolEthSepolia));
chains[0] = TokenPool.ChainUpdate({
remoteChainSelector: baseSepoliaNetworkDetails.chainSelector,
allowed: true,
remotePoolAddress: abi.encode(address(burnMintTokenPoolBaseSepolia)),
remotePoolAddresses: remotePoolAddressesEthSepolia,
remoteTokenAddress: abi.encode(address(mockERC20TokenBaseSepolia)),
outboundRateLimiterConfig: RateLimiter.Config({ isEnabled: true, capacity: 100_000, rate: 167 }),
inboundRateLimiterConfig: RateLimiter.Config({ isEnabled: true, capacity: 100_000, rate: 167 })
});
burnMintTokenPoolEthSepolia.applyChainUpdates(chains);
uint64[] memory remoteChainSelectorsToRemove = new uint64[](0);
burnMintTokenPoolEthSepolia.applyChainUpdates(remoteChainSelectorsToRemove, chains);
vm.stopPrank();
}
}
Expand All @@ -460,15 +468,16 @@ contract CCIPv1_5BurnMintPoolFork is Test {
vm.startPrank(alice);
chains = new TokenPool.ChainUpdate[](1);
bytes[] memory remotePoolAddressesBaseSepolia = new bytes[](1);
remotePoolAddressesBaseSepolia[0] = abi.encode(address(burnMintTokenPoolEthSepolia));
chains[0] = TokenPool.ChainUpdate({
remoteChainSelector: ethSepoliaNetworkDetails.chainSelector,
allowed: true,
remotePoolAddress: abi.encode(address(burnMintTokenPoolEthSepolia)),
remotePoolAddresses: remotePoolAddressesBaseSepolia,
remoteTokenAddress: abi.encode(address(mockERC20TokenEthSepolia)),
outboundRateLimiterConfig: RateLimiter.Config({ isEnabled: true, capacity: 100_000, rate: 167 }),
inboundRateLimiterConfig: RateLimiter.Config({ isEnabled: true, capacity: 100_000, rate: 167 })
});
burnMintTokenPoolBaseSepolia.applyChainUpdates(chains);
burnMintTokenPoolBaseSepolia.applyChainUpdates(remoteChainSelectorsToRemove, chains);
vm.stopPrank();
}
}
Expand Down Expand Up @@ -590,7 +599,10 @@ contract CCIPv1_5BurnMintPoolFork is Test {
CCIPLocalSimulatorFork public ccipLocalSimulatorFork;
MockERC20BurnAndMintToken public mockERC20TokenEthSepolia;
MockERC20BurnAndMintToken public mockERC20TokenBaseSepolia;
BurnMintTokenPool public burnMintTokenPoolEthSepolia;
BurnMintTokenPool public burnMintTokenPoolBaseSepolia;
Register.NetworkDetails ethSepoliaNetworkDetails;
Register.NetworkDetails baseSepoliaNetworkDetails;
uint256 ethSepoliaFork;
Expand Down Expand Up @@ -625,12 +637,14 @@ contract CCIPv1_5BurnMintPoolFork is Test {
function test_forkSupportNewCCIPToken() public {
// Step 3) Deploy BurnMintTokenPool on Ethereum Sepolia
vm.selectFork(ethSepoliaFork);
Register.NetworkDetails memory ethSepoliaNetworkDetails = ccipLocalSimulatorFork.getNetworkDetails(block.chainid);
ethSepoliaNetworkDetails = ccipLocalSimulatorFork.getNetworkDetails(block.chainid);
address[] memory allowlist = new address[](0);
uint8 localTokenDecimals = 18;
vm.startPrank(alice);
BurnMintTokenPool burnMintTokenPoolEthSepolia = new BurnMintTokenPool(
burnMintTokenPoolEthSepolia = new BurnMintTokenPool(
IBurnMintERC20(address(mockERC20TokenEthSepolia)),
localTokenDecimals,
allowlist,
ethSepoliaNetworkDetails.rmnProxyAddress,
ethSepoliaNetworkDetails.routerAddress
Expand All @@ -642,8 +656,9 @@ contract CCIPv1_5BurnMintPoolFork is Test {
baseSepoliaNetworkDetails = ccipLocalSimulatorFork.getNetworkDetails(block.chainid);
vm.startPrank(alice);
BurnMintTokenPool burnMintTokenPoolBaseSepolia = new BurnMintTokenPool(
burnMintTokenPoolBaseSepolia = new BurnMintTokenPool(
IBurnMintERC20(address(mockERC20TokenBaseSepolia)),
localTokenDecimals,
allowlist,
baseSepoliaNetworkDetails.rmnProxyAddress,
baseSepoliaNetworkDetails.routerAddress
Expand Down Expand Up @@ -729,31 +744,34 @@ contract CCIPv1_5BurnMintPoolFork is Test {
vm.startPrank(alice);
TokenPool.ChainUpdate[] memory chains = new TokenPool.ChainUpdate[](1);
bytes[] memory remotePoolAddressesEthSepolia = new bytes[](1);
remotePoolAddressesEthSepolia[0] = abi.encode(address(burnMintTokenPoolEthSepolia));
chains[0] = TokenPool.ChainUpdate({
remoteChainSelector: baseSepoliaNetworkDetails.chainSelector,
allowed: true,
remotePoolAddress: abi.encode(address(burnMintTokenPoolBaseSepolia)),
remotePoolAddresses: remotePoolAddressesEthSepolia,
remoteTokenAddress: abi.encode(address(mockERC20TokenBaseSepolia)),
outboundRateLimiterConfig: RateLimiter.Config({ isEnabled: true, capacity: 100_000, rate: 167 }),
inboundRateLimiterConfig: RateLimiter.Config({ isEnabled: true, capacity: 100_000, rate: 167 })
});
burnMintTokenPoolEthSepolia.applyChainUpdates(chains);
uint64[] memory remoteChainSelectorsToRemove = new uint64[](0);
burnMintTokenPoolEthSepolia.applyChainUpdates(remoteChainSelectorsToRemove, chains);
vm.stopPrank();
// Step 14) Configure Token Pool on Base Sepolia
vm.selectFork(baseSepoliaFork);
vm.startPrank(alice);
chains = new TokenPool.ChainUpdate[](1);
bytes[] memory remotePoolAddressesBaseSepolia = new bytes[](1);
remotePoolAddressesBaseSepolia[0] = abi.encode(address(burnMintTokenPoolEthSepolia));
chains[0] = TokenPool.ChainUpdate({
remoteChainSelector: ethSepoliaNetworkDetails.chainSelector,
allowed: true,
remotePoolAddress: abi.encode(address(burnMintTokenPoolEthSepolia)),
remotePoolAddresses: remotePoolAddressesBaseSepolia,
remoteTokenAddress: abi.encode(address(mockERC20TokenEthSepolia)),
outboundRateLimiterConfig: RateLimiter.Config({ isEnabled: true, capacity: 100_000, rate: 167 }),
inboundRateLimiterConfig: RateLimiter.Config({ isEnabled: true, capacity: 100_000, rate: 167 })
});
burnMintTokenPoolBaseSepolia.applyChainUpdates(chains);
burnMintTokenPoolBaseSepolia.applyChainUpdates(remoteChainSelectorsToRemove, chains);
vm.stopPrank();
// Step 15) Mint tokens on Ethereum Sepolia and transfer them to Base Sepolia
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ contract CCIPv1_5LockReleasePoolFork is Test {
CCIPLocalSimulatorFork public ccipLocalSimulatorFork;
MockERC20TokenOwner public mockERC20TokenEthSepolia;
MockERC20TokenOwner public mockERC20TokenBaseSepolia;
LockReleaseTokenPool public lockReleaseTokenPoolEthSepolia;
LockReleaseTokenPool public lockReleaseTokenPoolBaseSepolia;
Register.NetworkDetails ethSepoliaNetworkDetails;
Register.NetworkDetails baseSepoliaNetworkDetails;
uint256 ethSepoliaFork;
uint256 baseSepoliaFork;
Expand Down Expand Up @@ -195,12 +200,14 @@ contract CCIPv1_5LockReleasePoolFork is Test {
function test_forkSupportNewCCIPToken() public {
// Step 3) Deploy LockReleaseTokenPool on Ethereum Sepolia
vm.selectFork(ethSepoliaFork);
Register.NetworkDetails memory ethSepoliaNetworkDetails = ccipLocalSimulatorFork.getNetworkDetails(block.chainid);
ethSepoliaNetworkDetails = ccipLocalSimulatorFork.getNetworkDetails(block.chainid);
address[] memory allowlist = new address[](0);
uint8 localTokenDecimals = 18;
vm.startPrank(alice);
LockReleaseTokenPool lockReleaseTokenPoolEthSepolia = new LockReleaseTokenPool(
lockReleaseTokenPoolEthSepolia = new LockReleaseTokenPool(
IERC20(address(mockERC20TokenEthSepolia)),
localTokenDecimals,
allowlist,
ethSepoliaNetworkDetails.rmnProxyAddress,
true, // acceptLiquidity
Expand All @@ -220,11 +227,12 @@ contract CCIPv1_5LockReleasePoolFork is Test {
// Step 4) Deploy LockReleaseTokenPool on Base Sepolia
vm.selectFork(baseSepoliaFork);
Register.NetworkDetails memory baseSepoliaNetworkDetails = ccipLocalSimulatorFork.getNetworkDetails(block.chainid);
baseSepoliaNetworkDetails = ccipLocalSimulatorFork.getNetworkDetails(block.chainid);
vm.startPrank(alice);
LockReleaseTokenPool lockReleaseTokenPoolBaseSepolia = new LockReleaseTokenPool(
lockReleaseTokenPoolBaseSepolia = new LockReleaseTokenPool(
IERC20(address(mockERC20TokenBaseSepolia)),
localTokenDecimals,
allowlist,
baseSepoliaNetworkDetails.rmnProxyAddress,
true, // acceptLiquidity
Expand Down Expand Up @@ -407,15 +415,17 @@ contract CCIPv1_5LockReleasePoolFork is Test {
vm.startPrank(alice);
TokenPool.ChainUpdate[] memory chains = new TokenPool.ChainUpdate[](1);
bytes[] memory remotePoolAddressesEthSepolia = new bytes[](1);
remotePoolAddressesEthSepolia[0] = abi.encode(address(lockReleaseTokenPoolBaseSepolia));
chains[0] = TokenPool.ChainUpdate({
remoteChainSelector: baseSepoliaNetworkDetails.chainSelector,
allowed: true,
remotePoolAddress: abi.encode(address(lockReleaseTokenPoolBaseSepolia)),
remotePoolAddresses: remotePoolAddressesEthSepolia,
remoteTokenAddress: abi.encode(address(mockERC20TokenBaseSepolia)),
outboundRateLimiterConfig: RateLimiter.Config({ isEnabled: true, capacity: liquidityAmount, rate: 167 }),
inboundRateLimiterConfig: RateLimiter.Config({ isEnabled: true, capacity: liquidityAmount, rate: 167 })
});
lockReleaseTokenPoolEthSepolia.applyChainUpdates(chains);
uint64[] memory remoteChainSelectorsToRemove = new uint64[](0);
lockReleaseTokenPoolEthSepolia.applyChainUpdates(remoteChainSelectorsToRemove, chains);
vm.stopPrank();
}
}
Expand All @@ -433,15 +443,16 @@ contract CCIPv1_5LockReleasePoolFork is Test {
vm.startPrank(alice);
chains = new TokenPool.ChainUpdate[](1);
bytes[] memory remotePoolAddressesBaseSepolia = new bytes[](1);
remotePoolAddressesBaseSepolia[0] = abi.encode(address(lockReleaseTokenPoolEthSepolia));
chains[0] = TokenPool.ChainUpdate({
remoteChainSelector: ethSepoliaNetworkDetails.chainSelector,
allowed: true,
remotePoolAddress: abi.encode(address(lockReleaseTokenPoolEthSepolia)),
remotePoolAddresses: remotePoolAddressesBaseSepolia,
remoteTokenAddress: abi.encode(address(mockERC20TokenEthSepolia)),
outboundRateLimiterConfig: RateLimiter.Config({ isEnabled: true, capacity: liquidityAmount, rate: 167 }),
inboundRateLimiterConfig: RateLimiter.Config({ isEnabled: true, capacity: liquidityAmount, rate: 167 })
});
lockReleaseTokenPoolBaseSepolia.applyChainUpdates(chains);
lockReleaseTokenPoolBaseSepolia.applyChainUpdates(remoteChainSelectorsToRemove, chains);
vm.stopPrank();
}
}
Expand Down Expand Up @@ -534,6 +545,11 @@ contract CCIPv1_5LockReleasePoolFork is Test {
CCIPLocalSimulatorFork public ccipLocalSimulatorFork;
MockERC20TokenOwner public mockERC20TokenEthSepolia;
MockERC20TokenOwner public mockERC20TokenBaseSepolia;
LockReleaseTokenPool public lockReleaseTokenPoolEthSepolia;
LockReleaseTokenPool public lockReleaseTokenPoolBaseSepolia;
Register.NetworkDetails ethSepoliaNetworkDetails;
Register.NetworkDetails baseSepoliaNetworkDetails;
uint256 ethSepoliaFork;
uint256 baseSepoliaFork;
Expand Down Expand Up @@ -567,12 +583,14 @@ contract CCIPv1_5LockReleasePoolFork is Test {
function test_forkSupportNewCCIPToken() public {
// Step 3) Deploy LockReleaseTokenPool on Ethereum Sepolia
vm.selectFork(ethSepoliaFork);
Register.NetworkDetails memory ethSepoliaNetworkDetails = ccipLocalSimulatorFork.getNetworkDetails(block.chainid);
ethSepoliaNetworkDetails = ccipLocalSimulatorFork.getNetworkDetails(block.chainid);
address[] memory allowlist = new address[](0);
uint8 localTokenDecimals = 18;
vm.startPrank(alice);
LockReleaseTokenPool lockReleaseTokenPoolEthSepolia = new LockReleaseTokenPool(
lockReleaseTokenPoolEthSepolia = new LockReleaseTokenPool(
IERC20(address(mockERC20TokenEthSepolia)),
localTokenDecimals,
allowlist,
ethSepoliaNetworkDetails.rmnProxyAddress,
true, // acceptLiquidity
Expand All @@ -582,11 +600,12 @@ contract CCIPv1_5LockReleasePoolFork is Test {
// Step 4) Deploy LockReleaseTokenPool on Base Sepolia
vm.selectFork(baseSepoliaFork);
Register.NetworkDetails memory baseSepoliaNetworkDetails = ccipLocalSimulatorFork.getNetworkDetails(block.chainid);
baseSepoliaNetworkDetails = ccipLocalSimulatorFork.getNetworkDetails(block.chainid);
vm.startPrank(alice);
LockReleaseTokenPool lockReleaseTokenPoolBaseSepolia = new LockReleaseTokenPool(
lockReleaseTokenPoolBaseSepolia = new LockReleaseTokenPool(
IERC20(address(mockERC20TokenBaseSepolia)),
localTokenDecimals,
allowlist,
baseSepoliaNetworkDetails.rmnProxyAddress,
true, // acceptLiquidity
Expand Down Expand Up @@ -679,31 +698,34 @@ contract CCIPv1_5LockReleasePoolFork is Test {
vm.startPrank(alice);
TokenPool.ChainUpdate[] memory chains = new TokenPool.ChainUpdate[](1);
bytes[] memory remotePoolAddressesEthSepolia = new bytes[](1);
remotePoolAddressesEthSepolia[0] = abi.encode(address(lockReleaseTokenPoolBaseSepolia));
chains[0] = TokenPool.ChainUpdate({
remoteChainSelector: baseSepoliaNetworkDetails.chainSelector,
allowed: true,
remotePoolAddress: abi.encode(address(lockReleaseTokenPoolBaseSepolia)),
remotePoolAddresses: remotePoolAddressesEthSepolia,
remoteTokenAddress: abi.encode(address(mockERC20TokenBaseSepolia)),
outboundRateLimiterConfig: RateLimiter.Config({ isEnabled: true, capacity: liquidityAmount, rate: 167 }),
inboundRateLimiterConfig: RateLimiter.Config({ isEnabled: true, capacity: liquidityAmount, rate: 167 })
});
lockReleaseTokenPoolEthSepolia.applyChainUpdates(chains);
uint64[] memory remoteChainSelectorsToRemove = new uint64[](0);
lockReleaseTokenPoolEthSepolia.applyChainUpdates(remoteChainSelectorsToRemove, chains);
vm.stopPrank();
// Step 14) Configure Token Pool on Base Sepolia
vm.selectFork(baseSepoliaFork);
vm.startPrank(alice);
chains = new TokenPool.ChainUpdate[](1);
bytes[] memory remotePoolAddressesBaseSepolia = new bytes[](1);
remotePoolAddressesBaseSepolia[0] = abi.encode(address(lockReleaseTokenPoolEthSepolia));
chains[0] = TokenPool.ChainUpdate({
remoteChainSelector: ethSepoliaNetworkDetails.chainSelector,
allowed: true,
remotePoolAddress: abi.encode(address(lockReleaseTokenPoolEthSepolia)),
remotePoolAddresses: remotePoolAddressesBaseSepolia,
remoteTokenAddress: abi.encode(address(mockERC20TokenEthSepolia)),
outboundRateLimiterConfig: RateLimiter.Config({ isEnabled: true, capacity: liquidityAmount, rate: 167 }),
inboundRateLimiterConfig: RateLimiter.Config({ isEnabled: true, capacity: liquidityAmount, rate: 167 })
});
lockReleaseTokenPoolBaseSepolia.applyChainUpdates(chains);
lockReleaseTokenPoolBaseSepolia.applyChainUpdates(remoteChainSelectorsToRemove, chains);
vm.stopPrank();
// Step 15) Transfer tokens from Ethereum Sepolia to Base Sepolia
Expand Down

0 comments on commit a76c17c

Please sign in to comment.