diff --git a/packages/cli/src/deploy/common.ts b/packages/cli/src/deploy/common.ts index 3cef84101b..e66902133b 100644 --- a/packages/cli/src/deploy/common.ts +++ b/packages/cli/src/deploy/common.ts @@ -1,14 +1,9 @@ -import { Abi, Account, Address, Chain, Client, Hex, Transport, padHex } from "viem"; +import { Abi, Account, Address, Chain, Client, Hex, Transport } from "viem"; import IBaseWorldAbi from "@latticexyz/world/out/IBaseWorld.sol/IBaseWorld.abi.json" assert { type: "json" }; import { helloStoreEvent } from "@latticexyz/store"; import { helloWorldEvent } from "@latticexyz/world"; import { LibraryMap } from "./getLibraryMap"; -export const salt = padHex("0x", { size: 32 }); - -// https://eips.ethereum.org/EIPS/eip-170 -export const contractSizeLimit = parseInt("6000", 16); - export const worldDeployEvents = [helloStoreEvent, helloWorldEvent] as const; export const worldAbi = IBaseWorldAbi; diff --git a/packages/cli/src/deploy/createPrepareDeploy.ts b/packages/cli/src/deploy/createPrepareDeploy.ts index 065ade5e0b..00f2d1c621 100644 --- a/packages/cli/src/deploy/createPrepareDeploy.ts +++ b/packages/cli/src/deploy/createPrepareDeploy.ts @@ -1,17 +1,18 @@ -import { DeterministicContract, LibraryPlaceholder, salt } from "./common"; +import { DeterministicContract, LibraryPlaceholder } from "./common"; import { spliceHex } from "@latticexyz/common"; -import { Hex, getCreate2Address, Address } from "viem"; +import { Hex, Address } from "viem"; import { LibraryMap } from "./getLibraryMap"; +import { getContractAddress } from "@latticexyz/common/internal"; export function createPrepareDeploy( bytecodeWithPlaceholders: Hex, placeholders: readonly LibraryPlaceholder[], ): DeterministicContract["prepareDeploy"] { - return function prepareDeploy(deployer: Address, libraryMap?: LibraryMap) { + return function prepareDeploy(deployerAddress: Address, libraryMap?: LibraryMap) { let bytecode = bytecodeWithPlaceholders; if (placeholders.length === 0) { - return { bytecode, address: getCreate2Address({ from: deployer, bytecode, salt }) }; + return { bytecode, address: getContractAddress({ deployerAddress, bytecode }) }; } if (!libraryMap) { @@ -19,12 +20,16 @@ export function createPrepareDeploy( } for (const placeholder of placeholders) { - const address = libraryMap.getAddress({ name: placeholder.name, path: placeholder.path, deployer }); + const address = libraryMap.getAddress({ + name: placeholder.name, + path: placeholder.path, + deployer: deployerAddress, + }); bytecode = spliceHex(bytecode, placeholder.start, placeholder.length, address); } return { bytecode, - address: getCreate2Address({ from: deployer, bytecode, salt }), + address: getContractAddress({ deployerAddress, bytecode }), }; }; } diff --git a/packages/cli/src/deploy/deploy.ts b/packages/cli/src/deploy/deploy.ts index d2d00f3906..853300632b 100644 --- a/packages/cli/src/deploy/deploy.ts +++ b/packages/cli/src/deploy/deploy.ts @@ -1,5 +1,4 @@ import { Address, Hex, stringToHex } from "viem"; -import { ensureDeployer } from "./ensureDeployer"; import { deployWorld } from "./deployWorld"; import { ensureTables } from "./ensureTables"; import { @@ -18,16 +17,15 @@ import { ensureModules } from "./ensureModules"; import { ensureNamespaceOwner } from "./ensureNamespaceOwner"; import { debug } from "./debug"; import { resourceToHex, resourceToLabel } from "@latticexyz/common"; -import { ensureContractsDeployed } from "./ensureContractsDeployed"; import { randomBytes } from "crypto"; import { Table } from "@latticexyz/config"; import { ensureResourceTags } from "./ensureResourceTags"; -import { waitForTransactions } from "./waitForTransactions"; import { ContractArtifact } from "@latticexyz/world/node"; import { World } from "@latticexyz/world"; import { deployCustomWorld } from "./deployCustomWorld"; import { uniqueBy } from "@latticexyz/common/utils"; import { getLibraryMap } from "./getLibraryMap"; +import { ensureContractsDeployed, ensureDeployer, waitForTransactions } from "@latticexyz/common/internal"; type DeployOptions = { config: World; diff --git a/packages/cli/src/deploy/deployCustomWorld.ts b/packages/cli/src/deploy/deployCustomWorld.ts index 54016b47c9..ad6b2f4226 100644 --- a/packages/cli/src/deploy/deployCustomWorld.ts +++ b/packages/cli/src/deploy/deployCustomWorld.ts @@ -1,14 +1,13 @@ -import { Account, Chain, Client, Hex, Transport, concatHex, encodeDeployData, getCreate2Address, isHex } from "viem"; +import { Account, Chain, Client, Hex, Transport, concatHex, encodeDeployData, isHex } from "viem"; import { waitForTransactionReceipt } from "viem/actions"; import { resourceToHex, sendTransaction, writeContract } from "@latticexyz/common"; import { debug } from "./debug"; import { logsToWorldDeploy } from "./logsToWorldDeploy"; -import { WorldDeploy, salt, worldAbi } from "./common"; +import { WorldDeploy, worldAbi } from "./common"; import { getWorldContracts } from "./getWorldContracts"; -import { ensureContractsDeployed } from "./ensureContractsDeployed"; +import { ensureContractsDeployed, getContractAddress, waitForTransactions } from "@latticexyz/common/internal"; import { ContractArtifact, ReferenceIdentifier } from "@latticexyz/world/node"; import { World } from "@latticexyz/world"; -import { waitForTransactions } from "./waitForTransactions"; function findArtifact(ref: ReferenceIdentifier, artifacts: readonly ContractArtifact[]): ContractArtifact { const artifact = artifacts.find((a) => a.sourcePath === ref.sourcePath && a.name === ref.name); @@ -31,9 +30,8 @@ function getDeployable(deployerAddress: Hex, artifact: ContractArtifact, artifac return concatHex( artifact.bytecode.map((ref): Hex => { if (isHex(ref)) return ref; - return getCreate2Address({ - from: deployerAddress, - salt, + return getContractAddress({ + deployerAddress, bytecode: getDeployable(deployerAddress, findArtifact(ref, artifacts), artifacts), }); }), diff --git a/packages/cli/src/deploy/ensureModules.ts b/packages/cli/src/deploy/ensureModules.ts index 5dc2128514..ea68626b81 100644 --- a/packages/cli/src/deploy/ensureModules.ts +++ b/packages/cli/src/deploy/ensureModules.ts @@ -4,8 +4,8 @@ import { Module, WorldDeploy, worldAbi } from "./common"; import { debug } from "./debug"; import { isDefined } from "@latticexyz/common/utils"; import pRetry from "p-retry"; -import { ensureContractsDeployed } from "./ensureContractsDeployed"; import { LibraryMap } from "./getLibraryMap"; +import { ensureContractsDeployed } from "@latticexyz/common/internal"; export async function ensureModules({ client, diff --git a/packages/cli/src/deploy/ensureResourceTags.ts b/packages/cli/src/deploy/ensureResourceTags.ts index 0b286e954a..4bd855f347 100644 --- a/packages/cli/src/deploy/ensureResourceTags.ts +++ b/packages/cli/src/deploy/ensureResourceTags.ts @@ -8,11 +8,11 @@ import { ensureModules } from "./ensureModules"; import metadataModule from "@latticexyz/world-module-metadata/out/MetadataModule.sol/MetadataModule.json" assert { type: "json" }; import { getContractArtifact } from "../utils/getContractArtifact"; import { createPrepareDeploy } from "./createPrepareDeploy"; -import { waitForTransactions } from "./waitForTransactions"; import { LibraryMap } from "./getLibraryMap"; import { getKeyTuple, getSchemaPrimitives } from "@latticexyz/protocol-parser/internal"; import { getRecords } from "@latticexyz/store-sync"; import { CommonDeployOptions } from "./common"; +import { waitForTransactions } from "@latticexyz/common/internal"; const metadataModuleArtifact = getContractArtifact(metadataModule); diff --git a/packages/cli/src/deploy/ensureSystems.ts b/packages/cli/src/deploy/ensureSystems.ts index 0db527850d..1cabbf2423 100644 --- a/packages/cli/src/deploy/ensureSystems.ts +++ b/packages/cli/src/deploy/ensureSystems.ts @@ -5,8 +5,8 @@ import { debug } from "./debug"; import { getSystems } from "./getSystems"; import { getResourceAccess } from "./getResourceAccess"; import pRetry from "p-retry"; -import { ensureContractsDeployed } from "./ensureContractsDeployed"; import { LibraryMap } from "./getLibraryMap"; +import { ensureContractsDeployed } from "@latticexyz/common/internal"; // TODO: move each system registration+access to batch call to be atomic diff --git a/packages/cli/src/deploy/ensureWorldFactory.ts b/packages/cli/src/deploy/ensureWorldFactory.ts index 3343755def..8f00e6cbdc 100644 --- a/packages/cli/src/deploy/ensureWorldFactory.ts +++ b/packages/cli/src/deploy/ensureWorldFactory.ts @@ -1,7 +1,7 @@ import { Client, Transport, Chain, Account, Hex, Address } from "viem"; -import { ensureContractsDeployed } from "./ensureContractsDeployed"; import { getWorldFactoryContracts } from "./getWorldFactoryContracts"; import { getWorldProxyFactoryContracts } from "./getWorldProxyFactoryContracts"; +import { ensureContractsDeployed } from "@latticexyz/common/internal"; export async function ensureWorldFactory( client: Client, diff --git a/packages/cli/src/deploy/getWorldContracts.ts b/packages/cli/src/deploy/getWorldContracts.ts index c20a01fad4..f0de3388be 100644 --- a/packages/cli/src/deploy/getWorldContracts.ts +++ b/packages/cli/src/deploy/getWorldContracts.ts @@ -4,36 +4,33 @@ import batchCallSystemBuild from "@latticexyz/world/out/BatchCallSystem.sol/Batc import registrationSystemBuild from "@latticexyz/world/out/RegistrationSystem.sol/RegistrationSystem.json" assert { type: "json" }; import initModuleBuild from "@latticexyz/world/out/InitModule.sol/InitModule.json" assert { type: "json" }; import initModuleAbi from "@latticexyz/world/out/InitModule.sol/InitModule.abi.json" assert { type: "json" }; -import { Hex, getCreate2Address, encodeDeployData, size } from "viem"; -import { salt } from "./common"; +import { Hex, encodeDeployData, size } from "viem"; +import { getContractAddress } from "@latticexyz/common/internal"; export function getWorldContracts(deployerAddress: Hex) { const accessManagementSystemDeployedBytecodeSize = size(accessManagementSystemBuild.deployedBytecode.object as Hex); const accessManagementSystemBytecode = accessManagementSystemBuild.bytecode.object as Hex; - const accessManagementSystem = getCreate2Address({ - from: deployerAddress, + const accessManagementSystem = getContractAddress({ + deployerAddress, bytecode: accessManagementSystemBytecode, - salt, }); const balanceTransferSystemDeployedBytecodeSize = size(balanceTransferSystemBuild.deployedBytecode.object as Hex); const balanceTransferSystemBytecode = balanceTransferSystemBuild.bytecode.object as Hex; - const balanceTransferSystem = getCreate2Address({ - from: deployerAddress, + const balanceTransferSystem = getContractAddress({ + deployerAddress, bytecode: balanceTransferSystemBytecode, - salt, }); const batchCallSystemDeployedBytecodeSize = size(batchCallSystemBuild.deployedBytecode.object as Hex); const batchCallSystemBytecode = batchCallSystemBuild.bytecode.object as Hex; - const batchCallSystem = getCreate2Address({ from: deployerAddress, bytecode: batchCallSystemBytecode, salt }); + const batchCallSystem = getContractAddress({ deployerAddress, bytecode: batchCallSystemBytecode }); const registrationDeployedBytecodeSize = size(registrationSystemBuild.deployedBytecode.object as Hex); const registrationBytecode = registrationSystemBuild.bytecode.object as Hex; - const registration = getCreate2Address({ - from: deployerAddress, + const registration = getContractAddress({ + deployerAddress, bytecode: registrationBytecode, - salt, }); const initModuleDeployedBytecodeSize = size(initModuleBuild.deployedBytecode.object as Hex); @@ -42,7 +39,7 @@ export function getWorldContracts(deployerAddress: Hex) { abi: initModuleAbi, args: [accessManagementSystem, balanceTransferSystem, batchCallSystem, registration], }); - const initModule = getCreate2Address({ from: deployerAddress, bytecode: initModuleBytecode, salt }); + const initModule = getContractAddress({ deployerAddress, bytecode: initModuleBytecode }); return { AccessManagementSystem: { diff --git a/packages/cli/src/deploy/getWorldFactoryContracts.ts b/packages/cli/src/deploy/getWorldFactoryContracts.ts index f98acbc380..572fabfe55 100644 --- a/packages/cli/src/deploy/getWorldFactoryContracts.ts +++ b/packages/cli/src/deploy/getWorldFactoryContracts.ts @@ -1,8 +1,8 @@ import worldFactoryBuild from "@latticexyz/world/out/WorldFactory.sol/WorldFactory.json" assert { type: "json" }; import worldFactoryAbi from "@latticexyz/world/out/WorldFactory.sol/WorldFactory.abi.json" assert { type: "json" }; -import { Hex, getCreate2Address, encodeDeployData, size } from "viem"; -import { salt } from "./common"; +import { Hex, encodeDeployData, size } from "viem"; import { getWorldContracts } from "./getWorldContracts"; +import { getContractAddress } from "@latticexyz/common/internal"; export function getWorldFactoryContracts(deployerAddress: Hex) { const worldContracts = getWorldContracts(deployerAddress); @@ -13,7 +13,7 @@ export function getWorldFactoryContracts(deployerAddress: Hex) { abi: worldFactoryAbi, args: [worldContracts.InitModule.address], }); - const worldFactory = getCreate2Address({ from: deployerAddress, bytecode: worldFactoryBytecode, salt }); + const worldFactory = getContractAddress({ deployerAddress, bytecode: worldFactoryBytecode }); return { ...worldContracts, diff --git a/packages/cli/src/deploy/getWorldProxyFactoryContracts.ts b/packages/cli/src/deploy/getWorldProxyFactoryContracts.ts index 5662df94a5..d291dbf2ab 100644 --- a/packages/cli/src/deploy/getWorldProxyFactoryContracts.ts +++ b/packages/cli/src/deploy/getWorldProxyFactoryContracts.ts @@ -1,8 +1,8 @@ import worldProxyFactoryBuild from "@latticexyz/world/out/WorldProxyFactory.sol/WorldProxyFactory.json" assert { type: "json" }; import worldProxyFactoryAbi from "@latticexyz/world/out/WorldProxyFactory.sol/WorldProxyFactory.abi.json" assert { type: "json" }; -import { Hex, getCreate2Address, encodeDeployData, size } from "viem"; -import { salt } from "./common"; +import { Hex, encodeDeployData, size } from "viem"; import { getWorldContracts } from "./getWorldContracts"; +import { getContractAddress } from "@latticexyz/common/internal"; export function getWorldProxyFactoryContracts(deployerAddress: Hex) { const worldContracts = getWorldContracts(deployerAddress); @@ -13,7 +13,7 @@ export function getWorldProxyFactoryContracts(deployerAddress: Hex) { abi: worldProxyFactoryAbi, args: [worldContracts.InitModule.address], }); - const worldProxyFactory = getCreate2Address({ from: deployerAddress, bytecode: worldProxyFactoryBytecode, salt }); + const worldProxyFactory = getContractAddress({ deployerAddress, bytecode: worldProxyFactoryBytecode }); return { ...worldContracts, diff --git a/packages/cli/src/verify.ts b/packages/cli/src/verify.ts index c6e20663a0..9a711a043d 100644 --- a/packages/cli/src/verify.ts +++ b/packages/cli/src/verify.ts @@ -1,13 +1,13 @@ -import { Chain, Client, Hex, Transport, getCreate2Address, sliceHex, zeroHash } from "viem"; +import { Chain, Client, Hex, Transport, sliceHex, zeroHash } from "viem"; import { getWorldFactoryContracts } from "./deploy/getWorldFactoryContracts"; import { verifyContract } from "./verify/verifyContract"; import PQueue from "p-queue"; import { getWorldProxyFactoryContracts } from "./deploy/getWorldProxyFactoryContracts"; -import { getDeployer } from "./deploy/getDeployer"; import { MUDError } from "@latticexyz/common/errors"; -import { Module, salt } from "./deploy/common"; +import { Module } from "./deploy/common"; import { getStorageAt } from "viem/actions"; import { execa } from "execa"; +import { getContractAddress, getDeployer } from "@latticexyz/common/internal"; type VerifyOptions = { client: Client; @@ -58,10 +58,9 @@ export async function verify({ rpc, verifier, verifierUrl, - address: getCreate2Address({ - from: deployerAddress, + address: getContractAddress({ + deployerAddress, bytecode: bytecode, - salt, }), }).catch((error) => { console.error(`Error verifying system contract ${name}:`, error); @@ -93,10 +92,9 @@ export async function verify({ rpc, verifier, verifierUrl, - address: getCreate2Address({ - from: deployerAddress, + address: getContractAddress({ + deployerAddress, bytecode: bytecode, - salt, }), }).catch((error) => { console.error(`Error verifying world factory contract ${name}:`, error); diff --git a/packages/common/package.json b/packages/common/package.json index ab8e05b62a..25427de799 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -19,6 +19,7 @@ "./type-utils": "./dist/type-utils.js", "./utils": "./dist/utils.js", "./kms": "./dist/kms.js", + "./internal": "./dist/internal.js", "./tsconfig.base.json": "./tsconfig.base.json" }, "typesVersions": { @@ -49,6 +50,9 @@ ], "kms": [ "./dist/kms.d.ts" + ], + "internal": [ + "./dist/internal.d.ts" ] } }, diff --git a/packages/common/src/deploy/common.ts b/packages/common/src/deploy/common.ts new file mode 100644 index 0000000000..633a7eba80 --- /dev/null +++ b/packages/common/src/deploy/common.ts @@ -0,0 +1,7 @@ +import { stringToHex } from "viem"; + +// salt for deterministic deploys of singleton contracts +export const singletonSalt = stringToHex("", { size: 32 }); + +// https://eips.ethereum.org/EIPS/eip-170 +export const contractSizeLimit = parseInt("6000", 16); diff --git a/packages/cli/src/deploy/create2/README.md b/packages/common/src/deploy/create2/README.md similarity index 100% rename from packages/cli/src/deploy/create2/README.md rename to packages/common/src/deploy/create2/README.md diff --git a/packages/cli/src/deploy/create2/deployment.json b/packages/common/src/deploy/create2/deployment.json similarity index 100% rename from packages/cli/src/deploy/create2/deployment.json rename to packages/common/src/deploy/create2/deployment.json diff --git a/packages/common/src/deploy/debug.ts b/packages/common/src/deploy/debug.ts new file mode 100644 index 0000000000..2642d0b81a --- /dev/null +++ b/packages/common/src/deploy/debug.ts @@ -0,0 +1,10 @@ +import { debug as parentDebug } from "../debug"; + +export const debug = parentDebug.extend("deploy"); +export const error = parentDebug.extend("deploy"); + +// Pipe debug output to stdout instead of stderr +debug.log = console.debug.bind(console); + +// Pipe error output to stderr +error.log = console.error.bind(console); diff --git a/packages/cli/src/deploy/ensureContract.ts b/packages/common/src/deploy/ensureContract.ts similarity index 71% rename from packages/cli/src/deploy/ensureContract.ts rename to packages/common/src/deploy/ensureContract.ts index c02f93965a..cadc5688ef 100644 --- a/packages/cli/src/deploy/ensureContract.ts +++ b/packages/common/src/deploy/ensureContract.ts @@ -1,9 +1,8 @@ import { Client, Transport, Chain, Account, concatHex, getCreate2Address, Hex } from "viem"; -import { getBytecode } from "viem/actions"; -import { contractSizeLimit, salt } from "./common"; -import { sendTransaction } from "@latticexyz/common"; +import { getCode } from "viem/actions"; +import { contractSizeLimit, singletonSalt } from "./common"; import { debug } from "./debug"; -import pRetry from "p-retry"; +import { sendTransaction } from "../sendTransaction"; export type Contract = { bytecode: Hex; @@ -25,9 +24,9 @@ export async function ensureContract({ throw new Error(`Found unlinked public library in ${debugLabel} bytecode`); } - const address = getCreate2Address({ from: deployerAddress, salt, bytecode }); + const address = getCreate2Address({ from: deployerAddress, salt: singletonSalt, bytecode }); - const contractCode = await getBytecode(client, { address, blockTag: "pending" }); + const contractCode = await getCode(client, { address, blockTag: "pending" }); if (contractCode) { debug("found", debugLabel, "at", address); return []; @@ -48,17 +47,10 @@ export async function ensureContract({ debug("deploying", debugLabel, "at", address); return [ - await pRetry( - () => - sendTransaction(client, { - chain: client.chain ?? null, - to: deployerAddress, - data: concatHex([salt, bytecode]), - }), - { - retries: 3, - onFailedAttempt: () => debug(`failed to deploy ${debugLabel}, retrying...`), - }, - ), + await sendTransaction(client, { + chain: client.chain ?? null, + to: deployerAddress, + data: concatHex([singletonSalt, bytecode]), + }), ]; } diff --git a/packages/cli/src/deploy/ensureContractsDeployed.ts b/packages/common/src/deploy/ensureContractsDeployed.ts similarity index 87% rename from packages/cli/src/deploy/ensureContractsDeployed.ts rename to packages/common/src/deploy/ensureContractsDeployed.ts index 6724641799..739d6ce2bd 100644 --- a/packages/cli/src/deploy/ensureContractsDeployed.ts +++ b/packages/common/src/deploy/ensureContractsDeployed.ts @@ -1,7 +1,7 @@ import { Client, Transport, Chain, Account, Hex } from "viem"; import { Contract, ensureContract } from "./ensureContract"; -import { uniqueBy } from "@latticexyz/common/utils"; -import { waitForTransactions } from "./waitForTransactions"; +import { waitForTransactions } from "../waitForTransactions"; +import { uniqueBy } from "../utils/uniqueBy"; export async function ensureContractsDeployed({ client, diff --git a/packages/cli/src/deploy/ensureDeployer.ts b/packages/common/src/deploy/ensureDeployer.ts similarity index 100% rename from packages/cli/src/deploy/ensureDeployer.ts rename to packages/common/src/deploy/ensureDeployer.ts diff --git a/packages/common/src/deploy/getContractAddress.ts b/packages/common/src/deploy/getContractAddress.ts new file mode 100644 index 0000000000..8da9441699 --- /dev/null +++ b/packages/common/src/deploy/getContractAddress.ts @@ -0,0 +1,12 @@ +import { Hex, getCreate2Address } from "viem"; +import { singletonSalt } from "./common"; + +export function getContractAddress({ + deployerAddress, + bytecode, +}: { + readonly deployerAddress: Hex; + readonly bytecode: Hex; +}): Hex { + return getCreate2Address({ from: deployerAddress, bytecode, salt: singletonSalt }); +} diff --git a/packages/cli/src/deploy/getDeployer.ts b/packages/common/src/deploy/getDeployer.ts similarity index 81% rename from packages/cli/src/deploy/getDeployer.ts rename to packages/common/src/deploy/getDeployer.ts index 03f22eda3a..dea14ab7d9 100644 --- a/packages/cli/src/deploy/getDeployer.ts +++ b/packages/common/src/deploy/getDeployer.ts @@ -1,14 +1,14 @@ import { Address, Chain, Client, Transport, sliceHex } from "viem"; -import { getBytecode } from "viem/actions"; +import { getCode } from "viem/actions"; import deployment from "./create2/deployment.json"; import { debug } from "./debug"; const deployer = `0x${deployment.address}` as const; export async function getDeployer(client: Client): Promise
{ - const bytecode = await getBytecode(client, { address: deployer }); + const bytecode = await getCode(client, { address: deployer }); if (bytecode) { - debug("found CREATE2 deployer at", deployer); + debug("found deployer bytecode at", deployer); // check if deployed bytecode is the same as the expected bytecode (minus 14-bytes creation code prefix) if (bytecode !== sliceHex(`0x${deployment.creationCode}`, 14)) { console.warn( diff --git a/packages/common/src/exports/internal.ts b/packages/common/src/exports/internal.ts new file mode 100644 index 0000000000..a25edda57a --- /dev/null +++ b/packages/common/src/exports/internal.ts @@ -0,0 +1,6 @@ +export * from "../waitForTransactions"; +export * from "../deploy/ensureContract"; +export * from "../deploy/ensureContractsDeployed"; +export * from "../deploy/ensureDeployer"; +export * from "../deploy/getContractAddress"; +export * from "../deploy/getDeployer"; diff --git a/packages/cli/src/deploy/waitForTransactions.ts b/packages/common/src/waitForTransactions.ts similarity index 95% rename from packages/cli/src/deploy/waitForTransactions.ts rename to packages/common/src/waitForTransactions.ts index 934233de22..ad3c26127e 100644 --- a/packages/cli/src/deploy/waitForTransactions.ts +++ b/packages/common/src/waitForTransactions.ts @@ -17,6 +17,7 @@ export async function waitForTransactions({ // wait for each tx separately/serially, because parallelizing results in RPC errors for (const hash of hashes) { const receipt = await waitForTransactionReceipt(client, { hash }); + // TODO: handle user op failures? if (receipt.status === "reverted") { throw new Error(`Transaction reverted: ${hash}`); } diff --git a/packages/common/tsup.config.ts b/packages/common/tsup.config.ts index 2ea1df785a..851bbf70b4 100644 --- a/packages/common/tsup.config.ts +++ b/packages/common/tsup.config.ts @@ -11,6 +11,7 @@ export default defineConfig((opts) => ({ "type-utils": "src/type-utils/index.ts", utils: "src/utils/index.ts", kms: "src/exports/kms.ts", + internal: "src/exports/internal.ts", }, target: "esnext", format: ["esm"],