latticexyz / mud

MUD is a framework for building autonomous worlds
https://mud.dev
MIT License
736 stars 185 forks source link

make batchCall easier to work with in the client #1728

Open holic opened 1 year ago

holic commented 1 year ago

there's several places in #1611 that I avoided wiring up batchCall because it was trickier to use

it would be nice if we had a typed helper for batchCall that would take in a list of abi-typed calls (like writeContract) and execute them through batchCall

yonadaaa commented 1 year ago

For me the ideal API is:

batchCall([
  {
    resource: { type: "system", namespace: "", name: "RegisterSystem" },
    functionName: "register",
    args: [match]
  },
  {
    resource: { type: "system", namespace: "", name: "NameSystem" },
    functionName: "setName",
    args: [name]
  },
]);
holic commented 9 months ago

done here: https://github.com/latticexyz/mud/pull/1745

edit: nevermind, these helpers are just for single system calls, not batch calls

yonadaaa commented 9 months ago

@holic They are for batch calls! https://github.com/latticexyz/skystrife-public/blob/main/packages/client/src/app/amalgema-ui/SummonIsland/Footer.tsx#L79-L97

The encodeSystemCalls name is somewhat misleading, should maybe be encodeBatchCall