Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update donut contract #2080

Merged
merged 3 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function EthersWriteContractTest() {
const signer = new JsonRpcSigner(provider, address)
const contract = new ethers.Contract(donutAddress, abi, signer)
// @ts-expect-error ethers types are correct
const tx = await contract.purchase(1, { value: ethers.parseEther('0.0003') })
const tx = await contract.purchase(1, { value: ethers.parseEther('0.0001') })
toast({ title: 'Succcess', description: tx.hash, status: 'success', isClosable: true })
} catch {
toast({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { abi, address } from '../../utils/DonutContract'

export function WagmiWriteContractTest() {
const toast = useToast()
const { status, chain } = useAccount()
const { status, chain, address: accountAddress } = useAccount()
const {
data: donutsOwned,
refetch: fetchDonutsOwned,
Expand All @@ -16,13 +16,14 @@ export function WagmiWriteContractTest() {
} = useReadContract({
abi,
address,
functionName: 'getBalance'
functionName: 'getBalance',
args: [accountAddress]
})
const { data: simulateData, error: simulateError } = useSimulateContract({
abi,
address,
functionName: 'purchase',
value: parseEther('0.0003'),
value: parseEther('0.0001'),
args: [1]
})
const { writeContract, reset, data, error, isPending } = useWriteContract()
Expand Down
75 changes: 54 additions & 21 deletions apps/laboratory/src/utils/DonutContract.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,73 @@
export const abi = [
{ inputs: [], stateMutability: 'nonpayable', type: 'constructor' },
{
inputs: [{ internalType: 'address', name: '', type: 'address' }],
name: 'donutBalances',
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
stateMutability: 'view',
inputs: [
{
internalType: 'uint256',
name: 'amount',
type: 'uint256'
}
],
name: 'purchase',
outputs: [],
stateMutability: 'payable',
type: 'function'
},
{
inputs: [],
name: 'getBalance',
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
stateMutability: 'view',
type: 'function'
stateMutability: 'nonpayable',
type: 'constructor'
},
{
inputs: [],
name: 'owner',
outputs: [{ internalType: 'address', name: '', type: 'address' }],
inputs: [
{
internalType: 'address',
name: '',
type: 'address'
}
],
name: 'donutBalances',
outputs: [
{
internalType: 'uint256',
name: '',
type: 'uint256'
}
],
stateMutability: 'view',
type: 'function'
},
{
inputs: [{ internalType: 'uint256', name: 'amount', type: 'uint256' }],
name: 'purchase',
outputs: [],
stateMutability: 'payable',
inputs: [
{
internalType: 'address',
name: 'check',
type: 'address'
}
],
name: 'getBalance',
outputs: [
{
internalType: 'uint256',
name: '',
type: 'uint256'
}
],
stateMutability: 'view',
type: 'function'
},
{
inputs: [{ internalType: 'uint256', name: 'amount', type: 'uint256' }],
name: 'restock',
outputs: [],
stateMutability: 'nonpayable',
inputs: [],
name: 'owner',
outputs: [
{
internalType: 'address',
name: '',
type: 'address'
}
],
stateMutability: 'view',
type: 'function'
}
]

export const address = '0xed2671343dad40fe7fea57d8b0de1369f9dba956'
export const address = '0xfcfCFD8D9f4A23D8DD11b03b212B69262A3ba1b8'
Loading