diff --git a/src/encodeMulti.ts b/src/encodeMulti.ts index 39e3894..967d9af 100644 --- a/src/encodeMulti.ts +++ b/src/encodeMulti.ts @@ -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), @@ -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('') @@ -44,7 +50,7 @@ export const encodeMulti = ( return { operation: OperationType.DelegateCall, - to: multiSendContractAddress || MULTI_SEND_CONTRACT_ADDRESS, + to: multiSendContractAddress, value: '0x00', data, }