@latticexyz/common 2.2.15-f2c69f4d1600c9dd2fc79bd0002ba7c43250b98c → 2.2.15-ff8a065dc8e5216ad23e68f6a6c4856ecb2208a3

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.
@@ -0,0 +1,2 @@
1
+ function o(l,n){let e=new Map;for(let a of l){let u=n(a);e.has(u)||e.set(u,a)}return Array.from(e.values())}export{o as a};
2
+ //# sourceMappingURL=chunk-Y4MH6TRP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/uniqueBy.ts"],"sourcesContent":["export function uniqueBy<value, key>(values: readonly value[], getKey: (value: value) => key): readonly value[] {\n const map = new Map<key, value>();\n for (const value of values) {\n const key = getKey(value);\n if (!map.has(key)) {\n map.set(key, value);\n }\n }\n return Array.from(map.values());\n}\n"],"mappings":"AAAO,SAASA,EAAqBC,EAA0BC,EAAiD,CAC9G,IAAMC,EAAM,IAAI,IAChB,QAAWC,KAASH,EAAQ,CAC1B,IAAMI,EAAMH,EAAOE,CAAK,EACnBD,EAAI,IAAIE,CAAG,GACdF,EAAI,IAAIE,EAAKD,CAAK,EAGtB,OAAO,MAAM,KAAKD,EAAI,OAAO,CAAC,CAChC","names":["uniqueBy","values","getKey","map","value","key"]}
@@ -3,15 +3,16 @@ import { Client, Transport, Chain, Account, Hex, Address } from 'viem';
3
3
  declare function waitForTransactions({ client, hashes, debugLabel, }: {
4
4
  readonly client: Client<Transport, Chain | undefined, Account>;
5
5
  readonly hashes: readonly Hex[];
6
- readonly debugLabel: string;
6
+ readonly debugLabel?: string;
7
7
  }): Promise<void>;
8
8
 
9
9
  type Contract = {
10
10
  bytecode: Hex;
11
11
  deployedBytecodeSize?: number;
12
12
  debugLabel?: string;
13
+ salt?: Hex;
13
14
  };
14
- declare function ensureContract({ client, deployerAddress, bytecode, deployedBytecodeSize, debugLabel, }: {
15
+ declare function ensureContract({ client, deployerAddress, bytecode, deployedBytecodeSize, debugLabel, salt, }: {
15
16
  readonly client: Client<Transport, Chain | undefined, Account>;
16
17
  readonly deployerAddress: Hex;
17
18
  } & Contract): Promise<readonly Hex[]>;
@@ -24,9 +25,10 @@ declare function ensureContractsDeployed({ client, deployerAddress, contracts, }
24
25
 
25
26
  declare function ensureDeployer(client: Client<Transport, Chain | undefined, Account>): Promise<Address>;
26
27
 
27
- declare function getContractAddress({ deployerAddress, bytecode, }: {
28
+ declare function getContractAddress({ deployerAddress, bytecode, salt, }: {
28
29
  readonly deployerAddress: Hex;
29
30
  readonly bytecode: Hex;
31
+ readonly salt?: Hex;
30
32
  }): Hex;
31
33
 
32
34
  declare function getDeployer(client: Client<Transport, Chain | undefined>): Promise<Address | undefined>;
package/dist/internal.js CHANGED
@@ -1,13 +1,13 @@
1
- import{e as g}from"./chunk-RCAJ6T6T.js";import{a as d}from"./chunk-TCWGPC6G.js";import{a as x}from"./chunk-RPQA434J.js";import{waitForTransactionReceipt as T}from"viem/actions";async function C({client:e,hashes:o,debugLabel:f="transactions"}){if(o.length){d(`waiting for ${f} to confirm`);for(let r of o)if((await T(e,{hash:r})).status==="reverted")throw new Error(`Transaction reverted: ${r}`)}}import{concatHex as H,getCreate2Address as R}from"viem";import{getCode as P}from"viem/actions";import{stringToHex as $}from"viem";var c=$("",{size:32}),l=parseInt("6000",16);var a=d.extend("deploy"),E=d.extend("deploy");a.log=console.debug.bind(console);E.log=console.error.bind(console);async function h({client:e,deployerAddress:o,bytecode:f,deployedBytecodeSize:r,debugLabel:t="contract"}){if(f.includes("__$"))throw new Error(`Found unlinked public library in ${t} bytecode`);let s=R({from:o,salt:c,bytecode:f});return await P(e,{address:s,blockTag:"pending"})?(a("found",t,"at",s),[]):(r!=null&&(r>l?console.warn(`
1
+ import{e as g}from"./chunk-RCAJ6T6T.js";import{a as c}from"./chunk-TCWGPC6G.js";import{a as x}from"./chunk-Y4MH6TRP.js";import{waitForTransactionReceipt as T}from"viem/actions";async function C({client:e,hashes:o,debugLabel:a="transactions"}){if(o.length){c(`waiting for ${a} to confirm`);for(let r of o)if((await T(e,{hash:r})).status==="reverted")throw new Error(`Transaction reverted: ${r}`)}}import{concatHex as H,getCreate2Address as R}from"viem";import{getCode as P}from"viem/actions";import{stringToHex as $}from"viem";var p=$("",{size:32}),l=parseInt("6000",16);var f=c.extend("deploy"),E=c.extend("deploy");f.log=console.debug.bind(console);E.log=console.error.bind(console);async function h({client:e,deployerAddress:o,bytecode:a,deployedBytecodeSize:r,debugLabel:t="contract",salt:s=p}){if(a.includes("__$"))throw new Error(`Found unlinked public library in ${t} bytecode`);let i=R({from:o,salt:s,bytecode:a});return await P(e,{address:i,blockTag:"pending"})?(f("found",t,"at",i),[]):(r!=null&&(r>l?console.warn(`
2
2
  Bytecode for ${t} (${r} bytes) is over the contract size limit (${l} bytes). Run \`forge build --sizes\` for more info.
3
3
  `):r>l*.95&&console.warn(`
4
4
  Bytecode for ${t} (${r} bytes) is almost over the contract size limit (${l} bytes). Run \`forge build --sizes\` for more info.
5
- `)),a("deploying",t,"at",s),[await g(e,{chain:e.chain??null,to:o,data:H([c,f])})])}async function te({client:e,deployerAddress:o,contracts:f}){let r=x(f,s=>s.bytecode),t=(await Promise.all(r.map(s=>h({client:e,deployerAddress:o,...s})))).flat();return await C({client:e,hashes:t,debugLabel:"contract deploys"}),t}import{getBalance as B,sendRawTransaction as F,sendTransaction as b,waitForTransactionReceipt as A}from"viem/actions";var n={gasPrice:1e11,gasLimit:1e5,signerAddress:"3fab184622dc19b6109349b94811493bf2a45362",transaction:"f8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222",address:"4e59b44847b379578588920ca78fbf26c0b4956c",creationCode:"604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"};import{sliceHex as D}from"viem";import{getCode as z}from"viem/actions";var m=`0x${n.address}`;async function w(e){let o=await z(e,{address:m});if(o)return a("found deployer bytecode at",m),o!==D(`0x${n.creationCode}`,14)&&console.warn(`
5
+ `)),f("deploying",t,"at",i),[await g(e,{chain:e.chain??null,to:o,data:H([s,a])})])}async function te({client:e,deployerAddress:o,contracts:a}){let r=x(a,s=>s.bytecode),t=(await Promise.all(r.map(s=>h({client:e,deployerAddress:o,...s})))).flat();return await C({client:e,hashes:t,debugLabel:"contract deploys"}),t}import{getBalance as B,sendRawTransaction as F,sendTransaction as b,waitForTransactionReceipt as A}from"viem/actions";var n={gasPrice:1e11,gasLimit:1e5,signerAddress:"3fab184622dc19b6109349b94811493bf2a45362",transaction:"f8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222",address:"4e59b44847b379578588920ca78fbf26c0b4956c",creationCode:"604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"};import{sliceHex as D}from"viem";import{getCode as z}from"viem/actions";var m=`0x${n.address}`;async function w(e){let o=await z(e,{address:m});if(o)return f("found deployer bytecode at",m),o!==D(`0x${n.creationCode}`,14)&&console.warn(`
6
6
  \u26A0\uFE0F Bytecode for deployer at ${m} did not match the expected CREATE2 bytecode. You may have unexpected results.
7
- `),m}var u=`0x${n.address}`;async function he(e){let o=await w(e);if(o!==void 0)return o;let f=BigInt(n.gasLimit)*BigInt(n.gasPrice),r=await B(e,{address:`0x${n.signerAddress}`}),t=f-r;if(t>0){a("sending gas for CREATE2 deployer to signer at",n.signerAddress);let p=await b(e,{chain:e.chain??null,to:`0x${n.signerAddress}`,value:t}),y=await A(e,{hash:p});if(y.status!=="success")throw console.error("failed to send gas to deployer signer",y),new Error("failed to send gas to deployer signer")}a("deploying CREATE2 deployer at",u);let s=await F(e,{serializedTransaction:`0x${n.transaction}`}).catch(p=>{if(String(p).includes("only replay-protected (EIP-155) transactions allowed over RPC"))return console.warn(`
7
+ `),m}var u=`0x${n.address}`;async function he(e){let o=await w(e);if(o!==void 0)return o;let a=BigInt(n.gasLimit)*BigInt(n.gasPrice),r=await B(e,{address:`0x${n.signerAddress}`}),t=a-r;if(t>0){f("sending gas for CREATE2 deployer to signer at",n.signerAddress);let d=await b(e,{chain:e.chain??null,to:`0x${n.signerAddress}`,value:t}),y=await A(e,{hash:d});if(y.status!=="success")throw console.error("failed to send gas to deployer signer",y),new Error("failed to send gas to deployer signer")}f("deploying CREATE2 deployer at",u);let s=await F(e,{serializedTransaction:`0x${n.transaction}`}).catch(d=>{if(String(d).includes("only replay-protected (EIP-155) transactions allowed over RPC"))return console.warn(`
8
8
  \u26A0\uFE0F Your chain or RPC does not allow for non EIP-155 signed transactions, so your deploys will not be determinstic and contract addresses may change between deploys.
9
9
 
10
10
  We recommend running your chain's node with \`--rpc.allow-unprotected-txs\` to enable determinstic deployments.
11
- `),a("deploying CREATE2 deployer"),b(e,{chain:e.chain??null,data:`0x${n.creationCode}`});throw p}),i=await A(e,{hash:s});if(!i.contractAddress)throw new Error("Deploy receipt did not have contract address, was the deployer not deployed?");return i.contractAddress!==u&&console.warn(`
12
- \u26A0\uFE0F CREATE2 deployer created at ${i.contractAddress} does not match the CREATE2 determinstic deployer we expected (${u})`),i.contractAddress}import{getCreate2Address as I}from"viem";function $e({deployerAddress:e,bytecode:o}){return I({from:e,bytecode:o,salt:c})}export{h as ensureContract,te as ensureContractsDeployed,he as ensureDeployer,$e as getContractAddress,w as getDeployer,C as waitForTransactions};
11
+ `),f("deploying CREATE2 deployer"),b(e,{chain:e.chain??null,data:`0x${n.creationCode}`});throw d}),i=await A(e,{hash:s});if(!i.contractAddress)throw new Error("Deploy receipt did not have contract address, was the deployer not deployed?");return i.contractAddress!==u&&console.warn(`
12
+ \u26A0\uFE0F CREATE2 deployer created at ${i.contractAddress} does not match the CREATE2 determinstic deployer we expected (${u})`),i.contractAddress}import{getCreate2Address as I}from"viem";function $e({deployerAddress:e,bytecode:o,salt:a=p}){return I({from:e,bytecode:o,salt:a})}export{h as ensureContract,te as ensureContractsDeployed,he as ensureDeployer,$e as getContractAddress,w as getDeployer,C as waitForTransactions};
13
13
  //# sourceMappingURL=internal.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/waitForTransactions.ts","../src/deploy/ensureContract.ts","../src/deploy/common.ts","../src/deploy/debug.ts","../src/deploy/ensureContractsDeployed.ts","../src/deploy/ensureDeployer.ts","../src/deploy/create2/deployment.json","../src/deploy/getDeployer.ts","../src/deploy/getContractAddress.ts"],"sourcesContent":["import { Client, Transport, Chain, Account, Hex } from \"viem\";\nimport { debug } from \"./debug\";\nimport { waitForTransactionReceipt } from \"viem/actions\";\n\nexport async function waitForTransactions({\n client,\n hashes,\n debugLabel = \"transactions\",\n}: {\n readonly client: Client<Transport, Chain | undefined, Account>;\n readonly hashes: readonly Hex[];\n readonly debugLabel: string;\n}): Promise<void> {\n if (!hashes.length) return;\n\n debug(`waiting for ${debugLabel} to confirm`);\n // wait for each tx separately/serially, because parallelizing results in RPC errors\n for (const hash of hashes) {\n const receipt = await waitForTransactionReceipt(client, { hash });\n // TODO: handle user op failures?\n if (receipt.status === \"reverted\") {\n throw new Error(`Transaction reverted: ${hash}`);\n }\n }\n}\n","import { Client, Transport, Chain, Account, concatHex, getCreate2Address, Hex } from \"viem\";\nimport { getCode } from \"viem/actions\";\nimport { contractSizeLimit, singletonSalt } from \"./common\";\nimport { debug } from \"./debug\";\nimport { sendTransaction } from \"../sendTransaction\";\n\nexport type Contract = {\n bytecode: Hex;\n deployedBytecodeSize?: number;\n debugLabel?: string;\n};\n\nexport async function ensureContract({\n client,\n deployerAddress,\n bytecode,\n deployedBytecodeSize,\n debugLabel = \"contract\",\n}: {\n readonly client: Client<Transport, Chain | undefined, Account>;\n readonly deployerAddress: Hex;\n} & Contract): Promise<readonly Hex[]> {\n if (bytecode.includes(\"__$\")) {\n throw new Error(`Found unlinked public library in ${debugLabel} bytecode`);\n }\n\n const address = getCreate2Address({ from: deployerAddress, salt: singletonSalt, bytecode });\n\n const contractCode = await getCode(client, { address, blockTag: \"pending\" });\n if (contractCode) {\n debug(\"found\", debugLabel, \"at\", address);\n return [];\n }\n\n if (deployedBytecodeSize != null) {\n if (deployedBytecodeSize > contractSizeLimit) {\n console.warn(\n `\\nBytecode for ${debugLabel} (${deployedBytecodeSize} bytes) is over the contract size limit (${contractSizeLimit} bytes). Run \\`forge build --sizes\\` for more info.\\n`,\n );\n } else if (deployedBytecodeSize > contractSizeLimit * 0.95) {\n console.warn(\n // eslint-disable-next-line max-len\n `\\nBytecode for ${debugLabel} (${deployedBytecodeSize} bytes) is almost over the contract size limit (${contractSizeLimit} bytes). Run \\`forge build --sizes\\` for more info.\\n`,\n );\n }\n }\n\n debug(\"deploying\", debugLabel, \"at\", address);\n return [\n await sendTransaction(client, {\n chain: client.chain ?? null,\n to: deployerAddress,\n data: concatHex([singletonSalt, bytecode]),\n }),\n ];\n}\n","import { stringToHex } from \"viem\";\n\n// salt for deterministic deploys of singleton contracts\nexport const singletonSalt = stringToHex(\"\", { size: 32 });\n\n// https://eips.ethereum.org/EIPS/eip-170\nexport const contractSizeLimit = parseInt(\"6000\", 16);\n","import { debug as parentDebug } from \"../debug\";\n\nexport const debug = parentDebug.extend(\"deploy\");\nexport const error = parentDebug.extend(\"deploy\");\n\n// Pipe debug output to stdout instead of stderr\ndebug.log = console.debug.bind(console);\n\n// Pipe error output to stderr\nerror.log = console.error.bind(console);\n","import { Client, Transport, Chain, Account, Hex } from \"viem\";\nimport { Contract, ensureContract } from \"./ensureContract\";\nimport { waitForTransactions } from \"../waitForTransactions\";\nimport { uniqueBy } from \"../utils/uniqueBy\";\n\nexport async function ensureContractsDeployed({\n client,\n deployerAddress,\n contracts,\n}: {\n readonly client: Client<Transport, Chain | undefined, Account>;\n readonly deployerAddress: Hex;\n readonly contracts: readonly Contract[];\n}): Promise<readonly Hex[]> {\n // Deployments assume a deterministic deployer, so we only need to deploy the unique bytecode\n const uniqueContracts = uniqueBy(contracts, (contract) => contract.bytecode);\n\n const txs = (\n await Promise.all(uniqueContracts.map((contract) => ensureContract({ client, deployerAddress, ...contract })))\n ).flat();\n\n await waitForTransactions({\n client,\n hashes: txs,\n debugLabel: \"contract deploys\",\n });\n\n return txs;\n}\n","import { Account, Address, Chain, Client, Transport } from \"viem\";\nimport { getBalance, sendRawTransaction, sendTransaction, waitForTransactionReceipt } from \"viem/actions\";\nimport deployment from \"./create2/deployment.json\";\nimport { debug } from \"./debug\";\nimport { getDeployer } from \"./getDeployer\";\n\nconst deployer = `0x${deployment.address}` as const;\n\nexport async function ensureDeployer(client: Client<Transport, Chain | undefined, Account>): Promise<Address> {\n const existingDeployer = await getDeployer(client);\n if (existingDeployer !== undefined) {\n return existingDeployer;\n }\n\n // There's not really a way to simulate a pre-EIP-155 (no chain ID) transaction,\n // so we have to attempt to create the deployer first and, if it fails, fall back\n // to a regular deploy.\n\n // Send gas to deployment signer\n const gasRequired = BigInt(deployment.gasLimit) * BigInt(deployment.gasPrice);\n const currentBalance = await getBalance(client, { address: `0x${deployment.signerAddress}` });\n const gasNeeded = gasRequired - currentBalance;\n if (gasNeeded > 0) {\n debug(\"sending gas for CREATE2 deployer to signer at\", deployment.signerAddress);\n const gasTx = await sendTransaction(client, {\n chain: client.chain ?? null,\n to: `0x${deployment.signerAddress}`,\n value: gasNeeded,\n });\n const gasReceipt = await waitForTransactionReceipt(client, { hash: gasTx });\n if (gasReceipt.status !== \"success\") {\n console.error(\"failed to send gas to deployer signer\", gasReceipt);\n throw new Error(\"failed to send gas to deployer signer\");\n }\n }\n\n // Deploy the deployer\n debug(\"deploying CREATE2 deployer at\", deployer);\n const deployTx = await sendRawTransaction(client, { serializedTransaction: `0x${deployment.transaction}` }).catch(\n (error) => {\n // Do a regular contract create if the presigned transaction doesn't work due to replay protection\n if (String(error).includes(\"only replay-protected (EIP-155) transactions allowed over RPC\")) {\n console.warn(\n // eslint-disable-next-line max-len\n `\\n ⚠️ Your chain or RPC does not allow for non EIP-155 signed transactions, so your deploys will not be determinstic and contract addresses may change between deploys.\\n\\n We recommend running your chain's node with \\`--rpc.allow-unprotected-txs\\` to enable determinstic deployments.\\n`,\n );\n debug(\"deploying CREATE2 deployer\");\n return sendTransaction(client, {\n chain: client.chain ?? null,\n data: `0x${deployment.creationCode}`,\n });\n }\n throw error;\n },\n );\n\n const deployReceipt = await waitForTransactionReceipt(client, { hash: deployTx });\n if (!deployReceipt.contractAddress) {\n throw new Error(\"Deploy receipt did not have contract address, was the deployer not deployed?\");\n }\n\n if (deployReceipt.contractAddress !== deployer) {\n console.warn(\n `\\n ⚠️ CREATE2 deployer created at ${deployReceipt.contractAddress} does not match the CREATE2 determinstic deployer we expected (${deployer})`,\n );\n }\n\n return deployReceipt.contractAddress;\n}\n","{\n \"gasPrice\": 100000000000,\n \"gasLimit\": 100000,\n \"signerAddress\": \"3fab184622dc19b6109349b94811493bf2a45362\",\n \"transaction\": \"f8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222\",\n \"address\": \"4e59b44847b379578588920ca78fbf26c0b4956c\",\n \"creationCode\": \"604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3\"\n}\n","import { Address, Chain, Client, Transport, sliceHex } from \"viem\";\nimport { getCode } from \"viem/actions\";\nimport deployment from \"./create2/deployment.json\";\nimport { debug } from \"./debug\";\n\nconst deployer = `0x${deployment.address}` as const;\n\nexport async function getDeployer(client: Client<Transport, Chain | undefined>): Promise<Address | undefined> {\n const bytecode = await getCode(client, { address: deployer });\n if (bytecode) {\n debug(\"found deployer bytecode at\", deployer);\n // check if deployed bytecode is the same as the expected bytecode (minus 14-bytes creation code prefix)\n if (bytecode !== sliceHex(`0x${deployment.creationCode}`, 14)) {\n console.warn(\n `\\n ⚠️ Bytecode for deployer at ${deployer} did not match the expected CREATE2 bytecode. You may have unexpected results.\\n`,\n );\n }\n return deployer;\n }\n}\n","import { Hex, getCreate2Address } from \"viem\";\nimport { singletonSalt } from \"./common\";\n\nexport function getContractAddress({\n deployerAddress,\n bytecode,\n}: {\n readonly deployerAddress: Hex;\n readonly bytecode: Hex;\n}): Hex {\n return getCreate2Address({ from: deployerAddress, bytecode, salt: singletonSalt });\n}\n"],"mappings":"wHAEA,OAAS,6BAAAA,MAAiC,eAE1C,eAAsBC,EAAoB,CACxC,OAAAC,EACA,OAAAC,EACA,WAAAC,EAAa,cACf,EAIkB,CAChB,GAAKD,EAAO,OAEZ,CAAAE,EAAM,eAAeD,cAAuB,EAE5C,QAAWE,KAAQH,EAGjB,IAFgB,MAAMH,EAA0BE,EAAQ,CAAE,KAAAI,CAAK,CAAC,GAEpD,SAAW,WACrB,MAAM,IAAI,MAAM,yBAAyBA,GAAM,EAGrD,CCxBA,OAA4C,aAAAC,EAAW,qBAAAC,MAA8B,OACrF,OAAS,WAAAC,MAAe,eCDxB,OAAS,eAAAC,MAAmB,OAGrB,IAAMC,EAAgBD,EAAY,GAAI,CAAE,KAAM,EAAG,CAAC,EAG5CE,EAAoB,SAAS,OAAQ,EAAE,ECJ7C,IAAMC,EAAQA,EAAY,OAAO,QAAQ,EACnCC,EAAQD,EAAY,OAAO,QAAQ,EAGhDA,EAAM,IAAM,QAAQ,MAAM,KAAK,OAAO,EAGtCC,EAAM,IAAM,QAAQ,MAAM,KAAK,OAAO,EFGtC,eAAsBC,EAAe,CACnC,OAAAC,EACA,gBAAAC,EACA,SAAAC,EACA,qBAAAC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AAS,KACvB,KAAM,KAAKF,EAAW,cACxB,CAAC,EAEH,MAAMgB,CACR,CACF,EAEMC,EAAgB,MAAMJ,EAA0BX,EAAQ,CAAE,KAAMY,CAAS,CAAC,EAChF,GAAI,CAACG,EAAc,gBACjB,MAAM,IAAI,MAAM,8EAA8E,EAGhG,OAAIA,EAAc,kBAAoBlB,GACpC,QAAQ,KACN;AAAA,6CAAsCkB,EAAc,iFAAiFlB,IACvI,EAGKkB,EAAc,eACvB,CGpEA,OAAc,qBAAAC,MAAyB,OAGhC,SAASC,GAAmB,CACjC,gBAAAC,EACA,SAAAC,CACF,EAGQ,CACN,OAAOC,EAAkB,CAAE,KAAMF,EAAiB,SAAAC,EAAU,KAAME,CAAc,CAAC,CACnF","names":["waitForTransactionReceipt","waitForTransactions","client","hashes","debugLabel","debug","hash","concatHex","getCreate2Address","getCode","stringToHex","singletonSalt","contractSizeLimit","debug","error","ensureContract","client","deployerAddress","bytecode","deployedBytecodeSize","debugLabel","address","getCreate2Address","singletonSalt","getCode","debug","contractSizeLimit","sendTransaction","concatHex","ensureContractsDeployed","client","deployerAddress","contracts","uniqueContracts","uniqueBy","contract","txs","ensureContract","waitForTransactions","getBalance","sendRawTransaction","sendTransaction","waitForTransactionReceipt","deployment_default","sliceHex","getCode","deployer","deployment_default","getDeployer","client","bytecode","getCode","debug","sliceHex","deployer","deployment_default","ensureDeployer","client","existingDeployer","getDeployer","gasRequired","currentBalance","getBalance","gasNeeded","debug","gasTx","sendTransaction","gasReceipt","waitForTransactionReceipt","deployTx","sendRawTransaction","error","deployReceipt","getCreate2Address","getContractAddress","deployerAddress","bytecode","getCreate2Address","singletonSalt"]}
1
+ {"version":3,"sources":["../src/waitForTransactions.ts","../src/deploy/ensureContract.ts","../src/deploy/common.ts","../src/deploy/debug.ts","../src/deploy/ensureContractsDeployed.ts","../src/deploy/ensureDeployer.ts","../src/deploy/create2/deployment.json","../src/deploy/getDeployer.ts","../src/deploy/getContractAddress.ts"],"sourcesContent":["import { Client, Transport, Chain, Account, Hex } from \"viem\";\nimport { debug } from \"./debug\";\nimport { waitForTransactionReceipt } from \"viem/actions\";\n\nexport async function waitForTransactions({\n client,\n hashes,\n debugLabel = \"transactions\",\n}: {\n readonly client: Client<Transport, Chain | undefined, Account>;\n readonly hashes: readonly Hex[];\n readonly debugLabel?: string;\n}): Promise<void> {\n if (!hashes.length) return;\n\n debug(`waiting for ${debugLabel} to confirm`);\n // wait for each tx separately/serially, because parallelizing results in RPC errors\n for (const hash of hashes) {\n const receipt = await waitForTransactionReceipt(client, { hash });\n // TODO: handle user op failures?\n if (receipt.status === \"reverted\") {\n throw new Error(`Transaction reverted: ${hash}`);\n }\n }\n}\n","import { Client, Transport, Chain, Account, concatHex, getCreate2Address, Hex } from \"viem\";\nimport { getCode } from \"viem/actions\";\nimport { contractSizeLimit, singletonSalt } from \"./common\";\nimport { debug } from \"./debug\";\nimport { sendTransaction } from \"../sendTransaction\";\n\nexport type Contract = {\n bytecode: Hex;\n deployedBytecodeSize?: number;\n debugLabel?: string;\n salt?: Hex;\n};\n\nexport async function ensureContract({\n client,\n deployerAddress,\n bytecode,\n deployedBytecodeSize,\n debugLabel = \"contract\",\n salt = singletonSalt,\n}: {\n readonly client: Client<Transport, Chain | undefined, Account>;\n readonly deployerAddress: Hex;\n} & Contract): Promise<readonly Hex[]> {\n if (bytecode.includes(\"__$\")) {\n throw new Error(`Found unlinked public library in ${debugLabel} bytecode`);\n }\n\n const address = getCreate2Address({ from: deployerAddress, salt, bytecode });\n\n const contractCode = await getCode(client, { address, blockTag: \"pending\" });\n if (contractCode) {\n debug(\"found\", debugLabel, \"at\", address);\n return [];\n }\n\n if (deployedBytecodeSize != null) {\n if (deployedBytecodeSize > contractSizeLimit) {\n console.warn(\n `\\nBytecode for ${debugLabel} (${deployedBytecodeSize} bytes) is over the contract size limit (${contractSizeLimit} bytes). Run \\`forge build --sizes\\` for more info.\\n`,\n );\n } else if (deployedBytecodeSize > contractSizeLimit * 0.95) {\n console.warn(\n // eslint-disable-next-line max-len\n `\\nBytecode for ${debugLabel} (${deployedBytecodeSize} bytes) is almost over the contract size limit (${contractSizeLimit} bytes). Run \\`forge build --sizes\\` for more info.\\n`,\n );\n }\n }\n\n debug(\"deploying\", debugLabel, \"at\", address);\n return [\n await sendTransaction(client, {\n chain: client.chain ?? null,\n to: deployerAddress,\n data: concatHex([salt, bytecode]),\n }),\n ];\n}\n","import { stringToHex } from \"viem\";\n\n// salt for deterministic deploys of singleton contracts\nexport const singletonSalt = stringToHex(\"\", { size: 32 });\n\n// https://eips.ethereum.org/EIPS/eip-170\nexport const contractSizeLimit = parseInt(\"6000\", 16);\n","import { debug as parentDebug } from \"../debug\";\n\nexport const debug = parentDebug.extend(\"deploy\");\nexport const error = parentDebug.extend(\"deploy\");\n\n// Pipe debug output to stdout instead of stderr\ndebug.log = console.debug.bind(console);\n\n// Pipe error output to stderr\nerror.log = console.error.bind(console);\n","import { Client, Transport, Chain, Account, Hex } from \"viem\";\nimport { Contract, ensureContract } from \"./ensureContract\";\nimport { waitForTransactions } from \"../waitForTransactions\";\nimport { uniqueBy } from \"../utils/uniqueBy\";\n\nexport async function ensureContractsDeployed({\n client,\n deployerAddress,\n contracts,\n}: {\n readonly client: Client<Transport, Chain | undefined, Account>;\n readonly deployerAddress: Hex;\n readonly contracts: readonly Contract[];\n}): Promise<readonly Hex[]> {\n // Deployments assume a deterministic deployer, so we only need to deploy the unique bytecode\n const uniqueContracts = uniqueBy(contracts, (contract) => contract.bytecode);\n\n const txs = (\n await Promise.all(uniqueContracts.map((contract) => ensureContract({ client, deployerAddress, ...contract })))\n ).flat();\n\n await waitForTransactions({\n client,\n hashes: txs,\n debugLabel: \"contract deploys\",\n });\n\n return txs;\n}\n","import { Account, Address, Chain, Client, Transport } from \"viem\";\nimport { getBalance, sendRawTransaction, sendTransaction, waitForTransactionReceipt } from \"viem/actions\";\nimport deployment from \"./create2/deployment.json\";\nimport { debug } from \"./debug\";\nimport { getDeployer } from \"./getDeployer\";\n\nconst deployer = `0x${deployment.address}` as const;\n\nexport async function ensureDeployer(client: Client<Transport, Chain | undefined, Account>): Promise<Address> {\n const existingDeployer = await getDeployer(client);\n if (existingDeployer !== undefined) {\n return existingDeployer;\n }\n\n // There's not really a way to simulate a pre-EIP-155 (no chain ID) transaction,\n // so we have to attempt to create the deployer first and, if it fails, fall back\n // to a regular deploy.\n\n // Send gas to deployment signer\n const gasRequired = BigInt(deployment.gasLimit) * BigInt(deployment.gasPrice);\n const currentBalance = await getBalance(client, { address: `0x${deployment.signerAddress}` });\n const gasNeeded = gasRequired - currentBalance;\n if (gasNeeded > 0) {\n debug(\"sending gas for CREATE2 deployer to signer at\", deployment.signerAddress);\n const gasTx = await sendTransaction(client, {\n chain: client.chain ?? null,\n to: `0x${deployment.signerAddress}`,\n value: gasNeeded,\n });\n const gasReceipt = await waitForTransactionReceipt(client, { hash: gasTx });\n if (gasReceipt.status !== \"success\") {\n console.error(\"failed to send gas to deployer signer\", gasReceipt);\n throw new Error(\"failed to send gas to deployer signer\");\n }\n }\n\n // Deploy the deployer\n debug(\"deploying CREATE2 deployer at\", deployer);\n const deployTx = await sendRawTransaction(client, { serializedTransaction: `0x${deployment.transaction}` }).catch(\n (error) => {\n // Do a regular contract create if the presigned transaction doesn't work due to replay protection\n if (String(error).includes(\"only replay-protected (EIP-155) transactions allowed over RPC\")) {\n console.warn(\n // eslint-disable-next-line max-len\n `\\n ⚠️ Your chain or RPC does not allow for non EIP-155 signed transactions, so your deploys will not be determinstic and contract addresses may change between deploys.\\n\\n We recommend running your chain's node with \\`--rpc.allow-unprotected-txs\\` to enable determinstic deployments.\\n`,\n );\n debug(\"deploying CREATE2 deployer\");\n return sendTransaction(client, {\n chain: client.chain ?? null,\n data: `0x${deployment.creationCode}`,\n });\n }\n throw error;\n },\n );\n\n const deployReceipt = await waitForTransactionReceipt(client, { hash: deployTx });\n if (!deployReceipt.contractAddress) {\n throw new Error(\"Deploy receipt did not have contract address, was the deployer not deployed?\");\n }\n\n if (deployReceipt.contractAddress !== deployer) {\n console.warn(\n `\\n ⚠️ CREATE2 deployer created at ${deployReceipt.contractAddress} does not match the CREATE2 determinstic deployer we expected (${deployer})`,\n );\n }\n\n return deployReceipt.contractAddress;\n}\n","{\n \"gasPrice\": 100000000000,\n \"gasLimit\": 100000,\n \"signerAddress\": \"3fab184622dc19b6109349b94811493bf2a45362\",\n \"transaction\": \"f8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222\",\n \"address\": \"4e59b44847b379578588920ca78fbf26c0b4956c\",\n \"creationCode\": \"604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3\"\n}\n","import { Address, Chain, Client, Transport, sliceHex } from \"viem\";\nimport { getCode } from \"viem/actions\";\nimport deployment from \"./create2/deployment.json\";\nimport { debug } from \"./debug\";\n\nconst deployer = `0x${deployment.address}` as const;\n\nexport async function getDeployer(client: Client<Transport, Chain | undefined>): Promise<Address | undefined> {\n const bytecode = await getCode(client, { address: deployer });\n if (bytecode) {\n debug(\"found deployer bytecode at\", deployer);\n // check if deployed bytecode is the same as the expected bytecode (minus 14-bytes creation code prefix)\n if (bytecode !== sliceHex(`0x${deployment.creationCode}`, 14)) {\n console.warn(\n `\\n ⚠️ Bytecode for deployer at ${deployer} did not match the expected CREATE2 bytecode. You may have unexpected results.\\n`,\n );\n }\n return deployer;\n }\n}\n","import { Hex, getCreate2Address } from \"viem\";\nimport { singletonSalt } from \"./common\";\n\nexport function getContractAddress({\n deployerAddress,\n bytecode,\n salt = singletonSalt,\n}: {\n readonly deployerAddress: Hex;\n readonly bytecode: Hex;\n readonly salt?: Hex;\n}): Hex {\n return getCreate2Address({ from: deployerAddress, bytecode, salt });\n}\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AAAC,CAAK,CAAC,CACpE","names":["waitForTransactionReceipt","waitForTransactions","client","hashes","debugLabel","debug","hash","concatHex","getCreate2Address","getCode","stringToHex","singletonSalt","contractSizeLimit","debug","error","ensureContract","client","deployerAddress","bytecode","deployedBytecodeSize","debugLabel","salt","singletonSalt","address","getCreate2Address","getCode","debug","contractSizeLimit","sendTransaction","concatHex","ensureContractsDeployed","client","deployerAddress","contracts","uniqueContracts","uniqueBy","contract","txs","ensureContract","waitForTransactions","getBalance","sendRawTransaction","sendTransaction","waitForTransactionReceipt","deployment_default","sliceHex","getCode","deployer","deployment_default","getDeployer","client","bytecode","getCode","debug","sliceHex","deployer","deployment_default","ensureDeployer","client","existingDeployer","getDeployer","gasRequired","currentBalance","getBalance","gasNeeded","debug","gasTx","sendTransaction","gasReceipt","waitForTransactionReceipt","deployTx","sendRawTransaction","error","deployReceipt","getCreate2Address","getContractAddress","deployerAddress","bytecode","salt","singletonSalt","getCreate2Address"]}
package/dist/utils.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as i}from"./chunk-RPQA434J.js";function u(e,r){throw new Error(r??`Unexpected value: ${e}`)}function f(...e){return e.reduce((r,t)=>t>r?t:r)}function p(...e){return e.reduce((r,t)=>t<r?t:r)}function s(e,r){return e<r?-1:e>r?1:0}function*x(e,r){for(let t=0;t<e.length;t+=r)yield e.slice(t,t+r)}function y(e,r){let t=new Map;for(let o of e){let n=r(o);t.has(n)||t.set(n,[]),t.get(n).push(o)}return t}function T(e){return e}function b(e,r){return e.includes(r)}function w(e,r=" "){return e.replaceAll(/(^|\n)/g,`$1${r}`)}function h(e){return e!==void 0}function P(e){return e!==null}async function M(e){let r=[];for await(let t of e)r.push(t);return r}function q(e,r){return Object.fromEntries(Object.entries(e).map(([t,o])=>[t,r(o,t)]))}function O(e){return Array.from(new Set(e))}function C(e){return new Promise(r=>setTimeout(()=>r(),e))}function B(){return new Promise(e=>{typeof requestIdleCallback<"u"?requestIdleCallback(()=>e()):setTimeout(()=>e(),1)})}export{u as assertExhaustive,f as bigIntMax,p as bigIntMin,s as bigIntSort,x as chunk,y as groupBy,T as identity,b as includes,w as indent,h as isDefined,P as isNotNull,M as iteratorToArray,q as mapObject,O as unique,i as uniqueBy,C as wait,B as waitForIdle};
1
+ import{a as i}from"./chunk-Y4MH6TRP.js";function u(e,r){throw new Error(r??`Unexpected value: ${e}`)}function f(...e){return e.reduce((r,t)=>t>r?t:r)}function p(...e){return e.reduce((r,t)=>t<r?t:r)}function s(e,r){return e<r?-1:e>r?1:0}function*x(e,r){for(let t=0;t<e.length;t+=r)yield e.slice(t,t+r)}function y(e,r){let t=new Map;for(let o of e){let n=r(o);t.has(n)||t.set(n,[]),t.get(n).push(o)}return t}function T(e){return e}function b(e,r){return e.includes(r)}function w(e,r=" "){return e.replaceAll(/(^|\n)/g,`$1${r}`)}function h(e){return e!==void 0}function P(e){return e!==null}async function M(e){let r=[];for await(let t of e)r.push(t);return r}function q(e,r){return Object.fromEntries(Object.entries(e).map(([t,o])=>[t,r(o,t)]))}function O(e){return Array.from(new Set(e))}function C(e){return new Promise(r=>setTimeout(()=>r(),e))}function B(){return new Promise(e=>{typeof requestIdleCallback<"u"?requestIdleCallback(()=>e()):setTimeout(()=>e(),1)})}export{u as assertExhaustive,f as bigIntMax,p as bigIntMin,s as bigIntSort,x as chunk,y as groupBy,T as identity,b as includes,w as indent,h as isDefined,P as isNotNull,M as iteratorToArray,q as mapObject,O as unique,i as uniqueBy,C as wait,B as waitForIdle};
2
2
  //# sourceMappingURL=utils.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@latticexyz/common",
3
- "version": "2.2.15-f2c69f4d1600c9dd2fc79bd0002ba7c43250b98c",
3
+ "version": "2.2.15-ff8a065dc8e5216ad23e68f6a6c4856ecb2208a3",
4
4
  "description": "Common low level logic shared between packages",
5
5
  "repository": {
6
6
  "type": "git",
@@ -69,7 +69,7 @@
69
69
  "p-retry": "^5.1.2",
70
70
  "prettier": "3.2.5",
71
71
  "prettier-plugin-solidity": "1.3.1",
72
- "@latticexyz/schema-type": "2.2.15-f2c69f4d1600c9dd2fc79bd0002ba7c43250b98c"
72
+ "@latticexyz/schema-type": "2.2.15-ff8a065dc8e5216ad23e68f6a6c4856ecb2208a3"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@types/debug": "^4.1.7",
@@ -1,2 +0,0 @@
1
- function n(u,l){let e=new Map;for(let a of u)e.set(l(a),a);return Array.from(e.values())}export{n as a};
2
- //# sourceMappingURL=chunk-RPQA434J.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/uniqueBy.ts"],"sourcesContent":["export function uniqueBy<value, key>(values: readonly value[], getKey: (value: value) => key): readonly value[] {\n const map = new Map<key, value>();\n for (const value of values) {\n map.set(getKey(value), value);\n }\n return Array.from(map.values());\n}\n"],"mappings":"AAAO,SAASA,EAAqBC,EAA0BC,EAAiD,CAC9G,IAAMC,EAAM,IAAI,IAChB,QAAWC,KAASH,EAClBE,EAAI,IAAID,EAAOE,CAAK,EAAGA,CAAK,EAE9B,OAAO,MAAM,KAAKD,EAAI,OAAO,CAAC,CAChC","names":["uniqueBy","values","getKey","map","value"]}