@latticexyz/common 2.0.0-next.16 → 2.0.0-next.18
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/actions.d.ts +11 -0
- package/dist/actions.js +2 -0
- package/dist/actions.js.map +1 -0
- package/dist/chains.d.ts +25 -8
- package/dist/chains.js +1 -1
- package/dist/chains.js.map +1 -1
- package/dist/chunk-6NUUDPWM.js +2 -0
- package/dist/chunk-6NUUDPWM.js.map +1 -0
- package/dist/chunk-PEY5BGLC.js +2 -0
- package/dist/chunk-PEY5BGLC.js.map +1 -0
- package/dist/codegen.d.ts +106 -16
- package/dist/codegen.js +22 -32
- package/dist/codegen.js.map +1 -1
- package/dist/foundry.js.map +1 -1
- package/dist/getContract-93922960.d.ts +20 -0
- package/dist/index.d.ts +15 -14
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/type-utils.d.ts +7 -1
- package/dist/utils.d.ts +1 -4
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +10 -7
- package/src/actions/index.ts +2 -0
- package/src/actions/transactionQueue.ts +14 -0
- package/src/actions/writeObserver.ts +34 -0
- package/src/chains/latticeTestnet.ts +0 -1
- package/src/codegen/render-solidity/common.test.ts +79 -0
- package/src/codegen/render-solidity/common.ts +92 -41
- package/src/codegen/render-solidity/renderEnums.ts +4 -1
- package/src/codegen/render-solidity/renderTypeHelpers.ts +21 -2
- package/src/codegen/render-solidity/types.ts +5 -2
- package/src/codegen/utils/contractToInterface.ts +60 -42
- package/src/codegen/utils/extractUserTypes.ts +8 -1
- package/src/codegen/utils/format.ts +11 -0
- package/src/codegen/utils/formatAndWrite.ts +13 -1
- package/src/codegen/utils/loadUserTypesFile.ts +11 -4
- package/src/foundry/index.ts +1 -1
- package/src/getContract.ts +33 -14
- package/src/hexToResource.ts +3 -2
- package/src/index.ts +1 -0
- package/src/resourceToLabel.test.ts +16 -0
- package/src/resourceToLabel.ts +16 -0
- package/src/sendTransaction.ts +11 -11
- package/src/type-utils/common.ts +3 -0
- package/src/type-utils/evaluate.ts +2 -0
- package/src/type-utils/index.ts +2 -0
- package/src/type-utils/satisfy.ts +1 -0
- package/src/utils/groupBy.ts +1 -1
- package/src/utils/includes.ts +1 -0
- package/src/utils/index.ts +0 -1
- package/src/utils/mapObject.ts +2 -2
- package/src/utils/waitForIdle.ts +5 -1
- package/src/writeContract.ts +19 -15
- package/src/utils/curry.ts +0 -12
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Chain, Account, WalletClient, Transport, WalletActions } from 'viem';
|
|
2
|
+
import { C as ContractWrite } from './getContract-93922960.js';
|
|
3
|
+
|
|
4
|
+
declare function transactionQueue<TChain extends Chain, TAccount extends Account>(): (client: WalletClient<Transport, TChain, TAccount>) => Pick<WalletActions<TChain, TAccount>, "writeContract" | "sendTransaction">;
|
|
5
|
+
|
|
6
|
+
type WriteObserverParameters = {
|
|
7
|
+
onWrite: (write: ContractWrite) => void;
|
|
8
|
+
};
|
|
9
|
+
declare function writeObserver<TChain extends Chain, TAccount extends Account>({ onWrite, }: WriteObserverParameters): (client: WalletClient<Transport, TChain, TAccount>) => Pick<WalletActions<TChain, TAccount>, "writeContract">;
|
|
10
|
+
|
|
11
|
+
export { transactionQueue, writeObserver };
|
package/dist/actions.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{d as i,e as a}from"./chunk-PEY5BGLC.js";import"./chunk-TCWGPC6G.js";function T(){return r=>({writeContract:t=>i(r,t),sendTransaction:t=>a(r,t)})}import{getAction as s}from"viem/utils";import{writeContract as C}from"viem/actions";function d({onWrite:r}){let t=0;return e=>({writeContract:n=>{let o=s(e,C,"writeContract")(n),c=`${e.chain.id}:${e.account.address}:${t++}`;return r({id:c,request:n,result:o}),o}})}export{T as transactionQueue,d as writeObserver};
|
|
2
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/actions/transactionQueue.ts","../src/actions/writeObserver.ts"],"sourcesContent":["import type { Transport, Chain, Account, WalletActions, WalletClient } from \"viem\";\nimport { writeContract as mud_writeContract } from \"../writeContract\";\nimport { sendTransaction as mud_sendTransaction } from \"../sendTransaction\";\n\nexport function transactionQueue<TChain extends Chain, TAccount extends Account>(): (\n client: WalletClient<Transport, TChain, TAccount>,\n) => Pick<WalletActions<TChain, TAccount>, \"writeContract\" | \"sendTransaction\"> {\n return (client) => ({\n // Applies to: `client.writeContract`, `getContract(client, ...).write`\n writeContract: (args) => mud_writeContract(client, args),\n // Applies to: `client.sendTransaction`\n sendTransaction: (args) => mud_sendTransaction(client, args),\n });\n}\n","import type {\n WriteContractParameters,\n Transport,\n Chain,\n Account,\n WalletActions,\n WalletClient,\n WriteContractReturnType,\n} from \"viem\";\nimport { getAction } from \"viem/utils\";\nimport { writeContract } from \"viem/actions\";\nimport { type ContractWrite } from \"../getContract\";\n\ntype WriteObserverParameters = { onWrite: (write: ContractWrite) => void };\n\nexport function writeObserver<TChain extends Chain, TAccount extends Account>({\n onWrite,\n}: WriteObserverParameters): (\n client: WalletClient<Transport, TChain, TAccount>,\n) => Pick<WalletActions<TChain, TAccount>, \"writeContract\"> {\n let nextWriteId = 0;\n\n return (client) => ({\n // Applies to: `client.writeContract`, `getContract(client, ...).write`\n writeContract: (args): Promise<WriteContractReturnType> => {\n const result = getAction(client, writeContract, \"writeContract\")(args);\n\n const id = `${client.chain.id}:${client.account.address}:${nextWriteId++}`;\n onWrite({ id, request: args as WriteContractParameters, result });\n\n return result;\n },\n });\n}\n"],"mappings":"2EAIO,SAASA,GAEgE,CAC9E,OAAQC,IAAY,CAElB,cAAgBC,GAASC,EAAkBF,EAAQC,CAAI,EAEvD,gBAAkBA,GAASE,EAAoBH,EAAQC,CAAI,CAC7D,EACF,CCJA,OAAS,aAAAG,MAAiB,aAC1B,OAAS,iBAAAC,MAAqB,eAKvB,SAASC,EAA8D,CAC5E,QAAAC,CACF,EAE4D,CAC1D,IAAIC,EAAc,EAElB,OAAQC,IAAY,CAElB,cAAgBC,GAA2C,CACzD,IAAMC,EAASP,EAAUK,EAAQJ,EAAe,eAAe,EAAEK,CAAI,EAE/DE,EAAK,GAAGH,EAAO,MAAM,MAAMA,EAAO,QAAQ,WAAWD,MAC3D,OAAAD,EAAQ,CAAE,GAAAK,EAAI,QAASF,EAAiC,OAAAC,CAAO,CAAC,EAEzDA,CACT,CACF,EACF","names":["transactionQueue","client","args","writeContract","sendTransaction","getAction","writeContract","writeObserver","onWrite","nextWriteId","client","args","result","id"]}
|
package/dist/chains.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ type MUDChain = Chain & {
|
|
|
8
8
|
declare const latticeTestnet: {
|
|
9
9
|
readonly name: "Lattice Testnet";
|
|
10
10
|
readonly id: 4242;
|
|
11
|
-
readonly network: "lattice-testnet";
|
|
12
11
|
readonly nativeCurrency: {
|
|
13
12
|
readonly decimals: 18;
|
|
14
13
|
readonly name: "Ether";
|
|
@@ -37,9 +36,28 @@ declare const mudFoundry: {
|
|
|
37
36
|
readonly fees: {
|
|
38
37
|
readonly defaultPriorityFee: () => bigint;
|
|
39
38
|
};
|
|
39
|
+
readonly blockExplorers?: {
|
|
40
|
+
[key: string]: {
|
|
41
|
+
name: string;
|
|
42
|
+
url: string;
|
|
43
|
+
apiUrl?: string | undefined;
|
|
44
|
+
};
|
|
45
|
+
default: {
|
|
46
|
+
name: string;
|
|
47
|
+
url: string;
|
|
48
|
+
apiUrl?: string | undefined;
|
|
49
|
+
};
|
|
50
|
+
} | undefined;
|
|
51
|
+
readonly contracts?: {
|
|
52
|
+
[x: string]: viem.ChainContract | {
|
|
53
|
+
[sourceId: number]: viem.ChainContract | undefined;
|
|
54
|
+
} | undefined;
|
|
55
|
+
ensRegistry?: viem.ChainContract | undefined;
|
|
56
|
+
ensUniversalResolver?: viem.ChainContract | undefined;
|
|
57
|
+
multicall3?: viem.ChainContract | undefined;
|
|
58
|
+
} | undefined;
|
|
40
59
|
readonly id: 31337;
|
|
41
60
|
readonly name: "Foundry";
|
|
42
|
-
readonly network: "foundry";
|
|
43
61
|
readonly nativeCurrency: {
|
|
44
62
|
readonly decimals: 18;
|
|
45
63
|
readonly name: "Ether";
|
|
@@ -50,13 +68,12 @@ declare const mudFoundry: {
|
|
|
50
68
|
readonly http: readonly ["http://127.0.0.1:8545"];
|
|
51
69
|
readonly webSocket: readonly ["ws://127.0.0.1:8545"];
|
|
52
70
|
};
|
|
53
|
-
readonly public: {
|
|
54
|
-
readonly http: readonly ["http://127.0.0.1:8545"];
|
|
55
|
-
readonly webSocket: readonly ["ws://127.0.0.1:8545"];
|
|
56
|
-
};
|
|
57
71
|
};
|
|
58
|
-
readonly
|
|
59
|
-
readonly
|
|
72
|
+
readonly sourceId?: number | undefined;
|
|
73
|
+
readonly testnet?: boolean | undefined;
|
|
74
|
+
readonly custom?: Record<string, unknown> | undefined;
|
|
75
|
+
readonly formatters?: undefined;
|
|
76
|
+
readonly serializers?: viem.ChainSerializers<undefined> | undefined;
|
|
60
77
|
};
|
|
61
78
|
|
|
62
79
|
export { MUDChain, latticeTestnet, mudFoundry };
|
package/dist/chains.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var t={name:"Lattice Testnet",id:4242,
|
|
1
|
+
var t={name:"Lattice Testnet",id:4242,nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://follower.testnet-chain.linfra.xyz"],webSocket:["wss://follower.testnet-chain.linfra.xyz"]},public:{http:["https://follower.testnet-chain.linfra.xyz"],webSocket:["wss://follower.testnet-chain.linfra.xyz"]}},blockExplorers:{default:{name:"Otterscan",url:"https://explorer.testnet-chain.linfra.xyz"}},faucetUrl:"https://faucet.testnet-mud-services.linfra.xyz"};import{foundry as e}from"viem/chains";var r={...e,fees:{defaultPriorityFee:()=>0n}};export{t as latticeTestnet,r as mudFoundry};
|
|
2
2
|
//# sourceMappingURL=chains.js.map
|
package/dist/chains.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/chains/latticeTestnet.ts","../src/chains/mudFoundry.ts"],"sourcesContent":["import type { MUDChain } from \"./types\";\n\nexport const latticeTestnet = {\n name: \"Lattice Testnet\",\n id: 4242,\n
|
|
1
|
+
{"version":3,"sources":["../src/chains/latticeTestnet.ts","../src/chains/mudFoundry.ts"],"sourcesContent":["import type { MUDChain } from \"./types\";\n\nexport const latticeTestnet = {\n name: \"Lattice Testnet\",\n id: 4242,\n nativeCurrency: { decimals: 18, name: \"Ether\", symbol: \"ETH\" },\n rpcUrls: {\n default: {\n http: [\"https://follower.testnet-chain.linfra.xyz\"],\n webSocket: [\"wss://follower.testnet-chain.linfra.xyz\"],\n },\n public: {\n http: [\"https://follower.testnet-chain.linfra.xyz\"],\n webSocket: [\"wss://follower.testnet-chain.linfra.xyz\"],\n },\n },\n blockExplorers: {\n default: {\n name: \"Otterscan\",\n url: \"https://explorer.testnet-chain.linfra.xyz\",\n },\n },\n faucetUrl: \"https://faucet.testnet-mud-services.linfra.xyz\",\n} as const satisfies MUDChain;\n","import { foundry } from \"viem/chains\";\nimport { MUDChain } from \"./types\";\n\nexport const mudFoundry = {\n ...foundry,\n fees: {\n // This is intentionally defined as a function as a workaround for https://github.com/wagmi-dev/viem/pull/1280\n defaultPriorityFee: () => 0n,\n },\n} as const satisfies MUDChain;\n"],"mappings":"AAEO,IAAMA,EAAiB,CAC5B,KAAM,kBACN,GAAI,KACJ,eAAgB,CAAE,SAAU,GAAI,KAAM,QAAS,OAAQ,KAAM,EAC7D,QAAS,CACP,QAAS,CACP,KAAM,CAAC,2CAA2C,EAClD,UAAW,CAAC,yCAAyC,CACvD,EACA,OAAQ,CACN,KAAM,CAAC,2CAA2C,EAClD,UAAW,CAAC,yCAAyC,CACvD,CACF,EACA,eAAgB,CACd,QAAS,CACP,KAAM,YACN,IAAK,2CACP,CACF,EACA,UAAW,gDACb,ECvBA,OAAS,WAAAC,MAAe,cAGjB,IAAMC,EAAa,CACxB,GAAGD,EACH,KAAM,CAEJ,mBAAoB,IAAM,EAC5B,CACF","names":["latticeTestnet","foundry","mudFoundry"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var m=["table","offchainTable","namespace","module","system"];import{stringToHex as s,concatHex as u}from"viem";var o={table:"tb",offchainTable:"ot",namespace:"ns",module:"md",system:"sy"};function x(e){let r=o[e.type];return u([s(r,{size:2}),s(e.namespace.slice(0,14),{size:14}),s(e.name.slice(0,16),{size:16})])}var y="";function i({namespace:e,name:r}){return e===y?r:`${e}__${r}`}import{hexToString as t,sliceHex as n}from"viem";var f=Object.fromEntries(Object.entries(o).map(([e,r])=>[r,e]));function T(e){let r=f[e];if(m.includes(r))return r}function z(e){let r=t(n(e,0,2)).replace(/\0+$/,""),c=T(r),a=t(n(e,2,16)).replace(/\0+$/,""),p=t(n(e,16,32)).replace(/\0+$/,"");if(!c)throw new Error(`Unknown type (${r}) for resource (${i({namespace:a,name:p})})`);return{resourceId:e,type:c,namespace:a,name:p}}export{m as a,o as b,x as c,i as d,z as e};
|
|
2
|
+
//# sourceMappingURL=chunk-6NUUDPWM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resourceTypes.ts","../src/resourceToHex.ts","../src/resourceToLabel.ts","../src/hexToResource.ts"],"sourcesContent":["export const resourceTypes = [\"table\", \"offchainTable\", \"namespace\", \"module\", \"system\"] as const;\n\nexport type ResourceType = (typeof resourceTypes)[number];\n","import { Hex, stringToHex, concatHex } from \"viem\";\nimport { Resource } from \"./common\";\nimport { ResourceType } from \"./resourceTypes\";\n\n/** @internal */\nexport const resourceTypeIds = {\n // keep these in sync with storeResourceTypes.sol\n table: \"tb\",\n offchainTable: \"ot\",\n // keep these in sync with worldResourceTypes.sol\n namespace: \"ns\",\n module: \"md\",\n system: \"sy\",\n} as const satisfies Record<ResourceType, string>;\n\nexport function resourceToHex(resource: Omit<Resource, \"resourceId\">): Hex {\n const typeId = resourceTypeIds[resource.type];\n return concatHex([\n stringToHex(typeId, { size: 2 }),\n stringToHex(resource.namespace.slice(0, 14), { size: 14 }),\n stringToHex(resource.name.slice(0, 16), { size: 16 }),\n ]);\n}\n","const rootNamespace = \"\";\n\nexport type ResourceLabel<\n namespace extends string = string,\n name extends string = string,\n> = namespace extends typeof rootNamespace ? name : `${namespace}__${name}`;\n\nexport function resourceToLabel<namespace extends string, name extends string>({\n namespace,\n name,\n}: {\n readonly namespace: namespace;\n readonly name: name;\n}): ResourceLabel<namespace, name> {\n return (namespace === rootNamespace ? name : `${namespace}__${name}`) as ResourceLabel<namespace, name>;\n}\n","import { Hex, hexToString, sliceHex } from \"viem\";\nimport { Resource } from \"./common\";\nimport { ResourceType, resourceTypes } from \"./resourceTypes\";\nimport { resourceTypeIds } from \"./resourceToHex\";\nimport { ReverseMap } from \"./type-utils/common\";\nimport { resourceToLabel } from \"./resourceToLabel\";\n\nconst resourceTypeIdToType = Object.fromEntries(\n Object.entries(resourceTypeIds).map(([key, value]) => [value, key]),\n) as ReverseMap<typeof resourceTypeIds>;\n\nfunction getResourceType(resourceTypeId: string): ResourceType | undefined {\n // TODO: replace Partial with `noUncheckedIndexedAccess`\n const type = (resourceTypeIdToType as Partial<Record<string, ResourceType>>)[resourceTypeId];\n if (resourceTypes.includes(type as ResourceType)) {\n return type;\n }\n}\n\nexport function hexToResource(hex: Hex): Resource {\n const resourceTypeId = hexToString(sliceHex(hex, 0, 2)).replace(/\\0+$/, \"\");\n const type = getResourceType(resourceTypeId);\n const namespace = hexToString(sliceHex(hex, 2, 16)).replace(/\\0+$/, \"\");\n const name = hexToString(sliceHex(hex, 16, 32)).replace(/\\0+$/, \"\");\n\n if (!type) {\n throw new Error(`Unknown type (${resourceTypeId}) for resource (${resourceToLabel({ namespace, name })})`);\n }\n\n return { resourceId: hex, type, namespace, name };\n}\n"],"mappings":"AAAO,IAAMA,EAAgB,CAAC,QAAS,gBAAiB,YAAa,SAAU,QAAQ,ECAvF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CAAK,CAAC,IAAI,EAG3G,MAAO,CAAE,WAAYJ,EAAK,KAAAH,EAAM,UAAAM,EAAW,KAAAC,CAAK,CAClD","names":["resourceTypes","stringToHex","concatHex","resourceTypeIds","resourceToHex","resource","typeId","rootNamespace","resourceToLabel","namespace","name","hexToString","sliceHex","resourceTypeIdToType","resourceTypeIds","key","value","getResourceType","resourceTypeId","type","resourceTypes","hexToResource","hex","hexToString","sliceHex","namespace","name","resourceToLabel"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as u}from"./chunk-TCWGPC6G.js";import{getAddress as y}from"viem";import{getChainId as M}from"viem/actions";async function m({client:a,address:n,blockTag:r}){return`mud:createNonceManager:${a.chain?.id??await M(a)}:${y(n)}:${r}`}import{BaseError as P,NonceTooHighError as v,NonceTooLowError as A}from"viem";import{getTransactionCount as O}from"viem/actions";import R from"p-queue";var h=u.extend("createNonceManager");function C({client:a,address:n,blockTag:r="pending",broadcastChannelName:o}){let e={current:-1},c=null;typeof BroadcastChannel<"u"&&(o?Promise.resolve(o):m({client:a,address:n,blockTag:r})).then(d=>{c=new BroadcastChannel(d),c.addEventListener("message",x=>{let N=JSON.parse(x.data);h("got nonce from broadcast channel",N),e.current=N})});function t(){return e.current>=0}function i(){if(!t())throw new Error("call resetNonce before using nextNonce");let s=e.current++;return c?.postMessage(JSON.stringify(e.current)),s}async function l(){let s=await O(a,{address:n,blockTag:r});e.current=s,c?.postMessage(JSON.stringify(e.current)),h("reset nonce to",e.current)}function w(s){return s instanceof P&&s.walk(d=>d instanceof A||d instanceof v)!=null}let b=new R({concurrency:1});return{hasNonce:t,nextNonce:i,resetNonce:l,shouldResetNonce:w,mempoolQueue:b}}var T=new Map;async function g({client:a,address:n,blockTag:r="pending"}){let o=await m({client:a,address:n,blockTag:r}),e=T.get(o);if(e)return e;let c=C({client:a,address:n,blockTag:r});return T.set(o,c),c}import{simulateContract as k,writeContract as S}from"viem/actions";import W from"p-retry";import{parseAccount as B}from"viem/accounts";var p=u.extend("writeContract");async function dn(a,n){let r=n.account??a.account;if(!r)throw new Error("No account provided");let o=B(r),e=await g({client:a,address:o.address,blockTag:"pending"});async function c(){return n.gas?(p("gas provided, skipping simulate",n.functionName,n.address),n):(p("simulating",n.functionName,"at",n.address),(await k(a,{...n,blockTag:"pending",account:o})).request)}return e.mempoolQueue.add(()=>W(async()=>{let t=await c();e.hasNonce()||await e.resetNonce();let i=e.nextNonce();return p("calling",t.functionName,"with nonce",i,"at",t.address),await S(a,{nonce:i,...t})},{retries:3,onFailedAttempt:async t=>{if(e.shouldResetNonce(t)){p("got nonce error, retrying",t.message),await e.resetNonce();return}throw t}}),{throwOnTimeout:!0})}import{call as E,sendTransaction as F}from"viem/actions";import I from"p-retry";import{parseAccount as Q}from"viem/accounts";var f=u.extend("sendTransaction");async function hn(a,n){let r=n.account??a.account;if(!r)throw new Error("No account provided");let o=Q(r),e=await g({client:a,address:o.address,blockTag:"pending"});async function c(){return n.gas?(f("gas provided, skipping simulate",n.to),n):(f("simulating tx to",n.to),await E(a,{...n,blockTag:"pending",account:o}),n)}return await e.mempoolQueue.add(()=>I(async()=>{let t=await c();e.hasNonce()||await e.resetNonce();let i=e.nextNonce();f("sending tx with nonce",i,"to",t.to);let l={nonce:i,...t};return await F(a,l)},{retries:3,onFailedAttempt:async t=>{if(e.shouldResetNonce(t)){f("got nonce error, retrying",t.message),await e.resetNonce();return}throw t}}),{throwOnTimeout:!0})}export{m as a,C as b,g as c,dn as d,hn as e};
|
|
2
|
+
//# sourceMappingURL=chunk-PEY5BGLC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/getNonceManagerId.ts","../src/createNonceManager.ts","../src/getNonceManager.ts","../src/writeContract.ts","../src/sendTransaction.ts"],"sourcesContent":["import { BlockTag, Client, Hex, getAddress } from \"viem\";\nimport { getChainId } from \"viem/actions\";\n\nexport async function getNonceManagerId({\n client,\n address,\n blockTag,\n}: {\n client: Client;\n address: Hex;\n blockTag: BlockTag;\n}): Promise<string> {\n // TODO: improve this so we don't have to call getChainId every time\n const chainId = client.chain?.id ?? (await getChainId(client));\n return `mud:createNonceManager:${chainId}:${getAddress(address)}:${blockTag}`;\n}\n","import { BaseError, BlockTag, Client, Hex, NonceTooHighError, NonceTooLowError } from \"viem\";\nimport { debug as parentDebug } from \"./debug\";\nimport { getNonceManagerId } from \"./getNonceManagerId\";\nimport { getTransactionCount } from \"viem/actions\";\nimport PQueue from \"p-queue\";\n\nconst debug = parentDebug.extend(\"createNonceManager\");\n\nexport type CreateNonceManagerOptions = {\n client: Client;\n address: Hex;\n blockTag?: BlockTag;\n broadcastChannelName?: string;\n};\n\nexport type CreateNonceManagerResult = {\n hasNonce: () => boolean;\n nextNonce: () => number;\n resetNonce: () => Promise<void>;\n shouldResetNonce: (error: unknown) => boolean;\n mempoolQueue: PQueue;\n};\n\nexport function createNonceManager({\n client,\n address, // TODO: rename to account?\n blockTag = \"pending\",\n broadcastChannelName,\n}: CreateNonceManagerOptions): CreateNonceManagerResult {\n const nonceRef = { current: -1 };\n let channel: BroadcastChannel | null = null;\n\n if (typeof BroadcastChannel !== \"undefined\") {\n const channelName = broadcastChannelName\n ? Promise.resolve(broadcastChannelName)\n : getNonceManagerId({ client, address, blockTag });\n channelName.then((name) => {\n channel = new BroadcastChannel(name);\n // TODO: emit some sort of \"connected\" event so other channels can broadcast current nonce\n channel.addEventListener(\"message\", (event) => {\n const nonce = JSON.parse(event.data);\n debug(\"got nonce from broadcast channel\", nonce);\n nonceRef.current = nonce;\n });\n });\n }\n\n function hasNonce(): boolean {\n return nonceRef.current >= 0;\n }\n\n function nextNonce(): number {\n if (!hasNonce()) throw new Error(\"call resetNonce before using nextNonce\");\n const nonce = nonceRef.current++;\n channel?.postMessage(JSON.stringify(nonceRef.current));\n return nonce;\n }\n\n async function resetNonce(): Promise<void> {\n const nonce = await getTransactionCount(client, { address, blockTag });\n nonceRef.current = nonce;\n channel?.postMessage(JSON.stringify(nonceRef.current));\n debug(\"reset nonce to\", nonceRef.current);\n }\n\n function shouldResetNonce(error: unknown): boolean {\n return (\n error instanceof BaseError &&\n error.walk((e) => e instanceof NonceTooLowError || e instanceof NonceTooHighError) != null\n );\n }\n\n const mempoolQueue = new PQueue({ concurrency: 1 });\n\n return {\n hasNonce,\n nextNonce,\n resetNonce,\n shouldResetNonce,\n mempoolQueue,\n };\n}\n","import { CreateNonceManagerOptions, CreateNonceManagerResult, createNonceManager } from \"./createNonceManager\";\nimport { getNonceManagerId } from \"./getNonceManagerId\";\n\nconst nonceManagers = new Map<string, CreateNonceManagerResult>();\n\nexport async function getNonceManager({\n client,\n address, // TODO: rename to account?\n blockTag = \"pending\",\n}: CreateNonceManagerOptions): Promise<CreateNonceManagerResult> {\n const id = await getNonceManagerId({ client, address, blockTag });\n\n const existingNonceManager = nonceManagers.get(id);\n if (existingNonceManager) {\n return existingNonceManager;\n }\n\n const nonceManager = createNonceManager({ client, address, blockTag });\n nonceManagers.set(id, nonceManager);\n return nonceManager;\n}\n","import {\n Abi,\n Account,\n Chain,\n Client,\n SimulateContractParameters,\n Transport,\n WriteContractParameters,\n WriteContractReturnType,\n ContractFunctionName,\n ContractFunctionArgs,\n} from \"viem\";\nimport { simulateContract, writeContract as viem_writeContract } from \"viem/actions\";\nimport pRetry from \"p-retry\";\nimport { debug as parentDebug } from \"./debug\";\nimport { getNonceManager } from \"./getNonceManager\";\nimport { parseAccount } from \"viem/accounts\";\n\nconst debug = parentDebug.extend(\"writeContract\");\n\n// TODO: migrate away from this approach once we can hook into viem's nonce management: https://github.com/wagmi-dev/viem/discussions/1230\n\n/** @deprecated Use `walletClient.extend(transactionQueue())` instead. */\nexport async function writeContract<\n chain extends Chain | undefined,\n account extends Account | undefined,\n abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, \"nonpayable\" | \"payable\">,\n args extends ContractFunctionArgs<abi, \"nonpayable\" | \"payable\", functionName>,\n chainOverride extends Chain | undefined,\n>(\n client: Client<Transport, chain, account>,\n request: WriteContractParameters<abi, functionName, args, chain, account, chainOverride>,\n): Promise<WriteContractReturnType> {\n const rawAccount = request.account ?? client.account;\n if (!rawAccount) {\n // TODO: replace with viem AccountNotFoundError once its exported\n throw new Error(\"No account provided\");\n }\n const account = parseAccount(rawAccount);\n\n const nonceManager = await getNonceManager({\n client,\n address: account.address,\n blockTag: \"pending\",\n });\n\n async function prepareWrite(): Promise<\n WriteContractParameters<abi, functionName, args, chain, account, chainOverride>\n > {\n if (request.gas) {\n debug(\"gas provided, skipping simulate\", request.functionName, request.address);\n return request;\n }\n\n debug(\"simulating\", request.functionName, \"at\", request.address);\n const result = await simulateContract<chain, account, abi, functionName, args, chainOverride>(client, {\n ...request,\n blockTag: \"pending\",\n account,\n } as unknown as SimulateContractParameters<abi, functionName, args, chain, chainOverride>);\n\n return result.request as unknown as WriteContractParameters<abi, functionName, args, chain, account, chainOverride>;\n }\n\n return nonceManager.mempoolQueue.add(\n () =>\n pRetry(\n async () => {\n const preparedWrite = await prepareWrite();\n\n if (!nonceManager.hasNonce()) {\n await nonceManager.resetNonce();\n }\n\n const nonce = nonceManager.nextNonce();\n debug(\"calling\", preparedWrite.functionName, \"with nonce\", nonce, \"at\", preparedWrite.address);\n return await viem_writeContract(client, { nonce, ...preparedWrite } as typeof preparedWrite);\n },\n {\n retries: 3,\n onFailedAttempt: async (error) => {\n // On nonce errors, reset the nonce and retry\n if (nonceManager.shouldResetNonce(error)) {\n debug(\"got nonce error, retrying\", error.message);\n await nonceManager.resetNonce();\n return;\n }\n // TODO: prepareWrite again if there are gas errors?\n throw error;\n },\n },\n ),\n { throwOnTimeout: true },\n );\n}\n","import {\n Account,\n CallParameters,\n Chain,\n Client,\n SendTransactionParameters,\n Transport,\n SendTransactionReturnType,\n} from \"viem\";\nimport { call, sendTransaction as viem_sendTransaction } from \"viem/actions\";\nimport pRetry from \"p-retry\";\nimport { debug as parentDebug } from \"./debug\";\nimport { getNonceManager } from \"./getNonceManager\";\nimport { parseAccount } from \"viem/accounts\";\n\nconst debug = parentDebug.extend(\"sendTransaction\");\n\n// TODO: migrate away from this approach once we can hook into viem's nonce management: https://github.com/wagmi-dev/viem/discussions/1230\n\n/** @deprecated Use `walletClient.extend(transactionQueue())` instead. */\nexport async function sendTransaction<\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n TChainOverride extends Chain | undefined,\n>(\n client: Client<Transport, TChain, TAccount>,\n request: SendTransactionParameters<TChain, TAccount, TChainOverride>,\n): Promise<SendTransactionReturnType> {\n const rawAccount = request.account ?? client.account;\n if (!rawAccount) {\n // TODO: replace with viem AccountNotFoundError once its exported\n throw new Error(\"No account provided\");\n }\n const account = parseAccount(rawAccount);\n\n const nonceManager = await getNonceManager({\n client,\n address: account.address,\n blockTag: \"pending\",\n });\n\n async function prepare(): Promise<SendTransactionParameters<TChain, TAccount, TChainOverride>> {\n if (request.gas) {\n debug(\"gas provided, skipping simulate\", request.to);\n return request;\n }\n\n debug(\"simulating tx to\", request.to);\n await call(client, {\n ...request,\n blockTag: \"pending\",\n account,\n } as CallParameters<TChain>);\n\n return request;\n }\n\n return await nonceManager.mempoolQueue.add(\n () =>\n pRetry(\n async () => {\n const preparedRequest = await prepare();\n\n if (!nonceManager.hasNonce()) {\n await nonceManager.resetNonce();\n }\n\n const nonce = nonceManager.nextNonce();\n debug(\"sending tx with nonce\", nonce, \"to\", preparedRequest.to);\n const parameters: SendTransactionParameters<TChain, TAccount, TChainOverride> = { nonce, ...preparedRequest };\n return await viem_sendTransaction(client, parameters);\n },\n {\n retries: 3,\n onFailedAttempt: async (error) => {\n // On nonce errors, reset the nonce and retry\n if (nonceManager.shouldResetNonce(error)) {\n debug(\"got nonce error, retrying\", error.message);\n await nonceManager.resetNonce();\n return;\n }\n // TODO: prepare again if there are gas errors?\n throw error;\n },\n },\n ),\n { throwOnTimeout: true },\n );\n}\n"],"mappings":"wCAAA,OAAgC,cAAAA,MAAkB,OAClD,OAAS,cAAAC,MAAkB,eAE3B,eAAsBC,EAAk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Aa,SAAS,GACzB,MAAMA,EAAa,WAAW,EAGhC,IAAMM,EAAQN,EAAa,UAAU,EACrCN,EAAM,wBAAyBY,EAAO,KAAMD,EAAgB,EAAE,EAC9D,IAAME,EAA0E,CAAE,MAAAD,EAAO,GAAGD,CAAgB,EAC5G,OAAO,MAAMG,EAAqBZ,EAAQW,CAAU,CACtD,EACA,CACE,QAAS,EACT,gBAAiB,MAAOE,GAAU,CAEhC,GAAIT,EAAa,iBAAiBS,CAAK,EAAG,CACxCf,EAAM,4BAA6Be,EAAM,OAAO,EAChD,MAAMT,EAAa,WAAW,EAC9B,OAGF,MAAMS,CACR,CACF,CACF,EACF,CAAE,eAAgB,EAAK,CACzB,CACF","names":["getAddress","getChainId","getNonceManagerId","client","address","blockTag","BaseError","NonceTooHighError","NonceTooLowError","getTransactionCount","PQueue","debug","createNonceManager","client","address","blockTag","broadcastChannelName","nonceRef","channel","getNonceManagerId","name","event","nonce","hasNonce","nextNonce","resetNonce","shouldResetNonce","error","BaseError","e","NonceTooLowError","NonceTooHighError","mempoolQueue","nonceManagers","getNonceManager","client","address","blockTag","id","getNonceManagerId","existingNonceManager","nonceManager","createNonceManager","simulateContract","viem_writeContract","pRetry","parseAccount","debug","writeContract","client","request","rawAccount","account","nonceManager","getNonceManager","prepareWrite","simulateContract","pRetry","preparedWrite","nonce","viem_writeContract","error","call","viem_sendTransaction","pRetry","parseAccount","debug","sendTransaction","client","request","rawAccount","account","nonceManager","getNonceManager","prepare","call","pRetry","preparedRequest","nonce","parameters","viem_sendTransaction","error"]}
|
package/dist/codegen.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SchemaType } from '@latticexyz/schema-type/deprecated';
|
|
2
|
-
import { SchemaAbiType } from '@latticexyz/schema-type';
|
|
2
|
+
import { SchemaAbiType } from '@latticexyz/schema-type/internal';
|
|
3
3
|
|
|
4
4
|
declare module "prettier-plugin-solidity" {}
|
|
5
5
|
|
|
@@ -14,14 +14,17 @@ interface RelativeImportDatum {
|
|
|
14
14
|
}
|
|
15
15
|
type ImportDatum = AbsoluteImportDatum | RelativeImportDatum;
|
|
16
16
|
interface StaticResourceData {
|
|
17
|
-
/**
|
|
18
|
-
tableIdName: string;
|
|
17
|
+
/** Table namespace string */
|
|
19
18
|
namespace: string;
|
|
19
|
+
/** Table name string */
|
|
20
20
|
name: string;
|
|
21
|
+
/** Whether the table is offchain only (does not use storage) */
|
|
21
22
|
offchainOnly: boolean;
|
|
22
23
|
}
|
|
23
24
|
interface RenderType {
|
|
25
|
+
/** Fully-qualified name of the user-defined type (may include a library name as prefix) */
|
|
24
26
|
typeId: string;
|
|
27
|
+
/** Fully-qualified name of the user-defined type (may include a library name as prefix), followed by location (none/memory/storage) */
|
|
25
28
|
typeWithLocation: string;
|
|
26
29
|
/** The name of the enum element in SchemaType to use for schema registration (e.g. "UINT256_ARRAY") */
|
|
27
30
|
enumName: string;
|
|
@@ -60,7 +63,10 @@ interface RenderEnum {
|
|
|
60
63
|
memberNames: string[];
|
|
61
64
|
}
|
|
62
65
|
|
|
63
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Common header for all codegenerated solidity files
|
|
68
|
+
*/
|
|
69
|
+
declare const renderedSolidityHeader = "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.24;\n\n/* Autogenerated file. Do not edit manually. */";
|
|
64
70
|
/**
|
|
65
71
|
* Renders a list of lines
|
|
66
72
|
*/
|
|
@@ -69,14 +75,24 @@ declare function renderList<T>(list: T[], renderItem: (item: T, index: number) =
|
|
|
69
75
|
* Renders a comma-separated list of arguments for solidity functions, ignoring empty and undefined ones
|
|
70
76
|
*/
|
|
71
77
|
declare function renderArguments(args: (string | undefined)[]): string;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
keyTuple: RenderKeyTuple[];
|
|
75
|
-
}): {
|
|
78
|
+
interface RenderedCommonData {
|
|
79
|
+
/** `_tableId` variable prefixed with its type (empty string if absent) */
|
|
76
80
|
_typedTableId: string;
|
|
81
|
+
/** Comma-separated table key names prefixed with their types (empty string if 0 keys) */
|
|
77
82
|
_typedKeyArgs: string;
|
|
83
|
+
/** Definition and initialization of the dynamic `_keyTuple` bytes32 array */
|
|
78
84
|
_keyTupleDefinition: string;
|
|
79
|
-
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Renders some solidity statements commonly used within table libraries
|
|
88
|
+
* @param param0.staticResourceData static data about the table library
|
|
89
|
+
* @param param0.keyTuple key tuple of the table library
|
|
90
|
+
* @returns Rendered statement strings
|
|
91
|
+
*/
|
|
92
|
+
declare function renderCommonData({ staticResourceData, keyTuple, }: {
|
|
93
|
+
staticResourceData?: StaticResourceData;
|
|
94
|
+
keyTuple: RenderKeyTuple[];
|
|
95
|
+
}): RenderedCommonData;
|
|
80
96
|
/** For 2 paths which are relative to a common root, create a relative import path from one to another */
|
|
81
97
|
declare function solidityRelativeImportPath(fromPath: string, usedInPath: string): string;
|
|
82
98
|
/**
|
|
@@ -94,24 +110,61 @@ declare function renderRelativeImports(imports: RelativeImportDatum[]): string;
|
|
|
94
110
|
* Identical symbols from different paths are NOT handled, they should be checked before rendering.
|
|
95
111
|
*/
|
|
96
112
|
declare function renderAbsoluteImports(imports: AbsoluteImportDatum[]): string;
|
|
97
|
-
|
|
113
|
+
interface RenderWithStoreCallbackData {
|
|
114
|
+
/** `_store` variable prefixed with its type (undefined if library name) */
|
|
98
115
|
_typedStore: string | undefined;
|
|
116
|
+
/** `_store` variable (undefined if library name) */
|
|
99
117
|
_store: string;
|
|
118
|
+
/** Empty string if storeArgument is false, otherwise `" (using the specified store)"` */
|
|
100
119
|
_commentSuffix: string;
|
|
120
|
+
/** Prefix to differentiate different kinds of store usage within methods */
|
|
101
121
|
_methodNamePrefix: string;
|
|
122
|
+
/** Whether FieldLayout variable should be passed to store methods */
|
|
102
123
|
_useExplicitFieldLayout?: boolean;
|
|
103
|
-
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Renders several versions of the callback's result, which access Store in different ways
|
|
127
|
+
* @param storeArgument whether to render a version with `IStore _store` as an argument
|
|
128
|
+
* @param callback renderer for a method which uses store
|
|
129
|
+
* @returns Concatenated results of all callback calls
|
|
130
|
+
*/
|
|
131
|
+
declare function renderWithStore(storeArgument: boolean, callback: (data: RenderWithStoreCallbackData) => string): string;
|
|
132
|
+
/**
|
|
133
|
+
* Renders several versions of the callback's result, which have different method name suffixes
|
|
134
|
+
* @param withSuffixlessFieldMethods whether to render methods with an empty suffix
|
|
135
|
+
* @param fieldName name of the field which the methods access, used for a suffix
|
|
136
|
+
* @param callback renderer for a method to be suffixed
|
|
137
|
+
* @returns Concatenated results of all callback calls
|
|
138
|
+
*/
|
|
104
139
|
declare function renderWithFieldSuffix(withSuffixlessFieldMethods: boolean, fieldName: string, callback: (_methodNameSuffix: string) => string): string;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
declare function
|
|
140
|
+
/**
|
|
141
|
+
* Renders `_tableId` definition of the given table.
|
|
142
|
+
* @param param0 static resource data needed to construct the table ID
|
|
143
|
+
*/
|
|
144
|
+
declare function renderTableId({ namespace, name, offchainOnly, }: Pick<StaticResourceData, "namespace" | "name" | "offchainOnly">): string;
|
|
145
|
+
/**
|
|
146
|
+
* Renders solidity typecasts to get from the given type to `bytes32`
|
|
147
|
+
* @param name variable name to be typecasted
|
|
148
|
+
* @param param1 type data
|
|
149
|
+
*/
|
|
150
|
+
declare function renderValueTypeToBytes32(name: string, { typeUnwrap, internalTypeId }: Pick<RenderType, "typeUnwrap" | "internalTypeId">): string;
|
|
151
|
+
/**
|
|
152
|
+
* Whether the storage representation of the given solidity type is left aligned
|
|
153
|
+
*/
|
|
110
154
|
declare function isLeftAligned(field: Pick<RenderType, "internalTypeId">): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* The number of padding bits in the storage representation of a right-aligned solidity type
|
|
157
|
+
*/
|
|
111
158
|
declare function getLeftPaddingBits(field: Pick<RenderType, "internalTypeId" | "staticByteLength">): number;
|
|
112
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Render a list of enum data as solidity enum definitions
|
|
162
|
+
*/
|
|
113
163
|
declare function renderEnums(enums: RenderEnum[]): string;
|
|
114
164
|
|
|
165
|
+
/**
|
|
166
|
+
* Renders the necessary helper functions to typecast to/from the types of given fields and keys
|
|
167
|
+
*/
|
|
115
168
|
declare function renderTypeHelpers(options: {
|
|
116
169
|
fields: RenderField[];
|
|
117
170
|
keyTuple: RenderKeyTuple[];
|
|
@@ -147,29 +200,66 @@ declare function contractToInterface(data: string, contractName: string): {
|
|
|
147
200
|
};
|
|
148
201
|
|
|
149
202
|
interface SolidityUserDefinedType {
|
|
203
|
+
/** Fully-qualified name of the user-defined type (may include a library name as prefix) */
|
|
150
204
|
typeId: string;
|
|
205
|
+
/** Name of the wrapped primitive type */
|
|
151
206
|
internalTypeId: string;
|
|
207
|
+
/** Symbol which must be imported to use the type (either the type name, or the library name where the type is defined) */
|
|
152
208
|
importSymbol: string;
|
|
209
|
+
/** Path to the solidity file which contains the user type */
|
|
153
210
|
fromPath: string;
|
|
211
|
+
/** Whether `fromPath` is relative */
|
|
154
212
|
isRelativePath: boolean;
|
|
155
213
|
}
|
|
156
214
|
/**
|
|
157
215
|
* Parse the solidity data to extract user-defined type information.
|
|
158
216
|
* @param data contents of a solidity file with the user types declarations
|
|
159
217
|
* @param userTypeNames names of the user types to extract
|
|
218
|
+
* @param fromPath path to the solidity file from which the user types are extracted
|
|
219
|
+
* @returns record of type names mapped to the extracted type information
|
|
160
220
|
*/
|
|
161
221
|
declare function extractUserTypes(data: string, userTypeNames: string[], fromPath: string): Record<string, SolidityUserDefinedType>;
|
|
162
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Formats solidity code using prettier
|
|
225
|
+
* @param content solidity code
|
|
226
|
+
* @param prettierConfigPath optional path to a prettier config
|
|
227
|
+
* @returns formatted solidity code
|
|
228
|
+
*/
|
|
163
229
|
declare function formatSolidity(content: string, prettierConfigPath?: string): Promise<string>;
|
|
230
|
+
/**
|
|
231
|
+
* Formats typescript code using prettier
|
|
232
|
+
* @param content typescript code
|
|
233
|
+
* @returns formatted typescript code
|
|
234
|
+
*/
|
|
164
235
|
declare function formatTypescript(content: string): Promise<string>;
|
|
165
236
|
|
|
237
|
+
/**
|
|
238
|
+
* Formats solidity code using prettier and write it to a file
|
|
239
|
+
* @param output solidity code
|
|
240
|
+
* @param fullOutputPath full path to the output file
|
|
241
|
+
* @param logPrefix prefix for debug logs
|
|
242
|
+
*/
|
|
166
243
|
declare function formatAndWriteSolidity(output: string, fullOutputPath: string, logPrefix: string): Promise<void>;
|
|
244
|
+
/**
|
|
245
|
+
* Formats typescript code using prettier and write it to a file
|
|
246
|
+
* @param output typescript code
|
|
247
|
+
* @param fullOutputPath full path to the output file
|
|
248
|
+
* @param logPrefix prefix for debug logs
|
|
249
|
+
*/
|
|
167
250
|
declare function formatAndWriteTypescript(output: string, fullOutputPath: string, logPrefix: string): Promise<void>;
|
|
168
251
|
|
|
169
252
|
type UserType = {
|
|
170
253
|
filePath: string;
|
|
171
254
|
internalType: SchemaAbiType;
|
|
172
255
|
};
|
|
256
|
+
/**
|
|
257
|
+
* Load the user type files and extract type information from them.
|
|
258
|
+
* @param userTypes record of user type data mapped by type names
|
|
259
|
+
* @param outputBaseDirectory base path to the output directory
|
|
260
|
+
* @param remappings solc remappings
|
|
261
|
+
* @returns record of the user type information mapped by type names
|
|
262
|
+
*/
|
|
173
263
|
declare function loadAndExtractUserTypes(userTypes: Record<string, UserType>, outputBaseDirectory: string, remappings: [string, string][]): Record<string, SolidityUserDefinedType>;
|
|
174
264
|
|
|
175
265
|
/**
|
package/dist/codegen.js
CHANGED
|
@@ -1,31 +1,21 @@
|
|
|
1
|
-
import{a as
|
|
2
|
-
pragma solidity >=0.8.
|
|
1
|
+
import{c as Y,e as _}from"./chunk-6NUUDPWM.js";import{a as u}from"./chunk-TCWGPC6G.js";import{a as p}from"./chunk-UPQEB2HW.js";import q from"path";import{parse as b,visit as f}from"@solidity-parser/parser";function se(t,r){let n=b(t),i=H(b(t),r),s=[],o=[],a=[];if(!i)throw new p(`Contract not found: ${r}`);return f(i,{FunctionDefinition({name:y,visibility:T,parameters:c,stateMutability:R,returnParameters:g,isConstructor:k,isFallback:W,isReceiveEther:O}){try{if(k||W||O)return;if(T==="default")throw new p("Visibility is not specified");if(T==="external"||T==="public"){o.push({name:y===null?"":y,parameters:c.map(m),stateMutability:R||"",returnParameters:g===null?[]:g.map(m)});for(let{typeName:I}of c.concat(g??[])){let j=l(I);s=s.concat(h(n,j))}}}catch(I){throw I instanceof p&&(I.message=`Function "${y}" in contract "${r}": ${I.message}`),I}},CustomErrorDefinition({name:y,parameters:T}){a.push({name:y,parameters:T.map(m)});for(let c of T){let R=l(c.typeName);s=s.concat(h(n,R))}}}),{functions:o,errors:a,symbolImports:s}}function H(t,r){let n;return f(t,{ContractDefinition(i){i.name===r&&(n=i)}}),n}function m({name:t,typeName:r,storageLocation:n}){let i="",{name:s,stateMutability:o}=U(r);return i+=s,o!==null&&(i+=` ${o}`),n!==null&&(i+=` ${n}`),t!==null&&(i+=` ${t}`),i}function U(t){if(t===null)return{name:"",stateMutability:null};if(t.type==="ElementaryTypeName")return{name:t.name,stateMutability:t.stateMutability};if(t.type==="UserDefinedTypeName")return{name:t.namePath,stateMutability:null};if(t.type==="ArrayTypeName"){let r="";t.length?.type==="NumberLiteral"?r=t.length.number:t.length?.type==="Identifier"&&(r=t.length.name);let{name:n,stateMutability:i}=U(t.baseTypeName);return{name:`${n}[${r}]`,stateMutability:i}}else throw new p(`Invalid typeName.type ${t.type}`)}function l(t){if(t?.type==="UserDefinedTypeName")return[t.namePath.split(".")[0]];if(t?.type==="ArrayTypeName"){let r=l(t.baseTypeName);if(t.length?.type==="Identifier"){let n=t.length.name;r.push(n.split(".")[0])}return r}else return[]}function h(t,r){let n=[];for(let i of r){let s;if(f(t,{ImportDirective({path:o,symbolAliases:a}){if(a)for(let y of a){let T=y[1]||y[0];if(i===T){s={symbol:y[0],path:o};return}}}}),s)n.push(s);else throw new p(`Symbol "${i}" has no explicit import`)}return n}import{parse as K,visit as V}from"@solidity-parser/parser";function E(t,r,n){let i=K(t),s=n.at(0)===".",o={};return V(i,{TypeDefinition({name:a,definition:y},T){if(y.name.includes("fixed"))throw new p("Fixed point numbers are not supported by MUD");if(r.includes(a)){if(a in o)throw new p(`File has multiple user types with the same name: ${a}`);T?.type==="ContractDefinition"?o[a]={typeId:`${T.name}.${a}`,internalTypeId:y.name,importSymbol:T.name,fromPath:n,isRelativePath:s}:o[a]={typeId:a,internalTypeId:y.name,importSymbol:a,fromPath:n,isRelativePath:s}}}}),o}import d from"prettier";import z from"prettier-plugin-solidity";async function x(t,r){let n;r&&(n=await d.resolveConfig(r));try{return d.format(t,{plugins:[z],parser:"solidity-parse",printWidth:120,semi:!0,tabWidth:2,useTabs:!1,bracketSpacing:!0,...n})}catch(i){let s;return i instanceof Error?s=i.message:s=i,console.log(`Error during output formatting: ${s}`),t}}async function $(t){return d.format(t,{parser:"typescript"})}import{mkdir as w,writeFile as v}from"fs/promises";import{dirname as D}from"path";var A=u.extend("codegen"),J=u.extend("codegen");A.log=console.debug.bind(console);J.log=console.error.bind(console);async function fe(t,r,n){let i=await x(t);await w(D(r),{recursive:!0}),await v(r,i),A(`${n}: ${r}`)}async function de(t,r,n){let i=await $(t);await w(D(r),{recursive:!0}),await v(r,i),A(`${n}: ${r}`)}import{readFileSync as P}from"fs";import G from"path";function he(t,r,n){let i={};for(let[o,{filePath:a}]of Object.entries(t))a in i||(i[a]=[]),i[a].push(o);let s={};for(let[o,a]of Object.entries(i)){let{filePath:y,data:T}=X(r,o,n),c=E(T,a,y);for(let[R,g]of Object.entries(c))if(g.internalTypeId!==t[R].internalType)throw new p(`User type "${R}" has internal type "${g.internalTypeId}" but config specifies "${t[R].internalType}"`);s={...s,...c}}return s}function X(t,r,n){if(r.at(0)===".")return{filePath:"./"+G.relative(t,r),data:P(r,"utf8")};{let i=r;for(let[s,o]of n)if(i.includes(s)){i=i.replace(s,o);break}return{filePath:r,data:P(i,"utf8")}}}function B(t){return t.replace(/\\/g,"/")}var C=`// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity >=0.8.24;
|
|
3
3
|
|
|
4
|
-
/* Autogenerated file. Do not edit manually. */`;function S(r
|
|
5
|
-
bytes32[] memory _keyTuple = new bytes32[](${
|
|
6
|
-
${S(
|
|
7
|
-
`;return{_typedTableId:n,_typedKeyArgs:i,_keyTupleDefinition:s}}function
|
|
8
|
-
`)}function
|
|
9
|
-
`+
|
|
10
|
-
`+n("")),s}function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
bytes14("${r}"),
|
|
16
|
-
bytes16("${t}")
|
|
17
|
-
)
|
|
18
|
-
)
|
|
19
|
-
)
|
|
20
|
-
`,o=`
|
|
21
|
-
ResourceId constant _tableId = ${s};
|
|
22
|
-
ResourceId constant ${i} = _tableId;
|
|
23
|
-
`;return{hardcodedTableId:s,tableIdDefinition:o}}function q(r,{typeUnwrap:t,internalTypeId:n}){let i=t.length?`${t}(${r})`:r;if(n==="bytes32")return i;if(/^bytes\d{1,2}$/.test(n))return`bytes32(${i})`;if(/^uint\d{1,3}$/.test(n))return`bytes32(uint256(${i}))`;if(/^int\d{1,3}$/.test(n))return`bytes32(uint256(int256(${i})))`;if(n==="address")return`bytes32(uint256(uint160(${i})))`;if(n==="bool")return`_boolToBytes32(${i})`;throw new Error(`Unknown value type id ${n}`)}function J(r){return/^bytes\d{1,2}$/.test(r.internalTypeId)}function Oe(r){return J(r)?0:256-r.staticByteLength*8}function F(r,t,n){return t.map((i,s)=>n(i,s)+(s===t.length-1?"":r)).join(`
|
|
24
|
-
`)}function Ve(r){let t=D;return t+=S(r,({name:n,memberNames:i})=>`
|
|
4
|
+
/* Autogenerated file. Do not edit manually. */`;function S(t,r){return L("",t,r)}function N(t){let r=t.filter(n=>n!==void 0&&n!=="");return L(",",r,n=>n)}function We({staticResourceData:t,keyTuple:r}){let n=t?"":"ResourceId _tableId",i=N(r.map(({name:o,typeWithLocation:a})=>`${a} ${o}`)),s=`
|
|
5
|
+
bytes32[] memory _keyTuple = new bytes32[](${r.length});
|
|
6
|
+
${S(r,(o,a)=>`_keyTuple[${a}] = ${Q(o.name,o)};`)}
|
|
7
|
+
`;return{_typedTableId:n,_typedKeyArgs:i,_keyTupleDefinition:s}}function F(t,r){return B("./"+q.relative("./"+r,"./"+t))}function Oe(t){return M(t.map(r=>"path"in r?r:{symbol:r.symbol,path:F(r.fromPath,r.usedInPath)}))}function je(t){return M(t.map(({symbol:r,fromPath:n,usedInPath:i})=>({symbol:r,path:F(n,i)})))}function M(t){let r=new Map;for(let{symbol:i,path:s}of t)r.has(s)||r.set(s,new Set),r.get(s)?.add(i);let n=[];for(let[i,s]of r){let o=[...s].join(", ");n.push(`import { ${o} } from "${B(i)}";`)}return n.join(`
|
|
8
|
+
`)}function He(t,r){let n="";return n+=r({_typedStore:void 0,_store:"StoreSwitch",_commentSuffix:"",_methodNamePrefix:""}),n+=r({_typedStore:void 0,_store:"StoreCore",_commentSuffix:"",_methodNamePrefix:"_",_useExplicitFieldLayout:!0}),t&&(n+=`
|
|
9
|
+
`+r({_typedStore:"IStore _store",_store:"_store",_commentSuffix:" (using the specified store)",_methodNamePrefix:""})),n}function Ke(t,r,n){let i=`${r[0].toUpperCase()}${r.slice(1)}`,s="";return s+=n(i),t&&(s+=`
|
|
10
|
+
`+n("")),s}function Ve({namespace:t,name:r,offchainOnly:n}){let i=Y({type:n?"offchainTable":"table",namespace:t,name:r}),s=_(i);return`
|
|
11
|
+
// Hex below is the result of \`WorldResourceIdLib.encode({ namespace: ${JSON.stringify(s.namespace)}, name: ${JSON.stringify(s.name)}, typeId: ${n?"RESOURCE_OFFCHAIN_TABLE":"RESOURCE_TABLE"} });\`
|
|
12
|
+
ResourceId constant _tableId = ResourceId.wrap(${i});
|
|
13
|
+
`}function Q(t,{typeUnwrap:r,internalTypeId:n}){let i=r.length?`${r}(${t})`:t;if(n==="bytes32")return i;if(/^bytes\d{1,2}$/.test(n))return`bytes32(${i})`;if(/^uint\d{1,3}$/.test(n))return`bytes32(uint256(${i}))`;if(/^int\d{1,3}$/.test(n))return`bytes32(uint256(int256(${i})))`;if(n==="address")return`bytes32(uint256(uint160(${i})))`;if(n==="bool")return`_boolToBytes32(${i})`;throw new Error(`Unknown value type id ${n}`)}function Z(t){return/^bytes\d{1,2}$/.test(t.internalTypeId)}function ze(t){return Z(t)?0:256-t.staticByteLength*8}function L(t,r,n){return r.map((i,s)=>n(i,s)+(s===r.length-1?"":t)).join(`
|
|
14
|
+
`)}function Xe(t){let r=C;return r+=S(t,({name:n,memberNames:i})=>`
|
|
25
15
|
enum ${n} {
|
|
26
|
-
${
|
|
16
|
+
${N(i)}
|
|
27
17
|
}
|
|
28
|
-
`),
|
|
18
|
+
`),r}function Qe(t){let{fields:r,keyTuple:n}=t,i="";for(let s of ee([...r,...n]))i+=s;return r.some(({internalTypeId:s})=>s.match("bool"))&&(i+=`
|
|
29
19
|
/**
|
|
30
20
|
* @notice Cast a value to a bool.
|
|
31
21
|
* @dev Boolean values are encoded as uint8 (1 = true, 0 = false), but Solidity doesn't allow casting between uint8 and bool.
|
|
@@ -47,7 +37,7 @@ pragma solidity >=0.8.21;
|
|
|
47
37
|
result := value
|
|
48
38
|
}
|
|
49
39
|
}
|
|
50
|
-
`),i}function
|
|
40
|
+
`),i}function ee(t){let r=new Map,n=new Map;for(let{typeWrappingData:i,typeWrap:s,typeUnwrap:o,internalTypeId:a}of t){if(!i)continue;let{kind:y}=i;if(y==="staticArray"){let{elementType:T,staticLength:c}=i;r.set(s,te(s,T,c,a)),n.set(o,re(o,T,c,a))}}return[...r.values(),...n.values()]}function te(t,r,n,i){return`
|
|
51
41
|
/**
|
|
52
42
|
* @notice Cast a dynamic array to a static array.
|
|
53
43
|
* @dev In memory static arrays are just dynamic arrays without the 32 length bytes,
|
|
@@ -57,10 +47,10 @@ pragma solidity >=0.8.21;
|
|
|
57
47
|
* @param _value The dynamic array to cast.
|
|
58
48
|
* @return _result The static array.
|
|
59
49
|
*/
|
|
60
|
-
function ${
|
|
50
|
+
function ${t}(
|
|
61
51
|
${i} memory _value
|
|
62
52
|
) pure returns (
|
|
63
|
-
${
|
|
53
|
+
${r}[${n}] memory _result
|
|
64
54
|
) {
|
|
65
55
|
if (_value.length < ${n}) {
|
|
66
56
|
// return an uninitialized array if the length is smaller than the fixed length to avoid memory corruption
|
|
@@ -73,15 +63,15 @@ pragma solidity >=0.8.21;
|
|
|
73
63
|
}
|
|
74
64
|
}
|
|
75
65
|
}
|
|
76
|
-
`}function
|
|
66
|
+
`}function re(t,r,n,i){let s=n*32;return`
|
|
77
67
|
/**
|
|
78
68
|
* @notice Copy a static array to a dynamic array.
|
|
79
69
|
* @dev Static arrays don't have a length prefix, so this function copies the memory from the static array to a new dynamic array.
|
|
80
70
|
* @param _value The static array to copy.
|
|
81
71
|
* @return _result The dynamic array.
|
|
82
72
|
*/
|
|
83
|
-
function ${
|
|
84
|
-
${
|
|
73
|
+
function ${t}(
|
|
74
|
+
${r}[${n}] memory _value
|
|
85
75
|
) pure returns (
|
|
86
76
|
${i} memory _result
|
|
87
77
|
) {
|
|
@@ -94,5 +84,5 @@ pragma solidity >=0.8.21;
|
|
|
94
84
|
}
|
|
95
85
|
Memory.copy(fromPointer, toPointer, ${s});
|
|
96
86
|
}
|
|
97
|
-
`}import{SchemaType as e}from"@latticexyz/schema-type/deprecated";var
|
|
87
|
+
`}import{SchemaType as e}from"@latticexyz/schema-type/deprecated";var ot={[e.UINT8]:"RecsType.Number",[e.UINT16]:"RecsType.Number",[e.UINT24]:"RecsType.Number",[e.UINT32]:"RecsType.Number",[e.UINT40]:"RecsType.Number",[e.UINT48]:"RecsType.Number",[e.UINT56]:"RecsType.BigInt",[e.UINT64]:"RecsType.BigInt",[e.UINT72]:"RecsType.BigInt",[e.UINT80]:"RecsType.BigInt",[e.UINT88]:"RecsType.BigInt",[e.UINT96]:"RecsType.BigInt",[e.UINT104]:"RecsType.BigInt",[e.UINT112]:"RecsType.BigInt",[e.UINT120]:"RecsType.BigInt",[e.UINT128]:"RecsType.BigInt",[e.UINT136]:"RecsType.BigInt",[e.UINT144]:"RecsType.BigInt",[e.UINT152]:"RecsType.BigInt",[e.UINT160]:"RecsType.BigInt",[e.UINT168]:"RecsType.BigInt",[e.UINT176]:"RecsType.BigInt",[e.UINT184]:"RecsType.BigInt",[e.UINT192]:"RecsType.BigInt",[e.UINT200]:"RecsType.BigInt",[e.UINT208]:"RecsType.BigInt",[e.UINT216]:"RecsType.BigInt",[e.UINT224]:"RecsType.BigInt",[e.UINT232]:"RecsType.BigInt",[e.UINT240]:"RecsType.BigInt",[e.UINT248]:"RecsType.BigInt",[e.UINT256]:"RecsType.BigInt",[e.INT8]:"RecsType.Number",[e.INT16]:"RecsType.Number",[e.INT24]:"RecsType.Number",[e.INT32]:"RecsType.Number",[e.INT40]:"RecsType.Number",[e.INT48]:"RecsType.Number",[e.INT56]:"RecsType.BigInt",[e.INT64]:"RecsType.BigInt",[e.INT72]:"RecsType.BigInt",[e.INT80]:"RecsType.BigInt",[e.INT88]:"RecsType.BigInt",[e.INT96]:"RecsType.BigInt",[e.INT104]:"RecsType.BigInt",[e.INT112]:"RecsType.BigInt",[e.INT120]:"RecsType.BigInt",[e.INT128]:"RecsType.BigInt",[e.INT136]:"RecsType.BigInt",[e.INT144]:"RecsType.BigInt",[e.INT152]:"RecsType.BigInt",[e.INT160]:"RecsType.BigInt",[e.INT168]:"RecsType.BigInt",[e.INT176]:"RecsType.BigInt",[e.INT184]:"RecsType.BigInt",[e.INT192]:"RecsType.BigInt",[e.INT200]:"RecsType.BigInt",[e.INT208]:"RecsType.BigInt",[e.INT216]:"RecsType.BigInt",[e.INT224]:"RecsType.BigInt",[e.INT232]:"RecsType.BigInt",[e.INT240]:"RecsType.BigInt",[e.INT248]:"RecsType.BigInt",[e.INT256]:"RecsType.BigInt",[e.BYTES1]:"RecsType.String",[e.BYTES2]:"RecsType.String",[e.BYTES3]:"RecsType.String",[e.BYTES4]:"RecsType.String",[e.BYTES5]:"RecsType.String",[e.BYTES6]:"RecsType.String",[e.BYTES7]:"RecsType.String",[e.BYTES8]:"RecsType.String",[e.BYTES9]:"RecsType.String",[e.BYTES10]:"RecsType.String",[e.BYTES11]:"RecsType.String",[e.BYTES12]:"RecsType.String",[e.BYTES13]:"RecsType.String",[e.BYTES14]:"RecsType.String",[e.BYTES15]:"RecsType.String",[e.BYTES16]:"RecsType.String",[e.BYTES17]:"RecsType.String",[e.BYTES18]:"RecsType.String",[e.BYTES19]:"RecsType.String",[e.BYTES20]:"RecsType.String",[e.BYTES21]:"RecsType.String",[e.BYTES22]:"RecsType.String",[e.BYTES23]:"RecsType.String",[e.BYTES24]:"RecsType.String",[e.BYTES25]:"RecsType.String",[e.BYTES26]:"RecsType.String",[e.BYTES27]:"RecsType.String",[e.BYTES28]:"RecsType.String",[e.BYTES29]:"RecsType.String",[e.BYTES30]:"RecsType.String",[e.BYTES31]:"RecsType.String",[e.BYTES32]:"RecsType.String",[e.BOOL]:"RecsType.Boolean",[e.ADDRESS]:"RecsType.String",[e.UINT8_ARRAY]:"RecsType.NumberArray",[e.UINT16_ARRAY]:"RecsType.NumberArray",[e.UINT24_ARRAY]:"RecsType.NumberArray",[e.UINT32_ARRAY]:"RecsType.NumberArray",[e.UINT40_ARRAY]:"RecsType.NumberArray",[e.UINT48_ARRAY]:"RecsType.NumberArray",[e.UINT56_ARRAY]:"RecsType.BigIntArray",[e.UINT64_ARRAY]:"RecsType.BigIntArray",[e.UINT72_ARRAY]:"RecsType.BigIntArray",[e.UINT80_ARRAY]:"RecsType.BigIntArray",[e.UINT88_ARRAY]:"RecsType.BigIntArray",[e.UINT96_ARRAY]:"RecsType.BigIntArray",[e.UINT104_ARRAY]:"RecsType.BigIntArray",[e.UINT112_ARRAY]:"RecsType.BigIntArray",[e.UINT120_ARRAY]:"RecsType.BigIntArray",[e.UINT128_ARRAY]:"RecsType.BigIntArray",[e.UINT136_ARRAY]:"RecsType.BigIntArray",[e.UINT144_ARRAY]:"RecsType.BigIntArray",[e.UINT152_ARRAY]:"RecsType.BigIntArray",[e.UINT160_ARRAY]:"RecsType.BigIntArray",[e.UINT168_ARRAY]:"RecsType.BigIntArray",[e.UINT176_ARRAY]:"RecsType.BigIntArray",[e.UINT184_ARRAY]:"RecsType.BigIntArray",[e.UINT192_ARRAY]:"RecsType.BigIntArray",[e.UINT200_ARRAY]:"RecsType.BigIntArray",[e.UINT208_ARRAY]:"RecsType.BigIntArray",[e.UINT216_ARRAY]:"RecsType.BigIntArray",[e.UINT224_ARRAY]:"RecsType.BigIntArray",[e.UINT232_ARRAY]:"RecsType.BigIntArray",[e.UINT240_ARRAY]:"RecsType.BigIntArray",[e.UINT248_ARRAY]:"RecsType.BigIntArray",[e.UINT256_ARRAY]:"RecsType.BigIntArray",[e.INT8_ARRAY]:"RecsType.NumberArray",[e.INT16_ARRAY]:"RecsType.NumberArray",[e.INT24_ARRAY]:"RecsType.NumberArray",[e.INT32_ARRAY]:"RecsType.NumberArray",[e.INT40_ARRAY]:"RecsType.NumberArray",[e.INT48_ARRAY]:"RecsType.NumberArray",[e.INT56_ARRAY]:"RecsType.BigIntArray",[e.INT64_ARRAY]:"RecsType.BigIntArray",[e.INT72_ARRAY]:"RecsType.BigIntArray",[e.INT80_ARRAY]:"RecsType.BigIntArray",[e.INT88_ARRAY]:"RecsType.BigIntArray",[e.INT96_ARRAY]:"RecsType.BigIntArray",[e.INT104_ARRAY]:"RecsType.BigIntArray",[e.INT112_ARRAY]:"RecsType.BigIntArray",[e.INT120_ARRAY]:"RecsType.BigIntArray",[e.INT128_ARRAY]:"RecsType.BigIntArray",[e.INT136_ARRAY]:"RecsType.BigIntArray",[e.INT144_ARRAY]:"RecsType.BigIntArray",[e.INT152_ARRAY]:"RecsType.BigIntArray",[e.INT160_ARRAY]:"RecsType.BigIntArray",[e.INT168_ARRAY]:"RecsType.BigIntArray",[e.INT176_ARRAY]:"RecsType.BigIntArray",[e.INT184_ARRAY]:"RecsType.BigIntArray",[e.INT192_ARRAY]:"RecsType.BigIntArray",[e.INT200_ARRAY]:"RecsType.BigIntArray",[e.INT208_ARRAY]:"RecsType.BigIntArray",[e.INT216_ARRAY]:"RecsType.BigIntArray",[e.INT224_ARRAY]:"RecsType.BigIntArray",[e.INT232_ARRAY]:"RecsType.BigIntArray",[e.INT240_ARRAY]:"RecsType.BigIntArray",[e.INT248_ARRAY]:"RecsType.BigIntArray",[e.INT256_ARRAY]:"RecsType.BigIntArray",[e.BYTES1_ARRAY]:"RecsType.BigIntArray",[e.BYTES2_ARRAY]:"RecsType.BigIntArray",[e.BYTES3_ARRAY]:"RecsType.BigIntArray",[e.BYTES4_ARRAY]:"RecsType.BigIntArray",[e.BYTES5_ARRAY]:"RecsType.BigIntArray",[e.BYTES6_ARRAY]:"RecsType.BigIntArray",[e.BYTES7_ARRAY]:"RecsType.BigIntArray",[e.BYTES8_ARRAY]:"RecsType.BigIntArray",[e.BYTES9_ARRAY]:"RecsType.BigIntArray",[e.BYTES10_ARRAY]:"RecsType.BigIntArray",[e.BYTES11_ARRAY]:"RecsType.BigIntArray",[e.BYTES12_ARRAY]:"RecsType.BigIntArray",[e.BYTES13_ARRAY]:"RecsType.BigIntArray",[e.BYTES14_ARRAY]:"RecsType.BigIntArray",[e.BYTES15_ARRAY]:"RecsType.BigIntArray",[e.BYTES16_ARRAY]:"RecsType.BigIntArray",[e.BYTES17_ARRAY]:"RecsType.BigIntArray",[e.BYTES18_ARRAY]:"RecsType.BigIntArray",[e.BYTES19_ARRAY]:"RecsType.BigIntArray",[e.BYTES20_ARRAY]:"RecsType.BigIntArray",[e.BYTES21_ARRAY]:"RecsType.BigIntArray",[e.BYTES22_ARRAY]:"RecsType.BigIntArray",[e.BYTES23_ARRAY]:"RecsType.BigIntArray",[e.BYTES24_ARRAY]:"RecsType.BigIntArray",[e.BYTES25_ARRAY]:"RecsType.BigIntArray",[e.BYTES26_ARRAY]:"RecsType.BigIntArray",[e.BYTES27_ARRAY]:"RecsType.BigIntArray",[e.BYTES28_ARRAY]:"RecsType.BigIntArray",[e.BYTES29_ARRAY]:"RecsType.BigIntArray",[e.BYTES30_ARRAY]:"RecsType.BigIntArray",[e.BYTES31_ARRAY]:"RecsType.BigIntArray",[e.BYTES32_ARRAY]:"RecsType.BigIntArray",[e.BOOL_ARRAY]:"RecsType.T",[e.ADDRESS_ARRAY]:"RecsType.StringArray",[e.BYTES]:"RecsType.String",[e.STRING]:"RecsType.String"};export{se as contractToInterface,E as extractUserTypes,fe as formatAndWriteSolidity,de as formatAndWriteTypescript,x as formatSolidity,$ as formatTypescript,ze as getLeftPaddingBits,Z as isLeftAligned,he as loadAndExtractUserTypes,B as posixPath,M as renderAbsoluteImports,N as renderArguments,We as renderCommonData,Xe as renderEnums,Oe as renderImports,S as renderList,je as renderRelativeImports,Ve as renderTableId,Qe as renderTypeHelpers,Q as renderValueTypeToBytes32,Ke as renderWithFieldSuffix,He as renderWithStore,C as renderedSolidityHeader,ot as schemaTypesToRecsTypeStrings,F as solidityRelativeImportPath};
|
|
98
88
|
//# sourceMappingURL=codegen.js.map
|