-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
payment added but awaiting clearance on fow after payment
- Loading branch information
Showing
8 changed files
with
202 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.22; | ||
pragma solidity ^0.8.9; | ||
|
||
import "./MultiSigWallet.sol"; | ||
import './MultiSigWallet.sol'; | ||
|
||
/// @title A Multisig wallet | ||
/// @author DecenterAI | ||
/// @notice Serves as deposit contract | ||
|
||
contract Payment { | ||
MultiSigWallet public wallet; | ||
mapping(address => uint) public depositRecord; | ||
|
||
event Deposit(address indexed payer, uint _amount, bool status); | ||
event Erase(address indexed user); | ||
|
||
/** | ||
*@notice Deposits eth into the treasury | ||
*@param _amount The amount of eth deposited | ||
*/ | ||
function deposit(uint _amount) external payable { | ||
require(msg.value == _amount, "Invalid deposit amount"); | ||
//deposit to treasury | ||
(bool success, ) = address(wallet).call{value: msg.value}(""); | ||
//record deposit | ||
depositRecord[msg.sender] = msg.value; | ||
|
||
emit Deposit(msg.sender, _amount, success); | ||
} | ||
|
||
/** | ||
*@notice Removes deposit record for a user | ||
*@param _user Address of the depositor | ||
*/ | ||
function zeroDepositRecord(address _user) external { | ||
//remove record | ||
depositRecord[_user] = 0; | ||
emit Erase(_user); | ||
} | ||
MultiSigWallet public account; | ||
mapping(address => uint) public depositRecord; | ||
|
||
event Deposit(address indexed payer, uint _amount, bool status); | ||
event Erase(address indexed user); | ||
|
||
/** | ||
*@notice Deposits eth into the treasury | ||
*@param _amount The amount of eth deposited | ||
*/ | ||
function deposit(uint _amount, MultiSigWallet _wallet) external payable { | ||
require(msg.value == _amount, 'Invalid deposit amount'); | ||
//deposit to treasury | ||
(bool success, ) = address(_wallet).call{ value: msg.value }(''); | ||
//record deposit | ||
depositRecord[msg.sender] = msg.value; | ||
|
||
emit Deposit(msg.sender, _amount, success); | ||
} | ||
|
||
/** | ||
*@notice Removes deposit record for a user | ||
*@param _user Address of the depositor | ||
*/ | ||
function zeroDepositRecord(address _user) external { | ||
//remove record | ||
depositRecord[_user] = 0; | ||
emit Erase(_user); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
[ | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": true, | ||
"internalType": "address", | ||
"name": "payer", | ||
"type": "address" | ||
}, | ||
{ | ||
"indexed": false, | ||
"internalType": "uint256", | ||
"name": "_amount", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"indexed": false, | ||
"internalType": "bool", | ||
"name": "status", | ||
"type": "bool" | ||
} | ||
], | ||
"name": "Deposit", | ||
"type": "event" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": true, | ||
"internalType": "address", | ||
"name": "user", | ||
"type": "address" | ||
} | ||
], | ||
"name": "Erase", | ||
"type": "event" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "account", | ||
"outputs": [ | ||
{ | ||
"internalType": "contract MultiSigWallet", | ||
"name": "", | ||
"type": "address" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "uint256", | ||
"name": "_amount", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"internalType": "contract MultiSigWallet", | ||
"name": "_wallet", | ||
"type": "address" | ||
} | ||
], | ||
"name": "deposit", | ||
"outputs": [], | ||
"stateMutability": "payable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "", | ||
"type": "address" | ||
} | ||
], | ||
"name": "depositRecord", | ||
"outputs": [ | ||
{ | ||
"internalType": "uint256", | ||
"name": "", | ||
"type": "uint256" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "_user", | ||
"type": "address" | ||
} | ||
], | ||
"name": "zeroDepositRecord", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ethers } from 'ethers' | ||
import PaymentAbi from '@abi/Payment.json' | ||
import { ethersProvider, ethersSigner } from '@/lib/particle' | ||
const PaymentAddr = process.env.NEXT_PUBLIC_PAYMENT_CONTRACT_ADDRESS | ||
const WalletAddress = process.env.NEXT_PUBLIC_WALLET_CONTRACT_ADDRESS | ||
export const makePayment = async () => { | ||
//@ts-ignore | ||
// const provider = new ethers.providers.Web3Provider(window.ethereum) | ||
// const signer = provider.getSigner() | ||
const PaymentContract = new ethers.Contract(PaymentAddr, PaymentAbi, ethersSigner) | ||
const amountInWei = ethers.utils.parseEther('0.000000000000001') | ||
const options = { value: amountInWei } | ||
// const reciept = await contract.buyPunk(1001, options) | ||
try { | ||
const reciept = await PaymentContract.functions.deposit( | ||
amountInWei, | ||
WalletAddress, | ||
options, | ||
) | ||
console.log(reciept) | ||
return true | ||
} catch (error) { | ||
console.log(error) | ||
return false | ||
} | ||
} |