@layerzerolabs/protocol-v2-messagelib-evm-contracts 1.2.95

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/README.md +15 -0
  2. package/contracts/Executor.sol +339 -0
  3. package/contracts/ExecutorFeeLib.sol +241 -0
  4. package/contracts/MessageLibBase.sol +21 -0
  5. package/contracts/PriceFeed.sol +304 -0
  6. package/contracts/ReceiveLibBaseE2.sol +28 -0
  7. package/contracts/SendLibBase.sol +258 -0
  8. package/contracts/SendLibBaseE2.sol +140 -0
  9. package/contracts/SimpleReadExecutor.sol +110 -0
  10. package/contracts/Treasury.sol +74 -0
  11. package/contracts/Worker.sol +167 -0
  12. package/contracts/decompressor/DVNDecoder.sol +52 -0
  13. package/contracts/decompressor/DVNDecompressor.sol +70 -0
  14. package/contracts/decompressor/DecompressorExtension.sol +204 -0
  15. package/contracts/decompressor/ExecutorDecoder.sol +147 -0
  16. package/contracts/decompressor/ExecutorDecompressor.sol +58 -0
  17. package/contracts/interfaces/IExecutor.sol +47 -0
  18. package/contracts/interfaces/IExecutorFeeLib.sol +56 -0
  19. package/contracts/interfaces/ILayerZeroExecutor.sol +29 -0
  20. package/contracts/interfaces/ILayerZeroPriceFeed.sol +61 -0
  21. package/contracts/interfaces/ILayerZeroReadExecutor.sol +15 -0
  22. package/contracts/interfaces/ILayerZeroTreasury.sol +19 -0
  23. package/contracts/interfaces/IWorker.sol +29 -0
  24. package/contracts/libs/ExecutorOptions.sol +104 -0
  25. package/contracts/libs/SafeCall.sol +123 -0
  26. package/contracts/lowlat/EssenceDVNWrapper.sol +77 -0
  27. package/contracts/lowlat/MultiCall.sol +42 -0
  28. package/contracts/mocks/DVNMock.sol +28 -0
  29. package/contracts/mocks/ExecutorMock.sol +95 -0
  30. package/contracts/uln/LzExecutor.sol +129 -0
  31. package/contracts/uln/ReceiveUlnBase.sol +125 -0
  32. package/contracts/uln/SendUlnBase.sol +129 -0
  33. package/contracts/uln/UlnBase.sol +195 -0
  34. package/contracts/uln/dvn/DVN.sol +393 -0
  35. package/contracts/uln/dvn/DVNFeeLib.sol +288 -0
  36. package/contracts/uln/dvn/DeadDVN.sol +30 -0
  37. package/contracts/uln/dvn/MultiSig.sol +135 -0
  38. package/contracts/uln/dvn/SimpleReadDVN.sol +112 -0
  39. package/contracts/uln/dvn/adapters/CCIP/CCIPDVNAdapter.sol +151 -0
  40. package/contracts/uln/dvn/adapters/CCIP/CCIPDVNAdapterFeeLib.sol +71 -0
  41. package/contracts/uln/dvn/adapters/DVNAdapterBase.sol +114 -0
  42. package/contracts/uln/dvn/adapters/arbitrum/ArbitrumDVNAdapterL1.sol +126 -0
  43. package/contracts/uln/dvn/adapters/arbitrum/ArbitrumDVNAdapterL2.sol +50 -0
  44. package/contracts/uln/dvn/adapters/avalanche/NOTES.md +4 -0
  45. package/contracts/uln/dvn/adapters/axelar/AxelarDVNAdapter.sol +152 -0
  46. package/contracts/uln/dvn/adapters/axelar/AxelarDVNAdapterFeeLib.sol +127 -0
  47. package/contracts/uln/dvn/adapters/libs/DVNAdapterMessageCodec.sol +41 -0
  48. package/contracts/uln/dvn/adapters/optimism/OptimismDVNAdapterL1.sol +86 -0
  49. package/contracts/uln/dvn/adapters/optimism/OptimismDVNAdapterL2.sol +58 -0
  50. package/contracts/uln/interfaces/IDVN.sol +26 -0
  51. package/contracts/uln/interfaces/IDVNFeeLib.sol +56 -0
  52. package/contracts/uln/interfaces/ILayerZeroDVN.sol +34 -0
  53. package/contracts/uln/interfaces/ILayerZeroReadDVN.sol +27 -0
  54. package/contracts/uln/interfaces/IReceiveUlnE2.sol +13 -0
  55. package/contracts/uln/interfaces/adapters/IAxelarDVNAdapter.sol +50 -0
  56. package/contracts/uln/interfaces/adapters/IAxelarDVNAdapterFeeLib.sol +49 -0
  57. package/contracts/uln/interfaces/adapters/ICCIPDVNAdapter.sol +34 -0
  58. package/contracts/uln/interfaces/adapters/ICCIPDVNAdapterFeeLib.sol +46 -0
  59. package/contracts/uln/libs/DVNOptions.sol +181 -0
  60. package/contracts/uln/libs/ReadCmdCodecV1.sol +136 -0
  61. package/contracts/uln/libs/SupportedCmdTypes.sol +29 -0
  62. package/contracts/uln/libs/UlnOptions.sol +176 -0
  63. package/contracts/uln/readlib/ReadLib1002.sol +518 -0
  64. package/contracts/uln/readlib/ReadLib1002View.sol +98 -0
  65. package/contracts/uln/readlib/ReadLibBase.sol +187 -0
  66. package/contracts/uln/uln301/AddressSizeConfig.sol +22 -0
  67. package/contracts/uln/uln301/ReceiveLibBaseE1.sol +103 -0
  68. package/contracts/uln/uln301/ReceiveUln301.sol +83 -0
  69. package/contracts/uln/uln301/ReceiveUln301View.sol +89 -0
  70. package/contracts/uln/uln301/SendLibBaseE1.sol +194 -0
  71. package/contracts/uln/uln301/SendUln301.sol +99 -0
  72. package/contracts/uln/uln301/TreasuryFeeHandler.sol +41 -0
  73. package/contracts/uln/uln301/interfaces/IMessageLibE1.sol +22 -0
  74. package/contracts/uln/uln301/interfaces/INonceContract.sol +7 -0
  75. package/contracts/uln/uln301/interfaces/ITreasuryFeeHandler.sol +13 -0
  76. package/contracts/uln/uln301/interfaces/IUltraLightNode301.sol +7 -0
  77. package/contracts/uln/uln301/mocks/NonceContractMock.sol +23 -0
  78. package/contracts/uln/uln302/ReceiveUln302.sol +85 -0
  79. package/contracts/uln/uln302/ReceiveUln302View.sol +89 -0
  80. package/contracts/uln/uln302/SendUln302.sol +86 -0
  81. package/contracts/upgradeable/WorkerUpgradeable.sol +186 -0
  82. package/contracts/upgradeable/proxy/ProxyAdmin.sol +96 -0
  83. package/contracts/upgradeable/proxy/TransparentUpgradeableProxy.sol +131 -0
  84. package/dist/index.d.ts +7 -0
  85. package/dist/index.d.ts.map +1 -0
  86. package/dist/index.js +6 -0
  87. package/dist/index.js.map +1 -0
  88. package/package.json +70 -0
@@ -0,0 +1,186 @@
1
+ // SPDX-License-Identifier: LZBL-1.2
2
+
3
+ pragma solidity ^0.8.20;
4
+
5
+ import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
6
+ import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
7
+ import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
8
+
9
+ import { ISendLib } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ISendLib.sol";
10
+ import { Transfer } from "@layerzerolabs/lz-evm-protocol-v2/contracts/libs/Transfer.sol";
11
+
12
+ import { IWorker } from "../interfaces/IWorker.sol";
13
+
14
+ abstract contract WorkerUpgradeable is Initializable, AccessControlUpgradeable, PausableUpgradeable, IWorker {
15
+ bytes32 internal constant MESSAGE_LIB_ROLE = keccak256("MESSAGE_LIB_ROLE");
16
+ bytes32 internal constant ALLOWLIST = keccak256("ALLOWLIST");
17
+ bytes32 internal constant DENYLIST = keccak256("DENYLIST");
18
+ bytes32 internal constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
19
+
20
+ address public workerFeeLib;
21
+
22
+ uint64 public allowlistSize;
23
+ uint16 public defaultMultiplierBps;
24
+ address public priceFeed;
25
+
26
+ mapping(uint32 eid => uint8[] optionTypes) internal supportedOptionTypes;
27
+
28
+ /// @param _messageLibs array of message lib addresses that are granted the MESSAGE_LIB_ROLE
29
+ /// @param _priceFeed price feed address
30
+ /// @param _defaultMultiplierBps default multiplier for worker fee
31
+ /// @param _roleAdmin address that is granted the DEFAULT_ADMIN_ROLE (can grant and revoke all roles)
32
+ /// @param _admins array of admin addresses that are granted the ADMIN_ROLE
33
+ function __Worker_init(
34
+ address[] memory _messageLibs,
35
+ address _priceFeed,
36
+ uint16 _defaultMultiplierBps,
37
+ address _roleAdmin,
38
+ address[] memory _admins
39
+ ) internal onlyInitializing {
40
+ __Context_init_unchained();
41
+ __AccessControl_init_unchained();
42
+ __Pausable_init_unchained();
43
+ __Worker_init_unchained(_messageLibs, _priceFeed, _defaultMultiplierBps, _roleAdmin, _admins);
44
+ }
45
+
46
+ function __Worker_init_unchained(
47
+ address[] memory _messageLibs,
48
+ address _priceFeed,
49
+ uint16 _defaultMultiplierBps,
50
+ address _roleAdmin,
51
+ address[] memory _admins
52
+ ) internal onlyInitializing {
53
+ defaultMultiplierBps = _defaultMultiplierBps;
54
+ priceFeed = _priceFeed;
55
+
56
+ if (_roleAdmin != address(0x0)) {
57
+ _grantRole(DEFAULT_ADMIN_ROLE, _roleAdmin); // _roleAdmin can grant and revoke all roles
58
+ }
59
+
60
+ for (uint256 i = 0; i < _messageLibs.length; ++i) {
61
+ _grantRole(MESSAGE_LIB_ROLE, _messageLibs[i]);
62
+ }
63
+
64
+ for (uint256 i = 0; i < _admins.length; ++i) {
65
+ _grantRole(ADMIN_ROLE, _admins[i]);
66
+ }
67
+ }
68
+
69
+ // ========================= Modifier =========================
70
+
71
+ modifier onlyAcl(address _sender) {
72
+ if (!hasAcl(_sender)) {
73
+ revert Worker_NotAllowed();
74
+ }
75
+ _;
76
+ }
77
+
78
+ /// @dev Access control list using allowlist and denylist
79
+ /// @dev 1) if one address is in the denylist -> deny
80
+ /// @dev 2) else if address in the allowlist OR allowlist is empty (allows everyone)-> allow
81
+ /// @dev 3) else deny
82
+ /// @param _sender address to check
83
+ function hasAcl(address _sender) public view returns (bool) {
84
+ if (hasRole(DENYLIST, _sender)) {
85
+ return false;
86
+ } else if (allowlistSize == 0 || hasRole(ALLOWLIST, _sender)) {
87
+ return true;
88
+ } else {
89
+ return false;
90
+ }
91
+ }
92
+
93
+ // ========================= OnyDefaultAdmin =========================
94
+
95
+ /// @dev flag to pause execution of workers (if used with whenNotPaused modifier)
96
+ /// @param _paused true to pause, false to unpause
97
+ function setPaused(bool _paused) external onlyRole(DEFAULT_ADMIN_ROLE) {
98
+ if (_paused) {
99
+ _pause();
100
+ } else {
101
+ _unpause();
102
+ }
103
+ }
104
+
105
+ // ========================= OnlyAdmin =========================
106
+
107
+ /// @param _priceFeed price feed address
108
+ function setPriceFeed(address _priceFeed) external onlyRole(ADMIN_ROLE) {
109
+ priceFeed = _priceFeed;
110
+ emit SetPriceFeed(_priceFeed);
111
+ }
112
+
113
+ /// @param _workerFeeLib worker fee lib address
114
+ function setWorkerFeeLib(address _workerFeeLib) external onlyRole(ADMIN_ROLE) {
115
+ workerFeeLib = _workerFeeLib;
116
+ emit SetWorkerLib(_workerFeeLib);
117
+ }
118
+
119
+ /// @param _multiplierBps default multiplier for worker fee
120
+ function setDefaultMultiplierBps(uint16 _multiplierBps) external onlyRole(ADMIN_ROLE) {
121
+ defaultMultiplierBps = _multiplierBps;
122
+ emit SetDefaultMultiplierBps(_multiplierBps);
123
+ }
124
+
125
+ /// @dev supports withdrawing fee from ULN301, ULN302 and more
126
+ /// @param _lib message lib address
127
+ /// @param _to address to withdraw fee to
128
+ /// @param _amount amount to withdraw
129
+ function withdrawFee(address _lib, address _to, uint256 _amount) external onlyRole(ADMIN_ROLE) {
130
+ if (!hasRole(MESSAGE_LIB_ROLE, _lib)) revert Worker_OnlyMessageLib();
131
+ ISendLib(_lib).withdrawFee(_to, _amount);
132
+ emit Withdraw(_lib, _to, _amount);
133
+ }
134
+
135
+ /// @dev supports withdrawing token from the contract
136
+ /// @param _token token address
137
+ /// @param _to address to withdraw token to
138
+ /// @param _amount amount to withdraw
139
+ function withdrawToken(address _token, address _to, uint256 _amount) external onlyRole(ADMIN_ROLE) {
140
+ // transfers native if _token is address(0x0)
141
+ Transfer.nativeOrToken(_token, _to, _amount);
142
+ }
143
+
144
+ function setSupportedOptionTypes(uint32 _eid, uint8[] calldata _optionTypes) external onlyRole(ADMIN_ROLE) {
145
+ supportedOptionTypes[_eid] = _optionTypes;
146
+ }
147
+
148
+ // ========================= View Functions =========================
149
+ function getSupportedOptionTypes(uint32 _eid) external view returns (uint8[] memory) {
150
+ return supportedOptionTypes[_eid];
151
+ }
152
+
153
+ // ========================= Internal Functions =========================
154
+
155
+ /// @dev overrides AccessControl to allow for counting of allowlistSize
156
+ /// @param _role role to grant
157
+ /// @param _account address to grant role to
158
+ function _grantRole(bytes32 _role, address _account) internal override {
159
+ if (_role == ALLOWLIST && !hasRole(_role, _account)) {
160
+ ++allowlistSize;
161
+ }
162
+ super._grantRole(_role, _account);
163
+ }
164
+
165
+ /// @dev overrides AccessControl to allow for counting of allowlistSize
166
+ /// @param _role role to revoke
167
+ /// @param _account address to revoke role from
168
+ function _revokeRole(bytes32 _role, address _account) internal override {
169
+ if (_role == ALLOWLIST && hasRole(_role, _account)) {
170
+ --allowlistSize;
171
+ }
172
+ super._revokeRole(_role, _account);
173
+ }
174
+
175
+ /// @dev overrides AccessControl to disable renouncing of roles
176
+ function renounceRole(bytes32 /*role*/, address /*account*/) public pure override {
177
+ revert Worker_RoleRenouncingDisabled();
178
+ }
179
+
180
+ /**
181
+ * @dev This empty reserved space is put in place to allow future versions to add new
182
+ * variables without shifting down storage in the inheritance chain.
183
+ * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
184
+ */
185
+ uint256[47] private __gap;
186
+ }
@@ -0,0 +1,96 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ // OpenZeppelin Contracts v4.4.1 (proxy/transparent/ProxyAdmin.sol)
4
+
5
+ pragma solidity ^0.8.0;
6
+
7
+ import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
8
+
9
+ import { TransparentUpgradeableProxy } from "./TransparentUpgradeableProxy.sol";
10
+
11
+ /**
12
+ * @author OpenZeppelin. Modified from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v4.4/contracts/proxy/transparent/ProxyAdmin.sol
13
+ * to support custom errors and `initialOwner` constructor parameter.
14
+ * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an
15
+ * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.
16
+ */
17
+ contract ProxyAdmin is Ownable {
18
+ error ImplementationCallFailed();
19
+ error AdminCallFailed();
20
+
21
+ constructor(address initialOwner) {
22
+ _transferOwnership(initialOwner);
23
+ }
24
+
25
+ /**
26
+ * @dev Returns the current implementation of `proxy`.
27
+ *
28
+ * Requirements:
29
+ *
30
+ * - This contract must be the admin of `proxy`.
31
+ */
32
+ function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {
33
+ // We need to manually run the static call since the getter cannot be flagged as view
34
+ // bytes4(keccak256("implementation()")) == 0x5c60da1b
35
+ (bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b");
36
+ if (!success) {
37
+ revert ImplementationCallFailed();
38
+ }
39
+ return abi.decode(returndata, (address));
40
+ }
41
+
42
+ /**
43
+ * @dev Returns the current admin of `proxy`.
44
+ *
45
+ * Requirements:
46
+ *
47
+ * - This contract must be the admin of `proxy`.
48
+ */
49
+ function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {
50
+ // We need to manually run the static call since the getter cannot be flagged as view
51
+ // bytes4(keccak256("admin()")) == 0xf851a440
52
+ (bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440");
53
+ if (!success) {
54
+ revert AdminCallFailed();
55
+ }
56
+ return abi.decode(returndata, (address));
57
+ }
58
+
59
+ /**
60
+ * @dev Changes the admin of `proxy` to `newAdmin`.
61
+ *
62
+ * Requirements:
63
+ *
64
+ * - This contract must be the current admin of `proxy`.
65
+ */
66
+ function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {
67
+ proxy.changeAdmin(newAdmin);
68
+ }
69
+
70
+ /**
71
+ * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.
72
+ *
73
+ * Requirements:
74
+ *
75
+ * - This contract must be the admin of `proxy`.
76
+ */
77
+ function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {
78
+ proxy.upgradeTo(implementation);
79
+ }
80
+
81
+ /**
82
+ * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See
83
+ * {TransparentUpgradeableProxy-upgradeToAndCall}.
84
+ *
85
+ * Requirements:
86
+ *
87
+ * - This contract must be the admin of `proxy`.
88
+ */
89
+ function upgradeAndCall(
90
+ TransparentUpgradeableProxy proxy,
91
+ address implementation,
92
+ bytes memory data
93
+ ) public payable virtual onlyOwner {
94
+ proxy.upgradeToAndCall{ value: msg.value }(implementation, data);
95
+ }
96
+ }
@@ -0,0 +1,131 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ // OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)
4
+
5
+ pragma solidity ^0.8.0;
6
+
7
+ import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
8
+
9
+ /**
10
+ * @author OpenZeppelin. Modified from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v4.4/contracts/proxy/transparent/TransparentUpgradeableProxy.sol
11
+ * to support custom errors.
12
+ * @dev This contract implements a proxy that is upgradeable by an admin.
13
+ *
14
+ * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
15
+ * clashing], which can potentially be used in an attack, this contract uses the
16
+ * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
17
+ * things that go hand in hand:
18
+ *
19
+ * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
20
+ * that call matches one of the admin functions exposed by the proxy itself.
21
+ * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the
22
+ * implementation. If the admin tries to call a function on the implementation it will fail with an error indicating
23
+ * the proxy admin cannot fallback to the target implementation.
24
+ *
25
+ * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing
26
+ * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due
27
+ * to sudden errors when trying to call a function from the proxy implementation.
28
+ *
29
+ * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,
30
+ * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.
31
+ */
32
+ contract TransparentUpgradeableProxy is ERC1967Proxy {
33
+ /**
34
+ * @dev The proxy caller is the current admin, and can't fallback to the proxy target.
35
+ */
36
+ error AdminAccessDenied();
37
+
38
+ /**
39
+ * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and
40
+ * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.
41
+ */
42
+ constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) {
43
+ assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1));
44
+ _changeAdmin(admin_);
45
+ }
46
+
47
+ /**
48
+ * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.
49
+ */
50
+ modifier ifAdmin() {
51
+ if (msg.sender == _getAdmin()) {
52
+ _;
53
+ } else {
54
+ _fallback();
55
+ }
56
+ }
57
+
58
+ /**
59
+ * @dev Returns the current admin.
60
+ *
61
+ * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.
62
+ *
63
+ * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
64
+ * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
65
+ * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
66
+ */
67
+ function admin() external ifAdmin returns (address admin_) {
68
+ admin_ = _getAdmin();
69
+ }
70
+
71
+ /**
72
+ * @dev Returns the current implementation.
73
+ *
74
+ * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
75
+ *
76
+ * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
77
+ * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
78
+ * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
79
+ */
80
+ function implementation() external ifAdmin returns (address implementation_) {
81
+ implementation_ = _implementation();
82
+ }
83
+
84
+ /**
85
+ * @dev Changes the admin of the proxy.
86
+ *
87
+ * Emits an {AdminChanged} event.
88
+ *
89
+ * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.
90
+ */
91
+ function changeAdmin(address newAdmin) external virtual ifAdmin {
92
+ _changeAdmin(newAdmin);
93
+ }
94
+
95
+ /**
96
+ * @dev Upgrade the implementation of the proxy.
97
+ *
98
+ * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.
99
+ */
100
+ function upgradeTo(address newImplementation) external ifAdmin {
101
+ _upgradeToAndCall(newImplementation, bytes(""), false);
102
+ }
103
+
104
+ /**
105
+ * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified
106
+ * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the
107
+ * proxied contract.
108
+ *
109
+ * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.
110
+ */
111
+ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {
112
+ _upgradeToAndCall(newImplementation, data, true);
113
+ }
114
+
115
+ /**
116
+ * @dev Returns the current admin.
117
+ */
118
+ function _admin() internal view virtual returns (address) {
119
+ return _getAdmin();
120
+ }
121
+
122
+ /**
123
+ * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.
124
+ */
125
+ function _beforeFallback() internal virtual override {
126
+ if (msg.sender == _getAdmin()) {
127
+ revert AdminAccessDenied();
128
+ }
129
+ super._beforeFallback();
130
+ }
131
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The contract artifacts are the product of this package: read them by path, e.g.
3
+ * `@layerzerolabs/protocol-v2-messagelib-evm-contracts/artifacts/contracts/<Source>.sol/<Contract>.json`
4
+ * (`artifacts-zk/` for zkSync, `artifacts-tron/` for Tron).
5
+ */
6
+ export declare const PACKAGE_NAME = "@layerzerolabs/protocol-v2-messagelib-evm-contracts";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,YAAY,wDAAwD,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ // src/index.ts
2
+ var PACKAGE_NAME = "@layerzerolabs/protocol-v2-messagelib-evm-contracts";
3
+
4
+ export { PACKAGE_NAME };
5
+ //# sourceMappingURL=index.js.map
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":["PACKAGE_NAME"],"mappings":";AAKO,IAAMA,YAAAA,GAAe","file":"index.js","sourcesContent":["/**\n * The contract artifacts are the product of this package: read them by path, e.g.\n * `@layerzerolabs/protocol-v2-messagelib-evm-contracts/artifacts/contracts/<Source>.sol/<Contract>.json`\n * (`artifacts-zk/` for zkSync, `artifacts-tron/` for Tron).\n */\nexport const PACKAGE_NAME = '@layerzerolabs/protocol-v2-messagelib-evm-contracts';\n"]}
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@layerzerolabs/protocol-v2-messagelib-evm-contracts",
3
+ "version": "1.2.95",
4
+ "private": false,
5
+ "description": "Copied from @layerzerolabs/lz-evm-messagelib-v2 in the old LayerZero-Labs/monorepo",
6
+ "license": "LZBL-1.2",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "./artifacts/*": "./artifacts/*",
15
+ "./artifacts-zk/*": "./artifacts-zk/*",
16
+ "./artifacts-tron/*": "./artifacts-tron/*",
17
+ "./contracts/*": "./contracts/*",
18
+ "./package.json": "./package.json"
19
+ },
20
+ "main": "./dist/index.js",
21
+ "module": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
23
+ "files": [
24
+ "artifacts/contracts/**/!(*.dbg).json",
25
+ "artifacts-zk/contracts/**/!(*.dbg).json",
26
+ "artifacts-tron/contracts/**/!(*.dbg).json",
27
+ "contracts/**/*",
28
+ "dist/**/*"
29
+ ],
30
+ "devDependencies": {
31
+ "@arbitrum/nitro-contracts": "1.1.0",
32
+ "@axelar-network/axelar-gmp-sdk-solidity": "5.6.4",
33
+ "@chainlink/contracts-ccip": "0.7.6",
34
+ "@eth-optimism/contracts": "0.6.0",
35
+ "@layerzerolabs/hardhat-tron": "3.0.168",
36
+ "@layerzerolabs/lz-evm-protocol-v2": "npm:@layerzerolabs/protocol-v2-evm-contracts@1.2.95",
37
+ "@layerzerolabs/lz-evm-v1-0.7": "npm:@layerzerolabs/protocol-v1-0.7-evm-contracts@1.2.95",
38
+ "@layerzerolabs/toolbox-foundry": "^0.1.13",
39
+ "@layerzerolabs/tsup-configuration": "1.2.95",
40
+ "@layerzerolabs/typescript-configuration": "1.2.95",
41
+ "@layerzerolabs/vm-tooling-evm": "1.2.95",
42
+ "@matterlabs/hardhat-zksync-solc": "1.3.2",
43
+ "@openzeppelin/contracts": "4.9.5",
44
+ "@openzeppelin/contracts-upgradeable": "4.9.5",
45
+ "hardhat-deploy": "0.12.4",
46
+ "solidity-bytes-utils": "npm:@layerzerolabs/solidity-bytes-utils@0.8.0",
47
+ "tsup": "^8.4.0"
48
+ },
49
+ "publishConfig": {
50
+ "access": "restricted",
51
+ "registry": "https://registry.npmjs.org/"
52
+ },
53
+ "externalRepoConfig": {
54
+ "targets": [
55
+ "everdawn-externalization"
56
+ ]
57
+ },
58
+ "scripts": {
59
+ "build": "pnpm compile:evm && pnpm compile:zksync && pnpm compile:tron && tsup",
60
+ "clean": "rm -rf ./node_modules .turbo ./dist && pnpm generated:clean",
61
+ "compile:evm": "pnpm lz-tool hardhat compile --config ./hardhat.config.cjs",
62
+ "compile:tron": "pnpm lz-tool hardhat compile --config ./hardhat.config.cjs --network tron-mainnet",
63
+ "compile:zksync": "pnpm lz-tool hardhat compile --config ./hardhat.config.cjs --network zksync-mainnet",
64
+ "generated:clean": "rm -rf ./artifacts* ./hh-cache* ./out ./cache",
65
+ "lint": "eslint . --max-warnings 0 || (eslint . --fix --max-warnings 0 && false)",
66
+ "test": "pnpm lz-tool forge test",
67
+ "test:snapshot:check": "pnpm exec turbo-snapshot check",
68
+ "test:snapshot:update": "pnpm exec turbo-snapshot update"
69
+ }
70
+ }