@@ -2,7 +2,7 @@ import { erc20Abi, getAddress } from 'viem';
22import { describe , expect , it } from 'vitest' ;
33import { publicClient } from '../../test/utils' ;
44import { InputParamFetcherType } from '../encoding' ;
5- import { ComposableBatch } from './batch' ;
5+ import { createComposableBatch } from './batch' ;
66
77const ACCOUNT = getAddress ( '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' ) ;
88const USDC = getAddress ( '0x036CbD53842c5426634e7929541eC2318f3dCF7e' ) ;
@@ -24,7 +24,7 @@ const UNISWAP_V3_FACTORY_ABI = [
2424// ---------------------------------------------------------------------------
2525
2626describe ( 'ComposableBatch — construction' , ( ) => {
27- const batch = ComposableBatch ( publicClient , ACCOUNT ) ;
27+ const batch = createComposableBatch ( publicClient , ACCOUNT ) ;
2828
2929 it ( 'stores publicClient' , ( ) => {
3030 expect ( batch . publicClient ) . toBe ( publicClient ) ;
@@ -40,7 +40,7 @@ describe('ComposableBatch — construction', () => {
4040// ---------------------------------------------------------------------------
4141
4242describe ( 'ComposableBatch — erc20Token' , ( ) => {
43- const batch = ComposableBatch ( publicClient , ACCOUNT ) ;
43+ const batch = createComposableBatch ( publicClient , ACCOUNT ) ;
4444 const token = batch . erc20Token ( USDC ) ;
4545
4646 it ( 'returns an ERC20TokenInstance with the correct address' , ( ) => {
@@ -93,7 +93,7 @@ describe('ComposableBatch — erc20Token', () => {
9393// ---------------------------------------------------------------------------
9494
9595describe ( 'ComposableBatch — nativeToken' , ( ) => {
96- const batch = ComposableBatch ( publicClient , ACCOUNT ) ;
96+ const batch = createComposableBatch ( publicClient , ACCOUNT ) ;
9797 const native = batch . nativeToken ( ) ;
9898
9999 it ( 'balance uses accountAddress when address is omitted' , async ( ) => {
@@ -126,12 +126,12 @@ describe('ComposableBatch — nativeToken', () => {
126126
127127describe ( 'ComposableBatch — add, length, clear, toCalldata' , ( ) => {
128128 it ( 'length is 0 on a fresh batch' , ( ) => {
129- const batch = ComposableBatch ( publicClient , ACCOUNT ) ;
129+ const batch = createComposableBatch ( publicClient , ACCOUNT ) ;
130130 expect ( batch . length ) . toBe ( 0 ) ;
131131 } ) ;
132132
133133 it ( 'add(single call) increments length by 1' , ( ) => {
134- const batch = ComposableBatch ( publicClient , ACCOUNT ) ;
134+ const batch = createComposableBatch ( publicClient , ACCOUNT ) ;
135135 const call = batch
136136 . contract ( USDC , erc20Abi )
137137 . write ( { functionName : 'transfer' , args : [ WETH , 1n ] } ) ;
@@ -140,7 +140,7 @@ describe('ComposableBatch — add, length, clear, toCalldata', () => {
140140 } ) ;
141141
142142 it ( 'add(array of calls) increments length by the array size' , ( ) => {
143- const batch = ComposableBatch ( publicClient , ACCOUNT ) ;
143+ const batch = createComposableBatch ( publicClient , ACCOUNT ) ;
144144 const token = batch . contract ( USDC , erc20Abi ) ;
145145 const calls = [
146146 token . write ( { functionName : 'transfer' , args : [ WETH , 1n ] } ) ,
@@ -151,15 +151,15 @@ describe('ComposableBatch — add, length, clear, toCalldata', () => {
151151 } ) ;
152152
153153 it ( 'add() can be called multiple times and accumulates calls' , ( ) => {
154- const batch = ComposableBatch ( publicClient , ACCOUNT ) ;
154+ const batch = createComposableBatch ( publicClient , ACCOUNT ) ;
155155 const token = batch . contract ( USDC , erc20Abi ) ;
156156 batch . add ( token . write ( { functionName : 'transfer' , args : [ WETH , 1n ] } ) ) ;
157157 batch . add ( token . write ( { functionName : 'approve' , args : [ WETH , 1n ] } ) ) ;
158158 expect ( batch . length ) . toBe ( 2 ) ;
159159 } ) ;
160160
161161 it ( 'clear() resets length to 0' , ( ) => {
162- const batch = ComposableBatch ( publicClient , ACCOUNT ) ;
162+ const batch = createComposableBatch ( publicClient , ACCOUNT ) ;
163163 const call = batch
164164 . contract ( USDC , erc20Abi )
165165 . write ( { functionName : 'transfer' , args : [ WETH , 1n ] } ) ;
@@ -169,7 +169,7 @@ describe('ComposableBatch — add, length, clear, toCalldata', () => {
169169 } ) ;
170170
171171 it ( 'toCalldata() returns a hex string' , async ( ) => {
172- const batch = ComposableBatch ( publicClient , ACCOUNT ) ;
172+ const batch = createComposableBatch ( publicClient , ACCOUNT ) ;
173173 const call = batch
174174 . contract ( USDC , erc20Abi )
175175 . write ( { functionName : 'transfer' , args : [ WETH , 1n ] } ) ;
@@ -179,7 +179,7 @@ describe('ComposableBatch — add, length, clear, toCalldata', () => {
179179 } ) ;
180180
181181 it ( 'toCalldata() with multiple calls returns a hex string' , async ( ) => {
182- const batch = ComposableBatch ( publicClient , ACCOUNT ) ;
182+ const batch = createComposableBatch ( publicClient , ACCOUNT ) ;
183183 const token = batch . contract ( USDC , erc20Abi ) ;
184184 batch . add ( token . write ( { functionName : 'transfer' , args : [ WETH , 1n ] } ) ) ;
185185 batch . add ( token . write ( { functionName : 'approve' , args : [ WETH , 1_000_000n ] } ) ) ;
@@ -188,8 +188,8 @@ describe('ComposableBatch — add, length, clear, toCalldata', () => {
188188 } ) ;
189189
190190 it ( 'toCalldata() produces different output for different calls' , async ( ) => {
191- const batchA = ComposableBatch ( publicClient , ACCOUNT ) ;
192- const batchB = ComposableBatch ( publicClient , ACCOUNT ) ;
191+ const batchA = createComposableBatch ( publicClient , ACCOUNT ) ;
192+ const batchB = createComposableBatch ( publicClient , ACCOUNT ) ;
193193 const token = batchA . contract ( USDC , erc20Abi ) ;
194194 batchA . add ( token . write ( { functionName : 'transfer' , args : [ WETH , 1n ] } ) ) ;
195195 batchB . add (
@@ -206,12 +206,12 @@ describe('ComposableBatch — add, length, clear, toCalldata', () => {
206206
207207describe ( 'ComposableBatch — calls getter' , ( ) => {
208208 it ( 'calls is empty on a fresh batch' , ( ) => {
209- const batch = ComposableBatch ( publicClient , ACCOUNT ) ;
209+ const batch = createComposableBatch ( publicClient , ACCOUNT ) ;
210210 expect ( batch . calls ) . toHaveLength ( 0 ) ;
211211 } ) ;
212212
213213 it ( 'calls reflects added single call' , ( ) => {
214- const batch = ComposableBatch ( publicClient , ACCOUNT ) ;
214+ const batch = createComposableBatch ( publicClient , ACCOUNT ) ;
215215 const call = batch
216216 . contract ( USDC , erc20Abi )
217217 . write ( { functionName : 'transfer' , args : [ WETH , 1n ] } ) ;
@@ -221,7 +221,7 @@ describe('ComposableBatch — calls getter', () => {
221221 } ) ;
222222
223223 it ( 'calls reflects added array of calls' , ( ) => {
224- const batch = ComposableBatch ( publicClient , ACCOUNT ) ;
224+ const batch = createComposableBatch ( publicClient , ACCOUNT ) ;
225225 const token = batch . contract ( USDC , erc20Abi ) ;
226226 batch . add ( [
227227 token . write ( { functionName : 'transfer' , args : [ WETH , 1n ] } ) ,
@@ -231,14 +231,14 @@ describe('ComposableBatch — calls getter', () => {
231231 } ) ;
232232
233233 it ( 'calls is empty after clear()' , ( ) => {
234- const batch = ComposableBatch ( publicClient , ACCOUNT ) ;
234+ const batch = createComposableBatch ( publicClient , ACCOUNT ) ;
235235 batch . add ( batch . contract ( USDC , erc20Abi ) . write ( { functionName : 'transfer' , args : [ WETH , 1n ] } ) ) ;
236236 batch . clear ( ) ;
237237 expect ( batch . calls ) . toHaveLength ( 0 ) ;
238238 } ) ;
239239
240240 it ( 'calls returns a copy — mutating it does not affect the batch' , ( ) => {
241- const batch = ComposableBatch ( publicClient , ACCOUNT ) ;
241+ const batch = createComposableBatch ( publicClient , ACCOUNT ) ;
242242 batch . add ( batch . contract ( USDC , erc20Abi ) . write ( { functionName : 'transfer' , args : [ WETH , 1n ] } ) ) ;
243243 const snapshot = batch . calls ;
244244 snapshot . pop ( ) ;
@@ -251,7 +251,7 @@ describe('ComposableBatch — calls getter', () => {
251251// ---------------------------------------------------------------------------
252252
253253describe ( 'ComposableBatch — contract' , ( ) => {
254- const batch = ComposableBatch ( publicClient , ACCOUNT ) ;
254+ const batch = createComposableBatch ( publicClient , ACCOUNT ) ;
255255 const factory = batch . contract ( UNISWAP_V3_FACTORY , UNISWAP_V3_FACTORY_ABI ) ;
256256
257257 it ( 'returns a ContractInstance with the correct address' , ( ) => {
0 commit comments