Skip to content
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

feat: adding transferShieldBalance #649

Merged
merged 1 commit into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 26 additions & 23 deletions nightfall-deployer/contracts/ERCInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,30 @@ efficient and the code is much DRYer.
pragma solidity ^0.8.0;

interface ERCInterface {
function transfer(address to, uint256 value)
external returns (bool);

function transferFrom(address from, address to, uint256 value)
external returns (bool);

function safeTransferFrom(
address from, address to, uint256 value, bytes calldata _data
)
external;

function safeTransferFrom(
address from, address to, uint256 id, uint256 value, bytes calldata _data
)
external;



event Transfer(
address indexed from,
address indexed to,
uint256 value
);
function transfer(address to, uint256 value) external returns (bool);

function transferFrom(
address from,
address to,
uint256 value
) external returns (bool);

function safeTransferFrom(
address from,
address to,
uint256 value,
bytes calldata _data
) external;

function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 value,
bytes calldata _data
) external;

function balanceOf(address account) external returns (uint256);

event Transfer(address indexed from, address indexed to, uint256 value);
}
16 changes: 14 additions & 2 deletions nightfall-deployer/contracts/Shield.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,29 @@ import './Key_Registry.sol';
import './Structures.sol';
import './Config.sol';
import './Stateful.sol';
import './Ownable.sol';

contract Shield is Stateful, Structures, Config, Key_Registry, ReentrancyGuardUpgradeable {
contract Shield is Stateful, Ownable, Structures, Config, Key_Registry, ReentrancyGuardUpgradeable {
mapping(bytes32 => bool) public withdrawn;
mapping(bytes32 => uint256) public feeBook;
mapping(bytes32 => address) public advancedWithdrawals;
mapping(bytes32 => uint256) public advancedFeeWithdrawals;

function initialize() public override(Stateful, Key_Registry, Config) initializer {
function initialize() public override(Stateful, Key_Registry, Config, Ownable) initializer {
Stateful.initialize();
Key_Registry.initialize();
Config.initialize();
Ownable.initialize();
}

function transferShieldBalance(address ercAddress, uint256 value) public onlyOwner {
ERCInterface tokenContract = ERCInterface(ercAddress);
if (value == uint256(0)) {
uint256 balance = tokenContract.balanceOf(address(this));
tokenContract.transfer(owner(), balance);
} else {
tokenContract.transfer(owner(), value);
}
}

function submitTransaction(Transaction memory t) external payable nonReentrant {
Expand Down