-
Notifications
You must be signed in to change notification settings - Fork 19
fix: finalise legacy transfers #297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
297ca5b
7c1c32e
c25a7cd
e3ef7e0
61aaa7c
e76b515
6058dfe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,28 +4,35 @@ pragma solidity 0.8.24; | |
| import "../../common/Borsh.sol"; | ||
| import {AccessControlUpgradeable} from '@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol'; | ||
| import {UUPSUpgradeable} from '@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol'; | ||
| import {IENear} from './IENear.sol'; | ||
| import {IENear, INearProver} from './IENear.sol'; | ||
| import {ICustomMinter} from '../../common/ICustomMinter.sol'; | ||
| import "../../omni-bridge/contracts/SelectivePausableUpgradable.sol"; | ||
|
|
||
| contract ENearProxy is UUPSUpgradeable, AccessControlUpgradeable, ICustomMinter { | ||
| contract ENearProxy is UUPSUpgradeable, AccessControlUpgradeable, ICustomMinter, SelectivePausableUpgradable { | ||
| IENear public eNear; | ||
|
|
||
| bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); | ||
| bytes32 public constant PAUSE_ROLE = keccak256("PAUSE_ROLE"); | ||
| bytes public nearConnector; | ||
| uint256 public currentReceiptId; | ||
| INearProver public prover; | ||
|
|
||
| uint constant PAUSED_LEGACY_FIN_TRANSFER = 1 << 0; | ||
|
|
||
| /// @custom:oz-upgrades-unsafe-allow constructor | ||
| constructor() { | ||
| _disableInitializers(); | ||
| } | ||
|
|
||
| function initialize(address _eNear, bytes memory _nearConnector, uint256 _currentReceiptId, address _adminAddress) public initializer { | ||
| function initialize(address _eNear, address _prover, bytes memory _nearConnector, uint256 _currentReceiptId, address _adminAddress) public initializer { | ||
| __UUPSUpgradeable_init(); | ||
| __AccessControl_init(); | ||
| eNear = IENear(_eNear); | ||
| nearConnector = _nearConnector; | ||
| currentReceiptId = _currentReceiptId; | ||
| prover = INearProver(_prover); | ||
| _grantRole(DEFAULT_ADMIN_ROLE, _adminAddress); | ||
| _grantRole(PAUSE_ROLE, _msgSender()); | ||
| } | ||
|
|
||
| function mint(address token, address to, uint128 amount) public onlyRole(MINTER_ROLE) { | ||
|
|
@@ -53,6 +60,26 @@ contract ENearProxy is UUPSUpgradeable, AccessControlUpgradeable, ICustomMinter | |
| eNear.transferToNear(amount, string('')); | ||
| } | ||
|
|
||
| function finaliseNearToEthTransfer( | ||
| bytes memory proofData, | ||
| uint64 proofBlockHeight | ||
| ) external whenNotPaused(PAUSED_LEGACY_FIN_TRANSFER) { | ||
| require( | ||
| prover.proveOutcome(proofData, proofBlockHeight), | ||
| "Proof should be valid" | ||
| ); | ||
|
|
||
| eNear.finaliseNearToEthTransfer(proofData, proofBlockHeight); | ||
| } | ||
|
|
||
| function pauseAll() external onlyRole(PAUSE_ROLE) { | ||
| _pause(PAUSED_LEGACY_FIN_TRANSFER); | ||
| } | ||
|
|
||
| function pause(uint flags) external onlyRole(DEFAULT_ADMIN_ROLE) { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's also add
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should unify the naming of the role between our EVM contracts.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| _pause(flags); | ||
| } | ||
|
|
||
| function _authorizeUpgrade( | ||
| address newImplementation | ||
| ) internal override onlyRole(DEFAULT_ADMIN_ROLE) {} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to add a separate method to this contract? Why can't we finalize transactions directly in eNear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will replace eNear prover to the fake one to allow minting through the proxy