Skip to content

Commit

Permalink
Merge pull request #283 from bcnmy/SMA-134-executebatch-support
Browse files Browse the repository at this point in the history
buildUserOp: force encode for batch
  • Loading branch information
livingrockrises authored Sep 11, 2023
2 parents 9c47c4e + ebc192a commit c6e2db9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/account/src/BiconomySmartAccountV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,18 @@ export class BiconomySmartAccountV2 extends BaseSmartAccount {
const data = transactions.map((element: Transaction) => element.data ?? '0x')
const value = transactions.map((element: Transaction) => element.value ?? BigNumber.from('0'))

if (transactions.length === 0) {
throw new Error('Transactions array cannot be empty')
}

let callData = ''
if (transactions.length === 1) {
callData = await this.encodeExecute(to[0], value[0], data[0])
} else {
if (transactions.length > 1 || buildUseropDto?.forceEncodeForBatch) {
callData = await this.encodeExecuteBatch(to, value, data)
} else {
// transactions.length must be 1
callData = await this.encodeExecute(to[0], value[0], data[0])
}

let nonce = BigNumber.from(0)
try {
nonce = await this.getNonce()
Expand Down
1 change: 1 addition & 0 deletions packages/account/src/utils/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export type BuildUserOpOptions = {
overrides?: Overrides
skipBundlerGasEstimation?: boolean
params?: ModuleInfo
forceEncodeForBatch?: boolean
}

export type Overrides = {
Expand Down

0 comments on commit c6e2db9

Please sign in to comment.