Skip to content

Commit

Permalink
Merge pull request #75 from gnosis/fix-optimism-multisend
Browse files Browse the repository at this point in the history
fix multisend address for optimism
  • Loading branch information
jfschwarz authored Aug 18, 2023
2 parents b43f137 + 448ca73 commit 73e303a
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 9 deletions.
9 changes: 4 additions & 5 deletions extension/src/browser/Drawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import { useAllTransactions, useDispatch, useNewTransactions } from '../state'
import Submit from './Submit'
import { Transaction, TransactionBadge } from './Transaction'
import classes from './style.module.css'
import { ChainId, MULTI_SEND_ADDRESS } from '../../networks'

const TransactionsDrawer: React.FC = () => {
const [expanded, setExpanded] = useState(true)
const allTransactions = useAllTransactions()
const newTransactions = useNewTransactions()
const dispatch = useDispatch()
const provider = useProvider()
const { connection } = useConnection()
const { connection, chainId } = useConnection()

const scrollContainerRef = useRef<HTMLDivElement | null>(null)

Expand Down Expand Up @@ -58,14 +59,12 @@ const TransactionsDrawer: React.FC = () => {
}

const copyTransactionData = () => {
if (!chainId) throw new Error('chainId is undefined')
const metaTransactions = newTransactions.map((tx) => encodeSingle(tx.input))
const batchTransaction =
metaTransactions.length === 1
? metaTransactions[0]
: encodeMulti(
metaTransactions,
'0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761'
)
: encodeMulti(metaTransactions, MULTI_SEND_ADDRESS[chainId as ChainId])
const finalRequest = connection.moduleAddress
? wrapRequest(batchTransaction, connection)
: batchTransaction
Expand Down
10 changes: 7 additions & 3 deletions extension/src/browser/ProvideProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React, {
} from 'react'
import { decodeSingle, encodeMulti, encodeSingle } from 'react-multisend'

import { ChainId, EXPLORER_API_KEY } from '../networks'
import { ChainId, EXPLORER_API_KEY, MULTI_SEND_ADDRESS } from '../networks'
import {
ForkProvider,
useTenderlyProvider,
Expand Down Expand Up @@ -116,14 +116,18 @@ const ProvideProvider: React.FC<Props> = ({ simulate, children }) => {
encodeSingle(txState.input)
)

if (!chainId) {
throw new Error('chainId is undefined')
}

const batchTransactionHash = await wrappingProvider.request({
method: 'eth_sendTransaction',
params: [
metaTransactions.length === 1
? metaTransactions[0]
: encodeMulti(
metaTransactions,
'0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761'
MULTI_SEND_ADDRESS[chainId as ChainId]
),
],
})
Expand All @@ -135,7 +139,7 @@ const ProvideProvider: React.FC<Props> = ({ simulate, children }) => {
`multi-send batch has been submitted with transaction hash ${batchTransactionHash}`
)
return batchTransactionHash
}, [transactions, wrappingProvider, dispatch])
}, [transactions, wrappingProvider, dispatch, chainId])

return (
<ProviderContext.Provider
Expand Down
91 changes: 91 additions & 0 deletions extension/src/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,94 @@ export const NETWORK_NAME: Record<ChainId, string> = {
73799: 'Volta Testnet',
80001: 'Polygon Testnet',
}

export const MULTI_SEND_ADDRESS: Record<ChainId, string> = {
1: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 3: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
4: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
10: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 11: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 12: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 25: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 28: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 40: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 41: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 42: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
5: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
56: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 61: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 63: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 69: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 82: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 83: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 97: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
100: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 106: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 111: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 122: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 123: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
137: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
246: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 250: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 288: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 300: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 321: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 322: '0x6367360366E4c898488091ac315834B779d8f561',
// 336: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 338: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 420: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 588: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 592: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 595: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 686: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 787: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 1001: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 1008: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 1088: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 1284: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 1285: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 1287: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 1294: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 1807: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 1984: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 2001: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 2002: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 2008: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 2019: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 2020: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 2221: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 2222: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 4002: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 4918: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 4919: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 7341: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 7700: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 8217: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 9000: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 9001: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 10000: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 10001: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 11437: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 12357: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
42161: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 42170: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
42220: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 43113: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 43114: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 47805: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 71401: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
73799: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
80001: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 200101: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 200202: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 333999: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 421611: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 421613: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 11155111: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 1313161554: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 1313161555: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 1666600000: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 1666700000: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
// 11297108099: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
// 11297108109: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
}
2 changes: 1 addition & 1 deletion extension/src/settings/Connection/useZodiacModules.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { JsonRpcBatchProvider, Web3Provider } from '@ethersproject/providers'
import { JsonRpcBatchProvider } from '@ethersproject/providers'
import {
ContractAbis,
ContractAddresses,
Expand Down

0 comments on commit 73e303a

Please sign in to comment.