1- import { WalletClient , GetFunctionArgs } from 'viem' ;
1+ import { PublicClient , WalletClient , GetFunctionArgs } from 'viem' ;
22
33import { rollupCreator } from './contracts' ;
4+ import { validParentChainId } from './types/ParentChain' ;
45import { defaults } from './createRollupDefaults' ;
56import { createRollupGetCallValue } from './createRollupGetCallValue' ;
67import { createRollupGetMaxDataSize } from './createRollupGetMaxDataSize' ;
@@ -11,7 +12,7 @@ import {
1112import { isCustomFeeTokenAddress } from './utils/isCustomFeeTokenAddress' ;
1213import { ChainConfig } from './types/ChainConfig' ;
1314import { isAnyTrustChainConfig } from './utils/isAnyTrustChainConfig' ;
14- import type { OrbitClient } from './orbitClient ' ;
15+ import { getValidChainId } from './utils/getters ' ;
1516
1617export type CreateRollupFunctionInputs = GetFunctionArgs <
1718 typeof rollupCreator . abi ,
@@ -25,16 +26,20 @@ export type CreateRollupParams = Pick<CreateRollupFunctionInputs[0], RequiredKey
2526
2627export async function createRollup ( {
2728 params,
28- orbitClient ,
29+ publicClient ,
2930 walletClient,
3031} : {
3132 params : CreateRollupParams ;
32- orbitClient : OrbitClient ;
33+ publicClient : PublicClient ;
3334 walletClient : WalletClient ;
3435} ) : Promise < CreateRollupTransactionReceipt > {
35- const chainId = orbitClient . getValidChainId ( ) ;
36+ const chainId = getValidChainId ( publicClient ) ;
3637 const account = walletClient . account ?. address ;
3738
39+ if ( ! validParentChainId ( chainId ) ) {
40+ throw new Error ( 'chainId is undefined' ) ;
41+ }
42+
3843 if ( typeof account === 'undefined' ) {
3944 throw new Error ( 'account is undefined' ) ;
4045 }
@@ -50,8 +55,8 @@ export async function createRollup({
5055 const maxDataSize = createRollupGetMaxDataSize ( chainId ) ;
5156 const paramsWithDefaults = { ...defaults , ...params , maxDataSize } ;
5257
53- const { request } = await orbitClient . simulateContract ( {
54- address : orbitClient . getRollupCreatorAddress ( ) ,
58+ const { request } = await publicClient . simulateContract ( {
59+ address : rollupCreator . address [ chainId ] ,
5560 abi : rollupCreator . abi ,
5661 functionName : 'createRollup' ,
5762 args : [ paramsWithDefaults ] ,
@@ -60,7 +65,7 @@ export async function createRollup({
6065 } ) ;
6166
6267 const hash = await walletClient . writeContract ( request ) ;
63- const txReceipt = await orbitClient . waitForTransactionReceipt ( { hash } ) ;
68+ const txReceipt = await publicClient . waitForTransactionReceipt ( { hash } ) ;
6469
6570 return createRollupPrepareTransactionReceipt ( txReceipt ) ;
6671}
0 commit comments