-
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.
(feat) Quite a lot of code; we're failing our integration transfer test.
- Loading branch information
1 parent
ed06f0a
commit d956983
Showing
21 changed files
with
3,293 additions
and
35 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
38 changes: 38 additions & 0 deletions
38
smart-contracts/contracts/zilbridge/2/LockProxyTokenManagerStorage.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,38 @@ | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
pragma solidity ^0.8.20; | ||
|
||
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; | ||
|
||
interface ILockProxyTokenManagerStorage { | ||
event LockProxyUpdated(address oldLockProxy, address newLockProxy); | ||
function getLockProxy() external view returns (address); | ||
function setLockProxy(address lockProxy) external; | ||
} | ||
|
||
abstract contract LockProxyTokenManagerStorage is ILockProxyTokenManagerStorage { | ||
/// @custom:storage-location erc7201:zilliqa.storage.LockProxyTokenManagerStorage | ||
struct LockProxyTokenManagerStorageStruct { | ||
address lockProxy; | ||
} | ||
|
||
// keccack256(abi.encode(uint256(keccack256("zilliqa.storage.LockProxyTokenManagerStorage"))-1)) & ~bytes32(uint256(0xff)) | ||
bytes32 private constant Lock_Proxy_Storage_Location = 0xb22af1dfa3d79e3af56bf3b03e8c9cb6d48fc6bbb7ec48dcbfc0dbccf342f800; | ||
|
||
function _getLockProxyTokenManagerStorageStruct() private pure returns (LockProxyTokenManagerStorageStruct storage $) | ||
{ | ||
assembly { | ||
$.slot := Lock_Proxy_Storage_Location | ||
} | ||
} | ||
|
||
function getLockProxy() public view returns (address) { | ||
LockProxyTokenManagerStorageStruct storage $ = _getLockProxyTokenManagerStorageStruct(); | ||
return $.lockProxy; | ||
} | ||
|
||
function _setLockProxy(address lockProxy) internal { | ||
LockProxyTokenManagerStorageStruct storage $ = _getLockProxyTokenManagerStorageStruct(); | ||
emit LockProxyUpdated($.lockProxy, lockProxy); | ||
$.lockProxy = lockProxy; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
smart-contracts/contracts/zilbridge/2/LockProxyTokenManagerUpgradeable.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,54 @@ | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
pragma solidity ^0.8.20; | ||
|
||
import {TokenManagerUpgradeable, ITokenManager} from "contracts/periphery/TokenManagerUpgradeable.sol"; | ||
import { ILockProxyTokenManagerStorage, LockProxyTokenManagerStorage } from "contracts/zilbridge/2/LockProxyTokenManagerStorage.sol"; | ||
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
|
||
interface ILockProxyTokenManager is ITokenManager { | ||
// Args in this order to match other token managers. | ||
event SentToLockProxy(address indexed token, address indexed sender, uint amount); | ||
event WithdrawnFromLockProxy(address indexed token, address indexed receipient, uint amount); | ||
function setLockProxy(address lockProxy) external; | ||
} | ||
|
||
// This contract exists almost entirely to be used in tests to prove upgradeability. | ||
contract LockProxyTokenManagerUpgradeable is | ||
ILockProxyTokenManager, | ||
TokenManagerUpgradeable, | ||
LockProxyTokenManagerStorage | ||
{ | ||
/// @custom:oz-upgrades-unsafe-allow constructor | ||
constructor() { | ||
_disableInitializers(); | ||
} | ||
|
||
|
||
function setLockProxy(address lockProxy) external override(ILockProxyTokenManagerStorage, ILockProxyTokenManager) onlyOwner { | ||
_setLockProxy(lockProxy); | ||
} | ||
|
||
function initialize(address _gateway, address lockProxy) external initializer { | ||
__TokenManager_init(_gateway); | ||
// for some reason we can't call setLockProxy() here, so .. | ||
_setLockProxy(lockProxy); | ||
} | ||
|
||
// Outgoing | ||
function _handleTransfer( | ||
address /* token */, | ||
address /* from */, | ||
uint /* amount */ | ||
) pure internal override { | ||
revert(); | ||
} | ||
|
||
// Incoming | ||
function _handleAccept( | ||
address /* token */, | ||
address /* recipient */, | ||
uint /* amount */ | ||
) pure internal override { | ||
revert(); | ||
} | ||
} |
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
40 changes: 40 additions & 0 deletions
40
smart-contracts/contracts/zilbridge/2/ZilliqaLockProxyManagerUpgradeableV3.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,40 @@ | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
pragma solidity ^0.8.20; | ||
|
||
import {TokenManagerUpgradeableV3, ITokenManager} from "contracts/periphery/TokenManagerV3/TokenManagerUpgradeableV3.sol"; | ||
import {BridgedToken} from "contracts/periphery/BridgedToken.sol"; | ||
import { LockProxy } from "contracts/zilbridge/1/lockProxy.sol"; | ||
import {IERC20} from "contracts/periphery/LockAndReleaseTokenManagerUpgradeable.sol"; | ||
import { ILockProxyTokenManagerStorage, LockProxyTokenManagerStorage } from "contracts/zilbridge/2/LockProxyTokenManagerStorage.sol"; | ||
|
||
interface ILockProxyTokenManager is ILockProxyTokenManagerStorage { | ||
// Args in this order to match other token managers. | ||
event SentToLockProxy(address indexed token, address indexed sender, uint amount); | ||
event WithdrawnFromLockProxy(address indexed token, address indexed receipient, uint amount); | ||
} | ||
|
||
// This is the lock proxy token manager that runs on Zilliqa chains. It talks to a Scilla LockProxy via interop. | ||
contract ZilliqaLockProxyTokenManagerUpgradeableV3 is TokenManagerUpgradeableV3, ILockProxyTokenManager, LockProxyTokenManagerStorage { | ||
address public constant NATIVE_ASSET_HASH = address(0); | ||
|
||
constructor() { | ||
_disableInitializers(); | ||
} | ||
|
||
function reinitialize(uint fees) external reinitializer(2) { | ||
_setFees(fees); | ||
} | ||
|
||
function _handleTransfer(address /*token*/, address /*from*/, uint /*amount*/) internal pure override { | ||
revert("Not yet implemented"); | ||
} | ||
|
||
function _handleAccept(address /* token */, address /*recipient*/, uint /*amount*/) internal pure override { | ||
revert("Not yet implemented"); | ||
} | ||
|
||
function setLockProxy(address lockProxy) external onlyOwner { | ||
_setLockProxy(lockProxy); | ||
} | ||
|
||
} |
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,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Smart Contract Solutions, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included | ||
in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,3 @@ | ||
# Lib Contracts | ||
|
||
The contracts in this folder were copied from the OpenZeppelin repository at https://github.com/OpenZeppelin/openzeppelin-contracts for ease of reference. |
Oops, something went wrong.