11import type { Abi , AbiConstructor } from "abitype" ;
22import { parseEventLogs } from "../../event/actions/parse-logs.js" ;
3- import { FN_SELECTOR } from "../../extensions/stylus/__generated__/IStylusConstructor/write/stylus_constructor.js" ;
43import { contractDeployedEvent } from "../../extensions/stylus/__generated__/IStylusDeployer/events/ContractDeployed.js" ;
5- import { deploy } from "../../extensions/stylus/__generated__/IStylusDeployer/write/deploy.js" ;
64import { activateStylusContract } from "../../extensions/stylus/write/activateStylusContract.js" ;
7- import { eth_blockNumber } from "../../rpc/actions/eth_blockNumber.js" ;
8- import { getRpcClient } from "../../rpc/rpc.js" ;
5+ import { deployWithStylusConstructor } from "../../extensions/stylus/write/deployWithStylusConstructor.js" ;
96import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-confirm-transaction.js" ;
107import { sendTransaction } from "../../transaction/actions/send-transaction.js" ;
118import { prepareTransaction } from "../../transaction/prepare-transaction.js" ;
@@ -17,7 +14,7 @@ import { isZkSyncChain } from "../../utils/any-evm/zksync/isZkSyncChain.js";
1714import { isContractDeployed } from "../../utils/bytecode/is-contract-deployed.js" ;
1815import { ensureBytecodePrefix } from "../../utils/bytecode/prefix.js" ;
1916import { concatHex } from "../../utils/encoding/helpers/concat-hex.js" ;
20- import { type Hex , isHex , toHex } from "../../utils/encoding/hex.js" ;
17+ import { type Hex , isHex } from "../../utils/encoding/hex.js" ;
2118import type { Prettify } from "../../utils/type-utils.js" ;
2219import type { ClientAndChain } from "../../utils/types.js" ;
2320import type { Account } from "../../wallets/interfaces/wallet.js" ;
@@ -178,39 +175,12 @@ export async function deployContract(
178175 } ) ,
179176 } ) ;
180177 } else if ( options . isStylus && options . constructorParams ) {
181- const STYLUS_DEPLOYER = "0xCeCbA2F1dC234F70Dd89f2041029807F8D03A990" ;
182- const stylusDeployer = getContract ( {
183- address : STYLUS_DEPLOYER ,
178+ const deployTx = deployWithStylusConstructor ( {
179+ abi : options . abi ,
180+ bytecode : options . bytecode ,
184181 chain : options . chain ,
185182 client : options . client ,
186- } ) ;
187-
188- const constructorAbi = options . abi . find (
189- ( abi ) => abi . type === "constructor" ,
190- ) as AbiConstructor | undefined ;
191- const constructorCalldata = ( FN_SELECTOR +
192- encodeAbiParameters (
193- constructorAbi ?. inputs || [ ] , // Leave an empty array if there's no constructor
194- normalizeFunctionParams (
195- constructorAbi ,
196- options . constructorParams ,
197- ) . slice ( 2 ) ,
198- ) ) as `${typeof FN_SELECTOR } ${string } `;
199-
200- const rpcRequest = getRpcClient ( {
201- ...options ,
202- } ) ;
203- const blockNumber = await eth_blockNumber ( rpcRequest ) ;
204- const salt = toHex ( blockNumber , {
205- size : 32 ,
206- } ) ;
207-
208- const deployTx = deploy ( {
209- bytecode : options . bytecode ,
210- contract : stylusDeployer ,
211- initData : constructorCalldata ,
212- initValue : 0n ,
213- salt,
183+ constructorParams : options . constructorParams ,
214184 } ) ;
215185
216186 const receipt = await sendAndConfirmTransaction ( {
0 commit comments