Skip to content

Commit

Permalink
add bounty transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
lorbke committed Nov 16, 2024
1 parent 7d57a6b commit 60cdb49
Show file tree
Hide file tree
Showing 9 changed files with 680 additions and 409 deletions.
2 changes: 2 additions & 0 deletions packages/foundry/contracts/HumanOracleWithVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ contract HumanOracleWithVault is Permit2Vault {

createNewStake(voteId, bounty);

this.depositERC20Regular(worldToken, bounty);

emit VoteCreated(voteId, getVoteQuestion(voteId), getVoteStartBlock(voteId), getVoteDurationInBlocks(voteId));
}

Expand Down
12 changes: 12 additions & 0 deletions packages/foundry/contracts/Permit2Vault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ contract Permit2Vault is Ownable {
_reentrancyGuard = false;
}

event Deposited(address from, uint256 amount);
event Withdrawn(address to, uint256 amount);

// Deposit some amount of an ERC20 token from the caller
// into this contract using Permit2.
function depositERC20(
Expand Down Expand Up @@ -62,6 +65,14 @@ contract Permit2Vault is Ownable {
// the EIP712 hash of `permit`.
signature
);
emit Deposited(address(msg.sender), amount);
}

function depositERC20Regular(IERC20 token, uint256 amount) external {
tokenBalancesByUser[msg.sender][token] += amount;
totalBalance += amount;
token.transfer(address(this), amount);
emit Deposited(address(msg.sender), amount);
}

// Return ERC20 tokens deposited by the caller.
Expand All @@ -71,6 +82,7 @@ contract Permit2Vault is Ownable {
// TODO: In production, use an ERC20 compatibility library to
// execute thie transfer to support non-compliant tokens.
token.transfer(msg.sender, amount);
emit Withdrawn(msg.sender, amount);
}

function _toTokenPermissionsArray(IERC20[] calldata tokens, uint256[] calldata amounts)
Expand Down
28 changes: 28 additions & 0 deletions packages/foundry/contractsToVerify/Context.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}

function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}

function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
Loading

0 comments on commit 60cdb49

Please sign in to comment.