Skip to content

Commit

Permalink
by default use MultiSendCallOnly v1.4.1, MultiSend v1.4.1 if the batc…
Browse files Browse the repository at this point in the history
…h includes delegate calls
  • Loading branch information
jfschwarz committed May 30, 2024
1 parent 9a23b8a commit 07fa734
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/encodeMulti.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { pack } from '@ethersproject/solidity'
import { MetaTransaction, OperationType } from './types'

export const MULTI_SEND_ABI = ['function multiSend(bytes memory transactions)']
const MULTI_SEND_CONTRACT_ADDRESS = '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761'

const MULTISEND_141 = '0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526'
const MULTISEND_CALLONLY_141 = '0x9641d764fc13c8B624c04430C7356C1C7C8102e2'

/// Encodes the transaction as packed bytes of:
/// - `operation` as a `uint8` with `0` for a `call` or `1` for a `delegatecall` (=> 1 byte),
Expand All @@ -32,7 +34,11 @@ const remove0x = (hexString: string) => hexString.substr(2)
// For more information refer to https://docs.gnosis.io/safe/docs/contracts_details/#gnosis-safe-transactions.
export const encodeMulti = (
transactions: readonly MetaTransaction[],
multiSendContractAddress: string = MULTI_SEND_CONTRACT_ADDRESS
multiSendContractAddress: string = transactions.some(
(t) => t.operation === OperationType.DelegateCall
)
? MULTISEND_141
: MULTISEND_CALLONLY_141
): MetaTransaction => {
const transactionsEncoded =
'0x' + transactions.map(encodePacked).map(remove0x).join('')
Expand All @@ -44,7 +50,7 @@ export const encodeMulti = (

return {
operation: OperationType.DelegateCall,
to: multiSendContractAddress || MULTI_SEND_CONTRACT_ADDRESS,
to: multiSendContractAddress,
value: '0x00',
data,
}
Expand Down

0 comments on commit 07fa734

Please sign in to comment.