@@ -16,6 +16,7 @@ import {
16
16
getProvider ,
17
17
Multicall2Call ,
18
18
assert ,
19
+ getPermissionedMultisender ,
19
20
} from "../utils" ;
20
21
import { AugmentedTransaction , TransactionClient } from "./TransactionClient" ;
21
22
import lodash from "lodash" ;
@@ -260,10 +261,21 @@ export class MultiCallerClient {
260
261
return this . baseSigner ? getMultisender ( chainId , this . baseSigner . connect ( await getProvider ( chainId ) ) ) : undefined ;
261
262
}
262
263
264
+ async _getPermissionedMultisender ( chainId : number ) : Promise < Contract | undefined > {
265
+ return this . baseSigner
266
+ ? getPermissionedMultisender ( chainId , this . baseSigner . connect ( await getProvider ( chainId ) ) )
267
+ : undefined ;
268
+ }
269
+
263
270
async buildMultiSenderBundle ( transactions : AugmentedTransaction [ ] ) : Promise < AugmentedTransaction > {
264
271
// Validate all transactions have the same chainId and can be sent from multisender.
265
272
const { chainId } = transactions [ 0 ] ;
266
- const multisender = await this . _getMultisender ( chainId ) ;
273
+ // If any transactions are to be sent through the permissioned multisender, then we should use that instead
274
+ // of the default multisender. This means that the caller must only batch transactions to this chain that can
275
+ // be executed from the permissioned multisender.
276
+ const multisender = transactions . some ( ( t ) => t . sendThroughPermissionedMulticall )
277
+ ? await this . _getPermissionedMultisender ( chainId )
278
+ : await this . _getMultisender ( chainId ) ;
267
279
if ( ! multisender ) {
268
280
throw new Error ( "Multisender not available for this chain" ) ;
269
281
}
@@ -272,12 +284,17 @@ export class MultiCallerClient {
272
284
const callData : Multicall2Call [ ] = [ ] ;
273
285
let gasLimit : BigNumber | undefined = bnZero ;
274
286
transactions . forEach ( ( txn , idx ) => {
275
- if ( ! txn . unpermissioned || txn . chainId !== chainId ) {
287
+ if ( ! txn . unpermissioned || ! txn . sendThroughPermissionedMulticall || txn . chainId !== chainId ) {
276
288
this . logger . error ( {
277
289
at : "MultiCallerClient#buildMultiSenderBundle" ,
278
290
message : "Some transactions in the queue contain different target chain or are permissioned" ,
279
291
transactions : transactions . map ( ( { contract, chainId, unpermissioned } ) => {
280
- return { target : getTarget ( contract . address ) , unpermissioned : Boolean ( unpermissioned ) , chainId } ;
292
+ return {
293
+ target : getTarget ( contract . address ) ,
294
+ unpermissioned : Boolean ( unpermissioned ) ,
295
+ sendThroughPermissionedMulticall : Boolean ( txn . sendThroughPermissionedMulticall ) ,
296
+ chainId,
297
+ } ;
281
298
} ) ,
282
299
notificationPath : "across-error" ,
283
300
} ) ;
@@ -380,7 +397,7 @@ export class MultiCallerClient {
380
397
multisenderTxns = [ ] ,
381
398
unsendableTxns = [ ] ,
382
399
} = lodash . groupBy ( txns , ( txn ) => {
383
- if ( txn . unpermissioned ) {
400
+ if ( txn . unpermissioned || txn . sendThroughPermissionedMulticall ) {
384
401
return "multisenderTxns" ;
385
402
} else if ( txn . contract . multicall ) {
386
403
return "multicallerTxns" ;
0 commit comments