Skip to content

Commit

Permalink
refactor: use source chain signer (#1913)
Browse files Browse the repository at this point in the history
  • Loading branch information
fionnachan authored Sep 20, 2024
1 parent 4204152 commit 0c1df57
Showing 1 changed file with 5 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,10 @@ export function TransferPanel() {

const nativeCurrency = useNativeCurrency({ provider: childChainProvider })

const { isEOA, isSmartContractWallet } = useAccountType()
const { isSmartContractWallet } = useAccountType()

const { data: parentSigner } = useSigner({
chainId: parentChain.id
})
const { data: childSigner } = useSigner({
chainId: childChain.id
const { data: signer } = useSigner({
chainId: networks.sourceChain.id
})

const { openTransactionHistoryPanel, setTransferring } =
Expand Down Expand Up @@ -340,9 +337,8 @@ export function TransferPanel() {
if (!walletAddress) {
return
}
const signer = isDepositMode ? parentSigner : childSigner
if (!signer) {
throw 'Signer is undefined'
throw signerUndefinedError
}

setTransferring(true)
Expand Down Expand Up @@ -561,8 +557,7 @@ export function TransferPanel() {
return
}

const hasBothSigners = parentSigner && childSigner
if (isEOA && !hasBothSigners) {
if (!signer) {
throw signerUndefinedError
}

Expand All @@ -587,13 +582,6 @@ export function TransferPanel() {
const isBatchTransfer = isBatchTransferSupported && Number(amount2) > 0

try {
if (
(isDepositMode && !parentSigner) ||
(!isDepositMode && !childSigner)
) {
throw signerUndefinedError
}

const warningToken =
selectedToken && warningTokens[selectedToken.address.toLowerCase()]
if (warningToken) {
Expand Down Expand Up @@ -673,8 +661,6 @@ export function TransferPanel() {
? selectedToken?.l2Address
: selectedToken?.address

const signer = isDepositMode ? parentSigner : childSigner

const bridgeTransferStarter = await BridgeTransferStarterFactory.create({
sourceChainId,
sourceChainErc20Address,
Expand All @@ -689,8 +675,6 @@ export function TransferPanel() {
destinationChainId
})

if (!signer) throw Error('Signer not connected!')

if (isWithdrawal && selectedToken && !sourceChainErc20Address) {
/*
just a fail-safe - since our types allow for an optional `selectedToken?.l2Address`, we can theoretically end up with a case
Expand Down

0 comments on commit 0c1df57

Please sign in to comment.