@latticexyz/world 2.2.22-60085734145ea8db0b43084034bec9f8ea474dc4 → 2.2.22-7902888215e548882b314342e21caed5088b869c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/internal.d.ts +2 -16
- package/dist/internal.js +45 -113
- package/dist/internal.js.map +1 -1
- package/package.json +9 -9
package/dist/internal.d.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import { Abi, ContractFunctionName, Hex, EncodeFunctionDataParameters, Address, Chain, Account, Client, Transport, WalletActions } from 'viem';
|
2
2
|
import { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from 'abitype';
|
3
|
-
import { SmartAccount, BundlerActions } from 'viem/account-abstraction';
|
4
3
|
export { C as CODEGEN_DEFAULTS, b as CONFIG_DEFAULTS, k as CodegenInput, D as DEPLOY_DEFAULTS, j as DeployInput, M as MODULE_DEFAULTS, i as ModuleInput, N as NamespaceInput, h as NamespacesInput, a as SYSTEM_DEFAULTS, S as SYSTEM_DEPLOY_DEFAULTS, e as SystemDeployInput, f as SystemInput, g as SystemsInput, V as ValidateSystemOptions, W as WorldInput, o as defineNamespaces, t as defineSystem, d as defineWorld, p as requiredSystemKey, r as resolveCodegen, c as resolveDeploy, l as resolveNamespace, y as resolveNamespaceMode, n as resolveNamespaces, s as resolveSystem, w as resolveSystems, z as resolveWorld, v as validateNamespace, m as validateNamespaces, q as validateSystem, u as validateSystems, x as validateWorld } from './world-NqdA4pfW.js';
|
5
4
|
export { C as Codegen, f as Deploy, D as DynamicResolution, M as Module, N as Namespace, e as Namespaces, c as System, S as SystemDeploy, d as Systems, V as ValueWithType, W as World, i as isDynamicResolution, a as isValueWithType, r as resolveTableId, b as resolveWithContext } from './dynamicResolution-Bul4y_B0.js';
|
6
5
|
import '@ark/util';
|
@@ -160,19 +159,6 @@ declare function encodeSystemCalls<abis extends readonly Abi[]>(systemCalls: Sys
|
|
160
159
|
/** Encode system calls to be passed as arguments into `World.batchCallFrom` */
|
161
160
|
declare function encodeSystemCallsFrom<abis extends readonly Abi[]>(from: Address, systemCalls: SystemCalls<abis>): AbiParametersToPrimitiveTypes<ExtractAbiFunction<worldCallAbi, "batchCallFrom">["inputs"]>;
|
162
161
|
|
163
|
-
type SystemFunction$1 = {
|
164
|
-
systemId: Hex;
|
165
|
-
systemFunctionSelector: Hex;
|
166
|
-
};
|
167
|
-
|
168
|
-
type CallFromParameters$1 = {
|
169
|
-
worldAddress: Hex;
|
170
|
-
delegatorAddress: Hex;
|
171
|
-
worldFunctionToSystemFunction?: (worldFunctionSelector: Hex) => Promise<SystemFunction$1>;
|
172
|
-
publicClient?: Client;
|
173
|
-
};
|
174
|
-
declare function callFrom(params: CallFromParameters$1): <chain extends Chain, account extends Account | undefined>(client: Client<Transport, chain, account>) => Pick<WalletActions<chain, account>, "writeContract">;
|
175
|
-
|
176
162
|
type CallFromParameters = {
|
177
163
|
worldAddress: Hex;
|
178
164
|
delegatorAddress: Hex;
|
@@ -183,6 +169,6 @@ type SystemFunction = {
|
|
183
169
|
systemId: Hex;
|
184
170
|
systemFunctionSelector: Hex;
|
185
171
|
};
|
186
|
-
declare function
|
172
|
+
declare function callFrom(params: CallFromParameters): <chain extends Chain, account extends Account | undefined>(client: Client<Transport, chain, account>) => Pick<WalletActions<chain, account>, "writeContract">;
|
187
173
|
|
188
|
-
export { type SystemCall, type SystemCallFrom, type SystemCalls, callFrom, encodeSystemCall, encodeSystemCallFrom, encodeSystemCalls, encodeSystemCallsFrom
|
174
|
+
export { type SystemCall, type SystemCallFrom, type SystemCalls, callFrom, encodeSystemCall, encodeSystemCallFrom, encodeSystemCalls, encodeSystemCallsFrom };
|
package/dist/internal.js
CHANGED
@@ -119,23 +119,57 @@ function encodeSystemCallsFrom(from, systemCalls) {
|
|
119
119
|
// ts/actions/callFrom.ts
|
120
120
|
import {
|
121
121
|
slice,
|
122
|
-
concat
|
122
|
+
concat
|
123
123
|
} from "viem";
|
124
|
-
import { getAction
|
125
|
-
import { writeContract as viem_writeContract } from "viem/actions";
|
124
|
+
import { getAction, encodeFunctionData as encodeFunctionData5 } from "viem/utils";
|
125
|
+
import { readContract, writeContract as viem_writeContract } from "viem/actions";
|
126
126
|
import { readHex } from "@latticexyz/common";
|
127
|
-
|
128
|
-
// ts/worldFunctionToSystemFunction.ts
|
129
127
|
import {
|
130
|
-
getSchemaTypes,
|
131
128
|
getKeySchema,
|
132
129
|
getValueSchema,
|
133
|
-
|
134
|
-
decodeValueArgs
|
130
|
+
getSchemaTypes,
|
131
|
+
decodeValueArgs,
|
132
|
+
encodeKey
|
135
133
|
} from "@latticexyz/protocol-parser/internal";
|
136
|
-
|
137
|
-
|
138
|
-
|
134
|
+
function callFrom(params) {
|
135
|
+
return (client) => ({
|
136
|
+
async writeContract(writeArgs) {
|
137
|
+
const _writeContract = getAction(client, viem_writeContract, "writeContract");
|
138
|
+
if (writeArgs.address !== params.worldAddress || writeArgs.functionName === "call" || writeArgs.functionName === "callFrom" || writeArgs.functionName === "batchCallFrom" || writeArgs.functionName === "callWithSignature") {
|
139
|
+
return _writeContract(writeArgs);
|
140
|
+
}
|
141
|
+
if (writeArgs.functionName === "batchCall") {
|
142
|
+
const batchCallArgs = writeArgs;
|
143
|
+
const [systemCalls] = batchCallArgs.args;
|
144
|
+
if (!systemCalls.length) {
|
145
|
+
throw new Error("`batchCall` should have at least one system call.");
|
146
|
+
}
|
147
|
+
return _writeContract({
|
148
|
+
...batchCallArgs,
|
149
|
+
functionName: "batchCallFrom",
|
150
|
+
args: [systemCalls.map((systemCall) => ({ from: params.delegatorAddress, ...systemCall }))]
|
151
|
+
});
|
152
|
+
}
|
153
|
+
const worldCalldata = encodeFunctionData5({
|
154
|
+
abi: writeArgs.abi,
|
155
|
+
functionName: writeArgs.functionName,
|
156
|
+
args: writeArgs.args
|
157
|
+
});
|
158
|
+
const worldFunctionSelector = slice(worldCalldata, 0, 4);
|
159
|
+
const { systemId, systemFunctionSelector } = await worldFunctionToSystemFunction({
|
160
|
+
...params,
|
161
|
+
publicClient: params.publicClient ?? client,
|
162
|
+
worldFunctionSelector
|
163
|
+
});
|
164
|
+
const systemCalldata = concat([systemFunctionSelector, readHex(worldCalldata, 4)]);
|
165
|
+
return _writeContract({
|
166
|
+
...writeArgs,
|
167
|
+
functionName: "callFrom",
|
168
|
+
args: [params.delegatorAddress, systemId, systemCalldata]
|
169
|
+
});
|
170
|
+
}
|
171
|
+
});
|
172
|
+
}
|
139
173
|
var systemFunctionCache = /* @__PURE__ */ new Map();
|
140
174
|
async function worldFunctionToSystemFunction(params) {
|
141
175
|
const cacheKey = concat([params.worldAddress, params.worldFunctionSelector]);
|
@@ -199,107 +233,6 @@ async function retrieveSystemFunctionFromContract(publicClient, worldAddress, wo
|
|
199
233
|
return systemFunction;
|
200
234
|
}
|
201
235
|
|
202
|
-
// ts/actions/callFrom.ts
|
203
|
-
function callFrom(params) {
|
204
|
-
return (client) => ({
|
205
|
-
async writeContract(writeArgs) {
|
206
|
-
const _writeContract = getAction2(client, viem_writeContract, "writeContract");
|
207
|
-
if (writeArgs.address !== params.worldAddress || writeArgs.functionName === "call" || writeArgs.functionName === "callFrom" || writeArgs.functionName === "batchCallFrom" || writeArgs.functionName === "callWithSignature") {
|
208
|
-
return _writeContract(writeArgs);
|
209
|
-
}
|
210
|
-
if (writeArgs.functionName === "batchCall") {
|
211
|
-
const batchCallArgs = writeArgs;
|
212
|
-
const [systemCalls] = batchCallArgs.args;
|
213
|
-
if (!systemCalls.length) {
|
214
|
-
throw new Error("`batchCall` should have at least one system call.");
|
215
|
-
}
|
216
|
-
return _writeContract({
|
217
|
-
...batchCallArgs,
|
218
|
-
functionName: "batchCallFrom",
|
219
|
-
args: [systemCalls.map((systemCall) => ({ from: params.delegatorAddress, ...systemCall }))]
|
220
|
-
});
|
221
|
-
}
|
222
|
-
const worldCalldata = encodeFunctionData5({
|
223
|
-
abi: writeArgs.abi,
|
224
|
-
functionName: writeArgs.functionName,
|
225
|
-
args: writeArgs.args
|
226
|
-
});
|
227
|
-
const worldFunctionSelector = slice(worldCalldata, 0, 4);
|
228
|
-
const { systemId, systemFunctionSelector } = await worldFunctionToSystemFunction({
|
229
|
-
...params,
|
230
|
-
publicClient: params.publicClient ?? client,
|
231
|
-
worldFunctionSelector
|
232
|
-
});
|
233
|
-
const systemCalldata = concat2([systemFunctionSelector, readHex(worldCalldata, 4)]);
|
234
|
-
return _writeContract({
|
235
|
-
...writeArgs,
|
236
|
-
functionName: "callFrom",
|
237
|
-
args: [params.delegatorAddress, systemId, systemCalldata]
|
238
|
-
});
|
239
|
-
}
|
240
|
-
});
|
241
|
-
}
|
242
|
-
|
243
|
-
// ts/actions/sendUserOperationFrom.ts
|
244
|
-
import {
|
245
|
-
slice as slice2,
|
246
|
-
concat as concat3
|
247
|
-
} from "viem";
|
248
|
-
import { getAction as getAction3, encodeFunctionData as encodeFunctionData6 } from "viem/utils";
|
249
|
-
import { readHex as readHex2 } from "@latticexyz/common";
|
250
|
-
import { sendUserOperation as viem_sendUserOperation } from "viem/account-abstraction";
|
251
|
-
function sendUserOperationFrom(params) {
|
252
|
-
return (client) => ({
|
253
|
-
async sendUserOperation(args) {
|
254
|
-
const _sendUserOperation = getAction3(client, viem_sendUserOperation, "sendUserOperation");
|
255
|
-
if (args.callData) {
|
256
|
-
return _sendUserOperation(args);
|
257
|
-
}
|
258
|
-
const calls = await Promise.all(
|
259
|
-
args.calls.map(async (call) => {
|
260
|
-
if (!isDecodedCall(call)) return call;
|
261
|
-
if (call.to !== params.worldAddress || call.functionName === "call" || call.functionName === "callFrom" || call.functionName === "batchCallFrom" || call.functionName === "callWithSignature") {
|
262
|
-
return call;
|
263
|
-
}
|
264
|
-
if (call.functionName === "batchCall") {
|
265
|
-
const batchCallArgs = call.args;
|
266
|
-
const [systemCalls] = batchCallArgs.args;
|
267
|
-
if (!systemCalls.length) {
|
268
|
-
throw new Error("`batchCall` should have at least one system call.");
|
269
|
-
}
|
270
|
-
return {
|
271
|
-
...call,
|
272
|
-
functionName: "batchCallFrom",
|
273
|
-
args: [systemCalls.map((systemCall) => ({ from: params.delegatorAddress, ...systemCall }))]
|
274
|
-
};
|
275
|
-
}
|
276
|
-
const worldCalldata = encodeFunctionData6({
|
277
|
-
abi: call.abi,
|
278
|
-
functionName: call.functionName,
|
279
|
-
args: call.args
|
280
|
-
});
|
281
|
-
const worldFunctionSelector = slice2(worldCalldata, 0, 4);
|
282
|
-
const { systemId, systemFunctionSelector } = await worldFunctionToSystemFunction({
|
283
|
-
...params,
|
284
|
-
publicClient: params.publicClient ?? client,
|
285
|
-
worldFunctionSelector
|
286
|
-
});
|
287
|
-
const systemCalldata = concat3([systemFunctionSelector, readHex2(worldCalldata, 4)]);
|
288
|
-
return {
|
289
|
-
...call,
|
290
|
-
functionName: "callFrom",
|
291
|
-
args: [params.delegatorAddress, systemId, systemCalldata]
|
292
|
-
};
|
293
|
-
})
|
294
|
-
);
|
295
|
-
return _sendUserOperation({ ...args, calls });
|
296
|
-
}
|
297
|
-
});
|
298
|
-
}
|
299
|
-
function isDecodedCall(call) {
|
300
|
-
return typeof call === "object" && call != null && "functionName" in call && "args" in call && "to" in call;
|
301
|
-
}
|
302
|
-
|
303
236
|
// ts/config/v2/dynamicResolution.ts
|
304
237
|
function resolveTableId(tableName) {
|
305
238
|
return {
|
@@ -361,7 +294,6 @@ export {
|
|
361
294
|
resolveTableId,
|
362
295
|
resolveWithContext,
|
363
296
|
resolveWorld,
|
364
|
-
sendUserOperationFrom,
|
365
297
|
validateNamespace,
|
366
298
|
validateNamespaces,
|
367
299
|
validateSystem,
|
package/dist/internal.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../ts/encodeSystemCall.ts","../ts/normalizeSystemFunctionName.ts","../ts/encodeSystemCallFrom.ts","../ts/encodeSystemCalls.ts","../ts/encodeSystemCallsFrom.ts","../ts/actions/callFrom.ts","../ts/worldFunctionToSystemFunction.ts","../ts/actions/sendUserOperationFrom.ts","../ts/config/v2/dynamicResolution.ts"],"sourcesContent":["import { Abi, EncodeFunctionDataParameters, Hex, encodeFunctionData, type ContractFunctionName } from \"viem\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\nimport { worldCallAbi } from \"./worldCallAbi\";\nimport { internal_normalizeSystemFunctionName } from \"./normalizeSystemFunctionName\";\n\nexport type SystemCall<abi extends Abi, functionName extends ContractFunctionName<abi>> = {\n [k in ContractFunctionName<abi>]: {\n /**\n * System's resource ID\n */\n readonly systemId: Hex;\n /**\n * System ABI\n */\n readonly abi: abi;\n /**\n * System function name to call\n */\n readonly functionName: k;\n } & Pick<EncodeFunctionDataParameters<abi, k>, \"args\">;\n}[functionName];\n\n/** Encode a system call to be passed as arguments into `World.call` */\nexport function encodeSystemCall<abi extends Abi, functionName extends ContractFunctionName<abi>>({\n abi,\n systemId,\n functionName,\n args,\n}: SystemCall<abi, functionName>): AbiParametersToPrimitiveTypes<ExtractAbiFunction<worldCallAbi, \"call\">[\"inputs\"]> {\n return [\n systemId,\n encodeFunctionData<abi, functionName>({\n abi,\n functionName: internal_normalizeSystemFunctionName(systemId, functionName),\n args,\n } as EncodeFunctionDataParameters<abi, functionName>),\n ];\n}\n","import { hexToResource, resourceToLabel } from \"@latticexyz/common\";\nimport { Hex } from \"viem\";\n\n/** @internal */\nexport function internal_normalizeSystemFunctionName(systemId: Hex, functionName: string) {\n const resource = hexToResource(systemId);\n const worldFunctionPrefix = resource.namespace !== \"\" ? `${resource.namespace}__` : null;\n if (worldFunctionPrefix != null && functionName.startsWith(worldFunctionPrefix)) {\n console.warn(\n // eslint-disable-next-line max-len\n `Detected world function name \"${functionName}\" used in call to system \"${resourceToLabel(resource)}\".\\n\\nIt's recommended to use a system ABI and system function name with these methods instead.`,\n );\n return functionName.slice(worldFunctionPrefix.length);\n }\n return functionName;\n}\n","import { Abi, EncodeFunctionDataParameters, encodeFunctionData, Address, type ContractFunctionName } from \"viem\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\nimport { SystemCall } from \"./encodeSystemCall\";\nimport { worldCallAbi } from \"./worldCallAbi\";\nimport { internal_normalizeSystemFunctionName } from \"./normalizeSystemFunctionName\";\n\nexport type SystemCallFrom<abi extends Abi, functionName extends ContractFunctionName<abi>> = SystemCall<\n abi,\n functionName\n> & {\n readonly from: Address;\n};\n\n/** Encode a system call to be passed as arguments into `World.callFrom` */\nexport function encodeSystemCallFrom<abi extends Abi, functionName extends ContractFunctionName<abi>>({\n abi,\n from,\n systemId,\n functionName,\n args,\n}: SystemCallFrom<abi, functionName>): AbiParametersToPrimitiveTypes<\n ExtractAbiFunction<worldCallAbi, \"callFrom\">[\"inputs\"]\n> {\n return [\n from,\n systemId,\n encodeFunctionData<abi, functionName>({\n abi,\n functionName: internal_normalizeSystemFunctionName(systemId, functionName),\n args,\n } as EncodeFunctionDataParameters<abi, functionName>),\n ];\n}\n","import { Abi, encodeFunctionData, type ContractFunctionName } from \"viem\";\nimport { SystemCall } from \"./encodeSystemCall\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\nimport { worldCallAbi } from \"./worldCallAbi\";\nimport { internal_normalizeSystemFunctionName } from \"./normalizeSystemFunctionName\";\n\nexport type SystemCalls<abis extends readonly Abi[]> = {\n [k in keyof abis]: SystemCall<abis[k], ContractFunctionName<abis[k]>>;\n};\n\n/** Encode system calls to be passed as arguments into `World.batchCall` */\nexport function encodeSystemCalls<abis extends readonly Abi[]>(\n systemCalls: SystemCalls<abis>,\n): AbiParametersToPrimitiveTypes<ExtractAbiFunction<worldCallAbi, \"batchCall\">[\"inputs\"]> {\n return [\n systemCalls.map(({ abi, systemId, functionName, args }) => ({\n systemId,\n callData: encodeFunctionData({\n abi,\n functionName: internal_normalizeSystemFunctionName(systemId, functionName),\n args,\n }),\n })),\n ];\n}\n","import { Abi, Address, encodeFunctionData } from \"viem\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\nimport { worldCallAbi } from \"./worldCallAbi\";\nimport { internal_normalizeSystemFunctionName } from \"./normalizeSystemFunctionName\";\nimport { SystemCalls } from \"./encodeSystemCalls\";\n\n/** Encode system calls to be passed as arguments into `World.batchCallFrom` */\nexport function encodeSystemCallsFrom<abis extends readonly Abi[]>(\n from: Address,\n systemCalls: SystemCalls<abis>,\n): AbiParametersToPrimitiveTypes<ExtractAbiFunction<worldCallAbi, \"batchCallFrom\">[\"inputs\"]> {\n return [\n systemCalls.map(({ abi, systemId, functionName, args }) => ({\n from,\n systemId,\n callData: encodeFunctionData({\n abi,\n functionName: internal_normalizeSystemFunctionName(systemId, functionName),\n args,\n }),\n })),\n ];\n}\n","import {\n slice,\n concat,\n type Transport,\n type Chain,\n type Account,\n type Hex,\n type WalletActions,\n type Client,\n type WriteContractParameters,\n type EncodeFunctionDataParameters,\n} from \"viem\";\nimport { getAction, encodeFunctionData } from \"viem/utils\";\nimport { writeContract as viem_writeContract } from \"viem/actions\";\nimport { readHex } from \"@latticexyz/common\";\nimport { worldCallAbi } from \"../worldCallAbi\";\nimport { SystemFunction, worldFunctionToSystemFunction } from \"../worldFunctionToSystemFunction\";\n\ntype CallFromParameters = {\n worldAddress: Hex;\n delegatorAddress: Hex;\n worldFunctionToSystemFunction?: (worldFunctionSelector: Hex) => Promise<SystemFunction>;\n publicClient?: Client;\n};\n\n// By extending viem clients with this function after delegation, the delegation is automatically applied to World contract writes.\n// This means that these writes are made on behalf of the delegator.\n// Internally, it transforms the write arguments to use `callFrom`.\n//\n// Accepts either `worldFunctionToSystemFunction` or `publicClient` as an argument.\n// `worldFunctionToSystemFunction` allows manually providing the mapping function, thus users can utilize their client store for the lookup.\n// If `publicClient` is provided instead, this function retrieves the corresponding system function from the World contract.\n//\n// The function mapping is cached to avoid redundant retrievals for the same World function.\nexport function callFrom(\n params: CallFromParameters,\n): <chain extends Chain, account extends Account | undefined>(\n client: Client<Transport, chain, account>,\n) => Pick<WalletActions<chain, account>, \"writeContract\"> {\n return (client) => ({\n async writeContract(writeArgs) {\n const _writeContract = getAction(client, viem_writeContract, \"writeContract\");\n\n // Skip if the contract isn't the World or the function called should not be redirected through `callFrom`.\n if (\n writeArgs.address !== params.worldAddress ||\n writeArgs.functionName === \"call\" ||\n writeArgs.functionName === \"callFrom\" ||\n writeArgs.functionName === \"batchCallFrom\" ||\n writeArgs.functionName === \"callWithSignature\"\n ) {\n return _writeContract(writeArgs);\n }\n\n // Wrap system calls from `batchCall` with delegator for a `batchCallFrom`\n // TODO: remove this specific workaround once https://github.com/latticexyz/mud/pull/3506 lands\n if (writeArgs.functionName === \"batchCall\") {\n const batchCallArgs = writeArgs as unknown as WriteContractParameters<worldCallAbi, \"batchCall\">;\n const [systemCalls] = batchCallArgs.args;\n if (!systemCalls.length) {\n throw new Error(\"`batchCall` should have at least one system call.\");\n }\n\n return _writeContract({\n ...batchCallArgs,\n functionName: \"batchCallFrom\",\n args: [systemCalls.map((systemCall) => ({ from: params.delegatorAddress, ...systemCall }))],\n });\n }\n\n // Encode the World's calldata (which includes the World's function selector).\n const worldCalldata = encodeFunctionData({\n abi: writeArgs.abi,\n functionName: writeArgs.functionName,\n args: writeArgs.args,\n } as unknown as EncodeFunctionDataParameters);\n\n // The first 4 bytes of calldata represent the function selector.\n const worldFunctionSelector = slice(worldCalldata, 0, 4);\n\n // Get the systemId and System's function selector.\n const { systemId, systemFunctionSelector } = await worldFunctionToSystemFunction({\n ...params,\n publicClient: params.publicClient ?? client,\n worldFunctionSelector,\n });\n\n // Construct the System's calldata by replacing the World's function selector with the System's.\n // Use `readHex` instead of `slice` to prevent out-of-bounds errors with calldata that has no args.\n const systemCalldata = concat([systemFunctionSelector, readHex(worldCalldata, 4)]);\n\n // Call `writeContract` with the new args.\n return _writeContract({\n ...(writeArgs as unknown as WriteContractParameters<worldCallAbi, \"callFrom\">),\n functionName: \"callFrom\",\n args: [params.delegatorAddress, systemId, systemCalldata],\n });\n },\n });\n}\n","import {\n getSchemaTypes,\n getKeySchema,\n getValueSchema,\n encodeKey,\n decodeValueArgs,\n} from \"@latticexyz/protocol-parser/internal\";\nimport { Client, concat, Hex, PublicActions } from \"viem\";\nimport { readContract } from \"viem/actions\";\nimport { getAction } from \"viem/utils\";\nimport worldConfig from \"../mud.config\";\n\nexport type SystemFunction = { systemId: Hex; systemFunctionSelector: Hex };\n\nconst systemFunctionCache = new Map<Hex, SystemFunction>();\n\nexport async function worldFunctionToSystemFunction(params: {\n worldAddress: Hex;\n delegatorAddress: Hex;\n worldFunctionSelector: Hex;\n worldFunctionToSystemFunction?: (worldFunctionSelector: Hex) => Promise<SystemFunction>;\n publicClient: Client;\n}): Promise<SystemFunction> {\n const cacheKey = concat([params.worldAddress, params.worldFunctionSelector]);\n\n // Use cache if the function has been called previously.\n const cached = systemFunctionCache.get(cacheKey);\n if (cached) return cached;\n\n // If a mapping function is provided, use it. Otherwise, call the World contract.\n const systemFunction = params.worldFunctionToSystemFunction\n ? await params.worldFunctionToSystemFunction(params.worldFunctionSelector)\n : await retrieveSystemFunctionFromContract(params.publicClient, params.worldAddress, params.worldFunctionSelector);\n\n systemFunctionCache.set(cacheKey, systemFunction);\n\n return systemFunction;\n}\n\nasync function retrieveSystemFunctionFromContract(\n publicClient: Client,\n worldAddress: Hex,\n worldFunctionSelector: Hex,\n): Promise<SystemFunction> {\n const table = worldConfig.tables.world__FunctionSelectors;\n\n const keySchema = getSchemaTypes(getKeySchema(table));\n const valueSchema = getSchemaTypes(getValueSchema(table));\n\n const _readContract = getAction(publicClient, readContract, \"readContract\") as PublicActions[\"readContract\"];\n\n const [staticData, encodedLengths, dynamicData] = await _readContract({\n address: worldAddress,\n abi: [\n {\n type: \"function\",\n name: \"getRecord\",\n inputs: [\n {\n name: \"tableId\",\n type: \"bytes32\",\n internalType: \"ResourceId\",\n },\n {\n name: \"keyTuple\",\n type: \"bytes32[]\",\n internalType: \"bytes32[]\",\n },\n ],\n outputs: [\n {\n name: \"staticData\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"encodedLengths\",\n type: \"bytes32\",\n internalType: \"EncodedLengths\",\n },\n {\n name: \"dynamicData\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n ],\n stateMutability: \"view\",\n },\n ],\n functionName: \"getRecord\",\n args: [table.tableId, encodeKey(keySchema, { worldFunctionSelector })],\n });\n\n const decoded = decodeValueArgs(valueSchema, { staticData, encodedLengths, dynamicData });\n\n const systemFunction: SystemFunction = {\n systemId: decoded.systemId,\n systemFunctionSelector: decoded.systemFunctionSelector,\n };\n\n return systemFunction;\n}\n","import {\n slice,\n concat,\n type Transport,\n type Chain,\n type Hex,\n type Client,\n type EncodeFunctionDataParameters,\n Abi,\n WriteContractParameters,\n} from \"viem\";\nimport { getAction, encodeFunctionData } from \"viem/utils\";\nimport { readHex } from \"@latticexyz/common\";\nimport { BundlerActions, sendUserOperation as viem_sendUserOperation, SmartAccount } from \"viem/account-abstraction\";\nimport { worldFunctionToSystemFunction } from \"../worldFunctionToSystemFunction\";\nimport { worldCallAbi } from \"../worldCallAbi\";\n\ntype CallFromParameters = {\n worldAddress: Hex;\n delegatorAddress: Hex;\n worldFunctionToSystemFunction?: (worldFunctionSelector: Hex) => Promise<SystemFunction>;\n publicClient?: Client;\n};\n\ntype SystemFunction = { systemId: Hex; systemFunctionSelector: Hex };\n\n// By extending viem clients with this function after delegation, the delegation is automatically applied to World contract writes.\n// This means that these writes are made on behalf of the delegator.\n// Internally, it transforms the write arguments to use `callFrom`.\n//\n// Accepts either `worldFunctionToSystemFunction` or `publicClient` as an argument.\n// `worldFunctionToSystemFunction` allows manually providing the mapping function, thus users can utilize their client store for the lookup.\n// If `publicClient` is provided instead, this function retrieves the corresponding system function from the World contract.\n//\n// The function mapping is cached to avoid redundant retrievals for the same World function.\nexport function sendUserOperationFrom(\n params: CallFromParameters,\n): <chain extends Chain, account extends SmartAccount | undefined>(\n client: Client<Transport, chain, account>,\n) => Pick<BundlerActions<account>, \"sendUserOperation\"> {\n return (client) => ({\n async sendUserOperation(args) {\n const _sendUserOperation = getAction(client, viem_sendUserOperation, \"sendUserOperation\");\n\n if (args.callData) {\n return _sendUserOperation(args as never); // TODO: fix type issue\n }\n\n const calls = await Promise.all(\n args.calls.map(async (call) => {\n // Skip if the call doesn't match the decoded format (`functionName`, `args`, `to`)\n if (!isDecodedCall(call)) return call;\n\n // Skip if the contract isn't the World or the function called should not be redirected through `callFrom`.\n if (\n call.to !== params.worldAddress ||\n call.functionName === \"call\" ||\n call.functionName === \"callFrom\" ||\n call.functionName === \"batchCallFrom\" ||\n call.functionName === \"callWithSignature\"\n ) {\n return call;\n }\n\n // Wrap system calls from `batchCall` with delegator for a `batchCallFrom`\n // TODO: remove this specific workaround once https://github.com/latticexyz/mud/pull/3506 lands\n if (call.functionName === \"batchCall\") {\n const batchCallArgs = call.args as unknown as WriteContractParameters<worldCallAbi, \"batchCall\">;\n const [systemCalls] = batchCallArgs.args;\n if (!systemCalls.length) {\n throw new Error(\"`batchCall` should have at least one system call.\");\n }\n\n return {\n ...call,\n functionName: \"batchCallFrom\",\n args: [systemCalls.map((systemCall) => ({ from: params.delegatorAddress, ...systemCall }))],\n };\n }\n\n // Encode the World's calldata (which includes the World's function selector).\n const worldCalldata = encodeFunctionData({\n abi: call.abi,\n functionName: call.functionName,\n args: call.args,\n } as unknown as EncodeFunctionDataParameters);\n\n // The first 4 bytes of calldata represent the function selector.\n const worldFunctionSelector = slice(worldCalldata, 0, 4);\n\n // Get the systemId and System's function selector.\n const { systemId, systemFunctionSelector } = await worldFunctionToSystemFunction({\n ...params,\n publicClient: params.publicClient ?? client,\n worldFunctionSelector,\n });\n\n // Construct the System's calldata by replacing the World's function selector with the System's.\n // Use `readHex` instead of `slice` to prevent out-of-bounds errors with calldata that has no args.\n const systemCalldata = concat([systemFunctionSelector, readHex(worldCalldata, 4)]);\n\n return {\n ...call,\n functionName: \"callFrom\",\n args: [params.delegatorAddress, systemId, systemCalldata],\n };\n }),\n );\n\n // Call `sendUserOperation` with the new args.\n return _sendUserOperation({ ...args, calls } as never); // TODO: fix type issue\n },\n });\n}\n\n// Matching https://github.com/wevm/viem/blob/26e4bcafb3be976510b4d8170ef29bb69e014263/src/types/calls.ts#L6-L23 (not exported)\ntype DecodedCall = {\n abi: Abi;\n functionName: string;\n args: unknown[];\n to: Hex;\n};\n\nfunction isDecodedCall(call: unknown): call is DecodedCall {\n return typeof call === \"object\" && call != null && \"functionName\" in call && \"args\" in call && \"to\" in call;\n}\n","import { World } from \"./output\";\n\nexport type DynamicResolution = {\n // TODO: add systemAddress support\n type: \"tableId\";\n input: string;\n};\n\nexport type ValueWithType = {\n value: string | number | Uint8Array;\n type: string;\n};\n\n/**\n * Dynamically resolve a table name to a table id at deploy time\n */\nexport function resolveTableId(tableName: string) {\n return {\n type: \"tableId\",\n input: tableName,\n } as const;\n}\n\n/** Type guard for DynamicResolution */\nexport function isDynamicResolution(value: unknown): value is DynamicResolution {\n return typeof value === \"object\" && value !== null && \"type\" in value && \"input\" in value;\n}\n\n/** Type guard for ValueWithType */\nexport function isValueWithType(value: unknown): value is ValueWithType {\n return typeof value === \"object\" && value !== null && \"type\" in value && \"value\" in value;\n}\n\n/**\n * Turn a DynamicResolution object into a ValueWithType based on the provided context\n */\nexport function resolveWithContext(\n input: unknown,\n context: { config: World; systemAddresses?: Record<string, Promise<string>> },\n): ValueWithType {\n if (isValueWithType(input)) return input;\n\n if (isDynamicResolution(input)) {\n if (input.type === \"tableId\") {\n const tableEntries = Object.entries(context.config.tables).filter(\n ([tableName, table]) => tableName === input.input || table.name === input.input,\n );\n\n if (tableEntries.length > 1) {\n throw new Error(\n `Found more than one table with name \"${input.input}\". Try using one of the following table names instead: ${tableEntries.map(([tableName]) => tableName).join(\", \")}`,\n );\n }\n\n if (tableEntries.length === 1) {\n const [entry] = tableEntries;\n const [, table] = entry;\n return { type: \"bytes32\", value: table.tableId };\n }\n }\n }\n\n throw new Error(`Could not resolve dynamic resolution:\\n${JSON.stringify(input, null, 2)}`);\n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A,IACN,OAAO;AAAA,EACT;AACF;AAGO,SAAS,oBAAoB,OAA4C;AAC9E,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,SAAS,WAAW;AACtF;AAGO,SAAS,gBAAgB,OAAwC;AACtE,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,SAAS,WAAW;AACtF;AAKO,SAAS,mBACd,OACA,SACe;AACf,MAAI,gBAAgB,KAAK,EAAG,QAAO;AAEnC,MAAI,oBAAoB,KAAK,GAAG;AAC9B,QAAI,MAAM,SAAS,WAAW;AAC5B,YAAM,eAAe,OAAO,QAAQ,QAAQ,OAAO,MAAM,EAAE;AAAA,QACzD,CAAC,CAAC,WAAW,KAAK,MAAM,cAAc,MAAM,SAAS,MAAM,SAAS,MAAM;AAAA,MAC5E;AAEA,UAAI,aAAa,SAAS,GAAG;AAC3B,cAAM,IAAI;AAAA,UACR,wCAAwC,MAAM,KAAK,0DAA0D,aAAa,IAAI,CAAC,CAAC,SAAS,MAAM,SAAS,EAAE,KAAK,IAAI,CAAC;AAAA,QACtK;AAAA,MACF;AAEA,UAAI,aAAa,WAAW,GAAG;AAC7B,cAAM,CAAC,KAAK,IAAI;AAChB,cAAM,CAAC,EAAE,KAAK,IAAI;AAClB,eAAO,EAAE,MAAM,WAAW,OAAO,MAAM,QAAQ;AAAA,MACjD;AAAA,IACF;AAAA,EACF;AAEA,QAAM,IAAI,MAAM;AAAA,EAA0C,KAAK,UAAU,OAAO,MAAM,CAAC,CAAC,EAAE;AAC5F;","names":["encodeFunctionData","encodeFunctionData","encodeFunctionData","encodeFunctionData","encodeFunctionData","encodeFunctionData","concat","getAction","encodeFunctionData","getAction","encodeFunctionData","concat","slice","concat","getAction","encodeFunctionData","readHex","getAction","encodeFunctionData","slice","concat","readHex"]}
|
1
|
+
{"version":3,"sources":["../ts/encodeSystemCall.ts","../ts/normalizeSystemFunctionName.ts","../ts/encodeSystemCallFrom.ts","../ts/encodeSystemCalls.ts","../ts/encodeSystemCallsFrom.ts","../ts/actions/callFrom.ts","../ts/config/v2/dynamicResolution.ts"],"sourcesContent":["import { Abi, EncodeFunctionDataParameters, Hex, encodeFunctionData, type ContractFunctionName } from \"viem\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\nimport { worldCallAbi } from \"./worldCallAbi\";\nimport { internal_normalizeSystemFunctionName } from \"./normalizeSystemFunctionName\";\n\nexport type SystemCall<abi extends Abi, functionName extends ContractFunctionName<abi>> = {\n [k in ContractFunctionName<abi>]: {\n /**\n * System's resource ID\n */\n readonly systemId: Hex;\n /**\n * System ABI\n */\n readonly abi: abi;\n /**\n * System function name to call\n */\n readonly functionName: k;\n } & Pick<EncodeFunctionDataParameters<abi, k>, \"args\">;\n}[functionName];\n\n/** Encode a system call to be passed as arguments into `World.call` */\nexport function encodeSystemCall<abi extends Abi, functionName extends ContractFunctionName<abi>>({\n abi,\n systemId,\n functionName,\n args,\n}: SystemCall<abi, functionName>): AbiParametersToPrimitiveTypes<ExtractAbiFunction<worldCallAbi, \"call\">[\"inputs\"]> {\n return [\n systemId,\n encodeFunctionData<abi, functionName>({\n abi,\n functionName: internal_normalizeSystemFunctionName(systemId, functionName),\n args,\n } as EncodeFunctionDataParameters<abi, functionName>),\n ];\n}\n","import { hexToResource, resourceToLabel } from \"@latticexyz/common\";\nimport { Hex } from \"viem\";\n\n/** @internal */\nexport function internal_normalizeSystemFunctionName(systemId: Hex, functionName: string) {\n const resource = hexToResource(systemId);\n const worldFunctionPrefix = resource.namespace !== \"\" ? `${resource.namespace}__` : null;\n if (worldFunctionPrefix != null && functionName.startsWith(worldFunctionPrefix)) {\n console.warn(\n // eslint-disable-next-line max-len\n `Detected world function name \"${functionName}\" used in call to system \"${resourceToLabel(resource)}\".\\n\\nIt's recommended to use a system ABI and system function name with these methods instead.`,\n );\n return functionName.slice(worldFunctionPrefix.length);\n }\n return functionName;\n}\n","import { Abi, EncodeFunctionDataParameters, encodeFunctionData, Address, type ContractFunctionName } from \"viem\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\nimport { SystemCall } from \"./encodeSystemCall\";\nimport { worldCallAbi } from \"./worldCallAbi\";\nimport { internal_normalizeSystemFunctionName } from \"./normalizeSystemFunctionName\";\n\nexport type SystemCallFrom<abi extends Abi, functionName extends ContractFunctionName<abi>> = SystemCall<\n abi,\n functionName\n> & {\n readonly from: Address;\n};\n\n/** Encode a system call to be passed as arguments into `World.callFrom` */\nexport function encodeSystemCallFrom<abi extends Abi, functionName extends ContractFunctionName<abi>>({\n abi,\n from,\n systemId,\n functionName,\n args,\n}: SystemCallFrom<abi, functionName>): AbiParametersToPrimitiveTypes<\n ExtractAbiFunction<worldCallAbi, \"callFrom\">[\"inputs\"]\n> {\n return [\n from,\n systemId,\n encodeFunctionData<abi, functionName>({\n abi,\n functionName: internal_normalizeSystemFunctionName(systemId, functionName),\n args,\n } as EncodeFunctionDataParameters<abi, functionName>),\n ];\n}\n","import { Abi, encodeFunctionData, type ContractFunctionName } from \"viem\";\nimport { SystemCall } from \"./encodeSystemCall\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\nimport { worldCallAbi } from \"./worldCallAbi\";\nimport { internal_normalizeSystemFunctionName } from \"./normalizeSystemFunctionName\";\n\nexport type SystemCalls<abis extends readonly Abi[]> = {\n [k in keyof abis]: SystemCall<abis[k], ContractFunctionName<abis[k]>>;\n};\n\n/** Encode system calls to be passed as arguments into `World.batchCall` */\nexport function encodeSystemCalls<abis extends readonly Abi[]>(\n systemCalls: SystemCalls<abis>,\n): AbiParametersToPrimitiveTypes<ExtractAbiFunction<worldCallAbi, \"batchCall\">[\"inputs\"]> {\n return [\n systemCalls.map(({ abi, systemId, functionName, args }) => ({\n systemId,\n callData: encodeFunctionData({\n abi,\n functionName: internal_normalizeSystemFunctionName(systemId, functionName),\n args,\n }),\n })),\n ];\n}\n","import { Abi, Address, encodeFunctionData } from \"viem\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\nimport { worldCallAbi } from \"./worldCallAbi\";\nimport { internal_normalizeSystemFunctionName } from \"./normalizeSystemFunctionName\";\nimport { SystemCalls } from \"./encodeSystemCalls\";\n\n/** Encode system calls to be passed as arguments into `World.batchCallFrom` */\nexport function encodeSystemCallsFrom<abis extends readonly Abi[]>(\n from: Address,\n systemCalls: SystemCalls<abis>,\n): AbiParametersToPrimitiveTypes<ExtractAbiFunction<worldCallAbi, \"batchCallFrom\">[\"inputs\"]> {\n return [\n systemCalls.map(({ abi, systemId, functionName, args }) => ({\n from,\n systemId,\n callData: encodeFunctionData({\n abi,\n functionName: internal_normalizeSystemFunctionName(systemId, functionName),\n args,\n }),\n })),\n ];\n}\n","import {\n slice,\n concat,\n type Transport,\n type Chain,\n type Account,\n type Hex,\n type WalletActions,\n type Client,\n type PublicActions,\n type WriteContractParameters,\n type EncodeFunctionDataParameters,\n} from \"viem\";\nimport { getAction, encodeFunctionData } from \"viem/utils\";\nimport { readContract, writeContract as viem_writeContract } from \"viem/actions\";\nimport { readHex } from \"@latticexyz/common\";\nimport {\n getKeySchema,\n getValueSchema,\n getSchemaTypes,\n decodeValueArgs,\n encodeKey,\n} from \"@latticexyz/protocol-parser/internal\";\nimport worldConfig from \"../../mud.config\";\nimport { worldCallAbi } from \"../worldCallAbi\";\n\ntype CallFromParameters = {\n worldAddress: Hex;\n delegatorAddress: Hex;\n worldFunctionToSystemFunction?: (worldFunctionSelector: Hex) => Promise<SystemFunction>;\n publicClient?: Client;\n};\n\ntype SystemFunction = { systemId: Hex; systemFunctionSelector: Hex };\n\n// By extending viem clients with this function after delegation, the delegation is automatically applied to World contract writes.\n// This means that these writes are made on behalf of the delegator.\n// Internally, it transforms the write arguments to use `callFrom`.\n//\n// Accepts either `worldFunctionToSystemFunction` or `publicClient` as an argument.\n// `worldFunctionToSystemFunction` allows manually providing the mapping function, thus users can utilize their client store for the lookup.\n// If `publicClient` is provided instead, this function retrieves the corresponding system function from the World contract.\n//\n// The function mapping is cached to avoid redundant retrievals for the same World function.\nexport function callFrom(\n params: CallFromParameters,\n): <chain extends Chain, account extends Account | undefined>(\n client: Client<Transport, chain, account>,\n) => Pick<WalletActions<chain, account>, \"writeContract\"> {\n return (client) => ({\n async writeContract(writeArgs) {\n const _writeContract = getAction(client, viem_writeContract, \"writeContract\");\n\n // Skip if the contract isn't the World or the function called should not be redirected through `callFrom`.\n if (\n writeArgs.address !== params.worldAddress ||\n writeArgs.functionName === \"call\" ||\n writeArgs.functionName === \"callFrom\" ||\n writeArgs.functionName === \"batchCallFrom\" ||\n writeArgs.functionName === \"callWithSignature\"\n ) {\n return _writeContract(writeArgs);\n }\n\n // Wrap system calls from `batchCall` with delegator for a `batchCallFrom`\n // TODO: remove this specific workaround once https://github.com/latticexyz/mud/pull/3506 lands\n if (writeArgs.functionName === \"batchCall\") {\n const batchCallArgs = writeArgs as unknown as WriteContractParameters<worldCallAbi, \"batchCall\">;\n const [systemCalls] = batchCallArgs.args;\n if (!systemCalls.length) {\n throw new Error(\"`batchCall` should have at least one system call.\");\n }\n\n return _writeContract({\n ...batchCallArgs,\n functionName: \"batchCallFrom\",\n args: [systemCalls.map((systemCall) => ({ from: params.delegatorAddress, ...systemCall }))],\n });\n }\n\n // Encode the World's calldata (which includes the World's function selector).\n const worldCalldata = encodeFunctionData({\n abi: writeArgs.abi,\n functionName: writeArgs.functionName,\n args: writeArgs.args,\n } as unknown as EncodeFunctionDataParameters);\n\n // The first 4 bytes of calldata represent the function selector.\n const worldFunctionSelector = slice(worldCalldata, 0, 4);\n\n // Get the systemId and System's function selector.\n const { systemId, systemFunctionSelector } = await worldFunctionToSystemFunction({\n ...params,\n publicClient: params.publicClient ?? client,\n worldFunctionSelector,\n });\n\n // Construct the System's calldata by replacing the World's function selector with the System's.\n // Use `readHex` instead of `slice` to prevent out-of-bounds errors with calldata that has no args.\n const systemCalldata = concat([systemFunctionSelector, readHex(worldCalldata, 4)]);\n\n // Call `writeContract` with the new args.\n return _writeContract({\n ...(writeArgs as unknown as WriteContractParameters<worldCallAbi, \"callFrom\">),\n functionName: \"callFrom\",\n args: [params.delegatorAddress, systemId, systemCalldata],\n });\n },\n });\n}\n\nconst systemFunctionCache = new Map<Hex, SystemFunction>();\n\nasync function worldFunctionToSystemFunction(params: {\n worldAddress: Hex;\n delegatorAddress: Hex;\n worldFunctionSelector: Hex;\n worldFunctionToSystemFunction?: (worldFunctionSelector: Hex) => Promise<SystemFunction>;\n publicClient: Client;\n}): Promise<SystemFunction> {\n const cacheKey = concat([params.worldAddress, params.worldFunctionSelector]);\n\n // Use cache if the function has been called previously.\n const cached = systemFunctionCache.get(cacheKey);\n if (cached) return cached;\n\n // If a mapping function is provided, use it. Otherwise, call the World contract.\n const systemFunction = params.worldFunctionToSystemFunction\n ? await params.worldFunctionToSystemFunction(params.worldFunctionSelector)\n : await retrieveSystemFunctionFromContract(params.publicClient, params.worldAddress, params.worldFunctionSelector);\n\n systemFunctionCache.set(cacheKey, systemFunction);\n\n return systemFunction;\n}\n\nasync function retrieveSystemFunctionFromContract(\n publicClient: Client,\n worldAddress: Hex,\n worldFunctionSelector: Hex,\n): Promise<SystemFunction> {\n const table = worldConfig.tables.world__FunctionSelectors;\n\n const keySchema = getSchemaTypes(getKeySchema(table));\n const valueSchema = getSchemaTypes(getValueSchema(table));\n\n const _readContract = getAction(publicClient, readContract, \"readContract\") as PublicActions[\"readContract\"];\n\n const [staticData, encodedLengths, dynamicData] = await _readContract({\n address: worldAddress,\n abi: [\n {\n type: \"function\",\n name: \"getRecord\",\n inputs: [\n {\n name: \"tableId\",\n type: \"bytes32\",\n internalType: \"ResourceId\",\n },\n {\n name: \"keyTuple\",\n type: \"bytes32[]\",\n internalType: \"bytes32[]\",\n },\n ],\n outputs: [\n {\n name: \"staticData\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"encodedLengths\",\n type: \"bytes32\",\n internalType: \"EncodedLengths\",\n },\n {\n name: \"dynamicData\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n ],\n stateMutability: \"view\",\n },\n ],\n functionName: \"getRecord\",\n args: [table.tableId, encodeKey(keySchema, { worldFunctionSelector })],\n });\n\n const decoded = decodeValueArgs(valueSchema, { staticData, encodedLengths, dynamicData });\n\n const systemFunction: SystemFunction = {\n systemId: decoded.systemId,\n systemFunctionSelector: decoded.systemFunctionSelector,\n };\n\n return systemFunction;\n}\n","import { World } from \"./output\";\n\nexport type DynamicResolution = {\n // TODO: add systemAddress support\n type: \"tableId\";\n input: string;\n};\n\nexport type ValueWithType = {\n value: string | number | Uint8Array;\n type: string;\n};\n\n/**\n * Dynamically resolve a table name to a table id at deploy time\n */\nexport function resolveTableId(tableName: string) {\n return {\n type: \"tableId\",\n input: tableName,\n } as const;\n}\n\n/** Type guard for DynamicResolution */\nexport function isDynamicResolution(value: unknown): value is DynamicResolution {\n return typeof value === \"object\" && value !== null && \"type\" in value && \"input\" in value;\n}\n\n/** Type guard for ValueWithType */\nexport function isValueWithType(value: unknown): value is ValueWithType {\n return typeof value === \"object\" && value !== null && \"type\" in value && \"value\" in value;\n}\n\n/**\n * Turn a DynamicResolution object into a ValueWithType based on the provided context\n */\nexport function resolveWithContext(\n input: unknown,\n context: { config: World; systemAddresses?: Record<string, Promise<string>> },\n): ValueWithType {\n if (isValueWithType(input)) return input;\n\n if (isDynamicResolution(input)) {\n if (input.type === \"tableId\") {\n const tableEntries = Object.entries(context.config.tables).filter(\n ([tableName, table]) => tableName === input.input || table.name === input.input,\n );\n\n if (tableEntries.length > 1) {\n throw new Error(\n `Found more than one table with name \"${input.input}\". Try using one of the following table names instead: ${tableEntries.map(([tableName]) => tableName).join(\", \")}`,\n );\n }\n\n if (tableEntries.length === 1) {\n const [entry] = tableEntries;\n const [, table] = entry;\n return { type: \"bytes32\", value: table.tableId };\n }\n }\n }\n\n throw new Error(`Could not resolve dynamic resolution:\\n${JSON.stringify(input, null, 2)}`);\n}\n"],"mappings":";;;;;;;;;;;;;;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AAA,UACR,wCAAwC,MAAM,KAAK,0DAA0D,aAAa,IAAI,CAAC,CAAC,SAAS,MAAM,SAAS,EAAE,KAAK,IAAI,CAAC;AAAA,QACtK;AAAA,MACF;AAEA,UAAI,aAAa,WAAW,GAAG;AAC7B,cAAM,CAAC,KAAK,IAAI;AAChB,cAAM,CAAC,EAAE,KAAK,IAAI;AAClB,eAAO,EAAE,MAAM,WAAW,OAAO,MAAM,QAAQ;AAAA,MACjD;AAAA,IACF;AAAA,EACF;AAEA,QAAM,IAAI,MAAM;AAAA,EAA0C,KAAK,UAAU,OAAO,MAAM,CAAC,CAAC,EAAE;AAC5F;","names":["encodeFunctionData","encodeFunctionData","encodeFunctionData","encodeFunctionData","encodeFunctionData","encodeFunctionData","encodeFunctionData","encodeFunctionData"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@latticexyz/world",
|
3
|
-
"version": "2.2.22-
|
3
|
+
"version": "2.2.22-7902888215e548882b314342e21caed5088b869c",
|
4
4
|
"description": "World framework",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -43,12 +43,12 @@
|
|
43
43
|
"abitype": "1.0.6",
|
44
44
|
"arktype": "2.0.0-beta.6",
|
45
45
|
"debug": "^4.3.4",
|
46
|
-
"@latticexyz/
|
47
|
-
"@latticexyz/
|
48
|
-
"@latticexyz/
|
49
|
-
"@latticexyz/
|
50
|
-
"@latticexyz/
|
51
|
-
"@latticexyz/
|
46
|
+
"@latticexyz/block-logs-stream": "2.2.22-7902888215e548882b314342e21caed5088b869c",
|
47
|
+
"@latticexyz/common": "2.2.22-7902888215e548882b314342e21caed5088b869c",
|
48
|
+
"@latticexyz/config": "2.2.22-7902888215e548882b314342e21caed5088b869c",
|
49
|
+
"@latticexyz/protocol-parser": "2.2.22-7902888215e548882b314342e21caed5088b869c",
|
50
|
+
"@latticexyz/schema-type": "2.2.22-7902888215e548882b314342e21caed5088b869c",
|
51
|
+
"@latticexyz/store": "2.2.22-7902888215e548882b314342e21caed5088b869c"
|
52
52
|
},
|
53
53
|
"devDependencies": {
|
54
54
|
"@types/debug": "^4.1.7",
|
@@ -59,8 +59,8 @@
|
|
59
59
|
"glob": "^10.4.2",
|
60
60
|
"solhint": "^3.3.7",
|
61
61
|
"viem": "2.23.2",
|
62
|
-
"@latticexyz/abi-ts": "2.2.22-
|
63
|
-
"@latticexyz/gas-report": "2.2.22-
|
62
|
+
"@latticexyz/abi-ts": "2.2.22-7902888215e548882b314342e21caed5088b869c",
|
63
|
+
"@latticexyz/gas-report": "2.2.22-7902888215e548882b314342e21caed5088b869c"
|
64
64
|
},
|
65
65
|
"peerDependencies": {
|
66
66
|
"viem": "2.x"
|