@latticexyz/common 2.0.0-next.0 → 2.0.0-next.2
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/chains.js +1 -1
- package/dist/chains.js.map +1 -1
- package/dist/codegen.js +25 -25
- package/dist/codegen.js.map +1 -1
- package/dist/deprecated.js +2 -0
- package/dist/deprecated.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +20 -12
- package/src/chains/index.ts +1 -0
- package/src/chains/latticeTestnet.ts +0 -1
- package/src/chains/mudFoundry.ts +9 -0
- package/src/chains/types.ts +0 -1
- package/src/codegen/render-solidity/common.ts +12 -0
- package/src/createBurnerAccount.ts +10 -0
- package/src/createContract.ts +173 -0
- package/src/createNonceManager.ts +78 -0
- package/src/debug.ts +3 -0
- package/src/{TableId.ts → deprecated/TableId.ts} +1 -0
- package/src/deprecated/getTableIds.ts +6 -0
- package/src/deprecated/index.ts +2 -0
- package/src/hexToTableId.test.ts +10 -0
- package/src/hexToTableId.ts +7 -0
- package/src/index.ts +6 -1
- package/src/tableIdToHex.test.ts +24 -0
- package/src/tableIdToHex.ts +8 -0
- package/src/transportObserver.ts +23 -0
- package/src/type-utils/common.ts +2 -0
- /package/src/{TableId.test.ts → deprecated/TableId.test.ts} +0 -0
package/dist/chains.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var t={name:"Lattice Testnet",id:4242,network:"lattice-testnet",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:{otterscan:{name:"Otterscan",url:"https://explorer.testnet-chain.linfra.xyz"},default:{name:"Otterscan",url:"https://explorer.testnet-chain.linfra.xyz"}},
|
|
1
|
+
var t={name:"Lattice Testnet",id:4242,network:"lattice-testnet",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:{otterscan:{name:"Otterscan",url:"https://explorer.testnet-chain.linfra.xyz"},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"],"sourcesContent":["import type { MUDChain } from \"./types\";\n\nexport const latticeTestnet = {\n name: \"Lattice Testnet\",\n id: 4242,\n network: \"lattice-testnet\",\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 otterscan: {\n name: \"Otterscan\",\n url: \"https://explorer.testnet-chain.linfra.xyz\",\n },\n default: {\n name: \"Otterscan\",\n url: \"https://explorer.testnet-chain.linfra.xyz\",\n },\n },\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 network: \"lattice-testnet\",\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 otterscan: {\n name: \"Otterscan\",\n url: \"https://explorer.testnet-chain.linfra.xyz\",\n },\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 defaultPriorityFee: 0n,\n },\n} as const satisfies MUDChain;\n"],"mappings":"AAEO,IAAMA,EAAiB,CAC5B,KAAM,kBACN,GAAI,KACJ,QAAS,kBACT,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,UAAW,CACT,KAAM,YACN,IAAK,2CACP,EACA,QAAS,CACP,KAAM,YACN,IAAK,2CACP,CACF,EACA,UAAW,gDACb,EC5BA,OAAS,WAAAC,MAAe,cAGjB,IAAMC,EAAa,CACxB,GAAGD,EACH,KAAM,CACJ,mBAAoB,EACtB,CACF","names":["latticeTestnet","foundry","mudFoundry"]}
|
package/dist/codegen.js
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import{a}from"./chunk-UPQEB2HW.js";import
|
|
1
|
+
import{a}from"./chunk-UPQEB2HW.js";import F from"path";import{parse as C,visit as d}from"@solidity-parser/parser";function q(r,t){let n=C(r),i=!1,s=[],R=[],o=[];if(d(n,{ContractDefinition({name:T}){T===t&&(i=!0)},FunctionDefinition({name:T,visibility:y,parameters:p,stateMutability:I,returnParameters:g,isConstructor:v,isFallback:P,isReceiveEther:M},u){if(u!==void 0&&u.type==="ContractDefinition"&&u.name===t)try{if(v||P||M)return;if(y==="default")throw new a("Visibility is not specified");if(y==="external"||y==="public"){R.push({name:T===null?"":T,parameters:p.map(m),stateMutability:I||"",returnParameters:g===null?[]:g.map(m)});for(let{typeName:c}of p.concat(g??[])){let k=B(c);s=s.concat(N(n,k))}}}catch(c){throw c instanceof a&&(c.message=`Function "${T}" in contract "${t}": ${c.message}`),c}},CustomErrorDefinition({name:T,parameters:y}){o.push({name:T===null?"":T,parameters:y.map(m)});for(let p of y){let I=B(p.typeName);s=s.concat(N(n,I))}}}),!i)throw new a(`Contract not found: ${t}`);return{functions:R,errors:o,symbolImports:s}}function m({name:r,typeName:t,storageLocation:n}){let i="",{name:s,stateMutability:R}=S(t);return i+=s,R!==null&&(i+=` ${R}`),n!==null&&(i+=` ${n}`),r!==null&&(i+=` ${r}`),i}function S(r){if(r===null)return{name:"",stateMutability:null};if(r.type==="ElementaryTypeName")return{name:r.name,stateMutability:r.stateMutability};if(r.type==="UserDefinedTypeName")return{name:r.namePath,stateMutability:null};if(r.type==="ArrayTypeName"){let t="";r.length?.type==="NumberLiteral"?t=r.length.number:r.length?.type==="Identifier"&&(t=r.length.name);let{name:n,stateMutability:i}=S(r.baseTypeName);return{name:`${n}[${t}]`,stateMutability:i}}else throw new a(`Invalid typeName.type ${r.type}`)}function B(r){if(r?.type==="UserDefinedTypeName")return[r.namePath.split(".")[0]];if(r?.type==="ArrayTypeName"){let t=B(r.baseTypeName);if(r.length?.type==="Identifier"){let n=r.length.name;t.push(n.split(".")[0])}return t}else return[]}function N(r,t){let n=[];for(let i of t){let s;if(d(r,{ImportDirective({path:R,symbolAliases:o}){if(o)for(let T of o){let y=T[1]||T[0];if(i===y){s={symbol:T[0],path:R};return}}}}),s)n.push(s);else throw new a(`Symbol "${i}" has no explicit import`)}return n}import L from"chalk";import l from"prettier";import W from"prettier-plugin-solidity";async function _(r,t){let n;t&&(n=await l.resolveConfig(t));try{return l.format(r,{plugins:[W],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(L.yellow(`Error during output formatting: ${s}`)),r}}async function b(r){return l.format(r,{parser:"typescript"})}import{mkdirSync as E,writeFileSync as U}from"fs";import{dirname as h}from"path";async function ie(r,t,n){let i=await _(r);E(h(t),{recursive:!0}),U(t,i),console.log(`${n}: ${t}`)}async function se(r,t,n){let i=await b(r);E(h(t),{recursive:!0}),U(t,i),console.log(`${n}: ${t}`)}function f(r){return r.replace(/\\/g,"/")}var $=`// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity >=0.8.0;
|
|
3
3
|
|
|
4
|
-
/* Autogenerated file. Do not edit manually. */`;function Y(t
|
|
5
|
-
bytes32[] memory _keyTuple = new bytes32[](${
|
|
6
|
-
${Y(
|
|
7
|
-
`;return{_tableId:n,_typedTableId:
|
|
8
|
-
`)}function
|
|
9
|
-
`+
|
|
10
|
-
bytes32 constant _tableId = ${
|
|
11
|
-
bytes32 constant ${
|
|
12
|
-
`;return{hardcodedTableId:
|
|
13
|
-
`)}function
|
|
4
|
+
/* Autogenerated file. Do not edit manually. */`;function Y(r,t){return D("",r,t)}function A(r){let t=r.filter(n=>n!==void 0&&n!=="");return D(",",t,n=>n)}function ge({staticResourceData:r,keyTuple:t}){let n=r?"":"_tableId",i=r?"":"bytes32 _tableId",s=A(t.map(({name:T})=>T)),R=A(t.map(({name:T,typeWithLocation:y})=>`${y} ${T}`)),o=`
|
|
5
|
+
bytes32[] memory _keyTuple = new bytes32[](${t.length});
|
|
6
|
+
${Y(t,(T,y)=>`_keyTuple[${y}] = ${K(T.name,T)};`)}
|
|
7
|
+
`;return{_tableId:n,_typedTableId:i,_keyArgs:s,_typedKeyArgs:R,_keyTupleDefinition:o}}function x(r,t){return f("./"+F.relative("./"+t,"./"+r))}function ue(r){return w(r.map(t=>"path"in t?t:{symbol:t.symbol,path:x(t.fromPath,t.usedInPath)}))}function me(r){return w(r.map(({symbol:t,fromPath:n,usedInPath:i})=>({symbol:t,path:x(n,i)})))}function w(r){let t=new Map;for(let{symbol:i,path:s}of r)t.has(s)||t.set(s,new Set),t.get(s)?.add(i);let n=[];for(let[i,s]of t){let R=[...s].join(", ");n.push(`import { ${R} } from "${f(i)}";`)}return n.join(`
|
|
8
|
+
`)}function Be(r,t){let n="";return n+=t(void 0,"StoreSwitch","",void 0),r&&(n+=`
|
|
9
|
+
`+t("IStore _store","_store"," (using the specified store)","_store")),n}function le(r){let t=`bytes32(abi.encodePacked(bytes16("${r.namespace}"), bytes16("${r.name}")))`,n=`
|
|
10
|
+
bytes32 constant _tableId = ${t};
|
|
11
|
+
bytes32 constant ${r.tableIdName} = _tableId;
|
|
12
|
+
`;return{hardcodedTableId:t,tableIdDefinition:n}}function K(r,{typeUnwrap:t,internalTypeId:n}){let i=t.length?`${t}(${r})`:r;if(n==="bytes32")return i;if(n.match(/^bytes\d{1,2}$/))return`bytes32(${i})`;if(n.match(/^uint\d{1,3}$/))return`bytes32(uint256(${i}))`;if(n.match(/^int\d{1,3}$/))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 H(r){return r.internalTypeId.match(/^bytes\d{1,2}$/)!==null}function fe(r){return H(r)?0:256-r.staticByteLength*8}function D(r,t,n){return t.map((i,s)=>n(i,s)+(s===t.length-1?"":r)).join(`
|
|
13
|
+
`)}function de(r){let t=$;return t+=Y(r,({name:n,memberNames:i})=>`
|
|
14
14
|
enum ${n} {
|
|
15
|
-
${A(
|
|
15
|
+
${A(i)}
|
|
16
16
|
}
|
|
17
|
-
`),
|
|
17
|
+
`),t}function _e(r){let{fields:t,keyTuple:n}=r,i="";for(let s of j([...t,...n]))i+=s;return t.some(({internalTypeId:s})=>s.match("bool"))&&(i+=`
|
|
18
18
|
function _toBool(uint8 value) pure returns (bool result) {
|
|
19
19
|
assembly {
|
|
20
20
|
result := value
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
`),n.some(({internalTypeId:
|
|
23
|
+
`),n.some(({internalTypeId:s})=>s.match("bool"))&&(i+=`
|
|
24
24
|
function _boolToBytes32(bool value) pure returns (bytes32 result) {
|
|
25
25
|
assembly {
|
|
26
26
|
result := value
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
`),
|
|
30
|
-
function ${
|
|
31
|
-
${
|
|
29
|
+
`),i}function j(r){let t=new Map,n=new Map;for(let{typeWrappingData:i,typeWrap:s,typeUnwrap:R,internalTypeId:o}of r){if(!i)continue;let{kind:T}=i;if(T==="staticArray"){let{elementType:y,staticLength:p}=i;t.set(s,V(s,y,p,o)),n.set(R,O(R,y,p,o))}}return[...t.values(),...n.values()]}function V(r,t,n,i){return`
|
|
30
|
+
function ${r}(
|
|
31
|
+
${i} memory _value
|
|
32
32
|
) pure returns (
|
|
33
|
-
${
|
|
33
|
+
${t}[${n}] memory _result
|
|
34
34
|
) {
|
|
35
35
|
// in memory static arrays are just dynamic arrays without the length byte
|
|
36
36
|
assembly {
|
|
37
37
|
_result := add(_value, 0x20)
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
`}function
|
|
41
|
-
function ${
|
|
42
|
-
${
|
|
40
|
+
`}function O(r,t,n,i){let s=n*32;return`
|
|
41
|
+
function ${r}(
|
|
42
|
+
${t}[${n}] memory _value
|
|
43
43
|
) pure returns (
|
|
44
|
-
${
|
|
44
|
+
${i} memory _result
|
|
45
45
|
) {
|
|
46
|
-
_result = new ${
|
|
46
|
+
_result = new ${i}(${n});
|
|
47
47
|
uint256 fromPointer;
|
|
48
48
|
uint256 toPointer;
|
|
49
49
|
assembly {
|
|
50
50
|
fromPointer := _value
|
|
51
51
|
toPointer := add(_result, 0x20)
|
|
52
52
|
}
|
|
53
|
-
Memory.copy(fromPointer, toPointer, ${
|
|
53
|
+
Memory.copy(fromPointer, toPointer, ${s});
|
|
54
54
|
}
|
|
55
|
-
`}import{SchemaType as e}from"@latticexyz/schema-type/deprecated";var
|
|
55
|
+
`}import{SchemaType as e}from"@latticexyz/schema-type/deprecated";var De={[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{q as contractToInterface,ie as formatAndWriteSolidity,se as formatAndWriteTypescript,_ as formatSolidity,b as formatTypescript,fe as getLeftPaddingBits,H as isLeftAligned,f as posixPath,w as renderAbsoluteImports,A as renderArguments,ge as renderCommonData,de as renderEnums,ue as renderImports,Y as renderList,me as renderRelativeImports,le as renderTableId,_e as renderTypeHelpers,K as renderValueTypeToBytes32,Be as renderWithStore,$ as renderedSolidityHeader,De as schemaTypesToRecsTypeStrings,x as solidityRelativeImportPath};
|
|
56
56
|
//# sourceMappingURL=codegen.js.map
|
package/dist/codegen.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/codegen/render-solidity/common.ts","../src/codegen/utils/contractToInterface.ts","../src/codegen/utils/format.ts","../src/codegen/utils/formatAndWrite.ts","../src/codegen/utils/posixPath.ts","../src/codegen/render-solidity/renderEnums.ts","../src/codegen/render-solidity/renderTypeHelpers.ts","../src/codegen/render-typescript/schemaTypesToRecsTypeStrings.ts"],"sourcesContent":["import path from \"path\";\nimport {\n AbsoluteImportDatum,\n RelativeImportDatum,\n ImportDatum,\n StaticResourceData,\n RenderKeyTuple,\n RenderType,\n} from \"./types\";\nimport { posixPath } from \"../utils\";\n\nexport const renderedSolidityHeader = `// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\n/* Autogenerated file. Do not edit manually. */`;\n\n/**\n * Renders a list of lines\n */\nexport function renderList<T>(list: T[], renderItem: (item: T, index: number) => string): string {\n return internalRenderList(\"\", list, renderItem);\n}\n\n/**\n * Renders a comma-separated list of arguments for solidity functions, ignoring empty and undefined ones\n */\nexport function renderArguments(args: (string | undefined)[]): string {\n const filteredArgs = args.filter((arg) => arg !== undefined && arg !== \"\") as string[];\n return internalRenderList(\",\", filteredArgs, (arg) => arg);\n}\n\nexport function renderCommonData({\n staticResourceData,\n keyTuple,\n}: {\n staticResourceData?: StaticResourceData;\n keyTuple: RenderKeyTuple[];\n}): {\n _tableId: string;\n _typedTableId: string;\n _keyArgs: string;\n _typedKeyArgs: string;\n _keyTupleDefinition: string;\n} {\n // static resource means static tableId as well, and no tableId arguments\n const _tableId = staticResourceData ? \"\" : \"_tableId\";\n const _typedTableId = staticResourceData ? \"\" : \"bytes32 _tableId\";\n\n const _keyArgs = renderArguments(keyTuple.map(({ name }) => name));\n const _typedKeyArgs = renderArguments(keyTuple.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`));\n\n const _keyTupleDefinition = `\n bytes32[] memory _keyTuple = new bytes32[](${keyTuple.length});\n ${renderList(keyTuple, (key, index) => `_keyTuple[${index}] = ${renderValueTypeToBytes32(key.name, key)};`)}\n `;\n\n return {\n _tableId,\n _typedTableId,\n _keyArgs,\n _typedKeyArgs,\n _keyTupleDefinition,\n };\n}\n\n/** For 2 paths which are relative to a common root, create a relative import path from one to another */\nexport function solidityRelativeImportPath(fromPath: string, usedInPath: string): string {\n // 1st \"./\" must be added because path strips it,\n // but solidity expects it unless there's \"../\" (\"./../\" is fine).\n // 2nd and 3rd \"./\" forcefully avoid absolute paths (everything is relative to `src`).\n return posixPath(\"./\" + path.relative(\"./\" + usedInPath, \"./\" + fromPath));\n}\n\n/**\n * Aggregates, deduplicates and renders imports for symbols per path.\n * Identical symbols from different paths are NOT handled, they should be checked before rendering.\n */\nexport function renderImports(imports: ImportDatum[]): string {\n return renderAbsoluteImports(\n imports.map((importDatum) => {\n if (\"path\" in importDatum) {\n return importDatum;\n } else {\n return {\n symbol: importDatum.symbol,\n path: solidityRelativeImportPath(importDatum.fromPath, importDatum.usedInPath),\n };\n }\n })\n );\n}\n\n/**\n * Aggregates, deduplicates and renders imports for symbols per path.\n * Identical symbols from different paths are NOT handled, they should be checked before rendering.\n */\nexport function renderRelativeImports(imports: RelativeImportDatum[]): string {\n return renderAbsoluteImports(\n imports.map(({ symbol, fromPath, usedInPath }) => ({\n symbol,\n path: solidityRelativeImportPath(fromPath, usedInPath),\n }))\n );\n}\n\n/**\n * Aggregates, deduplicates and renders imports for symbols per path.\n * Identical symbols from different paths are NOT handled, they should be checked before rendering.\n */\nexport function renderAbsoluteImports(imports: AbsoluteImportDatum[]): string {\n // Aggregate symbols by import path, also deduplicating them\n const aggregatedImports = new Map<string, Set<string>>();\n for (const { symbol, path } of imports) {\n if (!aggregatedImports.has(path)) {\n aggregatedImports.set(path, new Set());\n }\n aggregatedImports.get(path)?.add(symbol);\n }\n // Render imports\n const renderedImports = [];\n for (const [path, symbols] of aggregatedImports) {\n const renderedSymbols = [...symbols].join(\", \");\n renderedImports.push(`import { ${renderedSymbols} } from \"${posixPath(path)}\";`);\n }\n return renderedImports.join(\"\\n\");\n}\n\nexport function renderWithStore(\n storeArgument: boolean,\n callback: (\n _typedStore: string | undefined,\n _store: string,\n _commentSuffix: string,\n _untypedStore: string | undefined\n ) => string\n): string {\n let result = \"\";\n result += callback(undefined, \"StoreSwitch\", \"\", undefined);\n\n if (storeArgument) {\n result += \"\\n\" + callback(\"IStore _store\", \"_store\", \" (using the specified store)\", \"_store\");\n }\n\n return result;\n}\n\nexport function renderTableId(staticResourceData: StaticResourceData): {\n hardcodedTableId: string;\n tableIdDefinition: string;\n} {\n const hardcodedTableId = `bytes32(abi.encodePacked(bytes16(\"${staticResourceData.namespace}\"), bytes16(\"${staticResourceData.name}\")))`;\n\n const tableIdDefinition = `\n bytes32 constant _tableId = ${hardcodedTableId};\n bytes32 constant ${staticResourceData.tableIdName} = _tableId;\n `;\n return {\n hardcodedTableId,\n tableIdDefinition,\n };\n}\n\nexport function renderValueTypeToBytes32(name: string, { typeUnwrap, internalTypeId }: RenderType): string {\n const innerText = typeUnwrap.length ? `${typeUnwrap}(${name})` : name;\n\n if (internalTypeId === \"bytes32\") {\n return innerText;\n } else if (internalTypeId.match(/^bytes\\d{1,2}$/)) {\n return `bytes32(${innerText})`;\n } else if (internalTypeId.match(/^uint\\d{1,3}$/)) {\n return `bytes32(uint256(${innerText}))`;\n } else if (internalTypeId.match(/^int\\d{1,3}$/)) {\n return `bytes32(uint256(int256(${innerText})))`;\n } else if (internalTypeId === \"address\") {\n return `bytes32(uint256(uint160(${innerText})))`;\n } else if (internalTypeId === \"bool\") {\n return `_boolToBytes32(${innerText})`;\n } else {\n throw new Error(`Unknown value type id ${internalTypeId}`);\n }\n}\n\nfunction internalRenderList<T>(\n lineTerminator: string,\n list: T[],\n renderItem: (item: T, index: number) => string\n): string {\n return list\n .map((item, index) => renderItem(item, index) + (index === list.length - 1 ? \"\" : lineTerminator))\n .join(\"\\n\");\n}\n","import { parse, visit } from \"@solidity-parser/parser\";\nimport type { SourceUnit, TypeName, VariableDeclaration } from \"@solidity-parser/parser/dist/src/ast-types\";\nimport { MUDError } from \"../../errors\";\n\nexport interface ContractInterfaceFunction {\n name: string;\n parameters: string[];\n stateMutability: string;\n returnParameters: string[];\n}\n\nexport interface ContractInterfaceError {\n name: string;\n parameters: string[];\n}\n\ninterface SymbolImport {\n symbol: string;\n path: string;\n}\n\n/**\n * Parse the contract data to get the functions necessary to generate an interface,\n * and symbols to import from the original contract.\n * @param data contents of a file with the solidity contract\n * @param contractName name of the contract\n * @returns interface data\n */\nexport function contractToInterface(\n data: string,\n contractName: string\n): {\n functions: ContractInterfaceFunction[];\n errors: ContractInterfaceError[];\n symbolImports: SymbolImport[];\n} {\n const ast = parse(data);\n\n let withContract = false;\n let symbolImports: SymbolImport[] = [];\n const functions: ContractInterfaceFunction[] = [];\n const errors: ContractInterfaceError[] = [];\n\n visit(ast, {\n ContractDefinition({ name }) {\n if (name === contractName) {\n withContract = true;\n }\n },\n FunctionDefinition(\n { name, visibility, parameters, stateMutability, returnParameters, isConstructor, isFallback, isReceiveEther },\n parent\n ) {\n if (parent !== undefined && parent.type === \"ContractDefinition\" && parent.name === contractName) {\n try {\n // skip constructor and fallbacks\n if (isConstructor || isFallback || isReceiveEther) return;\n // forbid default visibility (this check might be unnecessary, modern solidity already disallows this)\n if (visibility === \"default\") throw new MUDError(`Visibility is not specified`);\n\n if (visibility === \"external\" || visibility === \"public\") {\n functions.push({\n name: name === null ? \"\" : name,\n parameters: parameters.map(parseParameter),\n stateMutability: stateMutability || \"\",\n returnParameters: returnParameters === null ? [] : returnParameters.map(parseParameter),\n });\n\n for (const { typeName } of parameters.concat(returnParameters ?? [])) {\n const symbols = typeNameToSymbols(typeName);\n symbolImports = symbolImports.concat(symbolsToImports(ast, symbols));\n }\n }\n } catch (error: unknown) {\n if (error instanceof MUDError) {\n error.message = `Function \"${name}\" in contract \"${contractName}\": ${error.message}`;\n }\n throw error;\n }\n }\n },\n CustomErrorDefinition({ name, parameters }) {\n errors.push({\n name: name === null ? \"\" : name,\n parameters: parameters.map(parseParameter),\n });\n\n for (const parameter of parameters) {\n const symbols = typeNameToSymbols(parameter.typeName);\n symbolImports = symbolImports.concat(symbolsToImports(ast, symbols));\n }\n },\n });\n\n if (!withContract) {\n throw new MUDError(`Contract not found: ${contractName}`);\n }\n\n return {\n functions,\n errors,\n symbolImports,\n };\n}\n\nfunction parseParameter({ name, typeName, storageLocation }: VariableDeclaration): string {\n let typedNameWithLocation = \"\";\n\n const { name: flattenedTypeName, stateMutability } = flattenTypeName(typeName);\n // type name (e.g. uint256)\n typedNameWithLocation += flattenedTypeName;\n // optional mutability (e.g. address payable)\n if (stateMutability !== null) {\n typedNameWithLocation += ` ${stateMutability}`;\n }\n // location, when relevant (e.g. string memory)\n if (storageLocation !== null) {\n typedNameWithLocation += ` ${storageLocation}`;\n }\n // optional variable name\n if (name !== null) {\n typedNameWithLocation += ` ${name}`;\n }\n\n return typedNameWithLocation;\n}\n\nfunction flattenTypeName(typeName: TypeName | null): { name: string; stateMutability: string | null } {\n if (typeName === null) {\n return {\n name: \"\",\n stateMutability: null,\n };\n }\n if (typeName.type === \"ElementaryTypeName\") {\n return {\n name: typeName.name,\n stateMutability: typeName.stateMutability,\n };\n } else if (typeName.type === \"UserDefinedTypeName\") {\n return {\n name: typeName.namePath,\n stateMutability: null,\n };\n } else if (typeName.type === \"ArrayTypeName\") {\n let length = \"\";\n if (typeName.length?.type === \"NumberLiteral\") {\n length = typeName.length.number;\n } else if (typeName.length?.type === \"Identifier\") {\n length = typeName.length.name;\n }\n\n const { name, stateMutability } = flattenTypeName(typeName.baseTypeName);\n return {\n name: `${name}[${length}]`,\n stateMutability,\n };\n } else {\n // TODO function types are unsupported but could be useful\n throw new MUDError(`Invalid typeName.type ${typeName.type}`);\n }\n}\n\n// Get symbols that need to be imported for given typeName\nfunction typeNameToSymbols(typeName: TypeName | null): string[] {\n if (typeName?.type === \"UserDefinedTypeName\") {\n // split is needed to get a library, if types are internal to it\n const symbol = typeName.namePath.split(\".\")[0];\n return [symbol];\n } else if (typeName?.type === \"ArrayTypeName\") {\n const symbols = typeNameToSymbols(typeName.baseTypeName);\n // array types can also use symbols (constants) for length\n if (typeName.length?.type === \"Identifier\") {\n const innerTypeName = typeName.length.name;\n symbols.push(innerTypeName.split(\".\")[0]);\n }\n return symbols;\n } else {\n return [];\n }\n}\n\n// Get imports for given symbols.\n// To avoid circular dependencies of interfaces on their implementations,\n// symbols used for args/returns must always be imported from an auxiliary file.\n// To avoid parsing the entire project to build dependencies,\n// symbols must be imported with an explicit `import { symbol } from ...`\nfunction symbolsToImports(ast: SourceUnit, symbols: string[]): SymbolImport[] {\n const imports: SymbolImport[] = [];\n\n for (const symbol of symbols) {\n let symbolImport: SymbolImport | undefined;\n\n visit(ast, {\n ImportDirective({ path, symbolAliases }) {\n if (symbolAliases) {\n for (const symbolAndAlias of symbolAliases) {\n // either check the alias, or the original symbol if there's no alias\n const symbolAlias = symbolAndAlias[1] || symbolAndAlias[0];\n if (symbol === symbolAlias) {\n symbolImport = {\n // always use the original symbol for interface imports\n symbol: symbolAndAlias[0],\n path,\n };\n return;\n }\n }\n }\n },\n });\n\n if (symbolImport) {\n imports.push(symbolImport);\n } else {\n throw new MUDError(`Symbol \"${symbol}\" has no explicit import`);\n }\n }\n\n return imports;\n}\n","import chalk from \"chalk\";\nimport prettier from \"prettier\";\nimport prettierPluginSolidity from \"prettier-plugin-solidity\";\n\nexport async function formatSolidity(content: string, prettierConfigPath?: string): Promise<string> {\n let config;\n if (prettierConfigPath) {\n config = await prettier.resolveConfig(prettierConfigPath);\n }\n try {\n return prettier.format(content, {\n plugins: [prettierPluginSolidity],\n parser: \"solidity-parse\",\n\n printWidth: 120,\n semi: true,\n tabWidth: 2,\n useTabs: false,\n bracketSpacing: true,\n\n ...config,\n });\n } catch (error) {\n let message;\n if (error instanceof Error) {\n message = error.message;\n } else {\n message = error;\n }\n console.log(chalk.yellow(`Error during output formatting: ${message}`));\n return content;\n }\n}\n\nexport async function formatTypescript(content: string): Promise<string> {\n return prettier.format(content, {\n parser: \"typescript\",\n });\n}\n","import { mkdirSync, writeFileSync } from \"fs\";\nimport { dirname } from \"path\";\nimport { formatSolidity, formatTypescript } from \"./format\";\n\nexport async function formatAndWriteSolidity(output: string, fullOutputPath: string, logPrefix: string): Promise<void> {\n const formattedOutput = await formatSolidity(output);\n\n mkdirSync(dirname(fullOutputPath), { recursive: true });\n\n writeFileSync(fullOutputPath, formattedOutput);\n console.log(`${logPrefix}: ${fullOutputPath}`);\n}\n\nexport async function formatAndWriteTypescript(\n output: string,\n fullOutputPath: string,\n logPrefix: string\n): Promise<void> {\n const formattedOutput = await formatTypescript(output);\n\n mkdirSync(dirname(fullOutputPath), { recursive: true });\n\n writeFileSync(fullOutputPath, formattedOutput);\n console.log(`${logPrefix}: ${fullOutputPath}`);\n}\n","/**\n * Explicitly normalize a given path to a posix path (using `/` as separator).\n * This should be used for generating Solidity files that will be consumed by solc,\n * because solc expects `/` as path separator, but path.join produces `\\` if the user is on windows.\n */\nexport function posixPath(path: string): string {\n return path.replace(/\\\\/g, \"/\");\n}\n","import { renderArguments, renderList, renderedSolidityHeader } from \"./common\";\nimport { RenderEnum } from \"./types\";\n\nexport function renderEnums(enums: RenderEnum[]): string {\n let result = renderedSolidityHeader;\n\n result += renderList(\n enums,\n ({ name, memberNames }) => `\n enum ${name} {\n ${renderArguments(memberNames)}\n }\n `\n );\n\n return result;\n}\n","import { RenderField, RenderKeyTuple, RenderType } from \"./types\";\n\nexport function renderTypeHelpers(options: { fields: RenderField[]; keyTuple: RenderKeyTuple[] }): string {\n const { fields, keyTuple } = options;\n\n let result = \"\";\n\n for (const wrappingHelper of getWrappingHelpers([...fields, ...keyTuple])) {\n result += wrappingHelper;\n }\n\n // bool is special - it's the only primitive value type that can't be typecasted to/from\n if (fields.some(({ internalTypeId }) => internalTypeId.match(\"bool\"))) {\n result += `\n function _toBool(uint8 value) pure returns (bool result) {\n assembly {\n result := value\n }\n }\n `;\n }\n if (keyTuple.some(({ internalTypeId }) => internalTypeId.match(\"bool\"))) {\n result += `\n function _boolToBytes32(bool value) pure returns (bytes32 result) {\n assembly {\n result := value\n }\n }\n `;\n }\n\n return result;\n}\n\nfunction getWrappingHelpers(array: RenderType[]): string[] {\n const wrappers = new Map<string, string>();\n const unwrappers = new Map<string, string>();\n for (const { typeWrappingData, typeWrap, typeUnwrap, internalTypeId } of array) {\n if (!typeWrappingData) continue;\n const { kind } = typeWrappingData;\n\n if (kind === \"staticArray\") {\n const { elementType, staticLength } = typeWrappingData;\n wrappers.set(typeWrap, renderWrapperStaticArray(typeWrap, elementType, staticLength, internalTypeId));\n unwrappers.set(typeUnwrap, renderUnwrapperStaticArray(typeUnwrap, elementType, staticLength, internalTypeId));\n }\n }\n\n return [...wrappers.values(), ...unwrappers.values()];\n}\n\nfunction renderWrapperStaticArray(\n functionName: string,\n elementType: string,\n staticLength: number,\n internalTypeId: string\n): string {\n // WARNING: ensure this still works if changing major solidity versions!\n // (the memory layout for static arrays may change)\n return `\n function ${functionName}(\n ${internalTypeId} memory _value\n ) pure returns (\n ${elementType}[${staticLength}] memory _result\n ) {\n // in memory static arrays are just dynamic arrays without the length byte\n assembly {\n _result := add(_value, 0x20)\n }\n }\n `;\n}\n\nfunction renderUnwrapperStaticArray(\n functionName: string,\n elementType: string,\n staticLength: number,\n internalTypeId: string\n): string {\n // byte length for memory copying (more efficient than a loop)\n const byteLength = staticLength * 32;\n // TODO to optimize memory usage consider generalizing TightEncoder to a render-time utility\n return `\n function ${functionName}(\n ${elementType}[${staticLength}] memory _value\n ) pure returns (\n ${internalTypeId} memory _result\n ) {\n _result = new ${internalTypeId}(${staticLength});\n uint256 fromPointer;\n uint256 toPointer;\n assembly {\n fromPointer := _value\n toPointer := add(_result, 0x20)\n }\n Memory.copy(fromPointer, toPointer, ${byteLength});\n }\n `;\n}\n","import { SchemaType } from \"@latticexyz/schema-type/deprecated\";\n\nexport const schemaTypesToRecsTypeStrings: Record<SchemaType, string> = {\n [SchemaType.UINT8]: \"RecsType.Number\",\n [SchemaType.UINT16]: \"RecsType.Number\",\n [SchemaType.UINT24]: \"RecsType.Number\",\n [SchemaType.UINT32]: \"RecsType.Number\",\n [SchemaType.UINT40]: \"RecsType.Number\",\n [SchemaType.UINT48]: \"RecsType.Number\",\n [SchemaType.UINT56]: \"RecsType.BigInt\",\n [SchemaType.UINT64]: \"RecsType.BigInt\",\n [SchemaType.UINT72]: \"RecsType.BigInt\",\n [SchemaType.UINT80]: \"RecsType.BigInt\",\n [SchemaType.UINT88]: \"RecsType.BigInt\",\n [SchemaType.UINT96]: \"RecsType.BigInt\",\n [SchemaType.UINT104]: \"RecsType.BigInt\",\n [SchemaType.UINT112]: \"RecsType.BigInt\",\n [SchemaType.UINT120]: \"RecsType.BigInt\",\n [SchemaType.UINT128]: \"RecsType.BigInt\",\n [SchemaType.UINT136]: \"RecsType.BigInt\",\n [SchemaType.UINT144]: \"RecsType.BigInt\",\n [SchemaType.UINT152]: \"RecsType.BigInt\",\n [SchemaType.UINT160]: \"RecsType.BigInt\",\n [SchemaType.UINT168]: \"RecsType.BigInt\",\n [SchemaType.UINT176]: \"RecsType.BigInt\",\n [SchemaType.UINT184]: \"RecsType.BigInt\",\n [SchemaType.UINT192]: \"RecsType.BigInt\",\n [SchemaType.UINT200]: \"RecsType.BigInt\",\n [SchemaType.UINT208]: \"RecsType.BigInt\",\n [SchemaType.UINT216]: \"RecsType.BigInt\",\n [SchemaType.UINT224]: \"RecsType.BigInt\",\n [SchemaType.UINT232]: \"RecsType.BigInt\",\n [SchemaType.UINT240]: \"RecsType.BigInt\",\n [SchemaType.UINT248]: \"RecsType.BigInt\",\n [SchemaType.UINT256]: \"RecsType.BigInt\",\n [SchemaType.INT8]: \"RecsType.Number\",\n [SchemaType.INT16]: \"RecsType.Number\",\n [SchemaType.INT24]: \"RecsType.Number\",\n [SchemaType.INT32]: \"RecsType.Number\",\n [SchemaType.INT40]: \"RecsType.Number\",\n [SchemaType.INT48]: \"RecsType.Number\",\n [SchemaType.INT56]: \"RecsType.BigInt\",\n [SchemaType.INT64]: \"RecsType.BigInt\",\n [SchemaType.INT72]: \"RecsType.BigInt\",\n [SchemaType.INT80]: \"RecsType.BigInt\",\n [SchemaType.INT88]: \"RecsType.BigInt\",\n [SchemaType.INT96]: \"RecsType.BigInt\",\n [SchemaType.INT104]: \"RecsType.BigInt\",\n [SchemaType.INT112]: \"RecsType.BigInt\",\n [SchemaType.INT120]: \"RecsType.BigInt\",\n [SchemaType.INT128]: \"RecsType.BigInt\",\n [SchemaType.INT136]: \"RecsType.BigInt\",\n [SchemaType.INT144]: \"RecsType.BigInt\",\n [SchemaType.INT152]: \"RecsType.BigInt\",\n [SchemaType.INT160]: \"RecsType.BigInt\",\n [SchemaType.INT168]: \"RecsType.BigInt\",\n [SchemaType.INT176]: \"RecsType.BigInt\",\n [SchemaType.INT184]: \"RecsType.BigInt\",\n [SchemaType.INT192]: \"RecsType.BigInt\",\n [SchemaType.INT200]: \"RecsType.BigInt\",\n [SchemaType.INT208]: \"RecsType.BigInt\",\n [SchemaType.INT216]: \"RecsType.BigInt\",\n [SchemaType.INT224]: \"RecsType.BigInt\",\n [SchemaType.INT232]: \"RecsType.BigInt\",\n [SchemaType.INT240]: \"RecsType.BigInt\",\n [SchemaType.INT248]: \"RecsType.BigInt\",\n [SchemaType.INT256]: \"RecsType.BigInt\",\n [SchemaType.BYTES1]: \"RecsType.String\",\n [SchemaType.BYTES2]: \"RecsType.String\",\n [SchemaType.BYTES3]: \"RecsType.String\",\n [SchemaType.BYTES4]: \"RecsType.String\",\n [SchemaType.BYTES5]: \"RecsType.String\",\n [SchemaType.BYTES6]: \"RecsType.String\",\n [SchemaType.BYTES7]: \"RecsType.String\",\n [SchemaType.BYTES8]: \"RecsType.String\",\n [SchemaType.BYTES9]: \"RecsType.String\",\n [SchemaType.BYTES10]: \"RecsType.String\",\n [SchemaType.BYTES11]: \"RecsType.String\",\n [SchemaType.BYTES12]: \"RecsType.String\",\n [SchemaType.BYTES13]: \"RecsType.String\",\n [SchemaType.BYTES14]: \"RecsType.String\",\n [SchemaType.BYTES15]: \"RecsType.String\",\n [SchemaType.BYTES16]: \"RecsType.String\",\n [SchemaType.BYTES17]: \"RecsType.String\",\n [SchemaType.BYTES18]: \"RecsType.String\",\n [SchemaType.BYTES19]: \"RecsType.String\",\n [SchemaType.BYTES20]: \"RecsType.String\",\n [SchemaType.BYTES21]: \"RecsType.String\",\n [SchemaType.BYTES22]: \"RecsType.String\",\n [SchemaType.BYTES23]: \"RecsType.String\",\n [SchemaType.BYTES24]: \"RecsType.String\",\n [SchemaType.BYTES25]: \"RecsType.String\",\n [SchemaType.BYTES26]: \"RecsType.String\",\n [SchemaType.BYTES27]: \"RecsType.String\",\n [SchemaType.BYTES28]: \"RecsType.String\",\n [SchemaType.BYTES29]: \"RecsType.String\",\n [SchemaType.BYTES30]: \"RecsType.String\",\n [SchemaType.BYTES31]: \"RecsType.String\",\n [SchemaType.BYTES32]: \"RecsType.String\",\n [SchemaType.BOOL]: \"RecsType.Boolean\",\n [SchemaType.ADDRESS]: \"RecsType.String\",\n [SchemaType.UINT8_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT16_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT24_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT32_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT40_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT48_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT56_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT64_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT72_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT80_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT88_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT96_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT104_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT112_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT120_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT128_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT136_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT144_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT152_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT160_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT168_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT176_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT184_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT192_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT200_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT208_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT216_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT224_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT232_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT240_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT248_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT256_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT8_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT16_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT24_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT32_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT40_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT48_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT56_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT64_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT72_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT80_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT88_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT96_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT104_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT112_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT120_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT128_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT136_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT144_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT152_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT160_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT168_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT176_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT184_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT192_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT200_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT208_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT216_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT224_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT232_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT240_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT248_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT256_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES1_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES2_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES3_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES4_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES5_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES6_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES7_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES8_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES9_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES10_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES11_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES12_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES13_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES14_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES15_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES16_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES17_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES18_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES19_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES20_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES21_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES22_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES23_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES24_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES25_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES26_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES27_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES28_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES29_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES30_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES31_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES32_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BOOL_ARRAY]: \"RecsType.T\", // no boolean array\n [SchemaType.ADDRESS_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES]: \"RecsType.String\",\n [SchemaType.STRING]: \"RecsType.String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a,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,UAAU,EAAG,aACzB,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,KAAK,EAAG,kBACpB,CAACA,EAAW,MAAM,EAAG,iBACvB","names":["path","parse","visit","contractToInterface","data","contractName","ast","parse","withContract","symbolImports","functions","errors","visit","name","visibility","parameters","stateMutability","returnParameters","isConstructor","isFallback","isReceiveEther","parent","MUDError","parseParameter","typeName","symbols","typeNameToSymbols","symbolsToImports","error","parameter","storageLocation","typedNameWithLocation","flattenedTypeName","flattenTypeName","length","innerTypeName","imports","symbol","symbolImport","path","symbolAliases","symbolAndAlias","symbolAlias","chalk","prettier","prettierPluginSolidity","formatSolidity","content","prettierConfigPath","config","error","message","formatTypescript","mkdirSync","writeFileSync","dirname","formatAndWriteSolidity","output","fullOutputPath","logPrefix","formattedOutput","formatSolidity","mkdirSync","dirname","writeFileSync","formatAndWriteTypescript","formatTypescript","posixPath","path","renderedSolidityHeader","renderList","list","renderItem","internalRenderList","renderArguments","args","filteredArgs","arg","renderCommonData","staticResourceData","keyTuple","_tableId","_typedTableId","_keyArgs","name","_typedKeyArgs","typeWithLocation","_keyTupleDefinition","key","index","renderValueTypeToBytes32","solidityRelativeImportPath","fromPath","usedInPath","posixPath","path","renderImports","imports","renderAbsoluteImports","importDatum","renderRelativeImports","symbol","aggregatedImports","renderedImports","symbols","renderedSymbols","renderWithStore","storeArgument","callback","result","renderTableId","hardcodedTableId","tableIdDefinition","typeUnwrap","internalTypeId","innerText","lineTerminator","item","renderEnums","enums","result","renderedSolidityHeader","renderList","name","memberNames","renderArguments","renderTypeHelpers","options","fields","keyTuple","result","wrappingHelper","getWrappingHelpers","internalTypeId","array","wrappers","unwrappers","typeWrappingData","typeWrap","typeUnwrap","kind","elementType","staticLength","renderWrapperStaticArray","renderUnwrapperStaticArray","functionName","byteLength","SchemaType","schemaTypesToRecsTypeStrings"]}
|
|
1
|
+
{"version":3,"sources":["../src/codegen/render-solidity/common.ts","../src/codegen/utils/contractToInterface.ts","../src/codegen/utils/format.ts","../src/codegen/utils/formatAndWrite.ts","../src/codegen/utils/posixPath.ts","../src/codegen/render-solidity/renderEnums.ts","../src/codegen/render-solidity/renderTypeHelpers.ts","../src/codegen/render-typescript/schemaTypesToRecsTypeStrings.ts"],"sourcesContent":["import path from \"path\";\nimport {\n AbsoluteImportDatum,\n RelativeImportDatum,\n ImportDatum,\n StaticResourceData,\n RenderKeyTuple,\n RenderType,\n} from \"./types\";\nimport { posixPath } from \"../utils\";\n\nexport const renderedSolidityHeader = `// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\n/* Autogenerated file. Do not edit manually. */`;\n\n/**\n * Renders a list of lines\n */\nexport function renderList<T>(list: T[], renderItem: (item: T, index: number) => string): string {\n return internalRenderList(\"\", list, renderItem);\n}\n\n/**\n * Renders a comma-separated list of arguments for solidity functions, ignoring empty and undefined ones\n */\nexport function renderArguments(args: (string | undefined)[]): string {\n const filteredArgs = args.filter((arg) => arg !== undefined && arg !== \"\") as string[];\n return internalRenderList(\",\", filteredArgs, (arg) => arg);\n}\n\nexport function renderCommonData({\n staticResourceData,\n keyTuple,\n}: {\n staticResourceData?: StaticResourceData;\n keyTuple: RenderKeyTuple[];\n}): {\n _tableId: string;\n _typedTableId: string;\n _keyArgs: string;\n _typedKeyArgs: string;\n _keyTupleDefinition: string;\n} {\n // static resource means static tableId as well, and no tableId arguments\n const _tableId = staticResourceData ? \"\" : \"_tableId\";\n const _typedTableId = staticResourceData ? \"\" : \"bytes32 _tableId\";\n\n const _keyArgs = renderArguments(keyTuple.map(({ name }) => name));\n const _typedKeyArgs = renderArguments(keyTuple.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`));\n\n const _keyTupleDefinition = `\n bytes32[] memory _keyTuple = new bytes32[](${keyTuple.length});\n ${renderList(keyTuple, (key, index) => `_keyTuple[${index}] = ${renderValueTypeToBytes32(key.name, key)};`)}\n `;\n\n return {\n _tableId,\n _typedTableId,\n _keyArgs,\n _typedKeyArgs,\n _keyTupleDefinition,\n };\n}\n\n/** For 2 paths which are relative to a common root, create a relative import path from one to another */\nexport function solidityRelativeImportPath(fromPath: string, usedInPath: string): string {\n // 1st \"./\" must be added because path strips it,\n // but solidity expects it unless there's \"../\" (\"./../\" is fine).\n // 2nd and 3rd \"./\" forcefully avoid absolute paths (everything is relative to `src`).\n return posixPath(\"./\" + path.relative(\"./\" + usedInPath, \"./\" + fromPath));\n}\n\n/**\n * Aggregates, deduplicates and renders imports for symbols per path.\n * Identical symbols from different paths are NOT handled, they should be checked before rendering.\n */\nexport function renderImports(imports: ImportDatum[]): string {\n return renderAbsoluteImports(\n imports.map((importDatum) => {\n if (\"path\" in importDatum) {\n return importDatum;\n } else {\n return {\n symbol: importDatum.symbol,\n path: solidityRelativeImportPath(importDatum.fromPath, importDatum.usedInPath),\n };\n }\n })\n );\n}\n\n/**\n * Aggregates, deduplicates and renders imports for symbols per path.\n * Identical symbols from different paths are NOT handled, they should be checked before rendering.\n */\nexport function renderRelativeImports(imports: RelativeImportDatum[]): string {\n return renderAbsoluteImports(\n imports.map(({ symbol, fromPath, usedInPath }) => ({\n symbol,\n path: solidityRelativeImportPath(fromPath, usedInPath),\n }))\n );\n}\n\n/**\n * Aggregates, deduplicates and renders imports for symbols per path.\n * Identical symbols from different paths are NOT handled, they should be checked before rendering.\n */\nexport function renderAbsoluteImports(imports: AbsoluteImportDatum[]): string {\n // Aggregate symbols by import path, also deduplicating them\n const aggregatedImports = new Map<string, Set<string>>();\n for (const { symbol, path } of imports) {\n if (!aggregatedImports.has(path)) {\n aggregatedImports.set(path, new Set());\n }\n aggregatedImports.get(path)?.add(symbol);\n }\n // Render imports\n const renderedImports = [];\n for (const [path, symbols] of aggregatedImports) {\n const renderedSymbols = [...symbols].join(\", \");\n renderedImports.push(`import { ${renderedSymbols} } from \"${posixPath(path)}\";`);\n }\n return renderedImports.join(\"\\n\");\n}\n\nexport function renderWithStore(\n storeArgument: boolean,\n callback: (\n _typedStore: string | undefined,\n _store: string,\n _commentSuffix: string,\n _untypedStore: string | undefined\n ) => string\n): string {\n let result = \"\";\n result += callback(undefined, \"StoreSwitch\", \"\", undefined);\n\n if (storeArgument) {\n result += \"\\n\" + callback(\"IStore _store\", \"_store\", \" (using the specified store)\", \"_store\");\n }\n\n return result;\n}\n\nexport function renderTableId(staticResourceData: StaticResourceData): {\n hardcodedTableId: string;\n tableIdDefinition: string;\n} {\n const hardcodedTableId = `bytes32(abi.encodePacked(bytes16(\"${staticResourceData.namespace}\"), bytes16(\"${staticResourceData.name}\")))`;\n\n const tableIdDefinition = `\n bytes32 constant _tableId = ${hardcodedTableId};\n bytes32 constant ${staticResourceData.tableIdName} = _tableId;\n `;\n return {\n hardcodedTableId,\n tableIdDefinition,\n };\n}\n\nexport function renderValueTypeToBytes32(name: string, { typeUnwrap, internalTypeId }: RenderType): string {\n const innerText = typeUnwrap.length ? `${typeUnwrap}(${name})` : name;\n\n if (internalTypeId === \"bytes32\") {\n return innerText;\n } else if (internalTypeId.match(/^bytes\\d{1,2}$/)) {\n return `bytes32(${innerText})`;\n } else if (internalTypeId.match(/^uint\\d{1,3}$/)) {\n return `bytes32(uint256(${innerText}))`;\n } else if (internalTypeId.match(/^int\\d{1,3}$/)) {\n return `bytes32(uint256(int256(${innerText})))`;\n } else if (internalTypeId === \"address\") {\n return `bytes32(uint256(uint160(${innerText})))`;\n } else if (internalTypeId === \"bool\") {\n return `_boolToBytes32(${innerText})`;\n } else {\n throw new Error(`Unknown value type id ${internalTypeId}`);\n }\n}\n\nexport function isLeftAligned(field: Pick<RenderType, \"internalTypeId\">): boolean {\n return field.internalTypeId.match(/^bytes\\d{1,2}$/) !== null;\n}\n\nexport function getLeftPaddingBits(field: Pick<RenderType, \"internalTypeId\" | \"staticByteLength\">): number {\n if (isLeftAligned(field)) {\n return 0;\n } else {\n return 256 - field.staticByteLength * 8;\n }\n}\n\nfunction internalRenderList<T>(\n lineTerminator: string,\n list: T[],\n renderItem: (item: T, index: number) => string\n): string {\n return list\n .map((item, index) => renderItem(item, index) + (index === list.length - 1 ? \"\" : lineTerminator))\n .join(\"\\n\");\n}\n","import { parse, visit } from \"@solidity-parser/parser\";\nimport type { SourceUnit, TypeName, VariableDeclaration } from \"@solidity-parser/parser/dist/src/ast-types\";\nimport { MUDError } from \"../../errors\";\n\nexport interface ContractInterfaceFunction {\n name: string;\n parameters: string[];\n stateMutability: string;\n returnParameters: string[];\n}\n\nexport interface ContractInterfaceError {\n name: string;\n parameters: string[];\n}\n\ninterface SymbolImport {\n symbol: string;\n path: string;\n}\n\n/**\n * Parse the contract data to get the functions necessary to generate an interface,\n * and symbols to import from the original contract.\n * @param data contents of a file with the solidity contract\n * @param contractName name of the contract\n * @returns interface data\n */\nexport function contractToInterface(\n data: string,\n contractName: string\n): {\n functions: ContractInterfaceFunction[];\n errors: ContractInterfaceError[];\n symbolImports: SymbolImport[];\n} {\n const ast = parse(data);\n\n let withContract = false;\n let symbolImports: SymbolImport[] = [];\n const functions: ContractInterfaceFunction[] = [];\n const errors: ContractInterfaceError[] = [];\n\n visit(ast, {\n ContractDefinition({ name }) {\n if (name === contractName) {\n withContract = true;\n }\n },\n FunctionDefinition(\n { name, visibility, parameters, stateMutability, returnParameters, isConstructor, isFallback, isReceiveEther },\n parent\n ) {\n if (parent !== undefined && parent.type === \"ContractDefinition\" && parent.name === contractName) {\n try {\n // skip constructor and fallbacks\n if (isConstructor || isFallback || isReceiveEther) return;\n // forbid default visibility (this check might be unnecessary, modern solidity already disallows this)\n if (visibility === \"default\") throw new MUDError(`Visibility is not specified`);\n\n if (visibility === \"external\" || visibility === \"public\") {\n functions.push({\n name: name === null ? \"\" : name,\n parameters: parameters.map(parseParameter),\n stateMutability: stateMutability || \"\",\n returnParameters: returnParameters === null ? [] : returnParameters.map(parseParameter),\n });\n\n for (const { typeName } of parameters.concat(returnParameters ?? [])) {\n const symbols = typeNameToSymbols(typeName);\n symbolImports = symbolImports.concat(symbolsToImports(ast, symbols));\n }\n }\n } catch (error: unknown) {\n if (error instanceof MUDError) {\n error.message = `Function \"${name}\" in contract \"${contractName}\": ${error.message}`;\n }\n throw error;\n }\n }\n },\n CustomErrorDefinition({ name, parameters }) {\n errors.push({\n name: name === null ? \"\" : name,\n parameters: parameters.map(parseParameter),\n });\n\n for (const parameter of parameters) {\n const symbols = typeNameToSymbols(parameter.typeName);\n symbolImports = symbolImports.concat(symbolsToImports(ast, symbols));\n }\n },\n });\n\n if (!withContract) {\n throw new MUDError(`Contract not found: ${contractName}`);\n }\n\n return {\n functions,\n errors,\n symbolImports,\n };\n}\n\nfunction parseParameter({ name, typeName, storageLocation }: VariableDeclaration): string {\n let typedNameWithLocation = \"\";\n\n const { name: flattenedTypeName, stateMutability } = flattenTypeName(typeName);\n // type name (e.g. uint256)\n typedNameWithLocation += flattenedTypeName;\n // optional mutability (e.g. address payable)\n if (stateMutability !== null) {\n typedNameWithLocation += ` ${stateMutability}`;\n }\n // location, when relevant (e.g. string memory)\n if (storageLocation !== null) {\n typedNameWithLocation += ` ${storageLocation}`;\n }\n // optional variable name\n if (name !== null) {\n typedNameWithLocation += ` ${name}`;\n }\n\n return typedNameWithLocation;\n}\n\nfunction flattenTypeName(typeName: TypeName | null): { name: string; stateMutability: string | null } {\n if (typeName === null) {\n return {\n name: \"\",\n stateMutability: null,\n };\n }\n if (typeName.type === \"ElementaryTypeName\") {\n return {\n name: typeName.name,\n stateMutability: typeName.stateMutability,\n };\n } else if (typeName.type === \"UserDefinedTypeName\") {\n return {\n name: typeName.namePath,\n stateMutability: null,\n };\n } else if (typeName.type === \"ArrayTypeName\") {\n let length = \"\";\n if (typeName.length?.type === \"NumberLiteral\") {\n length = typeName.length.number;\n } else if (typeName.length?.type === \"Identifier\") {\n length = typeName.length.name;\n }\n\n const { name, stateMutability } = flattenTypeName(typeName.baseTypeName);\n return {\n name: `${name}[${length}]`,\n stateMutability,\n };\n } else {\n // TODO function types are unsupported but could be useful\n throw new MUDError(`Invalid typeName.type ${typeName.type}`);\n }\n}\n\n// Get symbols that need to be imported for given typeName\nfunction typeNameToSymbols(typeName: TypeName | null): string[] {\n if (typeName?.type === \"UserDefinedTypeName\") {\n // split is needed to get a library, if types are internal to it\n const symbol = typeName.namePath.split(\".\")[0];\n return [symbol];\n } else if (typeName?.type === \"ArrayTypeName\") {\n const symbols = typeNameToSymbols(typeName.baseTypeName);\n // array types can also use symbols (constants) for length\n if (typeName.length?.type === \"Identifier\") {\n const innerTypeName = typeName.length.name;\n symbols.push(innerTypeName.split(\".\")[0]);\n }\n return symbols;\n } else {\n return [];\n }\n}\n\n// Get imports for given symbols.\n// To avoid circular dependencies of interfaces on their implementations,\n// symbols used for args/returns must always be imported from an auxiliary file.\n// To avoid parsing the entire project to build dependencies,\n// symbols must be imported with an explicit `import { symbol } from ...`\nfunction symbolsToImports(ast: SourceUnit, symbols: string[]): SymbolImport[] {\n const imports: SymbolImport[] = [];\n\n for (const symbol of symbols) {\n let symbolImport: SymbolImport | undefined;\n\n visit(ast, {\n ImportDirective({ path, symbolAliases }) {\n if (symbolAliases) {\n for (const symbolAndAlias of symbolAliases) {\n // either check the alias, or the original symbol if there's no alias\n const symbolAlias = symbolAndAlias[1] || symbolAndAlias[0];\n if (symbol === symbolAlias) {\n symbolImport = {\n // always use the original symbol for interface imports\n symbol: symbolAndAlias[0],\n path,\n };\n return;\n }\n }\n }\n },\n });\n\n if (symbolImport) {\n imports.push(symbolImport);\n } else {\n throw new MUDError(`Symbol \"${symbol}\" has no explicit import`);\n }\n }\n\n return imports;\n}\n","import chalk from \"chalk\";\nimport prettier from \"prettier\";\nimport prettierPluginSolidity from \"prettier-plugin-solidity\";\n\nexport async function formatSolidity(content: string, prettierConfigPath?: string): Promise<string> {\n let config;\n if (prettierConfigPath) {\n config = await prettier.resolveConfig(prettierConfigPath);\n }\n try {\n return prettier.format(content, {\n plugins: [prettierPluginSolidity],\n parser: \"solidity-parse\",\n\n printWidth: 120,\n semi: true,\n tabWidth: 2,\n useTabs: false,\n bracketSpacing: true,\n\n ...config,\n });\n } catch (error) {\n let message;\n if (error instanceof Error) {\n message = error.message;\n } else {\n message = error;\n }\n console.log(chalk.yellow(`Error during output formatting: ${message}`));\n return content;\n }\n}\n\nexport async function formatTypescript(content: string): Promise<string> {\n return prettier.format(content, {\n parser: \"typescript\",\n });\n}\n","import { mkdirSync, writeFileSync } from \"fs\";\nimport { dirname } from \"path\";\nimport { formatSolidity, formatTypescript } from \"./format\";\n\nexport async function formatAndWriteSolidity(output: string, fullOutputPath: string, logPrefix: string): Promise<void> {\n const formattedOutput = await formatSolidity(output);\n\n mkdirSync(dirname(fullOutputPath), { recursive: true });\n\n writeFileSync(fullOutputPath, formattedOutput);\n console.log(`${logPrefix}: ${fullOutputPath}`);\n}\n\nexport async function formatAndWriteTypescript(\n output: string,\n fullOutputPath: string,\n logPrefix: string\n): Promise<void> {\n const formattedOutput = await formatTypescript(output);\n\n mkdirSync(dirname(fullOutputPath), { recursive: true });\n\n writeFileSync(fullOutputPath, formattedOutput);\n console.log(`${logPrefix}: ${fullOutputPath}`);\n}\n","/**\n * Explicitly normalize a given path to a posix path (using `/` as separator).\n * This should be used for generating Solidity files that will be consumed by solc,\n * because solc expects `/` as path separator, but path.join produces `\\` if the user is on windows.\n */\nexport function posixPath(path: string): string {\n return path.replace(/\\\\/g, \"/\");\n}\n","import { renderArguments, renderList, renderedSolidityHeader } from \"./common\";\nimport { RenderEnum } from \"./types\";\n\nexport function renderEnums(enums: RenderEnum[]): string {\n let result = renderedSolidityHeader;\n\n result += renderList(\n enums,\n ({ name, memberNames }) => `\n enum ${name} {\n ${renderArguments(memberNames)}\n }\n `\n );\n\n return result;\n}\n","import { RenderField, RenderKeyTuple, RenderType } from \"./types\";\n\nexport function renderTypeHelpers(options: { fields: RenderField[]; keyTuple: RenderKeyTuple[] }): string {\n const { fields, keyTuple } = options;\n\n let result = \"\";\n\n for (const wrappingHelper of getWrappingHelpers([...fields, ...keyTuple])) {\n result += wrappingHelper;\n }\n\n // bool is special - it's the only primitive value type that can't be typecasted to/from\n if (fields.some(({ internalTypeId }) => internalTypeId.match(\"bool\"))) {\n result += `\n function _toBool(uint8 value) pure returns (bool result) {\n assembly {\n result := value\n }\n }\n `;\n }\n if (keyTuple.some(({ internalTypeId }) => internalTypeId.match(\"bool\"))) {\n result += `\n function _boolToBytes32(bool value) pure returns (bytes32 result) {\n assembly {\n result := value\n }\n }\n `;\n }\n\n return result;\n}\n\nfunction getWrappingHelpers(array: RenderType[]): string[] {\n const wrappers = new Map<string, string>();\n const unwrappers = new Map<string, string>();\n for (const { typeWrappingData, typeWrap, typeUnwrap, internalTypeId } of array) {\n if (!typeWrappingData) continue;\n const { kind } = typeWrappingData;\n\n if (kind === \"staticArray\") {\n const { elementType, staticLength } = typeWrappingData;\n wrappers.set(typeWrap, renderWrapperStaticArray(typeWrap, elementType, staticLength, internalTypeId));\n unwrappers.set(typeUnwrap, renderUnwrapperStaticArray(typeUnwrap, elementType, staticLength, internalTypeId));\n }\n }\n\n return [...wrappers.values(), ...unwrappers.values()];\n}\n\nfunction renderWrapperStaticArray(\n functionName: string,\n elementType: string,\n staticLength: number,\n internalTypeId: string\n): string {\n // WARNING: ensure this still works if changing major solidity versions!\n // (the memory layout for static arrays may change)\n return `\n function ${functionName}(\n ${internalTypeId} memory _value\n ) pure returns (\n ${elementType}[${staticLength}] memory _result\n ) {\n // in memory static arrays are just dynamic arrays without the length byte\n assembly {\n _result := add(_value, 0x20)\n }\n }\n `;\n}\n\nfunction renderUnwrapperStaticArray(\n functionName: string,\n elementType: string,\n staticLength: number,\n internalTypeId: string\n): string {\n // byte length for memory copying (more efficient than a loop)\n const byteLength = staticLength * 32;\n // TODO to optimize memory usage consider generalizing TightEncoder to a render-time utility\n return `\n function ${functionName}(\n ${elementType}[${staticLength}] memory _value\n ) pure returns (\n ${internalTypeId} memory _result\n ) {\n _result = new ${internalTypeId}(${staticLength});\n uint256 fromPointer;\n uint256 toPointer;\n assembly {\n fromPointer := _value\n toPointer := add(_result, 0x20)\n }\n Memory.copy(fromPointer, toPointer, ${byteLength});\n }\n `;\n}\n","import { SchemaType } from \"@latticexyz/schema-type/deprecated\";\n\nexport const schemaTypesToRecsTypeStrings: Record<SchemaType, string> = {\n [SchemaType.UINT8]: \"RecsType.Number\",\n [SchemaType.UINT16]: \"RecsType.Number\",\n [SchemaType.UINT24]: \"RecsType.Number\",\n [SchemaType.UINT32]: \"RecsType.Number\",\n [SchemaType.UINT40]: \"RecsType.Number\",\n [SchemaType.UINT48]: \"RecsType.Number\",\n [SchemaType.UINT56]: \"RecsType.BigInt\",\n [SchemaType.UINT64]: \"RecsType.BigInt\",\n [SchemaType.UINT72]: \"RecsType.BigInt\",\n [SchemaType.UINT80]: \"RecsType.BigInt\",\n [SchemaType.UINT88]: \"RecsType.BigInt\",\n [SchemaType.UINT96]: \"RecsType.BigInt\",\n [SchemaType.UINT104]: \"RecsType.BigInt\",\n [SchemaType.UINT112]: \"RecsType.BigInt\",\n [SchemaType.UINT120]: \"RecsType.BigInt\",\n [SchemaType.UINT128]: \"RecsType.BigInt\",\n [SchemaType.UINT136]: \"RecsType.BigInt\",\n [SchemaType.UINT144]: \"RecsType.BigInt\",\n [SchemaType.UINT152]: \"RecsType.BigInt\",\n [SchemaType.UINT160]: \"RecsType.BigInt\",\n [SchemaType.UINT168]: \"RecsType.BigInt\",\n [SchemaType.UINT176]: \"RecsType.BigInt\",\n [SchemaType.UINT184]: \"RecsType.BigInt\",\n [SchemaType.UINT192]: \"RecsType.BigInt\",\n [SchemaType.UINT200]: \"RecsType.BigInt\",\n [SchemaType.UINT208]: \"RecsType.BigInt\",\n [SchemaType.UINT216]: \"RecsType.BigInt\",\n [SchemaType.UINT224]: \"RecsType.BigInt\",\n [SchemaType.UINT232]: \"RecsType.BigInt\",\n [SchemaType.UINT240]: \"RecsType.BigInt\",\n [SchemaType.UINT248]: \"RecsType.BigInt\",\n [SchemaType.UINT256]: \"RecsType.BigInt\",\n [SchemaType.INT8]: \"RecsType.Number\",\n [SchemaType.INT16]: \"RecsType.Number\",\n [SchemaType.INT24]: \"RecsType.Number\",\n [SchemaType.INT32]: \"RecsType.Number\",\n [SchemaType.INT40]: \"RecsType.Number\",\n [SchemaType.INT48]: \"RecsType.Number\",\n [SchemaType.INT56]: \"RecsType.BigInt\",\n [SchemaType.INT64]: \"RecsType.BigInt\",\n [SchemaType.INT72]: \"RecsType.BigInt\",\n [SchemaType.INT80]: \"RecsType.BigInt\",\n [SchemaType.INT88]: \"RecsType.BigInt\",\n [SchemaType.INT96]: \"RecsType.BigInt\",\n [SchemaType.INT104]: \"RecsType.BigInt\",\n [SchemaType.INT112]: \"RecsType.BigInt\",\n [SchemaType.INT120]: \"RecsType.BigInt\",\n [SchemaType.INT128]: \"RecsType.BigInt\",\n [SchemaType.INT136]: \"RecsType.BigInt\",\n [SchemaType.INT144]: \"RecsType.BigInt\",\n [SchemaType.INT152]: \"RecsType.BigInt\",\n [SchemaType.INT160]: \"RecsType.BigInt\",\n [SchemaType.INT168]: \"RecsType.BigInt\",\n [SchemaType.INT176]: \"RecsType.BigInt\",\n [SchemaType.INT184]: \"RecsType.BigInt\",\n [SchemaType.INT192]: \"RecsType.BigInt\",\n [SchemaType.INT200]: \"RecsType.BigInt\",\n [SchemaType.INT208]: \"RecsType.BigInt\",\n [SchemaType.INT216]: \"RecsType.BigInt\",\n [SchemaType.INT224]: \"RecsType.BigInt\",\n [SchemaType.INT232]: \"RecsType.BigInt\",\n [SchemaType.INT240]: \"RecsType.BigInt\",\n [SchemaType.INT248]: \"RecsType.BigInt\",\n [SchemaType.INT256]: \"RecsType.BigInt\",\n [SchemaType.BYTES1]: \"RecsType.String\",\n [SchemaType.BYTES2]: \"RecsType.String\",\n [SchemaType.BYTES3]: \"RecsType.String\",\n [SchemaType.BYTES4]: \"RecsType.String\",\n [SchemaType.BYTES5]: \"RecsType.String\",\n [SchemaType.BYTES6]: \"RecsType.String\",\n [SchemaType.BYTES7]: \"RecsType.String\",\n [SchemaType.BYTES8]: \"RecsType.String\",\n [SchemaType.BYTES9]: \"RecsType.String\",\n [SchemaType.BYTES10]: \"RecsType.String\",\n [SchemaType.BYTES11]: \"RecsType.String\",\n [SchemaType.BYTES12]: \"RecsType.String\",\n [SchemaType.BYTES13]: \"RecsType.String\",\n [SchemaType.BYTES14]: \"RecsType.String\",\n [SchemaType.BYTES15]: \"RecsType.String\",\n [SchemaType.BYTES16]: \"RecsType.String\",\n [SchemaType.BYTES17]: \"RecsType.String\",\n [SchemaType.BYTES18]: \"RecsType.String\",\n [SchemaType.BYTES19]: \"RecsType.String\",\n [SchemaType.BYTES20]: \"RecsType.String\",\n [SchemaType.BYTES21]: \"RecsType.String\",\n [SchemaType.BYTES22]: \"RecsType.String\",\n [SchemaType.BYTES23]: \"RecsType.String\",\n [SchemaType.BYTES24]: \"RecsType.String\",\n [SchemaType.BYTES25]: \"RecsType.String\",\n [SchemaType.BYTES26]: \"RecsType.String\",\n [SchemaType.BYTES27]: \"RecsType.String\",\n [SchemaType.BYTES28]: \"RecsType.String\",\n [SchemaType.BYTES29]: \"RecsType.String\",\n [SchemaType.BYTES30]: \"RecsType.String\",\n [SchemaType.BYTES31]: \"RecsType.String\",\n [SchemaType.BYTES32]: \"RecsType.String\",\n [SchemaType.BOOL]: \"RecsType.Boolean\",\n [SchemaType.ADDRESS]: \"RecsType.String\",\n [SchemaType.UINT8_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT16_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT24_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT32_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT40_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT48_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.UINT56_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT64_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT72_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT80_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT88_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT96_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT104_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT112_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT120_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT128_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT136_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT144_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT152_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT160_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT168_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT176_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT184_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT192_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT200_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT208_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT216_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT224_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT232_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT240_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT248_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.UINT256_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT8_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT16_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT24_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT32_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT40_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT48_ARRAY]: \"RecsType.NumberArray\",\n [SchemaType.INT56_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT64_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT72_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT80_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT88_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT96_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT104_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT112_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT120_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT128_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT136_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT144_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT152_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT160_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT168_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT176_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT184_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT192_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT200_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT208_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT216_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT224_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT232_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT240_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT248_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.INT256_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES1_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES2_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES3_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES4_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES5_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES6_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES7_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES8_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES9_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES10_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES11_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES12_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES13_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES14_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES15_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES16_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES17_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES18_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES19_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES20_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES21_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES22_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES23_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES24_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES25_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES26_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES27_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES28_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES29_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES30_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES31_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BYTES32_ARRAY]: \"RecsType.BigIntArray\",\n [SchemaType.BOOL_ARRAY]: \"RecsType.T\", // no boolean array\n [SchemaType.ADDRESS_ARRAY]: \"RecsType.StringArray\",\n [SchemaType.BYTES]: \"RecsType.String\",\n [SchemaType.STRING]: \"RecsType.String\",\n};\n"],"mappings":"mCAAA,OAAOA,MAAU,OCAjB,OAAS,SAAAC,EAAO,SAAAC,MAAa,0BA4BtB,SAASC,EACdC,EACAC,EAKA,CACA,IAAMC,EAAMC,EAAMH,CAAI,EAElBI,EAAe,GACfC,EAAgC,CAAC,EAC/BC,EAAyC,CAAC,EAC1CC,EAAmC,CAAC,EAqD1C,GAnDAC,EAAMN,EAAK,CACT,mBAAmB,CAAE,KAAAO,CAAK,EAAG,CACvBA,IAASR,IACXG,EAAe,GAEnB,EACA,mBACE,CAAE,KAAAK,EAAM,WAAAC,EAAY,WAAAC,EAAY,gBAAAC,EAAiB,iBAAAC,EAAkB,cAAAC,EAAe,WAAAC,EAAY,eAAAC,CAAe,EAC7GC,EACA,CACA,GAAIA,IAAW,QAAaA,EAAO,OAAS,sBAAwBA,EAAO,OAAShB,EAClF,GAAI,CAEF,GAAIa,GAAiBC,GAAcC,EAAgB,OAEnD,GAAIN,IAAe,UAAW,MAAM,IAAIQ,EAAS,6BAA6B,EAE9E,GAAIR,IAAe,YAAcA,IAAe,SAAU,CACxDJ,EAAU,KAAK,CACb,KAAMG,IAAS,KAAO,GAAKA,EAC3B,WAAYE,EAAW,IAAIQ,CAAc,EACzC,gBAAiBP,GAAmB,GACpC,iBAAkBC,IAAqB,KAAO,CAAC,EAAI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,YAAY,EAAG,uBAC3B,CAACA,EAAW,YAAY,EAAG,uBAC3B,CAACA,EAAW,YAAY,EAAG,uBAC3B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,UAAU,EAAG,aACzB,CAACA,EAAW,aAAa,EAAG,uBAC5B,CAACA,EAAW,KAAK,EAAG,kBACpB,CAACA,EAAW,MAAM,EAAG,iBACvB","names":["path","parse","visit","contractToInterface","data","contractName","ast","parse","withContract","symbolImports","functions","errors","visit","name","visibility","parameters","stateMutability","returnParameters","isConstructor","isFallback","isReceiveEther","parent","MUDError","parseParameter","typeName","symbols","typeNameToSymbols","symbolsToImports","error","parameter","storageLocation","typedNameWithLocation","flattenedTypeName","flattenTypeName","length","innerTypeName","imports","symbol","symbolImport","path","symbolAliases","symbolAndAlias","symbolAlias","chalk","prettier","prettierPluginSolidity","formatSolidity","content","prettierConfigPath","config","error","message","formatTypescript","mkdirSync","writeFileSync","dirname","formatAndWriteSolidity","output","fullOutputPath","logPrefix","formattedOutput","formatSolidity","mkdirSync","dirname","writeFileSync","formatAndWriteTypescript","formatTypescript","posixPath","path","renderedSolidityHeader","renderList","list","renderItem","internalRenderList","renderArguments","args","filteredArgs","arg","renderCommonData","staticResourceData","keyTuple","_tableId","_typedTableId","_keyArgs","name","_typedKeyArgs","typeWithLocation","_keyTupleDefinition","key","index","renderValueTypeToBytes32","solidityRelativeImportPath","fromPath","usedInPath","posixPath","path","renderImports","imports","renderAbsoluteImports","importDatum","renderRelativeImports","symbol","aggregatedImports","renderedImports","symbols","renderedSymbols","renderWithStore","storeArgument","callback","result","renderTableId","hardcodedTableId","tableIdDefinition","typeUnwrap","internalTypeId","innerText","isLeftAligned","field","getLeftPaddingBits","lineTerminator","item","renderEnums","enums","result","renderedSolidityHeader","renderList","name","memberNames","renderArguments","renderTypeHelpers","options","fields","keyTuple","result","wrappingHelper","getWrappingHelpers","internalTypeId","array","wrappers","unwrappers","typeWrappingData","typeWrap","typeUnwrap","kind","elementType","staticLength","renderWrapperStaticArray","renderUnwrapperStaticArray","functionName","byteLength","SchemaType","schemaTypesToRecsTypeStrings"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{stringToHex as i,hexToString as m,sliceHex as o,concatHex as c}from"viem";var n=class{namespace;name;constructor(e,t){this.namespace=e.substring(0,16),this.name=t.substring(0,16)}toString(){return`TableId<${this.namespace||"[empty]"}:${this.name||"[empty]"}>`}toHex(){return n.toHex(this.namespace,this.name)}static toHex(e,t){return c([i(e.substring(0,16),{size:16}),i(t.substring(0,16),{size:16})])}static fromHex(e){let t=m(o(e,0,16)).replace(/\0+$/,""),s=m(o(e,16,32)).replace(/\0+$/,"");return new n(t,s)}static parse(e){let t=e.match(/^TableId<(.+?):(.+?)>$/);if(!t)return null;let[,s,a]=t;return new n(s==="[empty]"?"":s,a==="[empty]"?"":a)}};function x(r){return Object.keys(r.tables).map(e=>new n(r.namespace,e))}export{n as TableId,x as getTableIds};
|
|
2
|
+
//# sourceMappingURL=deprecated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/deprecated/TableId.ts","../src/deprecated/getTableIds.ts"],"sourcesContent":["import { Hex, stringToHex, hexToString, sliceHex, concatHex } from \"viem\";\n\n/** @deprecated Use `tableIdToHex` and `hexToTableId` instead. */\nexport class TableId {\n readonly namespace: string;\n readonly name: string;\n\n constructor(namespace: string, name: string) {\n this.namespace = namespace.substring(0, 16);\n this.name = name.substring(0, 16);\n }\n\n toString(): string {\n return `TableId<${this.namespace || \"[empty]\"}:${this.name || \"[empty]\"}>`;\n }\n\n toHex(): Hex {\n return TableId.toHex(this.namespace, this.name);\n }\n\n static toHex(namespace: string, name: string): Hex {\n return concatHex([\n stringToHex(namespace.substring(0, 16), { size: 16 }),\n stringToHex(name.substring(0, 16), { size: 16 }),\n ]);\n }\n\n static fromHex(hex: Hex): TableId {\n const namespace = hexToString(sliceHex(hex, 0, 16)).replace(/\\0+$/, \"\");\n const name = hexToString(sliceHex(hex, 16, 32)).replace(/\\0+$/, \"\");\n return new TableId(namespace, name);\n }\n\n /** @deprecated Don't use this! This is a temporary hack for v2<>v1 compatibility until we can write v2 client libraries. This is here so it stays close to the formatting of `toString()` above. */\n static parse(tableIdString: string): TableId | null {\n const match = tableIdString.match(/^TableId<(.+?):(.+?)>$/);\n if (!match) return null;\n const [, namespace, name] = match;\n return new TableId(namespace === \"[empty]\" ? \"\" : namespace, name === \"[empty]\" ? \"\" : name);\n }\n}\n","import { TableId } from \"./TableId\";\n\n/** @deprecated Use `tableIdToHex` and `hexToTableId` instead. */\nexport function getTableIds(config: { namespace: string; tables: { [key: string]: unknown } }): TableId[] {\n return Object.keys(config.tables).map((table) => new TableId(config.namespace, table));\n}\n"],"mappings":"AAAA,OAAc,eAAAA,EAAa,eAAAC,EAAa,YAAAC,EAAU,aAAAC,MAAiB,OAG5D,IAAMC,EAAN,KAAc,CACV,UACA,KAET,YAAYC,EAAmBC,EAAc,CAC3C,KAAK,UAAYD,EAAU,UAAU,EAAG,EAAE,EAC1C,KAAK,KAAOC,EAAK,UAAU,EAAG,EAAE,CAClC,CAEA,UAAmB,CACjB,MAAO,WAAW,KAAK,WAAa,aAAa,KAAK,MAAQ,YAChE,CAEA,OAAa,CACX,OAAOF,EAAQ,MAAM,KAAK,UAAW,KAAK,IAAI,CAChD,CAEA,OAAO,MAAMC,EAAmBC,EAAmB,CACjD,OAAOH,EAAU,CACfH,EAAYK,EAAU,UAAU,EAAG,EAAE,EAAG,CAAE,KAAM,EAAG,CAAC,EACpDL,EAAYM,EAAK,UAAU,EAAG,EAAE,EAAG,CAAE,KAAM,EAAG,CAAC,CACjD,CAAC,CACH,CAEA,OAAO,QAAQC,EAAmB,CAChC,IAAMF,EAAYJ,EAAYC,EAASK,EAAK,EAAG,EAAE,CAAC,EAAE,QAAQ,OAAQ,EAAE,EAChED,EAAOL,EAAYC,EAASK,EAAK,GAAI,EAAE,CAAC,EAAE,QAAQ,OAAQ,EAAE,EAClE,OAAO,IAAIH,EAAQC,EAAWC,CAAI,CACpC,CAGA,OAAO,MAAME,EAAuC,CAClD,IAAMC,EAAQD,EAAc,MAAM,wBAAwB,EAC1D,GAAI,CAACC,EAAO,OAAO,KACnB,GAAM,CAAC,CAAEJ,EAAWC,CAAI,EAAIG,EAC5B,OAAO,IAAIL,EAAQC,IAAc,UAAY,GAAKA,EAAWC,IAAS,UAAY,GAAKA,CAAI,CAC7F,CACF,ECrCO,SAASI,EAAYC,EAA8E,CACxG,OAAO,OAAO,KAAKA,EAAO,MAAM,EAAE,IAAKC,GAAU,IAAIC,EAAQF,EAAO,UAAWC,CAAK,CAAC,CACvF","names":["stringToHex","hexToString","sliceHex","concatHex","TableId","namespace","name","hex","tableIdString","match","getTableIds","config","table","TableId"]}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{privateKeyToAccount as w}from"viem/accounts";function q(e){return{...w(e)}}import{getContract as M}from"viem";import O from"p-retry";import{BaseError as H,NonceTooHighError as k,NonceTooLowError as R}from"viem";import W from"debug";var l=W("mud:common");var x=l.extend("createNonceManager");function b({publicClient:e,address:n,blockTag:r}){let t={current:-1},a=typeof BroadcastChannel<"u"?new BroadcastChannel(`mud:createNonceManager:${e.chain?.id}:${n}`):null;a&&a.addEventListener("message",o=>{let T=JSON.parse(o.data);x("got nonce from broadcast channel",T),t.current=T});function s(){return t.current>=0}function d(){if(!s())throw new Error("call resetNonce before using nextNonce");let o=t.current++;return a?.postMessage(JSON.stringify(t.current)),o}async function u(){let o=await e.getTransactionCount({address:n,blockTag:r});t.current=o,a?.postMessage(JSON.stringify(t.current)),x("reset nonce to",t.current)}function C(o){return o instanceof H&&o.walk(T=>T instanceof R||T instanceof k)!=null}return{hasNonce:s,nextNonce:d,resetNonce:u,shouldResetNonce:C}}var m=l.extend("createContract");function E(e){let n=e.length&&Array.isArray(e[0]),r=n?e[0]:[],t=(n?e[1]:e[0])??{};return{args:r,options:t}}function Te({abi:e,address:n,publicClient:r,walletClient:t,onWrite:a}){let s=M({abi:e,address:n,publicClient:r,walletClient:t});if(s.write){let d=0,u=b({publicClient:r,address:t.account.address});s.write=new Proxy({},{get(C,o){async function T(c){if(c.gas)return m("gas provided, skipping simulate",o,c),c;m("simulating write",o,c);let{request:p}=await r.simulateContract({...c,account:c.account??t.account});return p}async function y(c){let p=await T(c);return await O(async()=>{u.hasNonce()||await u.resetNonce();let i=u.nextNonce();return m("calling write function with nonce",i,p),await t.writeContract({nonce:i,...p})},{retries:3,onFailedAttempt:async i=>{if(u.shouldResetNonce(i)){m("got nonce error, retrying",i),await u.resetNonce();return}throw i}})}return(...c)=>{let p=`${t.chain.id}:${t.account.address}:${d++}`,{args:i,options:N}=E(c),g={address:n,abi:e,functionName:o,args:i,...N},f=y(g);return a?.({id:p,request:g,result:f}),f}}})}return s}import{hexToString as A,sliceHex as h}from"viem";function me(e){let n=A(h(e,0,16)).replace(/\0+$/,""),r=A(h(e,16,32)).replace(/\0+$/,"");return{namespace:n,name:r}}import{stringToHex as P,concatHex as G}from"viem";function xe(e,n){return G([P(e.substring(0,16),{size:16}),P(n.substring(0,16),{size:16})])}import{keccak256 as $}from"viem";var B=l.extend("transportObserver");function Ne(e){return n=>{let r=e(n);return{...r,request:async a=>{if(a.method==="eth_sendRawTransaction"&&a.params instanceof Array){let s=a.params.map(d=>$(d));B("saw txs",s)}return r.request(a)}}}}export{q as createBurnerAccount,Te as createContract,b as createNonceManager,me as hexToTableId,xe as tableIdToHex,Ne as transportObserver};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/TableId.ts"],"sourcesContent":["import { Hex, stringToHex, hexToString, sliceHex, concatHex } from \"viem\";\n\nexport class TableId {\n readonly namespace: string;\n readonly name: string;\n\n constructor(namespace: string, name: string) {\n this.namespace = namespace.substring(0, 16);\n this.name = name.substring(0, 16);\n }\n\n toString(): string {\n return `TableId<${this.namespace || \"[empty]\"}:${this.name || \"[empty]\"}>`;\n }\n\n toHex(): Hex {\n return TableId.toHex(this.namespace, this.name);\n }\n\n static toHex(namespace: string, name: string): Hex {\n return concatHex([\n stringToHex(namespace.substring(0, 16), { size: 16 }),\n stringToHex(name.substring(0, 16), { size: 16 }),\n ]);\n }\n\n static fromHex(hex: Hex): TableId {\n const namespace = hexToString(sliceHex(hex, 0, 16)).replace(/\\0+$/, \"\");\n const name = hexToString(sliceHex(hex, 16, 32)).replace(/\\0+$/, \"\");\n return new TableId(namespace, name);\n }\n\n /** @deprecated Don't use this! This is a temporary hack for v2<>v1 compatibility until we can write v2 client libraries. This is here so it stays close to the formatting of `toString()` above. */\n static parse(tableIdString: string): TableId | null {\n const match = tableIdString.match(/^TableId<(.+?):(.+?)>$/);\n if (!match) return null;\n const [, namespace, name] = match;\n return new TableId(namespace === \"[empty]\" ? \"\" : namespace, name === \"[empty]\" ? \"\" : name);\n }\n}\n"],"mappings":"AAAA,OAAc,eAAAA,EAAa,eAAAC,EAAa,YAAAC,EAAU,aAAAC,MAAiB,OAE5D,IAAMC,EAAN,KAAc,CACV,UACA,KAET,YAAYC,EAAmBC,EAAc,CAC3C,KAAK,UAAYD,EAAU,UAAU,EAAG,EAAE,EAC1C,KAAK,KAAOC,EAAK,UAAU,EAAG,EAAE,CAClC,CAEA,UAAmB,CACjB,MAAO,WAAW,KAAK,WAAa,aAAa,KAAK,MAAQ,YAChE,CAEA,OAAa,CACX,OAAOF,EAAQ,MAAM,KAAK,UAAW,KAAK,IAAI,CAChD,CAEA,OAAO,MAAMC,EAAmBC,EAAmB,CACjD,OAAOH,EAAU,CACfH,EAAYK,EAAU,UAAU,EAAG,EAAE,EAAG,CAAE,KAAM,EAAG,CAAC,EACpDL,EAAYM,EAAK,UAAU,EAAG,EAAE,EAAG,CAAE,KAAM,EAAG,CAAC,CACjD,CAAC,CACH,CAEA,OAAO,QAAQC,EAAmB,CAChC,IAAMF,EAAYJ,EAAYC,EAASK,EAAK,EAAG,EAAE,CAAC,EAAE,QAAQ,OAAQ,EAAE,EAChED,EAAOL,EAAYC,EAASK,EAAK,GAAI,EAAE,CAAC,EAAE,QAAQ,OAAQ,EAAE,EAClE,OAAO,IAAIH,EAAQC,EAAWC,CAAI,CACpC,CAGA,OAAO,MAAME,EAAuC,CAClD,IAAMC,EAAQD,EAAc,MAAM,wBAAwB,EAC1D,GAAI,CAACC,EAAO,OAAO,KACnB,GAAM,CAAC,CAAEJ,EAAWC,CAAI,EAAIG,EAC5B,OAAO,IAAIL,EAAQC,IAAc,UAAY,GAAKA,EAAWC,IAAS,UAAY,GAAKA,CAAI,CAC7F,CACF","names":["stringToHex","hexToString","sliceHex","concatHex","TableId","namespace","name","hex","tableIdString","match"]}
|
|
1
|
+
{"version":3,"sources":["../src/createBurnerAccount.ts","../src/createContract.ts","../src/createNonceManager.ts","../src/debug.ts","../src/hexToTableId.ts","../src/tableIdToHex.ts","../src/transportObserver.ts"],"sourcesContent":["import { Account, Hex } from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\n\nexport function createBurnerAccount(privateKey: Hex): Account {\n const account = privateKeyToAccount(privateKey);\n // We may override account features here\n return {\n ...account,\n };\n}\n","import {\n Abi,\n Account,\n Address,\n Chain,\n GetContractParameters,\n GetContractReturnType,\n Hex,\n PublicClient,\n SimulateContractParameters,\n Transport,\n WalletClient,\n WriteContractParameters,\n getContract,\n} from \"viem\";\nimport pRetry from \"p-retry\";\nimport { createNonceManager } from \"./createNonceManager\";\nimport { debug as parentDebug } from \"./debug\";\nimport { UnionOmit } from \"./type-utils/common\";\n\nconst debug = parentDebug.extend(\"createContract\");\n\n// copied from viem because this isn't exported\n// TODO: import from viem?\nfunction getFunctionParameters(values: [args?: readonly unknown[], options?: object]): {\n args: readonly unknown[];\n options: object;\n} {\n const hasArgs = values.length && Array.isArray(values[0]);\n const args = hasArgs ? values[0]! : [];\n const options = (hasArgs ? values[1] : values[0]) ?? {};\n return { args, options };\n}\n\nexport type ContractWrite = {\n id: string;\n request: WriteContractParameters;\n result: Promise<Hex>;\n};\n\nexport type CreateContractOptions<\n TTransport extends Transport,\n TAddress extends Address,\n TAbi extends Abi,\n TChain extends Chain,\n TAccount extends Account,\n TPublicClient extends PublicClient<TTransport, TChain>,\n TWalletClient extends WalletClient<TTransport, TChain, TAccount>\n> = Required<GetContractParameters<TTransport, TChain, TAccount, TAbi, TPublicClient, TWalletClient, TAddress>> & {\n onWrite?: (write: ContractWrite) => void;\n};\n\nexport function createContract<\n TTransport extends Transport,\n TAddress extends Address,\n TAbi extends Abi,\n TChain extends Chain,\n TAccount extends Account,\n TPublicClient extends PublicClient<TTransport, TChain>,\n TWalletClient extends WalletClient<TTransport, TChain, TAccount>\n>({\n abi,\n address,\n publicClient,\n walletClient,\n onWrite,\n}: CreateContractOptions<\n TTransport,\n TAddress,\n TAbi,\n TChain,\n TAccount,\n TPublicClient,\n TWalletClient\n>): GetContractReturnType<TAbi, TPublicClient, TWalletClient, TAddress> {\n const contract = getContract<TTransport, TAddress, TAbi, TChain, TAccount, TPublicClient, TWalletClient>({\n abi,\n address,\n publicClient,\n walletClient,\n }) as unknown as GetContractReturnType<Abi, PublicClient, WalletClient>;\n\n if (contract.write) {\n let nextWriteId = 0;\n const nonceManager = createNonceManager({\n publicClient: publicClient as PublicClient,\n address: walletClient.account.address,\n });\n\n // Replace write calls with our own proxy. Implemented ~the same as viem, but adds better handling of nonces (via queue + retries).\n contract.write = new Proxy(\n {},\n {\n get(_, functionName: string): GetContractReturnType<Abi, PublicClient, WalletClient>[\"write\"][string] {\n async function prepareWrite(\n options: WriteContractParameters\n ): Promise<WriteContractParameters<TAbi, typeof functionName, TChain, TAccount>> {\n if (options.gas) {\n debug(\"gas provided, skipping simulate\", functionName, options);\n return options as unknown as WriteContractParameters<TAbi, typeof functionName, TChain, TAccount>;\n }\n\n debug(\"simulating write\", functionName, options);\n const { request } = await publicClient.simulateContract({\n ...options,\n account: options.account ?? walletClient.account,\n } as unknown as SimulateContractParameters<TAbi, typeof functionName, TChain>);\n\n return request as unknown as WriteContractParameters<TAbi, typeof functionName, TChain, TAccount>;\n }\n\n async function write(options: WriteContractParameters): Promise<Hex> {\n const preparedWrite = await prepareWrite(options);\n\n return await pRetry(\n async () => {\n if (!nonceManager.hasNonce()) {\n await nonceManager.resetNonce();\n }\n\n const nonce = nonceManager.nextNonce();\n debug(\"calling write function with nonce\", nonce, preparedWrite);\n return await walletClient.writeContract({\n nonce,\n ...preparedWrite,\n });\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);\n await nonceManager.resetNonce();\n return;\n }\n // TODO: prepareWrite again if there are gas errors?\n throw error;\n },\n }\n );\n }\n\n return (...parameters) => {\n const id = `${walletClient.chain.id}:${walletClient.account.address}:${nextWriteId++}`;\n const { args, options } = <\n {\n args: unknown[];\n options: UnionOmit<WriteContractParameters, \"address\" | \"abi\" | \"functionName\" | \"args\">;\n }\n >getFunctionParameters(parameters as any);\n\n const request = {\n address,\n abi,\n functionName,\n args,\n ...options,\n };\n\n const result = write(request);\n\n onWrite?.({ id, request, result });\n\n return result;\n };\n },\n }\n );\n }\n\n return contract as unknown as GetContractReturnType<TAbi, TPublicClient, TWalletClient, TAddress>;\n}\n","import {\n BaseError,\n BlockTag,\n Hex,\n NonceTooHighError,\n NonceTooLowError,\n PublicClient,\n TransactionExecutionError,\n} from \"viem\";\nimport { debug as parentDebug } from \"./debug\";\n\nconst debug = parentDebug.extend(\"createNonceManager\");\n\ntype CreateNonceManagerOptions = {\n publicClient: PublicClient;\n address: Hex;\n blockTag?: BlockTag;\n};\n\ntype CreateNonceManagerResult = {\n hasNonce: () => boolean;\n nextNonce: () => number;\n resetNonce: () => Promise<void>;\n shouldResetNonce: (error: unknown) => boolean;\n};\n\nexport function createNonceManager({\n publicClient,\n address,\n blockTag,\n}: CreateNonceManagerOptions): CreateNonceManagerResult {\n const nonceRef = { current: -1 };\n const channel =\n typeof BroadcastChannel !== \"undefined\"\n ? // TODO: fetch chain ID or require it via types?\n new BroadcastChannel(`mud:createNonceManager:${publicClient.chain?.id}:${address}`)\n : null;\n\n if (channel) {\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 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 publicClient.getTransactionCount({ 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 return {\n hasNonce,\n nextNonce,\n resetNonce,\n shouldResetNonce,\n };\n}\n","import createDebug from \"debug\";\n\nexport const debug = createDebug(\"mud:common\");\n","import { Hex, hexToString, sliceHex } from \"viem\";\n\nexport function hexToTableId(hex: Hex): { namespace: string; name: string } {\n const namespace = hexToString(sliceHex(hex, 0, 16)).replace(/\\0+$/, \"\");\n const name = hexToString(sliceHex(hex, 16, 32)).replace(/\\0+$/, \"\");\n return { namespace, name };\n}\n","import { Hex, stringToHex, concatHex } from \"viem\";\n\nexport function tableIdToHex(namespace: string, name: string): Hex {\n return concatHex([\n stringToHex(namespace.substring(0, 16), { size: 16 }),\n stringToHex(name.substring(0, 16), { size: 16 }),\n ]);\n}\n","import { Hex, Transport, keccak256 } from \"viem\";\nimport { debug as parentDebug } from \"./debug\";\n\nconst debug = parentDebug.extend(\"transportObserver\");\n\nexport function transportObserver<TTransport extends Transport>(transport: TTransport): TTransport {\n return ((opts) => {\n const result = transport(opts);\n const request: typeof result.request = async (req) => {\n if (req.method === \"eth_sendRawTransaction\" && req.params instanceof Array) {\n const txs = req.params.map((data: Hex) => keccak256(data));\n debug(\"saw txs\", txs);\n // TODO: pass these tx hashes into dev tools\n }\n // TODO: add support for `eth_sendTransaction`\n return result.request(req);\n };\n return {\n ...result,\n request,\n };\n }) as TTransport;\n}\n"],"mappings":"AACA,OAAS,uBAAAA,MAA2B,gBAE7B,SAASC,EAAoBC,EAA0B,CAG5D,MAAO,CACL,GAHcF,EAAoBE,CAAU,CAI9C,CACF,CCTA,OAaE,eAAAC,MACK,OACP,OAAOC,MAAY,UCfnB,OACE,aAAAC,EAGA,qBAAAC,EACA,oBAAAC,MAGK,OCRP,OAAOC,MAAiB,QAEjB,IAAMC,EAAQD,E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AAWM,CAAG,EAItB,OAAOF,EAAO,QAAQC,CAAG,CAC3B,CAIA,CACF,CACF","names":["privateKeyToAccount","createBurnerAccount","privateKey","getContract","pRetry","BaseError","NonceTooHighError","NonceTooLowError","createDebug","debug","debug","createNonceManager","publicClient","address","blockTag","nonceRef","channel","event","nonce","hasNonce","nextNonce","resetNonce","shouldResetNonce","error","BaseError","e","NonceTooLowError","NonceTooHighError","debug","getFunctionParameters","values","hasArgs","args","options","createContract","abi","address","publicClient","walletClient","onWrite","contract","getContract","nextWriteId","nonceManager","createNonceManager","_","functionName","prepareWrite","request","write","preparedWrite","pRetry","nonce","error","parameters","id","result","hexToString","sliceHex","hexToTableId","hex","namespace","name","stringToHex","concatHex","tableIdToHex","namespace","name","keccak256","debug","transportObserver","transport","opts","result","req","txs","data","keccak256"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@latticexyz/common",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.2",
|
|
4
4
|
"description": "Common low level logic shared between packages",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,21 +11,31 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": "./dist/index.js",
|
|
14
|
+
"./chains": "./dist/chains.js",
|
|
14
15
|
"./codegen": "./dist/codegen.js",
|
|
16
|
+
"./deprecated": "./dist/deprecated.js",
|
|
17
|
+
"./errors": "./dist/errors.js",
|
|
15
18
|
"./foundry": "./dist/foundry.js",
|
|
16
19
|
"./type-utils": "./dist/type-utils.js",
|
|
17
|
-
"./utils": "./dist/utils.js"
|
|
18
|
-
"./errors": "./dist/errors.js",
|
|
19
|
-
"./chains": "./dist/chains.js"
|
|
20
|
+
"./utils": "./dist/utils.js"
|
|
20
21
|
},
|
|
21
22
|
"typesVersions": {
|
|
22
23
|
"*": {
|
|
23
24
|
"index": [
|
|
24
25
|
"./src/index.ts"
|
|
25
26
|
],
|
|
27
|
+
"chains": [
|
|
28
|
+
"./src/chains/index.ts"
|
|
29
|
+
],
|
|
26
30
|
"codegen": [
|
|
27
31
|
"./src/codegen/index.ts"
|
|
28
32
|
],
|
|
33
|
+
"deprecated": [
|
|
34
|
+
"./src/deprecated/index.ts"
|
|
35
|
+
],
|
|
36
|
+
"errors": [
|
|
37
|
+
"./src/errors/index.ts"
|
|
38
|
+
],
|
|
29
39
|
"foundry": [
|
|
30
40
|
"./src/foundry/index.ts"
|
|
31
41
|
],
|
|
@@ -34,25 +44,23 @@
|
|
|
34
44
|
],
|
|
35
45
|
"utils": [
|
|
36
46
|
"./src/utils/index.ts"
|
|
37
|
-
],
|
|
38
|
-
"errors": [
|
|
39
|
-
"./src/errors/index.ts"
|
|
40
|
-
],
|
|
41
|
-
"chains": [
|
|
42
|
-
"./src/chains/index.ts"
|
|
43
47
|
]
|
|
44
48
|
}
|
|
45
49
|
},
|
|
46
50
|
"dependencies": {
|
|
47
51
|
"@solidity-parser/parser": "^0.16.0",
|
|
52
|
+
"abitype": "0.9.3",
|
|
48
53
|
"chalk": "^5.2.0",
|
|
54
|
+
"debug": "^4.3.4",
|
|
49
55
|
"execa": "^7.0.0",
|
|
56
|
+
"p-retry": "^5.1.2",
|
|
50
57
|
"prettier": "^2.8.4",
|
|
51
58
|
"prettier-plugin-solidity": "^1.1.2",
|
|
52
|
-
"viem": "1.
|
|
53
|
-
"@latticexyz/schema-type": "2.0.0-next.
|
|
59
|
+
"viem": "1.6.0",
|
|
60
|
+
"@latticexyz/schema-type": "2.0.0-next.2"
|
|
54
61
|
},
|
|
55
62
|
"devDependencies": {
|
|
63
|
+
"@types/debug": "^4.1.7",
|
|
56
64
|
"@types/node": "^18.15.11",
|
|
57
65
|
"tsup": "^6.7.0",
|
|
58
66
|
"vitest": "0.31.4"
|
package/src/chains/index.ts
CHANGED
package/src/chains/types.ts
CHANGED
|
@@ -180,6 +180,18 @@ export function renderValueTypeToBytes32(name: string, { typeUnwrap, internalTyp
|
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
+
export function isLeftAligned(field: Pick<RenderType, "internalTypeId">): boolean {
|
|
184
|
+
return field.internalTypeId.match(/^bytes\d{1,2}$/) !== null;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function getLeftPaddingBits(field: Pick<RenderType, "internalTypeId" | "staticByteLength">): number {
|
|
188
|
+
if (isLeftAligned(field)) {
|
|
189
|
+
return 0;
|
|
190
|
+
} else {
|
|
191
|
+
return 256 - field.staticByteLength * 8;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
183
195
|
function internalRenderList<T>(
|
|
184
196
|
lineTerminator: string,
|
|
185
197
|
list: T[],
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Account, Hex } from "viem";
|
|
2
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
3
|
+
|
|
4
|
+
export function createBurnerAccount(privateKey: Hex): Account {
|
|
5
|
+
const account = privateKeyToAccount(privateKey);
|
|
6
|
+
// We may override account features here
|
|
7
|
+
return {
|
|
8
|
+
...account,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Abi,
|
|
3
|
+
Account,
|
|
4
|
+
Address,
|
|
5
|
+
Chain,
|
|
6
|
+
GetContractParameters,
|
|
7
|
+
GetContractReturnType,
|
|
8
|
+
Hex,
|
|
9
|
+
PublicClient,
|
|
10
|
+
SimulateContractParameters,
|
|
11
|
+
Transport,
|
|
12
|
+
WalletClient,
|
|
13
|
+
WriteContractParameters,
|
|
14
|
+
getContract,
|
|
15
|
+
} from "viem";
|
|
16
|
+
import pRetry from "p-retry";
|
|
17
|
+
import { createNonceManager } from "./createNonceManager";
|
|
18
|
+
import { debug as parentDebug } from "./debug";
|
|
19
|
+
import { UnionOmit } from "./type-utils/common";
|
|
20
|
+
|
|
21
|
+
const debug = parentDebug.extend("createContract");
|
|
22
|
+
|
|
23
|
+
// copied from viem because this isn't exported
|
|
24
|
+
// TODO: import from viem?
|
|
25
|
+
function getFunctionParameters(values: [args?: readonly unknown[], options?: object]): {
|
|
26
|
+
args: readonly unknown[];
|
|
27
|
+
options: object;
|
|
28
|
+
} {
|
|
29
|
+
const hasArgs = values.length && Array.isArray(values[0]);
|
|
30
|
+
const args = hasArgs ? values[0]! : [];
|
|
31
|
+
const options = (hasArgs ? values[1] : values[0]) ?? {};
|
|
32
|
+
return { args, options };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type ContractWrite = {
|
|
36
|
+
id: string;
|
|
37
|
+
request: WriteContractParameters;
|
|
38
|
+
result: Promise<Hex>;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type CreateContractOptions<
|
|
42
|
+
TTransport extends Transport,
|
|
43
|
+
TAddress extends Address,
|
|
44
|
+
TAbi extends Abi,
|
|
45
|
+
TChain extends Chain,
|
|
46
|
+
TAccount extends Account,
|
|
47
|
+
TPublicClient extends PublicClient<TTransport, TChain>,
|
|
48
|
+
TWalletClient extends WalletClient<TTransport, TChain, TAccount>
|
|
49
|
+
> = Required<GetContractParameters<TTransport, TChain, TAccount, TAbi, TPublicClient, TWalletClient, TAddress>> & {
|
|
50
|
+
onWrite?: (write: ContractWrite) => void;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export function createContract<
|
|
54
|
+
TTransport extends Transport,
|
|
55
|
+
TAddress extends Address,
|
|
56
|
+
TAbi extends Abi,
|
|
57
|
+
TChain extends Chain,
|
|
58
|
+
TAccount extends Account,
|
|
59
|
+
TPublicClient extends PublicClient<TTransport, TChain>,
|
|
60
|
+
TWalletClient extends WalletClient<TTransport, TChain, TAccount>
|
|
61
|
+
>({
|
|
62
|
+
abi,
|
|
63
|
+
address,
|
|
64
|
+
publicClient,
|
|
65
|
+
walletClient,
|
|
66
|
+
onWrite,
|
|
67
|
+
}: CreateContractOptions<
|
|
68
|
+
TTransport,
|
|
69
|
+
TAddress,
|
|
70
|
+
TAbi,
|
|
71
|
+
TChain,
|
|
72
|
+
TAccount,
|
|
73
|
+
TPublicClient,
|
|
74
|
+
TWalletClient
|
|
75
|
+
>): GetContractReturnType<TAbi, TPublicClient, TWalletClient, TAddress> {
|
|
76
|
+
const contract = getContract<TTransport, TAddress, TAbi, TChain, TAccount, TPublicClient, TWalletClient>({
|
|
77
|
+
abi,
|
|
78
|
+
address,
|
|
79
|
+
publicClient,
|
|
80
|
+
walletClient,
|
|
81
|
+
}) as unknown as GetContractReturnType<Abi, PublicClient, WalletClient>;
|
|
82
|
+
|
|
83
|
+
if (contract.write) {
|
|
84
|
+
let nextWriteId = 0;
|
|
85
|
+
const nonceManager = createNonceManager({
|
|
86
|
+
publicClient: publicClient as PublicClient,
|
|
87
|
+
address: walletClient.account.address,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// Replace write calls with our own proxy. Implemented ~the same as viem, but adds better handling of nonces (via queue + retries).
|
|
91
|
+
contract.write = new Proxy(
|
|
92
|
+
{},
|
|
93
|
+
{
|
|
94
|
+
get(_, functionName: string): GetContractReturnType<Abi, PublicClient, WalletClient>["write"][string] {
|
|
95
|
+
async function prepareWrite(
|
|
96
|
+
options: WriteContractParameters
|
|
97
|
+
): Promise<WriteContractParameters<TAbi, typeof functionName, TChain, TAccount>> {
|
|
98
|
+
if (options.gas) {
|
|
99
|
+
debug("gas provided, skipping simulate", functionName, options);
|
|
100
|
+
return options as unknown as WriteContractParameters<TAbi, typeof functionName, TChain, TAccount>;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
debug("simulating write", functionName, options);
|
|
104
|
+
const { request } = await publicClient.simulateContract({
|
|
105
|
+
...options,
|
|
106
|
+
account: options.account ?? walletClient.account,
|
|
107
|
+
} as unknown as SimulateContractParameters<TAbi, typeof functionName, TChain>);
|
|
108
|
+
|
|
109
|
+
return request as unknown as WriteContractParameters<TAbi, typeof functionName, TChain, TAccount>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async function write(options: WriteContractParameters): Promise<Hex> {
|
|
113
|
+
const preparedWrite = await prepareWrite(options);
|
|
114
|
+
|
|
115
|
+
return await pRetry(
|
|
116
|
+
async () => {
|
|
117
|
+
if (!nonceManager.hasNonce()) {
|
|
118
|
+
await nonceManager.resetNonce();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const nonce = nonceManager.nextNonce();
|
|
122
|
+
debug("calling write function with nonce", nonce, preparedWrite);
|
|
123
|
+
return await walletClient.writeContract({
|
|
124
|
+
nonce,
|
|
125
|
+
...preparedWrite,
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
retries: 3,
|
|
130
|
+
onFailedAttempt: async (error) => {
|
|
131
|
+
// On nonce errors, reset the nonce and retry
|
|
132
|
+
if (nonceManager.shouldResetNonce(error)) {
|
|
133
|
+
debug("got nonce error, retrying", error);
|
|
134
|
+
await nonceManager.resetNonce();
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
// TODO: prepareWrite again if there are gas errors?
|
|
138
|
+
throw error;
|
|
139
|
+
},
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return (...parameters) => {
|
|
145
|
+
const id = `${walletClient.chain.id}:${walletClient.account.address}:${nextWriteId++}`;
|
|
146
|
+
const { args, options } = <
|
|
147
|
+
{
|
|
148
|
+
args: unknown[];
|
|
149
|
+
options: UnionOmit<WriteContractParameters, "address" | "abi" | "functionName" | "args">;
|
|
150
|
+
}
|
|
151
|
+
>getFunctionParameters(parameters as any);
|
|
152
|
+
|
|
153
|
+
const request = {
|
|
154
|
+
address,
|
|
155
|
+
abi,
|
|
156
|
+
functionName,
|
|
157
|
+
args,
|
|
158
|
+
...options,
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const result = write(request);
|
|
162
|
+
|
|
163
|
+
onWrite?.({ id, request, result });
|
|
164
|
+
|
|
165
|
+
return result;
|
|
166
|
+
};
|
|
167
|
+
},
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return contract as unknown as GetContractReturnType<TAbi, TPublicClient, TWalletClient, TAddress>;
|
|
173
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseError,
|
|
3
|
+
BlockTag,
|
|
4
|
+
Hex,
|
|
5
|
+
NonceTooHighError,
|
|
6
|
+
NonceTooLowError,
|
|
7
|
+
PublicClient,
|
|
8
|
+
TransactionExecutionError,
|
|
9
|
+
} from "viem";
|
|
10
|
+
import { debug as parentDebug } from "./debug";
|
|
11
|
+
|
|
12
|
+
const debug = parentDebug.extend("createNonceManager");
|
|
13
|
+
|
|
14
|
+
type CreateNonceManagerOptions = {
|
|
15
|
+
publicClient: PublicClient;
|
|
16
|
+
address: Hex;
|
|
17
|
+
blockTag?: BlockTag;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type CreateNonceManagerResult = {
|
|
21
|
+
hasNonce: () => boolean;
|
|
22
|
+
nextNonce: () => number;
|
|
23
|
+
resetNonce: () => Promise<void>;
|
|
24
|
+
shouldResetNonce: (error: unknown) => boolean;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export function createNonceManager({
|
|
28
|
+
publicClient,
|
|
29
|
+
address,
|
|
30
|
+
blockTag,
|
|
31
|
+
}: CreateNonceManagerOptions): CreateNonceManagerResult {
|
|
32
|
+
const nonceRef = { current: -1 };
|
|
33
|
+
const channel =
|
|
34
|
+
typeof BroadcastChannel !== "undefined"
|
|
35
|
+
? // TODO: fetch chain ID or require it via types?
|
|
36
|
+
new BroadcastChannel(`mud:createNonceManager:${publicClient.chain?.id}:${address}`)
|
|
37
|
+
: null;
|
|
38
|
+
|
|
39
|
+
if (channel) {
|
|
40
|
+
channel.addEventListener("message", (event) => {
|
|
41
|
+
const nonce = JSON.parse(event.data);
|
|
42
|
+
debug("got nonce from broadcast channel", nonce);
|
|
43
|
+
nonceRef.current = nonce;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function hasNonce(): boolean {
|
|
48
|
+
return nonceRef.current >= 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function nextNonce(): number {
|
|
52
|
+
if (!hasNonce()) throw new Error("call resetNonce before using nextNonce");
|
|
53
|
+
const nonce = nonceRef.current++;
|
|
54
|
+
channel?.postMessage(JSON.stringify(nonceRef.current));
|
|
55
|
+
return nonce;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function resetNonce(): Promise<void> {
|
|
59
|
+
const nonce = await publicClient.getTransactionCount({ address, blockTag });
|
|
60
|
+
nonceRef.current = nonce;
|
|
61
|
+
channel?.postMessage(JSON.stringify(nonceRef.current));
|
|
62
|
+
debug("reset nonce to", nonceRef.current);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function shouldResetNonce(error: unknown): boolean {
|
|
66
|
+
return (
|
|
67
|
+
error instanceof BaseError &&
|
|
68
|
+
error.walk((e) => e instanceof NonceTooLowError || e instanceof NonceTooHighError) != null
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
hasNonce,
|
|
74
|
+
nextNonce,
|
|
75
|
+
resetNonce,
|
|
76
|
+
shouldResetNonce,
|
|
77
|
+
};
|
|
78
|
+
}
|
package/src/debug.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TableId } from "./TableId";
|
|
2
|
+
|
|
3
|
+
/** @deprecated Use `tableIdToHex` and `hexToTableId` instead. */
|
|
4
|
+
export function getTableIds(config: { namespace: string; tables: { [key: string]: unknown } }): TableId[] {
|
|
5
|
+
return Object.keys(config.tables).map((table) => new TableId(config.namespace, table));
|
|
6
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { hexToTableId } from "./hexToTableId";
|
|
3
|
+
|
|
4
|
+
describe("hexToTableId", () => {
|
|
5
|
+
it("can convert from hex string", () => {
|
|
6
|
+
const tableId = hexToTableId("0x6e616d657370616365000000000000006e616d65000000000000000000000000");
|
|
7
|
+
expect(tableId.namespace).toMatchInlineSnapshot('"namespace"');
|
|
8
|
+
expect(tableId.name).toMatchInlineSnapshot('"name"');
|
|
9
|
+
});
|
|
10
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Hex, hexToString, sliceHex } from "viem";
|
|
2
|
+
|
|
3
|
+
export function hexToTableId(hex: Hex): { namespace: string; name: string } {
|
|
4
|
+
const namespace = hexToString(sliceHex(hex, 0, 16)).replace(/\0+$/, "");
|
|
5
|
+
const name = hexToString(sliceHex(hex, 16, 32)).replace(/\0+$/, "");
|
|
6
|
+
return { namespace, name };
|
|
7
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { tableIdToHex } from "./tableIdToHex";
|
|
3
|
+
import { hexToTableId } from "./hexToTableId";
|
|
4
|
+
|
|
5
|
+
describe("tableIdToHex", () => {
|
|
6
|
+
it("can convert to hex string", () => {
|
|
7
|
+
const tableIdHex = tableIdToHex("namespace", "name");
|
|
8
|
+
expect(tableIdHex).toMatchInlineSnapshot('"0x6e616d657370616365000000000000006e616d65000000000000000000000000"');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("truncates namespaces >16 bytes", () => {
|
|
12
|
+
const hex = "0x41566572794c6f6e674e616d657370616e616d65000000000000000000000000";
|
|
13
|
+
const tableIdHex = tableIdToHex("AVeryLongNamespace", "name");
|
|
14
|
+
expect(tableIdHex).toEqual(hex);
|
|
15
|
+
expect(hexToTableId(tableIdHex).namespace).toMatchInlineSnapshot('"AVeryLongNamespa"');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("truncates names >16 bytes", () => {
|
|
19
|
+
const hex = "0x6e616d65737061636500000000000000416e556e6e65636573736172696c794c";
|
|
20
|
+
const tableIdHex = tableIdToHex("namespace", "AnUnnecessarilyLongName");
|
|
21
|
+
expect(tableIdHex).toEqual(hex);
|
|
22
|
+
expect(hexToTableId(tableIdHex).name).toMatchInlineSnapshot('"AnUnnecessarilyL"');
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Hex, Transport, keccak256 } from "viem";
|
|
2
|
+
import { debug as parentDebug } from "./debug";
|
|
3
|
+
|
|
4
|
+
const debug = parentDebug.extend("transportObserver");
|
|
5
|
+
|
|
6
|
+
export function transportObserver<TTransport extends Transport>(transport: TTransport): TTransport {
|
|
7
|
+
return ((opts) => {
|
|
8
|
+
const result = transport(opts);
|
|
9
|
+
const request: typeof result.request = async (req) => {
|
|
10
|
+
if (req.method === "eth_sendRawTransaction" && req.params instanceof Array) {
|
|
11
|
+
const txs = req.params.map((data: Hex) => keccak256(data));
|
|
12
|
+
debug("saw txs", txs);
|
|
13
|
+
// TODO: pass these tx hashes into dev tools
|
|
14
|
+
}
|
|
15
|
+
// TODO: add support for `eth_sendTransaction`
|
|
16
|
+
return result.request(req);
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
...result,
|
|
20
|
+
request,
|
|
21
|
+
};
|
|
22
|
+
}) as TTransport;
|
|
23
|
+
}
|
package/src/type-utils/common.ts
CHANGED
|
@@ -17,3 +17,5 @@ export type OrDefault<T, Default> = T extends undefined ? Default : T;
|
|
|
17
17
|
export type OrDefaults<T extends object, Defaults> = {
|
|
18
18
|
[key in keyof Defaults]: key extends keyof T ? OrDefault<T[key], Defaults[key]> : Defaults[key];
|
|
19
19
|
};
|
|
20
|
+
|
|
21
|
+
export type UnionOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;
|
|
File without changes
|