Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Multichain] fix: Use readonly provider for predicting address during safe creation [SW-265] #4322

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/components/new-safe/create/steps/ReviewStep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { selectRpc } from '@/store/settingsSlice'
import { AppRoutes } from '@/config/routes'
import { type ReplayedSafeProps } from '@/store/slices'
import { predictAddressBasedOnReplayData } from '@/components/welcome/MyAccounts/utils/multiChainSafe'
import { createWeb3 } from '@/hooks/wallets/web3'
import { createWeb3ReadOnly } from '@/hooks/wallets/web3'
import { type DeploySafeProps } from '@safe-global/protocol-kit'
import { updateAddressBook } from '../../logic/address-book'

Expand Down Expand Up @@ -147,6 +147,7 @@ const ReviewStep = ({ data, onSubmit, onBack, setStep }: StepRenderProps<NewSafe
const dispatch = useAppDispatch()
const router = useRouter()
const [gasPrice] = useGasPrice()
const customRpc = useAppSelector(selectRpc)
const [payMethod, setPayMethod] = useState(PayMethod.PayLater)
const [executionMethod, setExecutionMethod] = useState(ExecutionMethod.RELAY)
const [isCreating, setIsCreating] = useState<boolean>(false)
Expand Down Expand Up @@ -222,7 +223,11 @@ const ReviewStep = ({ data, onSubmit, onBack, setStep }: StepRenderProps<NewSafe

const replayedSafeWithNonce = { ...newSafeProps, saltNonce: nextAvailableNonce }

const safeAddress = await predictAddressBasedOnReplayData(replayedSafeWithNonce, createWeb3(wallet.provider))
const customRpcUrl = customRpc[chain.chainId]
const provider = createWeb3ReadOnly(chain, customRpcUrl)
if (!provider) return

const safeAddress = await predictAddressBasedOnReplayData(replayedSafeWithNonce, provider)

for (const network of data.networks) {
await createSafe(network, replayedSafeWithNonce, safeAddress)
Expand Down
Loading