diff --git a/contract_manager/scripts/upgrade_evm_entropy_contracts.ts b/contract_manager/scripts/upgrade_evm_entropy_contracts.ts index dae4c1fccc..71f7a3ce70 100644 --- a/contract_manager/scripts/upgrade_evm_entropy_contracts.ts +++ b/contract_manager/scripts/upgrade_evm_entropy_contracts.ts @@ -67,6 +67,18 @@ async function main() { for (const contract of Object.values(DefaultStore.entropy_contracts)) { if (selectedChains.includes(contract.chain)) { const artifact = JSON.parse(readFileSync(argv["std-output"], "utf8")); + // Normalize Foundry artifact bytecode which may be a string or an object { object: "..." } + let bytecode: string = (artifact as any)["bytecode"]; // eslint-disable-line @typescript-eslint/no-explicit-any + if ( + typeof bytecode === "object" && + bytecode !== null && + "object" in (bytecode as unknown as Record) + ) { + bytecode = (bytecode as unknown as { object: string }).object; + } + if (!bytecode.startsWith("0x")) { + bytecode = `0x${bytecode}`; + } console.log("Deploying contract to", contract.chain.getId()); try { const address = await runIfNotCached( @@ -75,7 +87,7 @@ async function main() { return contract.chain.deploy( toPrivateKey(argv["private-key"]), artifact["abi"], - artifact["bytecode"], + bytecode, [], 2, ); diff --git a/contract_manager/scripts/upgrade_evm_pricefeed_contracts.ts b/contract_manager/scripts/upgrade_evm_pricefeed_contracts.ts index 28f4e0519e..55ccc86e5c 100644 --- a/contract_manager/scripts/upgrade_evm_pricefeed_contracts.ts +++ b/contract_manager/scripts/upgrade_evm_pricefeed_contracts.ts @@ -40,12 +40,24 @@ async function main() { const payloads: Buffer[] = []; for (const chain of selectedChains) { const artifact = JSON.parse(readFileSync(argv["std-output"], "utf8")); + // Normalize Foundry artifact bytecode which may be a string or an object { object: "..." } + let bytecode: string = (artifact as any)["bytecode"]; // eslint-disable-line @typescript-eslint/no-explicit-any + if ( + typeof bytecode === "object" && + bytecode !== null && + "object" in (bytecode as unknown as Record) + ) { + bytecode = (bytecode as unknown as { object: string }).object; + } + if (!bytecode.startsWith("0x")) { + bytecode = `0x${bytecode}`; + } console.log("Deploying contract to", chain.getId()); const address = await runIfNotCached(`deploy-${chain.getId()}`, () => { return chain.deploy( toPrivateKey(argv["private-key"]), artifact["abi"], - artifact["bytecode"], + bytecode, [], ); });