diff --git a/packages/demo/package.json b/packages/demo/package.json
index b6035d6..b037606 100644
--- a/packages/demo/package.json
+++ b/packages/demo/package.json
@@ -1,6 +1,6 @@
{
"name": "safetxdemo",
- "version": "0.1.0",
+ "version": "0.2.0",
"private": true,
"scripts": {
"postinstall": "wagmi generate && .bin/prefix.sh '// @ts-nocheck' 'src/generated/*.ts'",
@@ -15,22 +15,22 @@
"@chakra-ui/react": "^2.8.1",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
- "@privy-io/react-auth": "^1.43.2",
- "@moleculexyz/wagmi-safe-wait-for-tx": "0.2.0",
- "@privy-io/wagmi-connector": "^0.1.4",
- "@wagmi/chains": "^1.8.0",
+ "@moleculexyz/wagmi-safe-wait-for-tx": "1.0.0",
+ "@privy-io/react-auth": "^1.60.4",
+ "@privy-io/wagmi": "^0.2.3",
+ "@tanstack/react-query": "^5.29.2",
"framer-motion": "^10.16.4",
- "next": "13.5.4",
+ "next": "^14.2.0",
"react": "^18",
"react-dom": "^18",
- "viem": "^1.15.4",
- "wagmi": "^1.4.3"
+ "viem": "^2.9.16",
+ "wagmi": "^2.5.19"
},
"devDependencies": {
"@types/node": "^18",
"@types/react": "^18",
"@types/react-dom": "^18",
- "@wagmi/cli": "^1.5.2",
+ "@wagmi/cli": "^2.1.4",
"eslint": "^8",
"eslint-config-next": "13.5.4",
"typescript": "^5.0.4"
diff --git a/packages/demo/src/abis/Storage.json b/packages/demo/src/abis/Storage.json
index e9726f9..1971420 100644
--- a/packages/demo/src/abis/Storage.json
+++ b/packages/demo/src/abis/Storage.json
@@ -25,14 +25,21 @@
"type": "event"
},
{
- "inputs": [
+ "inputs": [],
+ "name": "callMeToFail",
+ "outputs": [
{
- "internalType": "uint256",
- "name": "num",
- "type": "uint256"
+ "internalType": "bool",
+ "name": "",
+ "type": "bool"
}
],
- "name": "store",
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "retrieve",
"outputs": [
{
"internalType": "uint256",
@@ -40,12 +47,18 @@
"type": "uint256"
}
],
- "stateMutability": "nonpayable",
+ "stateMutability": "view",
"type": "function"
},
{
- "inputs": [],
- "name": "retrieve",
+ "inputs": [
+ {
+ "internalType": "uint256",
+ "name": "num",
+ "type": "uint256"
+ }
+ ],
+ "name": "store",
"outputs": [
{
"internalType": "uint256",
@@ -53,7 +66,7 @@
"type": "uint256"
}
],
- "stateMutability": "view",
+ "stateMutability": "nonpayable",
"type": "function"
}
-]
+]
\ No newline at end of file
diff --git a/packages/demo/src/app/layout.tsx b/packages/demo/src/app/layout.tsx
index 11f3416..596bbaf 100644
--- a/packages/demo/src/app/layout.tsx
+++ b/packages/demo/src/app/layout.tsx
@@ -20,12 +20,10 @@ export default function RootLayout({
-
-
+
+
Safetest
-
-
-
+
{children}
diff --git a/packages/demo/src/app/page.tsx b/packages/demo/src/app/page.tsx
index d06329b..fcd6427 100644
--- a/packages/demo/src/app/page.tsx
+++ b/packages/demo/src/app/page.tsx
@@ -2,9 +2,9 @@
import { ActiveAddress } from "@/components/ActiveAddress";
import {
- storageABI,
- useStorageRetrieve,
- useStorageStore,
+ storageAbi,
+ useReadStorageRetrieve,
+ useWriteStorageStore
} from "@/generated/wagmi";
import { safeDecodeLogs } from "@/utils/safeDecodeLogs";
import {
@@ -17,22 +17,19 @@ import {
} from "@chakra-ui/react";
import { useSafeWaitForTransaction } from "@moleculexyz/wagmi-safe-wait-for-tx";
import { useCallback, useEffect, useState } from "react";
-import { useAccount, useNetwork } from "wagmi";
-import { WriteContractResult } from "wagmi/actions";
+import { WriteContractReturnType } from "viem";
+import { useAccount } from "wagmi";
export default function Home() {
- //const { ready, wallet: activeWallet, setActiveWallet } = usePrivyWagmi();
- const { address } = useAccount();
-
- const { chain } = useNetwork();
+ const { address, chainId } = useAccount();
const toast = useToast();
- const [newVal, setNewVal] = useState();
+ const [newVal, setNewVal] = useState(0);
const [curVal, setCurVal] = useState();
- const [tx, setTx] = useState();
+ const [tx, setTx] = useState();
- const { data, error, status } = useStorageRetrieve();
- const { writeAsync } = useStorageStore();
+ const { data, error, status } = useReadStorageRetrieve();
+ const { writeContractAsync } = useWriteStorageStore();
const { data: receipt, isError, isLoading } = useSafeWaitForTransaction(tx);
useEffect(() => {
@@ -44,7 +41,7 @@ export default function Home() {
useEffect(() => {
if (!receipt) return;
- const numberChangedEvent = safeDecodeLogs(receipt, storageABI).find(
+ const numberChangedEvent = safeDecodeLogs(receipt, storageAbi).find(
(e) => e?.eventName == "NumberChanged"
);
if (!numberChangedEvent) {
@@ -62,14 +59,14 @@ export default function Home() {
}, [receipt, toast]);
const onSubmit = useCallback(async () => {
- if (!address || !chain || newVal === undefined) return;
+ if (!address || !chainId || newVal === undefined) return;
setTx(
- await writeAsync({
+ await writeContractAsync({
args: [BigInt(newVal || 0n)],
})
);
- }, [address, chain, newVal, writeAsync]);
+ }, [address, chainId, newVal, writeContractAsync]);
return (
@@ -89,7 +86,7 @@ export default function Home() {
name="newVal"
type="number"
value={newVal}
- onChange={(v) => setNewVal(v.target.valueAsNumber)}
+ onChange={(v: any) => { v.preventDefault(); setNewVal(v.target.valueAsNumber) }}
/>