From 7fa2ca1831234b54a55c20632d29877e5e711eb7 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Thu, 12 Oct 2023 12:42:42 +0100 Subject: [PATCH] docs(world): add changeset for system call helpers (#1747) Co-authored-by: alvarius --- .changeset/chatty-planets-heal.md | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .changeset/chatty-planets-heal.md diff --git a/.changeset/chatty-planets-heal.md b/.changeset/chatty-planets-heal.md new file mode 100644 index 0000000000..c1270e5d4b --- /dev/null +++ b/.changeset/chatty-planets-heal.md @@ -0,0 +1,47 @@ +--- +"@latticexyz/world": minor +--- + +Added TS helpers for calling systems dynamically via the World. + +- `encodeSystemCall` for `world.call` + + ```ts + worldContract.write.call(encodeSystemCall({ + abi: worldContract.abi, + systemId: resourceToHex({ ... }), + functionName: "registerDelegation", + args: [ ... ], + })); + ``` + +- `encodeSystemCallFrom` for `world.callFrom` + + ```ts + worldContract.write.callFrom(encodeSystemCallFrom({ + abi: worldContract.abi, + from: "0x...", + systemId: resourceToHex({ ... }), + functionName: "registerDelegation", + args: [ ... ], + })); + ``` + +- `encodeSystemCalls` for `world.batchCall` + + ```ts + worldContract.write.batchCall(encodeSystemCalls(abi, [{ + systemId: resourceToHex({ ... }), + functionName: "registerDelegation", + args: [ ... ], + }])); + ``` + +- `encodeSystemCallsFrom` for `world.batchCallFrom` + ```ts + worldContract.write.batchCallFrom(encodeSystemCallsFrom(abi, "0x...", [{ + systemId: resourceToHex({ ... }), + functionName: "registerDelegation", + args: [ ... ], + }])); + ```