From 2eef9eeb81a08d1efd4bb3dff5d7bb16ed90f46f Mon Sep 17 00:00:00 2001 From: Luka Isailovic Date: Wed, 27 Mar 2024 13:52:28 +0100 Subject: [PATCH] chore: update donut contract --- .../Ethers/EthersWriteContractTest.tsx | 2 +- .../Wagmi/WagmiWriteContractTest.tsx | 7 +- apps/laboratory/src/utils/DonutContract.ts | 75 +++++++++++++------ 3 files changed, 59 insertions(+), 25 deletions(-) diff --git a/apps/laboratory/src/components/Ethers/EthersWriteContractTest.tsx b/apps/laboratory/src/components/Ethers/EthersWriteContractTest.tsx index 6036691f87..4498ab5b74 100644 --- a/apps/laboratory/src/components/Ethers/EthersWriteContractTest.tsx +++ b/apps/laboratory/src/components/Ethers/EthersWriteContractTest.tsx @@ -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({ diff --git a/apps/laboratory/src/components/Wagmi/WagmiWriteContractTest.tsx b/apps/laboratory/src/components/Wagmi/WagmiWriteContractTest.tsx index b2013129c8..dc0b06aae6 100644 --- a/apps/laboratory/src/components/Wagmi/WagmiWriteContractTest.tsx +++ b/apps/laboratory/src/components/Wagmi/WagmiWriteContractTest.tsx @@ -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, @@ -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() diff --git a/apps/laboratory/src/utils/DonutContract.ts b/apps/laboratory/src/utils/DonutContract.ts index adca004477..50639294cc 100644 --- a/apps/laboratory/src/utils/DonutContract.ts +++ b/apps/laboratory/src/utils/DonutContract.ts @@ -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'