Skip to content

Commit

Permalink
Merge pull request #15 from zenbitETH/feat/input-decimal
Browse files Browse the repository at this point in the history
feat: decimals in the input
  • Loading branch information
HabacucMX authored Aug 11, 2024
2 parents 202b75f + 5104aa8 commit 6153781
Show file tree
Hide file tree
Showing 9 changed files with 258 additions and 18 deletions.
1 change: 1 addition & 0 deletions packages/hardhat/deployments/base/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8453
82 changes: 82 additions & 0 deletions packages/hardhat/deployments/base/Disperse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"address": "0xA7210b419372222429f2A692B253BAeb50AEa12a",
"abi": [
{
"inputs": [
{
"internalType": "address[]",
"name": "recipients",
"type": "address[]"
},
{
"internalType": "uint256[]",
"name": "values",
"type": "uint256[]"
}
],
"name": "disperseEther",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract IERC20",
"name": "tokenAddress",
"type": "address"
},
{
"internalType": "address payable[]",
"name": "recipients",
"type": "address[]"
},
{
"internalType": "uint256[]",
"name": "values",
"type": "uint256[]"
}
],
"name": "disperseToken",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"transactionHash": "0x81149d3320124de3c4dbe70921392ec4d5c89d2ebcb349722502d9601ac745c9",
"receipt": {
"to": null,
"from": "0xeCB4C1245665e8A1F43826355aaB0Dd6bF336e05",
"contractAddress": "0xA7210b419372222429f2A692B253BAeb50AEa12a",
"transactionIndex": 58,
"gasUsed": "395201",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"blockHash": "0x6bb30588be6145372124f36501833deac4d6b749fe2c494b03ef0ca233e2cf24",
"transactionHash": "0x81149d3320124de3c4dbe70921392ec4d5c89d2ebcb349722502d9601ac745c9",
"logs": [],
"blockNumber": 18294923,
"cumulativeGasUsed": "18425310",
"status": 1,
"byzantium": true
},
"args": [],
"numDeployments": 1,
"solcInputHash": "533c6a1944291223de810cb4d69d3814",
"metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"recipients\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"}],\"name\":\"disperseEther\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"tokenAddress\",\"type\":\"address\"},{\"internalType\":\"address payable[]\",\"name\":\"recipients\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"}],\"name\":\"disperseToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/Disperse.sol\":\"Disperse\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\\n}\\n\",\"keccak256\":\"0x287b55befed2961a7eabd7d7b1b2839cbca8a5b80ef8dcbb25ed3d4c2002c305\",\"license\":\"MIT\"},\"contracts/Disperse.sol\":{\"content\":\"//SPDX-License-Identifier: Unlicense\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ncontract Disperse {\\n function disperseToken(\\n IERC20 tokenAddress,\\n address payable[] calldata recipients,\\n uint256[] calldata values\\n ) external {\\n IERC20 token = IERC20(tokenAddress);\\n uint256 total = 0;\\n for (uint256 i = 0; i < recipients.length; i++) total += values[i];\\n\\n require(token.transferFrom(msg.sender, address(this), total));\\n\\n for (uint256 i = 0; i < recipients.length; i++) {\\n token.transfer(recipients[i], values[i]);\\n }\\n }\\n\\n function disperseEther(address[] memory recipients, uint256[] memory values)\\n external\\n payable\\n {\\n for (uint256 i = 0; i < recipients.length; i++)\\n payable(recipients[i]).transfer(values[i]);\\n uint256 balance = address(this).balance;\\n // Refund remaining amount to msg.sender\\n if (balance > 0) payable(msg.sender).transfer(balance);\\n }\\n}\\n\",\"keccak256\":\"0xe7a44b26df32fdcf1b29c1320603ebd31aacf797c860a0ad1681a3f047e0dc09\",\"license\":\"Unlicense\"}},\"version\":1}",
"bytecode": "0x608060405234801561001057600080fd5b50610630806100206000396000f3fe6080604052600436106100295760003560e01c8063c73a2d601461002e578063e63d38ed14610050575b600080fd5b34801561003a57600080fd5b5061004e61004936600461033b565b610063565b005b61004e61005e366004610494565b610211565b846000805b858110156100a85784848281811061008257610082610556565b90506020020135826100949190610582565b9150806100a08161059b565b915050610068565b506040516323b872dd60e01b8152336004820152306024820152604481018290526001600160a01b038316906323b872dd906064016020604051808303816000875af11580156100fc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061012091906105b4565b61012957600080fd5b60005b8581101561020757826001600160a01b031663a9059cbb88888481811061015557610155610556565b905060200201602081019061016a91906105dd565b87878581811061017c5761017c610556565b6040516001600160e01b031960e087901b1681526001600160a01b03909416600485015260200291909101356024830152506044016020604051808303816000875af11580156101d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101f491906105b4565b50806101ff8161059b565b91505061012c565b5050505050505050565b60005b825181101561029b5782818151811061022f5761022f610556565b60200260200101516001600160a01b03166108fc83838151811061025557610255610556565b60200260200101519081150290604051600060405180830381858888f19350505050158015610288573d6000803e3d6000fd5b50806102938161059b565b915050610214565b504780156102d257604051339082156108fc029083906000818181858888f193505050501580156102d0573d6000803e3d6000fd5b505b505050565b6001600160a01b03811681146102ec57600080fd5b50565b60008083601f84011261030157600080fd5b50813567ffffffffffffffff81111561031957600080fd5b6020830191508360208260051b850101111561033457600080fd5b9250929050565b60008060008060006060868803121561035357600080fd5b853561035e816102d7565b9450602086013567ffffffffffffffff8082111561037b57600080fd5b61038789838a016102ef565b909650945060408801359150808211156103a057600080fd5b506103ad888289016102ef565b969995985093965092949392505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156103fd576103fd6103be565b604052919050565b600067ffffffffffffffff82111561041f5761041f6103be565b5060051b60200190565b600082601f83011261043a57600080fd5b8135602061044f61044a83610405565b6103d4565b82815260059290921b8401810191818101908684111561046e57600080fd5b8286015b848110156104895780358352918301918301610472565b509695505050505050565b600080604083850312156104a757600080fd5b823567ffffffffffffffff808211156104bf57600080fd5b818501915085601f8301126104d357600080fd5b813560206104e361044a83610405565b82815260059290921b8401810191818101908984111561050257600080fd5b948201945b8386101561052957853561051a816102d7565b82529482019490820190610507565b9650508601359250508082111561053f57600080fd5b5061054c85828601610429565b9150509250929050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b808201808211156105955761059561056c565b92915050565b6000600182016105ad576105ad61056c565b5060010190565b6000602082840312156105c657600080fd5b815180151581146105d657600080fd5b9392505050565b6000602082840312156105ef57600080fd5b81356105d6816102d756fea2646970667358221220bf6622f86e77c5f909ab388acfe994756b85666127ac64d63590250913e4e51464736f6c63430008110033",
"deployedBytecode": "0x6080604052600436106100295760003560e01c8063c73a2d601461002e578063e63d38ed14610050575b600080fd5b34801561003a57600080fd5b5061004e61004936600461033b565b610063565b005b61004e61005e366004610494565b610211565b846000805b858110156100a85784848281811061008257610082610556565b90506020020135826100949190610582565b9150806100a08161059b565b915050610068565b506040516323b872dd60e01b8152336004820152306024820152604481018290526001600160a01b038316906323b872dd906064016020604051808303816000875af11580156100fc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061012091906105b4565b61012957600080fd5b60005b8581101561020757826001600160a01b031663a9059cbb88888481811061015557610155610556565b905060200201602081019061016a91906105dd565b87878581811061017c5761017c610556565b6040516001600160e01b031960e087901b1681526001600160a01b03909416600485015260200291909101356024830152506044016020604051808303816000875af11580156101d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101f491906105b4565b50806101ff8161059b565b91505061012c565b5050505050505050565b60005b825181101561029b5782818151811061022f5761022f610556565b60200260200101516001600160a01b03166108fc83838151811061025557610255610556565b60200260200101519081150290604051600060405180830381858888f19350505050158015610288573d6000803e3d6000fd5b50806102938161059b565b915050610214565b504780156102d257604051339082156108fc029083906000818181858888f193505050501580156102d0573d6000803e3d6000fd5b505b505050565b6001600160a01b03811681146102ec57600080fd5b50565b60008083601f84011261030157600080fd5b50813567ffffffffffffffff81111561031957600080fd5b6020830191508360208260051b850101111561033457600080fd5b9250929050565b60008060008060006060868803121561035357600080fd5b853561035e816102d7565b9450602086013567ffffffffffffffff8082111561037b57600080fd5b61038789838a016102ef565b909650945060408801359150808211156103a057600080fd5b506103ad888289016102ef565b969995985093965092949392505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156103fd576103fd6103be565b604052919050565b600067ffffffffffffffff82111561041f5761041f6103be565b5060051b60200190565b600082601f83011261043a57600080fd5b8135602061044f61044a83610405565b6103d4565b82815260059290921b8401810191818101908684111561046e57600080fd5b8286015b848110156104895780358352918301918301610472565b509695505050505050565b600080604083850312156104a757600080fd5b823567ffffffffffffffff808211156104bf57600080fd5b818501915085601f8301126104d357600080fd5b813560206104e361044a83610405565b82815260059290921b8401810191818101908984111561050257600080fd5b948201945b8386101561052957853561051a816102d7565b82529482019490820190610507565b9650508601359250508082111561053f57600080fd5b5061054c85828601610429565b9150509250929050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b808201808211156105955761059561056c565b92915050565b6000600182016105ad576105ad61056c565b5060010190565b6000602082840312156105c657600080fd5b815180151581146105d657600080fd5b9392505050565b6000602082840312156105ef57600080fd5b81356105d6816102d756fea2646970667358221220bf6622f86e77c5f909ab388acfe994756b85666127ac64d63590250913e4e51464736f6c63430008110033",
"devdoc": {
"kind": "dev",
"methods": {},
"version": 1
},
"userdoc": {
"kind": "user",
"methods": {},
"version": 1
},
"storageLayout": {
"storage": [],
"types": null
}
}
Loading

0 comments on commit 6153781

Please sign in to comment.