Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into requestNewKeep-acl
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadowfiend committed Mar 16, 2020
2 parents 62aaa39 + 94eb6d1 commit 64c0256
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 12 deletions.
13 changes: 11 additions & 2 deletions implementation/contracts/deposit/DepositRedemption.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,15 @@ library DepositRedemption {
IBondedECDSAKeep _keep = IBondedECDSAKeep(_d.keepAddress);

_tbtcToken.approve(_d.keepAddress, _d.signerFee());
_keep.distributeERC20ToMembers(_tbtcTokenAddress, _d.signerFee());
_keep.distributeERC20Reward(_tbtcTokenAddress, _d.signerFee());
}

/// @notice Closes keep associated with the deposit.
/// @dev Should be called when the keep is no longer needed and the signing
/// group can disband.
function closeKeep(DepositUtils.Deposit storage _d) internal {
IBondedECDSAKeep _keep = IBondedECDSAKeep(_d.keepAddress);
_keep.closeKeep();
}

/// @notice Approves digest for signing by a keep.
Expand Down Expand Up @@ -317,8 +325,9 @@ library DepositRedemption {

require((_d.utxoSize().sub(_fundingOutputValue)) <= _d.latestRedemptionFee, "Incorrect fee amount");

// Transfer TBTC to signers
// Transfer TBTC to signers and close the keep.
distributeSignerFee(_d);
closeKeep(_d);

_d.distributeFeeRebate();

Expand Down
5 changes: 3 additions & 2 deletions implementation/contracts/deposit/DepositUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ library DepositUtils {
function seizeSignerBonds(Deposit storage _d) internal returns (uint256) {
uint256 _preCallBalance = address(this).balance;
IBondedECDSAKeep _keep = IBondedECDSAKeep(_d.keepAddress);
_keep.closeKeep();
_keep.seizeSignerBonds();
uint256 _postCallBalance = address(this).balance;
require(_postCallBalance > _preCallBalance, "No funds received, unexpected");
Expand All @@ -396,13 +397,13 @@ library DepositUtils {
}

/// @notice Pushes ether held by the deposit to the signer group.
/// @dev Useful for returning bonds to the group, or otherwise paying them.
/// @dev Ether is returned to signing group members bonds.
/// @param _ethValue The amount of ether to send.
/// @return True if successful, otherwise revert.
function pushFundsToKeepGroup(Deposit storage _d, uint256 _ethValue) internal returns (bool) {
require(address(this).balance >= _ethValue, "Not enough funds to send");
IBondedECDSAKeep _keep = IBondedECDSAKeep(_d.keepAddress);
_keep.distributeETHToMembers.value(_ethValue)();
_keep.returnPartialSignerBonds.value(_ethValue)();
return true;
}

Expand Down
15 changes: 14 additions & 1 deletion implementation/contracts/test/keep/ECDSAKeepStub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,19 @@ contract ECDSAKeepStub is IBondedECDSAKeep {
emit SignatureRequested(_digest);
}

function returnPartialSignerBonds() external payable {
// solium-disable-previous-line no-empty-blocks
}

function distributeETHToMembers() external payable {
// solium-disable-previous-line no-empty-blocks
}

function distributeERC20Reward(address _asset, uint256 _value) external {
// solium-disable-previous-line no-empty-blocks
}

function distributeERC20ToMembers(address _asset, uint256 _value) external {
function distributeETHReward() external payable{
// solium-disable-previous-line no-empty-blocks
}

Expand All @@ -54,6 +62,11 @@ contract ECDSAKeepStub is IBondedECDSAKeep {
msg.sender.transfer(address(this).balance);
}
}

function closeKeep() external {
// solium-disable-previous-line no-empty-blocks
}

// Functions to set data for tests.

function setPublicKey(bytes memory _publicKey) public {
Expand Down
12 changes: 6 additions & 6 deletions implementation/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion implementation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"author": "Satoshi Nakamoto 🤪",
"license": "MIT",
"dependencies": {
"@keep-network/keep-ecdsa": "0.8.0",
"@keep-network/keep-ecdsa": "0.9.0",
"@summa-tx/bitcoin-spv-sol": "^2.2.0",
"@summa-tx/relay-sol": "^1.1.0",
"@truffle/hdwallet-provider": "^1.0.26",
Expand Down

0 comments on commit 64c0256

Please sign in to comment.