Skip to content

Commit d40229d

Browse files
author
Mark Brivvins
committed
63-align stake withdrawal interface
1 parent 54040de commit d40229d

3 files changed

Lines changed: 43 additions & 17 deletions

File tree

contracts/Endorsement.sol

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,6 @@ abstract contract Endorsement is
7979
/** A map targetAddress => stake with the total stake by target */
8080
mapping(address => uint) public totalStake;
8181

82-
event WithdrawStake(
83-
address indexed _from,
84-
address indexed _to,
85-
uint256 _value,
86-
string _transactionId
87-
);
88-
8982
// Oracle related:
9083

9184
/**
@@ -239,16 +232,6 @@ abstract contract Endorsement is
239232
_triggerEndorse(msg.sender, target, amount, transactionId);
240233
}
241234

242-
function withdrawStake(
243-
address target,
244-
uint256 amount,
245-
string memory transactionId
246-
) public virtual {
247-
require(msg.sender == tx.origin, "should be a user");
248-
249-
_withdrawStake(msg.sender, target, amount, transactionId);
250-
}
251-
252235
function _withdrawStake(
253236
address source,
254237
address target,
@@ -272,6 +255,19 @@ abstract contract Endorsement is
272255
emit WithdrawStake(source, target, amount, transactionId);
273256
}
274257

258+
/**
259+
* @inheritdoc EndorsementInterface
260+
*/
261+
function withdrawStake(
262+
address target,
263+
uint256 amount,
264+
string memory transactionId
265+
) public override virtual {
266+
require(msg.sender == tx.origin, "should be a user");
267+
268+
_withdrawStake(msg.sender, target, amount, transactionId);
269+
}
270+
275271
/**
276272
* @dev This is called via oracle to forward an endorse call from a proxy contract. The caller must have the
277273
* PROXY_ENDORSER_ROLE.

contracts/EndorsementInterface.sol

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ interface EndorsementInterface {
2424
string memory transactionId
2525
) external;
2626

27+
/**
28+
* @notice Reduces or removes part of the caller's existing staked endorsement for a target.
29+
* A WithdrawStake event is emitted once the stake is withdrawn.
30+
* @param target the endorsed entity (address is just used as an id here)
31+
* @param amount the stake amount to withdraw
32+
* @param transactionId an id representing the "business transaction" for which the stake withdrawal was made; this is
33+
* _not_ necessarily an Ethereum transaction id.
34+
*/
35+
function withdrawStake(
36+
address target,
37+
uint256 amount,
38+
string memory transactionId
39+
) external;
40+
2741
// Events that might be emitted during the endorsement process.
2842

2943
/** A new staked endorsement was created. */
@@ -34,6 +48,14 @@ interface EndorsementInterface {
3448
string _transactionId
3549
);
3650

51+
/** Existing staked endorsement was reduced or removed. */
52+
event WithdrawStake(
53+
address indexed _from,
54+
address indexed _to,
55+
uint256 _value,
56+
string _transactionId
57+
);
58+
3759
/** A first-level previous endorser was rewarded */
3860
event RewardPreviousEndorserLevel1(address endorser, uint256 reward);
3961

contracts/UTTProxy.sol

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ contract UTTProxy is Initializable, OwnableUpgradeable, ChainlinkClient, Endorse
126126
});
127127
}
128128

129+
function withdrawStake(
130+
address,
131+
uint256,
132+
string memory
133+
) external pure override {
134+
revert("UTTProxy: withdrawStake not supported");
135+
}
136+
129137
function fulfill(
130138
bytes32 _requestId
131139
) external recordChainlinkFulfillment(_requestId) {

0 commit comments

Comments
 (0)