Skip to content

Commit

Permalink
few fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Jun 1, 2024
1 parent 595f432 commit 5eff5e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
1 change: 1 addition & 0 deletions packages/account-kit/src/exports/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export { AccountButton } from "../AccountButton";
export { useAccountModal } from "../useAccountModal";
export { AccountKitProvider } from "../AccountKitProvider";
export { usePreparedAppAccountClient as useAppAccountClient } from "../usePreparedAppAccountClient";
export type { AppAccountClient } from "../common";
15 changes: 5 additions & 10 deletions templates/react/packages/client/src/mud/createSystemCalls.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Account, Chain, Client, Hex, Transport } from "viem";
import { Hex } from "viem";
import { writeContract } from "viem/actions";
import { SetupNetworkResult } from "./setupNetwork";
import IWorldAbi from "contracts/out/IWorld.sol/IWorld.abi.json";
import { AppAccountClient } from "@latticexyz/account-kit";

export type SystemCalls = ReturnType<typeof createSystemCalls>;

export function createSystemCalls({ tables, useStore, waitForTransaction, worldAddress }: SetupNetworkResult) {
const addTask = async (client: Client<Transport, Chain, Account> | undefined, label: string) => {
if (!client) throw new Error("Not connected");

const addTask = async (client: AppAccountClient, label: string) => {
const tx = await writeContract(client, {
address: worldAddress,
abi: IWorldAbi,
Expand All @@ -18,9 +17,7 @@ export function createSystemCalls({ tables, useStore, waitForTransaction, worldA
await waitForTransaction(tx);
};

const toggleTask = async (client: Client<Transport, Chain, Account> | undefined, id: Hex) => {
if (!client) throw new Error("Not connected");

const toggleTask = async (client: AppAccountClient, id: Hex) => {
const isComplete = (useStore.getState().getValue(tables.Tasks, { id })?.completedAt ?? 0n) > 0n;
const tx = isComplete
? await writeContract(client, {
Expand All @@ -38,9 +35,7 @@ export function createSystemCalls({ tables, useStore, waitForTransaction, worldA
await waitForTransaction(tx);
};

const deleteTask = async (client: Client<Transport, Chain, Account> | undefined, id: Hex) => {
if (!client) throw new Error("Not connected");

const deleteTask = async (client: AppAccountClient, id: Hex) => {
const tx = await writeContract(client, {
address: worldAddress,
abi: IWorldAbi,
Expand Down

0 comments on commit 5eff5e3

Please sign in to comment.