@latticexyz/store 2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2 → 2.2.18-c2ad22c7feb566e1731ff16e8be291746bdffb3e
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/chunk-4TACS4IT.js +2 -0
- package/dist/{chunk-Y2IOLXYI.js.map → chunk-4TACS4IT.js.map} +1 -1
- package/dist/chunk-5YJ4WITG.js +2 -0
- package/dist/{chunk-YO3UX5MT.js.map → chunk-5YJ4WITG.js.map} +1 -1
- package/dist/codegen.js +210 -1005
- package/dist/codegen.js.map +1 -1
- package/dist/index.js +1 -22
- package/dist/internal.js +1 -302
- package/dist/internal.js.map +1 -1
- package/dist/mud.config.js +1 -60
- package/dist/mud.config.js.map +1 -1
- package/package.json +11 -47
- package/dist/chunk-Y2IOLXYI.js +0 -27
- package/dist/chunk-YO3UX5MT.js +0 -460
- package/dist/codegen.cjs +0 -1270
- package/dist/codegen.cjs.map +0 -1
- package/dist/codegen.d.cts +0 -173
- package/dist/index.cjs +0 -449
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -15
- package/dist/internal.cjs +0 -756
- package/dist/internal.cjs.map +0 -1
- package/dist/internal.d.cts +0 -88
- package/dist/mud.config.cjs +0 -468
- package/dist/mud.config.cjs.map +0 -1
- package/dist/mud.config.d.cts +0 -295
- package/dist/output-DjNNBwhs.d.cts +0 -215
- package/dist/store-7QsNcifl.d.cts +0 -326
package/dist/internal.js
CHANGED
@@ -1,303 +1,2 @@
|
|
1
|
-
import {
|
2
|
-
storeEventsAbi
|
3
|
-
} from "./chunk-Y2IOLXYI.js";
|
4
|
-
import {
|
5
|
-
AbiTypeScope,
|
6
|
-
CODEGEN_DEFAULTS,
|
7
|
-
CONFIG_DEFAULTS,
|
8
|
-
NoStaticKeyFieldError,
|
9
|
-
Scope,
|
10
|
-
TABLE_CODEGEN_DEFAULTS,
|
11
|
-
TABLE_DEFAULTS,
|
12
|
-
TABLE_DEPLOY_DEFAULTS,
|
13
|
-
defineNamespaces,
|
14
|
-
defineSchema,
|
15
|
-
defineStore,
|
16
|
-
defineTable,
|
17
|
-
defineTableShorthand,
|
18
|
-
defineTables,
|
19
|
-
expandTableShorthand,
|
20
|
-
extendScope,
|
21
|
-
extendedScope,
|
22
|
-
extractInternalType,
|
23
|
-
flattenNamespacedTables,
|
24
|
-
get,
|
25
|
-
getPath,
|
26
|
-
hasOwnKey,
|
27
|
-
isObject,
|
28
|
-
isSchemaInput,
|
29
|
-
isTableShorthandInput,
|
30
|
-
isUserTypes,
|
31
|
-
isValidPrimaryKey,
|
32
|
-
mapEnums,
|
33
|
-
mergeIfUndefined,
|
34
|
-
resolveCodegen,
|
35
|
-
resolveEnums,
|
36
|
-
resolveNamespace,
|
37
|
-
resolveNamespaces,
|
38
|
-
resolveSchema,
|
39
|
-
resolveStore,
|
40
|
-
resolveTable,
|
41
|
-
resolveTableCodegen,
|
42
|
-
resolveTables,
|
43
|
-
scopeWithEnums,
|
44
|
-
scopeWithUserTypes,
|
45
|
-
validateNamespace,
|
46
|
-
validateNamespaces,
|
47
|
-
validateSchema,
|
48
|
-
validateStore,
|
49
|
-
validateTable,
|
50
|
-
validateTableShorthand,
|
51
|
-
validateTables,
|
52
|
-
validateUserTypes
|
53
|
-
} from "./chunk-YO3UX5MT.js";
|
54
|
-
|
55
|
-
// ts/common.ts
|
56
|
-
var emptyRecord = {
|
57
|
-
staticData: "0x",
|
58
|
-
encodedLengths: "0x",
|
59
|
-
dynamicData: "0x"
|
60
|
-
};
|
61
|
-
|
62
|
-
// ts/getStoreLogs.ts
|
63
|
-
import {
|
64
|
-
toEventSelector,
|
65
|
-
numberToHex,
|
66
|
-
formatLog,
|
67
|
-
parseEventLogs
|
68
|
-
} from "viem";
|
69
|
-
|
70
|
-
// ts/debug.ts
|
71
|
-
import createDebug from "debug";
|
72
|
-
var debug = createDebug("mud:store");
|
73
|
-
debug.log = console.debug.bind(console);
|
74
|
-
var error = createDebug("mud:store");
|
75
|
-
error.log = console.error.bind(console);
|
76
|
-
|
77
|
-
// ts/getStoreLogs.ts
|
78
|
-
import { hexToResource, resourceToLabel } from "@latticexyz/common";
|
79
|
-
async function getStoreLogs(client, { address, tableId, fromBlock, toBlock } = {}) {
|
80
|
-
const topics = [storeEventsAbi.map(toEventSelector), tableId ?? null];
|
81
|
-
const tableIds = tableId ? Array.isArray(tableId) ? tableId : [tableId] : [];
|
82
|
-
const addresses = address ? Array.isArray(address) ? address : [address] : [];
|
83
|
-
debug(
|
84
|
-
`getting store logs for ${tableIds.length ? tableIds.map(hexToResource).map(resourceToLabel).join(", ") : "all tables"} at ${addresses.length ? addresses.join(", ") : "any address"}`
|
85
|
-
);
|
86
|
-
const logs = await client.request({
|
87
|
-
method: "eth_getLogs",
|
88
|
-
params: [
|
89
|
-
{
|
90
|
-
address,
|
91
|
-
topics,
|
92
|
-
fromBlock: typeof fromBlock === "bigint" ? numberToHex(fromBlock) : fromBlock,
|
93
|
-
toBlock: typeof toBlock === "bigint" ? numberToHex(toBlock) : toBlock
|
94
|
-
}
|
95
|
-
]
|
96
|
-
});
|
97
|
-
const formattedLogs = logs.map((log) => formatLog(log));
|
98
|
-
return parseEventLogs({
|
99
|
-
abi: storeEventsAbi,
|
100
|
-
args: { tableId },
|
101
|
-
logs: formattedLogs,
|
102
|
-
strict: true
|
103
|
-
});
|
104
|
-
}
|
105
|
-
|
106
|
-
// ts/flattenStoreLogs.ts
|
107
|
-
import { size } from "viem";
|
108
|
-
import { logSort, spliceHex } from "@latticexyz/common";
|
109
|
-
function getKey(log) {
|
110
|
-
return [log.address, log.args.tableId, log.args.keyTuple.join(",")].join(":");
|
111
|
-
}
|
112
|
-
function flattenStoreLogs(logs) {
|
113
|
-
const sortedLogs = logs.slice().sort(logSort);
|
114
|
-
const records = /* @__PURE__ */ new Map();
|
115
|
-
for (const log of sortedLogs) {
|
116
|
-
const key = getKey(log);
|
117
|
-
if (log.eventName === "Store_SetRecord") {
|
118
|
-
records.delete(key);
|
119
|
-
records.set(key, log);
|
120
|
-
} else if (log.eventName === "Store_SpliceStaticData") {
|
121
|
-
const previousRecord = records.get(key);
|
122
|
-
const { staticData, encodedLengths, dynamicData } = previousRecord?.args ?? emptyRecord;
|
123
|
-
const nextRecord = {
|
124
|
-
...log,
|
125
|
-
eventName: "Store_SetRecord",
|
126
|
-
args: {
|
127
|
-
tableId: log.args.tableId,
|
128
|
-
keyTuple: log.args.keyTuple,
|
129
|
-
staticData: spliceHex(staticData, log.args.start, size(log.args.data), log.args.data),
|
130
|
-
encodedLengths,
|
131
|
-
dynamicData
|
132
|
-
}
|
133
|
-
};
|
134
|
-
records.delete(key);
|
135
|
-
records.set(key, nextRecord);
|
136
|
-
} else if (log.eventName === "Store_SpliceDynamicData") {
|
137
|
-
const previousRecord = records.get(key);
|
138
|
-
const { staticData, dynamicData } = previousRecord?.args ?? emptyRecord;
|
139
|
-
const nextRecord = {
|
140
|
-
...log,
|
141
|
-
eventName: "Store_SetRecord",
|
142
|
-
args: {
|
143
|
-
tableId: log.args.tableId,
|
144
|
-
keyTuple: log.args.keyTuple,
|
145
|
-
staticData,
|
146
|
-
encodedLengths: log.args.encodedLengths,
|
147
|
-
dynamicData: spliceHex(dynamicData, log.args.start, log.args.deleteCount, log.args.data)
|
148
|
-
}
|
149
|
-
};
|
150
|
-
records.delete(key);
|
151
|
-
records.set(key, nextRecord);
|
152
|
-
} else if (log.eventName === "Store_DeleteRecord") {
|
153
|
-
records.delete(key);
|
154
|
-
}
|
155
|
-
}
|
156
|
-
return Array.from(records.values());
|
157
|
-
}
|
158
|
-
|
159
|
-
// ts/logToRecord.ts
|
160
|
-
import {
|
161
|
-
decodeKey,
|
162
|
-
decodeValueArgs,
|
163
|
-
getKeySchema,
|
164
|
-
getSchemaTypes,
|
165
|
-
getValueSchema
|
166
|
-
} from "@latticexyz/protocol-parser/internal";
|
167
|
-
function logToRecord({
|
168
|
-
table,
|
169
|
-
log
|
170
|
-
}) {
|
171
|
-
const keySchema = getSchemaTypes(getKeySchema(table));
|
172
|
-
const valueSchema = getSchemaTypes(getValueSchema(table));
|
173
|
-
const key = decodeKey(keySchema, log.args.keyTuple);
|
174
|
-
const value = decodeValueArgs(valueSchema, log.args);
|
175
|
-
return { ...key, ...value };
|
176
|
-
}
|
177
|
-
|
178
|
-
// ts/getRecord.ts
|
179
|
-
import {
|
180
|
-
decodeValueArgs as decodeValueArgs2,
|
181
|
-
getKeyTuple,
|
182
|
-
getSchemaTypes as getSchemaTypes2,
|
183
|
-
getValueSchema as getValueSchema2
|
184
|
-
} from "@latticexyz/protocol-parser/internal";
|
185
|
-
import { readContract } from "viem/actions";
|
186
|
-
import { getAction } from "viem/utils";
|
187
|
-
async function getRecord(client, { address, table, key, blockTag }) {
|
188
|
-
const [staticData, encodedLengths, dynamicData] = await getAction(
|
189
|
-
client,
|
190
|
-
readContract,
|
191
|
-
"readContract"
|
192
|
-
)({
|
193
|
-
address,
|
194
|
-
abi,
|
195
|
-
functionName: "getRecord",
|
196
|
-
args: [table.tableId, getKeyTuple(table, key)],
|
197
|
-
blockTag
|
198
|
-
});
|
199
|
-
return {
|
200
|
-
...key,
|
201
|
-
...decodeValueArgs2(getSchemaTypes2(getValueSchema2(table)), { staticData, encodedLengths, dynamicData })
|
202
|
-
};
|
203
|
-
}
|
204
|
-
var abi = [
|
205
|
-
{
|
206
|
-
type: "function",
|
207
|
-
name: "getRecord",
|
208
|
-
inputs: [
|
209
|
-
{
|
210
|
-
name: "tableId",
|
211
|
-
type: "bytes32",
|
212
|
-
internalType: "ResourceId"
|
213
|
-
},
|
214
|
-
{
|
215
|
-
name: "keyTuple",
|
216
|
-
type: "bytes32[]",
|
217
|
-
internalType: "bytes32[]"
|
218
|
-
}
|
219
|
-
],
|
220
|
-
outputs: [
|
221
|
-
{
|
222
|
-
name: "staticData",
|
223
|
-
type: "bytes",
|
224
|
-
internalType: "bytes"
|
225
|
-
},
|
226
|
-
{
|
227
|
-
name: "encodedLengths",
|
228
|
-
type: "bytes32",
|
229
|
-
internalType: "EncodedLengths"
|
230
|
-
},
|
231
|
-
{
|
232
|
-
name: "dynamicData",
|
233
|
-
type: "bytes",
|
234
|
-
internalType: "bytes"
|
235
|
-
}
|
236
|
-
],
|
237
|
-
stateMutability: "view"
|
238
|
-
}
|
239
|
-
];
|
240
|
-
|
241
|
-
// ts/getStaticDataLocation.ts
|
242
|
-
import { concatHex, hexToBigInt, keccak256, numberToHex as numberToHex2, toBytes } from "viem";
|
243
|
-
var SLOT = hexToBigInt(keccak256(toBytes("mud.store")));
|
244
|
-
function getStaticDataLocation(tableId, keyTuple) {
|
245
|
-
return numberToHex2(SLOT ^ hexToBigInt(keccak256(concatHex([tableId, ...keyTuple]))), { size: 32 });
|
246
|
-
}
|
247
|
-
export {
|
248
|
-
AbiTypeScope,
|
249
|
-
CODEGEN_DEFAULTS,
|
250
|
-
CONFIG_DEFAULTS,
|
251
|
-
NoStaticKeyFieldError,
|
252
|
-
Scope,
|
253
|
-
TABLE_CODEGEN_DEFAULTS,
|
254
|
-
TABLE_DEFAULTS,
|
255
|
-
TABLE_DEPLOY_DEFAULTS,
|
256
|
-
defineNamespaces,
|
257
|
-
defineSchema,
|
258
|
-
defineStore,
|
259
|
-
defineTable,
|
260
|
-
defineTableShorthand,
|
261
|
-
defineTables,
|
262
|
-
emptyRecord,
|
263
|
-
expandTableShorthand,
|
264
|
-
extendScope,
|
265
|
-
extendedScope,
|
266
|
-
extractInternalType,
|
267
|
-
flattenNamespacedTables,
|
268
|
-
flattenStoreLogs,
|
269
|
-
get,
|
270
|
-
getPath,
|
271
|
-
getRecord,
|
272
|
-
getStaticDataLocation,
|
273
|
-
getStoreLogs,
|
274
|
-
hasOwnKey,
|
275
|
-
isObject,
|
276
|
-
isSchemaInput,
|
277
|
-
isTableShorthandInput,
|
278
|
-
isUserTypes,
|
279
|
-
isValidPrimaryKey,
|
280
|
-
logToRecord,
|
281
|
-
mapEnums,
|
282
|
-
mergeIfUndefined,
|
283
|
-
resolveCodegen,
|
284
|
-
resolveEnums,
|
285
|
-
resolveNamespace,
|
286
|
-
resolveNamespaces,
|
287
|
-
resolveSchema,
|
288
|
-
resolveStore,
|
289
|
-
resolveTable,
|
290
|
-
resolveTableCodegen,
|
291
|
-
resolveTables,
|
292
|
-
scopeWithEnums,
|
293
|
-
scopeWithUserTypes,
|
294
|
-
validateNamespace,
|
295
|
-
validateNamespaces,
|
296
|
-
validateSchema,
|
297
|
-
validateStore,
|
298
|
-
validateTable,
|
299
|
-
validateTableShorthand,
|
300
|
-
validateTables,
|
301
|
-
validateUserTypes
|
302
|
-
};
|
1
|
+
import{g as d}from"./chunk-4TACS4IT.js";import{A as ue,B as xe,C as be,D as Se,E as Te,F as ke,G as Le,H as he,I as Be,J as Re,K as ve,L as Ae,M as Pe,N as De,O as Ne,P as He,Q as Ee,R as Ge,S as _e,T as Ce,U as Ke,V as Ie,a as $,b as q,c as F,d as J,e as Q,f as U,g as W,h as X,i as Y,j as Z,k as ee,l as te,m as oe,n as re,o as ae,p as ne,q as se,r as ce,s as ie,t as me,u as de,v as pe,w as le,x as ge,y as ye,z as fe}from"./chunk-5YJ4WITG.js";var p={staticData:"0x",encodedLengths:"0x",dynamicData:"0x"};import{toEventSelector as k,numberToHex as y,formatLog as L,parseEventLogs as h}from"viem";import g from"debug";var l=g("mud:store");l.log=console.debug.bind(console);var T=g("mud:store");T.log=console.error.bind(console);import{hexToResource as B,resourceToLabel as R}from"@latticexyz/common";async function et(r,{address:a,tableId:t,fromBlock:e,toBlock:o}={}){let n=[d.map(k),t??null],s=t?Array.isArray(t)?t:[t]:[],c=a?Array.isArray(a)?a:[a]:[];l(`getting store logs for ${s.length?s.map(B).map(R).join(", "):"all tables"} at ${c.length?c.join(", "):"any address"}`);let m=(await r.request({method:"eth_getLogs",params:[{address:a,topics:n,fromBlock:typeof e=="bigint"?y(e):e,toBlock:typeof o=="bigint"?y(o):o}]})).map(S=>L(S));return h({abi:d,args:{tableId:t},logs:m,strict:!0})}import{size as v}from"viem";import{logSort as A,spliceHex as f}from"@latticexyz/common";function P(r){return[r.address,r.args.tableId,r.args.keyTuple.join(",")].join(":")}function st(r){let a=r.slice().sort(A),t=new Map;for(let e of a){let o=P(e);if(e.eventName==="Store_SetRecord")t.delete(o),t.set(o,e);else if(e.eventName==="Store_SpliceStaticData"){let n=t.get(o),{staticData:s,encodedLengths:c,dynamicData:i}=n?.args??p,m={...e,eventName:"Store_SetRecord",args:{tableId:e.args.tableId,keyTuple:e.args.keyTuple,staticData:f(s,e.args.start,v(e.args.data),e.args.data),encodedLengths:c,dynamicData:i}};t.delete(o),t.set(o,m)}else if(e.eventName==="Store_SpliceDynamicData"){let n=t.get(o),{staticData:s,dynamicData:c}=n?.args??p,i={...e,eventName:"Store_SetRecord",args:{tableId:e.args.tableId,keyTuple:e.args.keyTuple,staticData:s,encodedLengths:e.args.encodedLengths,dynamicData:f(c,e.args.start,e.args.deleteCount,e.args.data)}};t.delete(o),t.set(o,i)}else e.eventName==="Store_DeleteRecord"&&t.delete(o)}return Array.from(t.values())}import{decodeKey as D,decodeValueArgs as N,getKeySchema as H,getSchemaTypes as u,getValueSchema as E}from"@latticexyz/protocol-parser/internal";function dt({table:r,log:a}){let t=u(H(r)),e=u(E(r)),o=D(t,a.args.keyTuple),n=N(e,a.args);return{...o,...n}}import{decodeValueArgs as G,getKeyTuple as _,getSchemaTypes as C,getValueSchema as K}from"@latticexyz/protocol-parser/internal";import{readContract as I}from"viem/actions";import{getAction as V}from"viem/utils";async function xt(r,{address:a,table:t,key:e,blockTag:o}){let[n,s,c]=await V(r,I,"readContract")({address:a,abi:j,functionName:"getRecord",args:[t.tableId,_(t,e)],blockTag:o});return{...e,...G(C(K(t)),{staticData:n,encodedLengths:s,dynamicData:c})}}var j=[{type:"function",name:"getRecord",inputs:[{name:"tableId",type:"bytes32",internalType:"ResourceId"},{name:"keyTuple",type:"bytes32[]",internalType:"bytes32[]"}],outputs:[{name:"staticData",type:"bytes",internalType:"bytes"},{name:"encodedLengths",type:"bytes32",internalType:"EncodedLengths"},{name:"dynamicData",type:"bytes",internalType:"bytes"}],stateMutability:"view"}];import{concatHex as w,hexToBigInt as x,keccak256 as b,numberToHex as O,toBytes as z}from"viem";var M=x(b(z("mud.store")));function kt(r,a){return O(M^x(b(w([r,...a]))),{size:32})}export{te as AbiTypeScope,U as CODEGEN_DEFAULTS,Z as CONFIG_DEFAULTS,le as NoStaticKeyFieldError,ee as Scope,W as TABLE_CODEGEN_DEFAULTS,Y as TABLE_DEFAULTS,X as TABLE_DEPLOY_DEFAULTS,Ee as defineNamespaces,ne as defineSchema,Ie as defineStore,pe as defineTable,ue as defineTableShorthand,Se as defineTables,p as emptyRecord,fe as expandTableShorthand,oe as extendScope,_e as extendedScope,Te as extractInternalType,Ge as flattenNamespacedTables,st as flattenStoreLogs,$ as get,q as getPath,xt as getRecord,kt as getStaticDataLocation,et as getStoreLogs,F as hasOwnKey,J as isObject,se as isSchemaInput,ge as isTableShorthandInput,ke as isUserTypes,ce as isValidPrimaryKey,dt as logToRecord,ve as mapEnums,Q as mergeIfUndefined,Ae as resolveCodegen,Re as resolveEnums,De as resolveNamespace,He as resolveNamespaces,ae as resolveSchema,Ke as resolveStore,de as resolveTable,me as resolveTableCodegen,be as resolveTables,Be as scopeWithEnums,Le as scopeWithUserTypes,Pe as validateNamespace,Ne as validateNamespaces,re as validateSchema,Ce as validateStore,ie as validateTable,ye as validateTableShorthand,xe as validateTables,he as validateUserTypes};
|
303
2
|
//# sourceMappingURL=internal.js.map
|
package/dist/internal.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../ts/common.ts","../ts/getStoreLogs.ts","../ts/debug.ts","../ts/flattenStoreLogs.ts","../ts/logToRecord.ts","../ts/getRecord.ts","../ts/getStaticDataLocation.ts"],"sourcesContent":["import { SchemaAbiType, SchemaAbiTypeToPrimitiveType, StaticAbiType } from \"@latticexyz/schema-type/internal\";\n\nexport type KeySchema = {\n readonly [k: string]: {\n readonly type: StaticAbiType;\n };\n};\nexport type ValueSchema = {\n readonly [k: string]: {\n readonly type: SchemaAbiType;\n };\n};\n\n/** Map a table schema like `{ value: { type: \"uint256\" } }` to its primitive types like `{ value: bigint }` */\nexport type SchemaToPrimitives<schema extends ValueSchema> = {\n readonly [key in keyof schema]: SchemaAbiTypeToPrimitiveType<schema[key][\"type\"]>;\n};\n\nexport const emptyRecord = {\n staticData: \"0x\",\n encodedLengths: \"0x\",\n dynamicData: \"0x\",\n} as const;\n","import {\n BlockNumber,\n BlockTag,\n Address,\n Log,\n Hex,\n GetLogsErrorType,\n Client,\n toEventSelector,\n LogTopic,\n RpcLog,\n numberToHex,\n formatLog,\n parseEventLogs,\n} from \"viem\";\nimport { storeEventsAbi } from \"./storeEventsAbi\";\nimport { debug } from \"./debug\";\nimport { hexToResource, resourceToLabel } from \"@latticexyz/common\";\n\nexport type GetStoreLogsParameters<\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n> = {\n /** Store address or list of store addresses from which logs originated */\n address?: Address | Address[] | undefined;\n /** Optionally match a specific table ID or list of table IDs */\n tableId?: Hex | Hex[] | undefined;\n /** Block number or tag after which to include logs */\n fromBlock?: fromBlock | BlockNumber | BlockTag | undefined;\n /** Block number or tag before which to include logs */\n toBlock?: toBlock | BlockNumber | BlockTag | undefined;\n};\n\nexport type GetStoreLogsReturnType<\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n _pending extends boolean = (fromBlock extends \"pending\" ? true : false) | (toBlock extends \"pending\" ? true : false),\n> = Log<bigint, number, _pending, undefined, true, storeEventsAbi, undefined>[];\n\nexport type GetStoreLogsErrorType = GetLogsErrorType;\n\n/**\n * Returns an unordered list of store event logs matching the provided parameters.\n *\n * @param client - Client to use\n * @param parameters - {@link GetStoreLogsParameters}\n * @returns A list of event logs. {@link GetStoreLogsReturnType}\n *\n * @example\n * import { createClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getStoreLogs } from '@latticexyz/store'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const storeLogs = await getStoreLogs(client)\n */\nexport async function getStoreLogs<\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n>(\n client: Client,\n { address, tableId, fromBlock, toBlock }: GetStoreLogsParameters<fromBlock, toBlock> = {},\n): Promise<GetStoreLogsReturnType<fromBlock, toBlock>> {\n /**\n * Note that this implementation follows Viem's [`getLogs`][0] action:\n * https://github.com/wevm/viem/blob/main/src/actions/public/getLogs.ts\n *\n * It's adapted to allow filtering by table ID(s), which Viem's `getLogs`\n * does not support due to how it builds topics.\n */\n\n const topics: LogTopic[] = [storeEventsAbi.map(toEventSelector), tableId ?? null];\n\n const tableIds = tableId ? (Array.isArray(tableId) ? tableId : [tableId]) : [];\n const addresses = address ? (Array.isArray(address) ? address : [address]) : [];\n debug(\n `getting store logs for ${\n tableIds.length ? tableIds.map(hexToResource).map(resourceToLabel).join(\", \") : \"all tables\"\n } at ${addresses.length ? addresses.join(\", \") : \"any address\"}`,\n );\n\n const logs: RpcLog[] = await client.request({\n method: \"eth_getLogs\",\n params: [\n {\n address,\n topics,\n fromBlock: typeof fromBlock === \"bigint\" ? numberToHex(fromBlock) : fromBlock,\n toBlock: typeof toBlock === \"bigint\" ? numberToHex(toBlock) : toBlock,\n },\n ],\n });\n\n const formattedLogs = logs.map((log) => formatLog(log));\n return parseEventLogs({\n abi: storeEventsAbi,\n args: { tableId },\n logs: formattedLogs,\n strict: true,\n }) as GetStoreLogsReturnType<fromBlock, toBlock>;\n}\n","import createDebug from \"debug\";\n\nexport const debug = createDebug(\"mud:store\");\ndebug.log = console.debug.bind(console);\n\nexport const error = createDebug(\"mud:store\");\nerror.log = console.error.bind(console);\n","import { Log, size } from \"viem\";\nimport { storeEventsAbi } from \"./storeEventsAbi\";\nimport { emptyRecord } from \"./common\";\nimport { StoreLog, StoreSetRecordLog } from \"./storeLog\";\nimport { logSort, spliceHex } from \"@latticexyz/common\";\n\nfunction getKey(log: Log<bigint, number, boolean, undefined, true, storeEventsAbi, undefined>) {\n return [log.address, log.args.tableId, log.args.keyTuple.join(\",\")].join(\":\");\n}\n\nexport function flattenStoreLogs(logs: StoreLog[]): StoreSetRecordLog[] {\n const sortedLogs = logs.slice().sort(logSort);\n const records = new Map<string, StoreSetRecordLog>();\n\n for (const log of sortedLogs) {\n const key = getKey(log);\n\n if (log.eventName === \"Store_SetRecord\") {\n // maps preserve order, so always delete then set so the record gets\n // added to the end of the map, thus preserving the log order\n records.delete(key);\n records.set(key, log);\n } else if (log.eventName === \"Store_SpliceStaticData\") {\n const previousRecord = records.get(key);\n const { staticData, encodedLengths, dynamicData } = previousRecord?.args ?? emptyRecord;\n const nextRecord = {\n ...log,\n eventName: \"Store_SetRecord\",\n args: {\n tableId: log.args.tableId,\n keyTuple: log.args.keyTuple,\n staticData: spliceHex(staticData, log.args.start, size(log.args.data), log.args.data),\n encodedLengths,\n dynamicData,\n },\n } satisfies StoreSetRecordLog;\n // maps preserve order, so always delete then set so the record gets\n // added to the end of the map, thus preserving the log order\n records.delete(key);\n records.set(key, nextRecord);\n } else if (log.eventName === \"Store_SpliceDynamicData\") {\n const previousRecord = records.get(key);\n const { staticData, dynamicData } = previousRecord?.args ?? emptyRecord;\n const nextRecord = {\n ...log,\n eventName: \"Store_SetRecord\",\n args: {\n tableId: log.args.tableId,\n keyTuple: log.args.keyTuple,\n staticData,\n encodedLengths: log.args.encodedLengths,\n dynamicData: spliceHex(dynamicData, log.args.start, log.args.deleteCount, log.args.data),\n },\n } satisfies StoreSetRecordLog;\n // maps preserve order, so always delete then set so the record gets\n // added to the end of the map, thus preserving the log order\n records.delete(key);\n records.set(key, nextRecord);\n } else if (log.eventName === \"Store_DeleteRecord\") {\n records.delete(key);\n }\n }\n\n return Array.from(records.values());\n}\n","import { Table } from \"@latticexyz/config\";\nimport {\n decodeKey,\n decodeValueArgs,\n getKeySchema,\n getSchemaPrimitives,\n getSchemaTypes,\n getValueSchema,\n} from \"@latticexyz/protocol-parser/internal\";\nimport { StoreLog } from \"./storeLog\";\n\ntype PartialTable = Pick<Table, \"schema\" | \"key\">;\ntype PartialLog = Pick<Extract<StoreLog, { eventName: \"Store_SetRecord\" }>, \"args\">;\n\nexport type LogToRecordArgs<table extends PartialTable> = {\n table: table;\n log: PartialLog;\n};\n\nexport function logToRecord<table extends PartialTable>({\n table,\n log,\n}: LogToRecordArgs<table>): getSchemaPrimitives<table[\"schema\"]> {\n const keySchema = getSchemaTypes(getKeySchema(table));\n const valueSchema = getSchemaTypes(getValueSchema(table));\n const key = decodeKey(keySchema, log.args.keyTuple);\n const value = decodeValueArgs(valueSchema, log.args);\n return { ...key, ...value };\n}\n","import { Address, Client, Hex } from \"viem\";\nimport { Table } from \"@latticexyz/config\";\nimport {\n decodeValueArgs,\n getKeySchema,\n getKeyTuple,\n getSchemaPrimitives,\n getSchemaTypes,\n getValueSchema,\n} from \"@latticexyz/protocol-parser/internal\";\nimport { readContract } from \"viem/actions\";\nimport { getAction } from \"viem/utils\";\n\nexport type GetRecordOptions<table extends Table> = {\n address: Address;\n table: table;\n key: getSchemaPrimitives<getKeySchema<table>>;\n blockTag?: \"latest\" | \"pending\";\n};\n\nexport async function getRecord<table extends Table>(\n client: Client,\n { address, table, key, blockTag }: GetRecordOptions<table>,\n): Promise<getSchemaPrimitives<table[\"schema\"]>> {\n const [staticData, encodedLengths, dynamicData] = await getAction(\n client,\n readContract,\n \"readContract\",\n )({\n address,\n abi,\n functionName: \"getRecord\",\n args: [table.tableId, getKeyTuple(table, key) as readonly Hex[]],\n blockTag,\n });\n\n return {\n ...key,\n ...decodeValueArgs(getSchemaTypes(getValueSchema(table)), { staticData, encodedLengths, dynamicData }),\n };\n}\n\nconst 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] as const;\n","import { Hex, concatHex, hexToBigInt, keccak256, numberToHex, toBytes } from \"viem\";\n\n// TODO: move to protocol-parser?\n// equivalent of StoreCore._getStaticDataLocation\n\nconst SLOT = hexToBigInt(keccak256(toBytes(\"mud.store\")));\n\nexport function getStaticDataLocation(tableId: Hex, keyTuple: readonly Hex[]): Hex {\n return numberToHex(SLOT ^ hexToBigInt(keccak256(concatHex([tableId, ...keyTuple]))), { size: 32 });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBO,IAAM,cAAc;AAAA,EACzB,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,aAAa;AACf;;;ACtBA;AAAA,EAQE;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACdP,OAAO,iBAAiB;AAEjB,IAAM,QAAQ,YAAY,WAAW;AAC5C,MAAM,MAAM,QAAQ,MAAM,KAAK,OAAO;AAE/B,IAAM,QAAQ,YAAY,WAAW;AAC5C,MAAM,MAAM,QAAQ,MAAM,KAAK,OAAO;;;ADWtC,SAAS,eAAe,uBAAuB;AA0C/C,eAAsB,aAIpB,QACA,EAAE,SAAS,SAAS,WAAW,QAAQ,IAAgD,CAAC,GACnC;AASrD,QAAM,SAAqB,CAAC,eAAe,IAAI,eAAe,GAAG,WAAW,IAAI;AAEhF,QAAM,WAAW,UAAW,MAAM,QAAQ,OAAO,IAAI,UAAU,CAAC,OAAO,IAAK,CAA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eAAe;AAK7E,IAAM,OAAO,YAAY,UAAU,QAAQ,WAAW,CAAC,CAAC;AAEjD,SAAS,sBAAsB,SAAc,UAA+B;AACjF,SAAOA,aAAY,OAAO,YAAY,UAAU,UAAU,CAAC,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC;AACnG;","names":["decodeValueArgs","getSchemaTypes","getValueSchema","numberToHex"]}
|
1
|
+
{"version":3,"sources":["../ts/common.ts","../ts/getStoreLogs.ts","../ts/debug.ts","../ts/flattenStoreLogs.ts","../ts/logToRecord.ts","../ts/getRecord.ts","../ts/getStaticDataLocation.ts"],"sourcesContent":["import { SchemaAbiType, SchemaAbiTypeToPrimitiveType, StaticAbiType } from \"@latticexyz/schema-type/internal\";\n\nexport type KeySchema = {\n readonly [k: string]: {\n readonly type: StaticAbiType;\n };\n};\nexport type ValueSchema = {\n readonly [k: string]: {\n readonly type: SchemaAbiType;\n };\n};\n\n/** Map a table schema like `{ value: { type: \"uint256\" } }` to its primitive types like `{ value: bigint }` */\nexport type SchemaToPrimitives<schema extends ValueSchema> = {\n readonly [key in keyof schema]: SchemaAbiTypeToPrimitiveType<schema[key][\"type\"]>;\n};\n\nexport const emptyRecord = {\n staticData: \"0x\",\n encodedLengths: \"0x\",\n dynamicData: \"0x\",\n} as const;\n","import {\n BlockNumber,\n BlockTag,\n Address,\n Log,\n Hex,\n GetLogsErrorType,\n Client,\n toEventSelector,\n LogTopic,\n RpcLog,\n numberToHex,\n formatLog,\n parseEventLogs,\n} from \"viem\";\nimport { storeEventsAbi } from \"./storeEventsAbi\";\nimport { debug } from \"./debug\";\nimport { hexToResource, resourceToLabel } from \"@latticexyz/common\";\n\nexport type GetStoreLogsParameters<\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n> = {\n /** Store address or list of store addresses from which logs originated */\n address?: Address | Address[] | undefined;\n /** Optionally match a specific table ID or list of table IDs */\n tableId?: Hex | Hex[] | undefined;\n /** Block number or tag after which to include logs */\n fromBlock?: fromBlock | BlockNumber | BlockTag | undefined;\n /** Block number or tag before which to include logs */\n toBlock?: toBlock | BlockNumber | BlockTag | undefined;\n};\n\nexport type GetStoreLogsReturnType<\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n _pending extends boolean = (fromBlock extends \"pending\" ? true : false) | (toBlock extends \"pending\" ? true : false),\n> = Log<bigint, number, _pending, undefined, true, storeEventsAbi, undefined>[];\n\nexport type GetStoreLogsErrorType = GetLogsErrorType;\n\n/**\n * Returns an unordered list of store event logs matching the provided parameters.\n *\n * @param client - Client to use\n * @param parameters - {@link GetStoreLogsParameters}\n * @returns A list of event logs. {@link GetStoreLogsReturnType}\n *\n * @example\n * import { createClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getStoreLogs } from '@latticexyz/store'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const storeLogs = await getStoreLogs(client)\n */\nexport async function getStoreLogs<\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n>(\n client: Client,\n { address, tableId, fromBlock, toBlock }: GetStoreLogsParameters<fromBlock, toBlock> = {},\n): Promise<GetStoreLogsReturnType<fromBlock, toBlock>> {\n /**\n * Note that this implementation follows Viem's [`getLogs`][0] action:\n * https://github.com/wevm/viem/blob/main/src/actions/public/getLogs.ts\n *\n * It's adapted to allow filtering by table ID(s), which Viem's `getLogs`\n * does not support due to how it builds topics.\n */\n\n const topics: LogTopic[] = [storeEventsAbi.map(toEventSelector), tableId ?? null];\n\n const tableIds = tableId ? (Array.isArray(tableId) ? tableId : [tableId]) : [];\n const addresses = address ? (Array.isArray(address) ? address : [address]) : [];\n debug(\n `getting store logs for ${\n tableIds.length ? tableIds.map(hexToResource).map(resourceToLabel).join(\", \") : \"all tables\"\n } at ${addresses.length ? addresses.join(\", \") : \"any address\"}`,\n );\n\n const logs: RpcLog[] = await client.request({\n method: \"eth_getLogs\",\n params: [\n {\n address,\n topics,\n fromBlock: typeof fromBlock === \"bigint\" ? numberToHex(fromBlock) : fromBlock,\n toBlock: typeof toBlock === \"bigint\" ? numberToHex(toBlock) : toBlock,\n },\n ],\n });\n\n const formattedLogs = logs.map((log) => formatLog(log));\n return parseEventLogs({\n abi: storeEventsAbi,\n args: { tableId },\n logs: formattedLogs,\n strict: true,\n }) as GetStoreLogsReturnType<fromBlock, toBlock>;\n}\n","import createDebug from \"debug\";\n\nexport const debug = createDebug(\"mud:store\");\ndebug.log = console.debug.bind(console);\n\nexport const error = createDebug(\"mud:store\");\nerror.log = console.error.bind(console);\n","import { Log, size } from \"viem\";\nimport { storeEventsAbi } from \"./storeEventsAbi\";\nimport { emptyRecord } from \"./common\";\nimport { StoreLog, StoreSetRecordLog } from \"./storeLog\";\nimport { logSort, spliceHex } from \"@latticexyz/common\";\n\nfunction getKey(log: Log<bigint, number, boolean, undefined, true, storeEventsAbi, undefined>) {\n return [log.address, log.args.tableId, log.args.keyTuple.join(\",\")].join(\":\");\n}\n\nexport function flattenStoreLogs(logs: StoreLog[]): StoreSetRecordLog[] {\n const sortedLogs = logs.slice().sort(logSort);\n const records = new Map<string, StoreSetRecordLog>();\n\n for (const log of sortedLogs) {\n const key = getKey(log);\n\n if (log.eventName === \"Store_SetRecord\") {\n // maps preserve order, so always delete then set so the record gets\n // added to the end of the map, thus preserving the log order\n records.delete(key);\n records.set(key, log);\n } else if (log.eventName === \"Store_SpliceStaticData\") {\n const previousRecord = records.get(key);\n const { staticData, encodedLengths, dynamicData } = previousRecord?.args ?? emptyRecord;\n const nextRecord = {\n ...log,\n eventName: \"Store_SetRecord\",\n args: {\n tableId: log.args.tableId,\n keyTuple: log.args.keyTuple,\n staticData: spliceHex(staticData, log.args.start, size(log.args.data), log.args.data),\n encodedLengths,\n dynamicData,\n },\n } satisfies StoreSetRecordLog;\n // maps preserve order, so always delete then set so the record gets\n // added to the end of the map, thus preserving the log order\n records.delete(key);\n records.set(key, nextRecord);\n } else if (log.eventName === \"Store_SpliceDynamicData\") {\n const previousRecord = records.get(key);\n const { staticData, dynamicData } = previousRecord?.args ?? emptyRecord;\n const nextRecord = {\n ...log,\n eventName: \"Store_SetRecord\",\n args: {\n tableId: log.args.tableId,\n keyTuple: log.args.keyTuple,\n staticData,\n encodedLengths: log.args.encodedLengths,\n dynamicData: spliceHex(dynamicData, log.args.start, log.args.deleteCount, log.args.data),\n },\n } satisfies StoreSetRecordLog;\n // maps preserve order, so always delete then set so the record gets\n // added to the end of the map, thus preserving the log order\n records.delete(key);\n records.set(key, nextRecord);\n } else if (log.eventName === \"Store_DeleteRecord\") {\n records.delete(key);\n }\n }\n\n return Array.from(records.values());\n}\n","import { Table } from \"@latticexyz/config\";\nimport {\n decodeKey,\n decodeValueArgs,\n getKeySchema,\n getSchemaPrimitives,\n getSchemaTypes,\n getValueSchema,\n} from \"@latticexyz/protocol-parser/internal\";\nimport { StoreLog } from \"./storeLog\";\n\ntype PartialTable = Pick<Table, \"schema\" | \"key\">;\ntype PartialLog = Pick<Extract<StoreLog, { eventName: \"Store_SetRecord\" }>, \"args\">;\n\nexport type LogToRecordArgs<table extends PartialTable> = {\n table: table;\n log: PartialLog;\n};\n\nexport function logToRecord<table extends PartialTable>({\n table,\n log,\n}: LogToRecordArgs<table>): getSchemaPrimitives<table[\"schema\"]> {\n const keySchema = getSchemaTypes(getKeySchema(table));\n const valueSchema = getSchemaTypes(getValueSchema(table));\n const key = decodeKey(keySchema, log.args.keyTuple);\n const value = decodeValueArgs(valueSchema, log.args);\n return { ...key, ...value };\n}\n","import { Address, Client, Hex } from \"viem\";\nimport { Table } from \"@latticexyz/config\";\nimport {\n decodeValueArgs,\n getKeySchema,\n getKeyTuple,\n getSchemaPrimitives,\n getSchemaTypes,\n getValueSchema,\n} from \"@latticexyz/protocol-parser/internal\";\nimport { readContract } from \"viem/actions\";\nimport { getAction } from \"viem/utils\";\n\nexport type GetRecordOptions<table extends Table> = {\n address: Address;\n table: table;\n key: getSchemaPrimitives<getKeySchema<table>>;\n blockTag?: \"latest\" | \"pending\";\n};\n\nexport async function getRecord<table extends Table>(\n client: Client,\n { address, table, key, blockTag }: GetRecordOptions<table>,\n): Promise<getSchemaPrimitives<table[\"schema\"]>> {\n const [staticData, encodedLengths, dynamicData] = await getAction(\n client,\n readContract,\n \"readContract\",\n )({\n address,\n abi,\n functionName: \"getRecord\",\n args: [table.tableId, getKeyTuple(table, key) as readonly Hex[]],\n blockTag,\n });\n\n return {\n ...key,\n ...decodeValueArgs(getSchemaTypes(getValueSchema(table)), { staticData, encodedLengths, dynamicData }),\n };\n}\n\nconst 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] as const;\n","import { Hex, concatHex, hexToBigInt, keccak256, numberToHex, toBytes } from \"viem\";\n\n// TODO: move to protocol-parser?\n// equivalent of StoreCore._getStaticDataLocation\n\nconst SLOT = hexToBigInt(keccak256(toBytes(\"mud.store\")));\n\nexport function getStaticDataLocation(tableId: Hex, keyTuple: readonly Hex[]): Hex {\n return numberToHex(SLOT ^ hexToBigInt(keccak256(concatHex([tableId, ...keyTuple]))), { size: 32 });\n}\n"],"mappings":"+bAkBO,IAAMA,EAAc,CACzB,WAAY,KACZ,eAAgB,KAChB,YAAa,IACf,ECtBA,OAQE,mBAAAC,EAGA,eAAAC,EACA,aAAAC,EACA,kBAAAC,MACK,OCdP,OAAOC,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AAM,cACN,KAAM,QACN,aAAc,OAChB,CACF,EACA,gBAAiB,MACnB,CACF,EC7EA,OAAc,aAAAC,EAAW,eAAAC,EAAa,aAAAC,EAAW,eAAAC,EAAa,WAAAC,MAAe,OAK7E,IAAMC,EAAOJ,EAAYC,EAAUE,EAAQ,WAAW,CAAC,CAAC,EAEjD,SAASE,GAAsBC,EAAcC,EAA+B,CACjF,OAAOL,EAAYE,EAAOJ,EAAYC,EAAUF,EAAU,CAACO,EAAS,GAAGC,CAAQ,CAAC,CAAC,CAAC,EAAG,CAAE,KAAM,EAAG,CAAC,CACnG","names":["emptyRecord","toEventSelector","numberToHex","formatLog","parseEventLogs","createDebug","debug","error","hexToResource","resourceToLabel","getStoreLogs","client","address","tableId","fromBlock","toBlock","topics","storeEventsAbi","toEventSelector","tableIds","addresses","debug","formattedLogs","numberToHex","log","formatLog","parseEventLogs","size","logSort","spliceHex","getKey","log","flattenStoreLogs","logs","sortedLogs","records","key","previousRecord","staticData","encodedLengths","dynamicData","emptyRecord","nextRecord","size","decodeKey","decodeValueArgs","getKeySchema","getSchemaTypes","getValueSchema","logToRecord","table","log","keySchema","valueSchema","key","value","decodeValueArgs","getKeyTuple","getSchemaTypes","getValueSchema","readContract","getAction","getRecord","client","address","table","key","blockTag","staticData","encodedLengths","dynamicData","abi","concatHex","hexToBigInt","keccak256","numberToHex","toBytes","SLOT","getStaticDataLocation","tableId","keyTuple"]}
|
package/dist/mud.config.js
CHANGED
@@ -1,61 +1,2 @@
|
|
1
|
-
import {
|
2
|
-
defineStore
|
3
|
-
} from "./chunk-YO3UX5MT.js";
|
4
|
-
|
5
|
-
// mud.config.ts
|
6
|
-
var mud_config_default = defineStore({
|
7
|
-
namespace: "store",
|
8
|
-
codegen: {
|
9
|
-
storeImportPath: "./src"
|
10
|
-
},
|
11
|
-
userTypes: {
|
12
|
-
ResourceId: { filePath: "./src/ResourceId.sol", type: "bytes32" },
|
13
|
-
FieldLayout: { filePath: "./src/FieldLayout.sol", type: "bytes32" },
|
14
|
-
Schema: { filePath: "./src/Schema.sol", type: "bytes32" }
|
15
|
-
},
|
16
|
-
tables: {
|
17
|
-
StoreHooks: {
|
18
|
-
schema: {
|
19
|
-
tableId: "ResourceId",
|
20
|
-
hooks: "bytes21[]"
|
21
|
-
},
|
22
|
-
key: ["tableId"]
|
23
|
-
},
|
24
|
-
Tables: {
|
25
|
-
schema: {
|
26
|
-
tableId: "ResourceId",
|
27
|
-
fieldLayout: "FieldLayout",
|
28
|
-
keySchema: "Schema",
|
29
|
-
valueSchema: "Schema",
|
30
|
-
abiEncodedKeyNames: "bytes",
|
31
|
-
abiEncodedFieldNames: "bytes"
|
32
|
-
},
|
33
|
-
key: ["tableId"]
|
34
|
-
},
|
35
|
-
ResourceIds: {
|
36
|
-
schema: {
|
37
|
-
resourceId: "ResourceId",
|
38
|
-
exists: "bool"
|
39
|
-
},
|
40
|
-
key: ["resourceId"]
|
41
|
-
},
|
42
|
-
// This is generic, codegen-only table used by `filterFromList` in `Hook.sol`
|
43
|
-
Hooks: {
|
44
|
-
schema: {
|
45
|
-
resourceId: "ResourceId",
|
46
|
-
hooks: "bytes21[]"
|
47
|
-
},
|
48
|
-
key: ["resourceId"],
|
49
|
-
codegen: {
|
50
|
-
tableIdArgument: true
|
51
|
-
},
|
52
|
-
deploy: {
|
53
|
-
disabled: true
|
54
|
-
}
|
55
|
-
}
|
56
|
-
}
|
57
|
-
});
|
58
|
-
export {
|
59
|
-
mud_config_default as default
|
60
|
-
};
|
1
|
+
import{V as e}from"./chunk-5YJ4WITG.js";var o=e({namespace:"store",codegen:{storeImportPath:"./src"},userTypes:{ResourceId:{filePath:"./src/ResourceId.sol",type:"bytes32"},FieldLayout:{filePath:"./src/FieldLayout.sol",type:"bytes32"},Schema:{filePath:"./src/Schema.sol",type:"bytes32"}},tables:{StoreHooks:{schema:{tableId:"ResourceId",hooks:"bytes21[]"},key:["tableId"]},Tables:{schema:{tableId:"ResourceId",fieldLayout:"FieldLayout",keySchema:"Schema",valueSchema:"Schema",abiEncodedKeyNames:"bytes",abiEncodedFieldNames:"bytes"},key:["tableId"]},ResourceIds:{schema:{resourceId:"ResourceId",exists:"bool"},key:["resourceId"]},Hooks:{schema:{resourceId:"ResourceId",hooks:"bytes21[]"},key:["resourceId"],codegen:{tableIdArgument:!0},deploy:{disabled:!0}}}});export{o as default};
|
61
2
|
//# sourceMappingURL=mud.config.js.map
|
package/dist/mud.config.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../mud.config.ts"],"sourcesContent":["import { defineStore } from \"./ts/config/v2/store\";\n\nexport default defineStore({\n namespace: \"store\",\n codegen: {\n storeImportPath: \"./src\",\n },\n userTypes: {\n ResourceId: { filePath: \"./src/ResourceId.sol\", type: \"bytes32\" },\n FieldLayout: { filePath: \"./src/FieldLayout.sol\", type: \"bytes32\" },\n Schema: { filePath: \"./src/Schema.sol\", type: \"bytes32\" },\n },\n tables: {\n StoreHooks: {\n schema: {\n tableId: \"ResourceId\",\n hooks: \"bytes21[]\",\n },\n key: [\"tableId\"],\n },\n Tables: {\n schema: {\n tableId: \"ResourceId\",\n fieldLayout: \"FieldLayout\",\n keySchema: \"Schema\",\n valueSchema: \"Schema\",\n abiEncodedKeyNames: \"bytes\",\n abiEncodedFieldNames: \"bytes\",\n },\n key: [\"tableId\"],\n },\n ResourceIds: {\n schema: {\n resourceId: \"ResourceId\",\n exists: \"bool\",\n },\n key: [\"resourceId\"],\n },\n // This is generic, codegen-only table used by `filterFromList` in `Hook.sol`\n Hooks: {\n schema: {\n resourceId: \"ResourceId\",\n hooks: \"bytes21[]\",\n },\n key: [\"resourceId\"],\n codegen: {\n tableIdArgument: true,\n },\n deploy: {\n disabled: true,\n },\n },\n },\n});\n"],"mappings":"
|
1
|
+
{"version":3,"sources":["../mud.config.ts"],"sourcesContent":["import { defineStore } from \"./ts/config/v2/store\";\n\nexport default defineStore({\n namespace: \"store\",\n codegen: {\n storeImportPath: \"./src\",\n },\n userTypes: {\n ResourceId: { filePath: \"./src/ResourceId.sol\", type: \"bytes32\" },\n FieldLayout: { filePath: \"./src/FieldLayout.sol\", type: \"bytes32\" },\n Schema: { filePath: \"./src/Schema.sol\", type: \"bytes32\" },\n },\n tables: {\n StoreHooks: {\n schema: {\n tableId: \"ResourceId\",\n hooks: \"bytes21[]\",\n },\n key: [\"tableId\"],\n },\n Tables: {\n schema: {\n tableId: \"ResourceId\",\n fieldLayout: \"FieldLayout\",\n keySchema: \"Schema\",\n valueSchema: \"Schema\",\n abiEncodedKeyNames: \"bytes\",\n abiEncodedFieldNames: \"bytes\",\n },\n key: [\"tableId\"],\n },\n ResourceIds: {\n schema: {\n resourceId: \"ResourceId\",\n exists: \"bool\",\n },\n key: [\"resourceId\"],\n },\n // This is generic, codegen-only table used by `filterFromList` in `Hook.sol`\n Hooks: {\n schema: {\n resourceId: \"ResourceId\",\n hooks: \"bytes21[]\",\n },\n key: [\"resourceId\"],\n codegen: {\n tableIdArgument: true,\n },\n deploy: {\n disabled: true,\n },\n },\n },\n});\n"],"mappings":"wCAEA,IAAOA,EAAQC,EAAY,CACzB,UAAW,QACX,QAAS,CACP,gBAAiB,OACnB,EACA,UAAW,CACT,WAAY,CAAE,SAAU,uBAAwB,KAAM,SAAU,EAChE,YAAa,CAAE,SAAU,wBAAyB,KAAM,SAAU,EAClE,OAAQ,CAAE,SAAU,mBAAoB,KAAM,SAAU,CAC1D,EACA,OAAQ,CACN,WAAY,CACV,OAAQ,CACN,QAAS,aACT,MAAO,WACT,EACA,IAAK,CAAC,SAAS,CACjB,EACA,OAAQ,CACN,OAAQ,CACN,QAAS,aACT,YAAa,cACb,UAAW,SACX,YAAa,SACb,mBAAoB,QACpB,qBAAsB,OACxB,EACA,IAAK,CAAC,SAAS,CACjB,EACA,YAAa,CACX,OAAQ,CACN,WAAY,aACZ,OAAQ,MACV,EACA,IAAK,CAAC,YAAY,CACpB,EAEA,MAAO,CACL,OAAQ,CACN,WAAY,aACZ,MAAO,WACT,EACA,IAAK,CAAC,YAAY,EAClB,QAAS,CACP,gBAAiB,EACnB,EACA,OAAQ,CACN,SAAU,EACZ,CACF,CACF,CACF,CAAC","names":["mud_config_default","defineStore"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@latticexyz/store",
|
3
|
-
"version": "2.2.18-
|
3
|
+
"version": "2.2.18-c2ad22c7feb566e1731ff16e8be291746bdffb3e",
|
4
4
|
"description": "Store",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -10,46 +10,10 @@
|
|
10
10
|
"license": "MIT",
|
11
11
|
"type": "module",
|
12
12
|
"exports": {
|
13
|
-
".":
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
},
|
18
|
-
"require": {
|
19
|
-
"require": "./dist/index.cjs",
|
20
|
-
"types": "./dist/index.d.cts"
|
21
|
-
}
|
22
|
-
},
|
23
|
-
"./internal": {
|
24
|
-
"import": {
|
25
|
-
"import": "./dist/internal.js",
|
26
|
-
"types": "./dist/internal.d.ts"
|
27
|
-
},
|
28
|
-
"require": {
|
29
|
-
"require": "./dist/internal.cjs",
|
30
|
-
"types": "./dist/internal.d.cts"
|
31
|
-
}
|
32
|
-
},
|
33
|
-
"./mud.config": {
|
34
|
-
"import": {
|
35
|
-
"import": "./dist/mud.config.js",
|
36
|
-
"types": "./dist/mud.config.d.ts"
|
37
|
-
},
|
38
|
-
"require": {
|
39
|
-
"require": "./dist/mud.config.cjs",
|
40
|
-
"types": "./dist/mud.config.d.cts"
|
41
|
-
}
|
42
|
-
},
|
43
|
-
"./codegen": {
|
44
|
-
"import": {
|
45
|
-
"import": "./dist/codegen.js",
|
46
|
-
"types": "./dist/codegen.d.ts"
|
47
|
-
},
|
48
|
-
"require": {
|
49
|
-
"require": "./dist/codegen.cjs",
|
50
|
-
"types": "./dist/codegen.d.cts"
|
51
|
-
}
|
52
|
-
},
|
13
|
+
".": "./dist/index.js",
|
14
|
+
"./internal": "./dist/internal.js",
|
15
|
+
"./mud.config": "./dist/mud.config.js",
|
16
|
+
"./codegen": "./dist/codegen.js",
|
53
17
|
"./out/*": "./out/*"
|
54
18
|
},
|
55
19
|
"typesVersions": {
|
@@ -78,10 +42,10 @@
|
|
78
42
|
"abitype": "1.0.6",
|
79
43
|
"arktype": "2.0.0-beta.6",
|
80
44
|
"debug": "^4.3.4",
|
81
|
-
"@latticexyz/common": "2.2.18-
|
82
|
-
"@latticexyz/config": "2.2.18-
|
83
|
-
"@latticexyz/
|
84
|
-
"@latticexyz/
|
45
|
+
"@latticexyz/common": "2.2.18-c2ad22c7feb566e1731ff16e8be291746bdffb3e",
|
46
|
+
"@latticexyz/config": "2.2.18-c2ad22c7feb566e1731ff16e8be291746bdffb3e",
|
47
|
+
"@latticexyz/protocol-parser": "2.2.18-c2ad22c7feb566e1731ff16e8be291746bdffb3e",
|
48
|
+
"@latticexyz/schema-type": "2.2.18-c2ad22c7feb566e1731ff16e8be291746bdffb3e"
|
85
49
|
},
|
86
50
|
"devDependencies": {
|
87
51
|
"@types/debug": "^4.1.7",
|
@@ -90,8 +54,8 @@
|
|
90
54
|
"forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1",
|
91
55
|
"solhint": "^3.3.7",
|
92
56
|
"viem": "2.21.19",
|
93
|
-
"@latticexyz/abi-ts": "2.2.18-
|
94
|
-
"@latticexyz/gas-report": "2.2.18-
|
57
|
+
"@latticexyz/abi-ts": "2.2.18-c2ad22c7feb566e1731ff16e8be291746bdffb3e",
|
58
|
+
"@latticexyz/gas-report": "2.2.18-c2ad22c7feb566e1731ff16e8be291746bdffb3e"
|
95
59
|
},
|
96
60
|
"peerDependencies": {
|
97
61
|
"viem": "2.x"
|
package/dist/chunk-Y2IOLXYI.js
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
// ts/storeEvents.ts
|
2
|
-
var helloStoreEvent = "event HelloStore(bytes32 indexed storeVersion)";
|
3
|
-
var storeSetRecordEvent = "event Store_SetRecord(bytes32 indexed tableId, bytes32[] keyTuple, bytes staticData, bytes32 encodedLengths, bytes dynamicData)";
|
4
|
-
var storeSpliceStaticDataEvent = "event Store_SpliceStaticData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, bytes data)";
|
5
|
-
var storeSpliceDynamicDataEvent = "event Store_SpliceDynamicData(bytes32 indexed tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint48 start, uint40 deleteCount, bytes32 encodedLengths, bytes data)";
|
6
|
-
var storeDeleteRecordEvent = "event Store_DeleteRecord(bytes32 indexed tableId, bytes32[] keyTuple)";
|
7
|
-
var storeEvents = [
|
8
|
-
storeSetRecordEvent,
|
9
|
-
storeSpliceStaticDataEvent,
|
10
|
-
storeSpliceDynamicDataEvent,
|
11
|
-
storeDeleteRecordEvent
|
12
|
-
];
|
13
|
-
|
14
|
-
// ts/storeEventsAbi.ts
|
15
|
-
import { parseAbi } from "abitype";
|
16
|
-
var storeEventsAbi = parseAbi(storeEvents);
|
17
|
-
|
18
|
-
export {
|
19
|
-
helloStoreEvent,
|
20
|
-
storeSetRecordEvent,
|
21
|
-
storeSpliceStaticDataEvent,
|
22
|
-
storeSpliceDynamicDataEvent,
|
23
|
-
storeDeleteRecordEvent,
|
24
|
-
storeEvents,
|
25
|
-
storeEventsAbi
|
26
|
-
};
|
27
|
-
//# sourceMappingURL=chunk-Y2IOLXYI.js.map
|