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

refactor: use source chain signer #1913

Merged
merged 2 commits into from
Sep 20, 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
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
}
Comment on lines -590 to -595
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked on L560


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!')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked on L560


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
Loading