|
1 | 1 | /** |
2 | 2 | * https://contributing.kleros.io/smart-contract-workflow |
3 | 3 | * @authors: [@fnanni-0] |
4 | | - * @reviewers: [@unknownunknown1, @MerlinEgalite, @hbarcelos, @shalzz] |
| 4 | + * @reviewers: [@unknownunknown1*, @MerlinEgalite*, @hbarcelos*, @shalzz*] |
5 | 5 | * @auditors: [] |
6 | 6 | * @bounties: [] |
7 | 7 | * @deployments: [] |
@@ -104,11 +104,31 @@ contract WrappedPinakion is Initializable { |
104 | 104 | * @param _amount The amount of wrapped pinakions to mint. |
105 | 105 | */ |
106 | 106 | function deposit(uint _amount) external { |
107 | | - _mint(_amount); |
| 107 | + _mint(msg.sender, _amount); |
108 | 108 | require(xPinakion.transferFrom(msg.sender, address(this), _amount), "Sender does not have enough approved funds."); |
109 | 109 | } |
110 | 110 |
|
111 | 111 |
|
| 112 | + /** @dev IERC20 Receiver functionality. |
| 113 | + * Converts bridged PNK (xPinakion) into wrapped PNK which can be staked in KlerosLiquid. |
| 114 | + * If the tokenBridge is calling this function, then this contract has already received |
| 115 | + * the xPinakion tokens. |
| 116 | + * @param _token The token address the _amount belongs to. |
| 117 | + * @param _amount The amount of wrapped pinakions to mint. |
| 118 | + * @param _data Calldata containing the address of the recipient. |
| 119 | + * Notice that the address has to be padded to 32 bytes. |
| 120 | + */ |
| 121 | + function onTokenBridged(address _token, uint _amount, bytes _data) external { |
| 122 | + require(msg.sender == address(tokenBridge), "Sender not authorized."); |
| 123 | + require(_token == address(xPinakion), "Token bridged is not xPinakion."); |
| 124 | + |
| 125 | + address recipient; |
| 126 | + assembly { |
| 127 | + recipient := calldataload(0x84) |
| 128 | + } |
| 129 | + _mint(recipient, _amount); |
| 130 | + } |
| 131 | + |
112 | 132 | /** @dev Withdraws bridged pinakions. |
113 | 133 | * @param _amount The amount of bridged pinakions to withdraw. |
114 | 134 | */ |
@@ -223,12 +243,13 @@ contract WrappedPinakion is Initializable { |
223 | 243 | * @dev Internal function that mints an amount of the token and assigns it to |
224 | 244 | * an account. This encapsulates the modification of balances such that the |
225 | 245 | * proper events are emitted. |
| 246 | + * @param _recipient The address which will receive the minted tokens. |
226 | 247 | * @param _amount The amount that will be created. |
227 | 248 | */ |
228 | | - function _mint(uint256 _amount) internal { |
| 249 | + function _mint(address _recipient, uint256 _amount) internal { |
229 | 250 | totalSupply = totalSupply.add(_amount); |
230 | | - balances[msg.sender] = balances[msg.sender].add(_amount); |
231 | | - emit Transfer(address(0x0), msg.sender, _amount); |
| 251 | + balances[_recipient] = balances[_recipient].add(_amount); |
| 252 | + emit Transfer(address(0x0), _recipient, _amount); |
232 | 253 | } |
233 | 254 |
|
234 | 255 | /** @dev Destroys `_amount` tokens from the caller. Cannot burn locked tokens. |
|
0 commit comments