-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into oft-and-adapter-fee-upgradeable
- Loading branch information
Showing
12 changed files
with
1,639 additions
and
86 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@layerzerolabs/devtools-ton": minor | ||
--- | ||
|
||
Added tool to debug TON lz messages |
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
This file was deleted.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
examples/oft-upgradeable/test/foundry/MyOFTUpgradeable.t.sol
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: UNLICENSED | ||
pragma solidity ^0.8.20; | ||
|
||
import { OFTTest } from "@layerzerolabs/oft-evm-upgradeable/test/OFT.t.sol"; | ||
import { MyOFTAdapterUpgradeable } from "../../contracts/MyOFTAdapterUpgradeable.sol"; | ||
import { EndpointV2Mock } from "@layerzerolabs/test-devtools-evm-foundry/contracts/mocks/EndpointV2Mock.sol"; | ||
import { MyOFTUpgradeable } from "../../contracts/MyOFTUpgradeable.sol"; | ||
import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; | ||
|
||
contract MyOFTUpgradeableTest is OFTTest { | ||
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; | ||
|
||
function test_oft_implementation_initialization_disabled() public { | ||
MyOFTUpgradeable oftUpgradeable = MyOFTUpgradeable( | ||
_deployContractAndProxy( | ||
type(MyOFTUpgradeable).creationCode, | ||
abi.encode(address(endpoints[aEid])), | ||
abi.encodeWithSelector( | ||
MyOFTUpgradeable.initialize.selector, | ||
"oftUpgradeable", | ||
"oftUpgradeable", | ||
address(this) | ||
) | ||
) | ||
); | ||
|
||
bytes32 implementationRaw = vm.load(address(oftUpgradeable), IMPLEMENTATION_SLOT); | ||
address implementationAddress = address(uint160(uint256(implementationRaw))); | ||
|
||
MyOFTUpgradeable oftUpgradeableImplementation = MyOFTUpgradeable(implementationAddress); | ||
|
||
vm.expectRevert(Initializable.InvalidInitialization.selector); | ||
oftUpgradeableImplementation.initialize("oftUpgradeable", "oftUpgradeable", address(this)); | ||
|
||
EndpointV2Mock endpoint = EndpointV2Mock(address(oftUpgradeable.endpoint())); | ||
assertEq(endpoint.delegates(address(oftUpgradeable)), address(this)); | ||
assertEq(endpoint.delegates(implementationAddress), address(0)); | ||
} | ||
|
||
function test_oft_adapter_implementation_initialization_disabled() public { | ||
MyOFTAdapterUpgradeable oftAdapter = MyOFTAdapterUpgradeable( | ||
_deployContractAndProxy( | ||
type(MyOFTAdapterUpgradeable).creationCode, | ||
abi.encode(address(cERC20Mock), address(endpoints[cEid])), | ||
abi.encodeWithSelector(MyOFTAdapterUpgradeable.initialize.selector, address(this)) | ||
) | ||
); | ||
|
||
bytes32 implementationRaw = vm.load(address(oftAdapter), IMPLEMENTATION_SLOT); | ||
address implementationAddress = address(uint160(uint256(implementationRaw))); | ||
|
||
MyOFTAdapterUpgradeable oftAdapterImplementation = MyOFTAdapterUpgradeable(implementationAddress); | ||
|
||
vm.expectRevert(Initializable.InvalidInitialization.selector); | ||
oftAdapterImplementation.initialize(address(this)); | ||
|
||
EndpointV2Mock endpoint = EndpointV2Mock(address(oftAdapter.endpoint())); | ||
assertEq(endpoint.delegates(address(oftAdapter)), address(this)); | ||
assertEq(endpoint.delegates(implementationAddress), address(0)); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -24,7 +24,8 @@ | |
"test:jest": "$npm_execpath turbo run test:jest $DOCKER_COMPOSE_RUN_TESTS_TURBO_ARGS", | ||
"test:local": ". bin/env && $npm_execpath start && $npm_execpath test", | ||
"test:local:jest": ". bin/env && $npm_execpath start && $npm_execpath test:jest", | ||
"test:user": "docker compose -f docker-compose.registry.yaml run --build --rm $DOCKER_COMPOSE_ARGS tests" | ||
"test:user": "docker compose -f docker-compose.registry.yaml run --build --rm $DOCKER_COMPOSE_ARGS tests", | ||
"ton:message-info": "ts-node packages/devtools-ton/scripts/debugTon.ts" | ||
}, | ||
"lint-staged": { | ||
"**/*.{js,ts,tsx,json}": [ | ||
|
@@ -33,6 +34,7 @@ | |
] | ||
}, | ||
"resolutions": { | ||
"@ton/ton": "npm:@layerzerolabs/[email protected]", | ||
"es5-ext": "git://github.com/LayerZero-Labs/es5-ext", | ||
"ethers": "^5.7.2", | ||
"hardhat-deploy": "^0.12.1", | ||
|
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
Oops, something went wrong.