Skip to content

Commit

Permalink
fix: add fallback for wallet client account address (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
chybisov authored Aug 9, 2024
1 parent 0048f08 commit a1ea259
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/core/EVM/EVMStepExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ import type {
} from 'viem'
import { publicActions } from 'viem'
import { config } from '../../config.js'
import { LiFiErrorCode } from '../../errors/constants.js'
import { TransactionError, ValidationError } from '../../errors/errors.js'
import { getStepTransaction } from '../../services/api.js'
import {
getTransactionFailedMessage,
isZeroAddress,
} from '../../utils/index.js'
import { ValidationError, TransactionError } from '../../errors/errors.js'
import { LiFiErrorCode } from '../../errors/constants.js'
import { parseEVMErrors } from './parseEVMErrors.js'
import { BaseStepExecutor } from '../BaseStepExecutor.js'
import { checkBalance } from '../checkBalance.js'
import { getSubstatusMessage } from '../processMessages.js'
Expand All @@ -31,6 +30,7 @@ import type {
import { waitForReceivingTransaction } from '../waitForReceivingTransaction.js'
import { checkAllowance } from './checkAllowance.js'
import { updateMultisigRouteProcess } from './multisig.js'
import { parseEVMErrors } from './parseEVMErrors.js'
import { switchChain } from './switchChain.js'
import type { MultisigConfig, MultisigTransaction } from './types.js'
import { getMaxPriorityFeePerGas } from './utils.js'
Expand Down Expand Up @@ -68,7 +68,12 @@ export class EVMStepExecutor extends BaseStepExecutor {
}

// Prevent execution of the quote by wallet different from the one which requested the quote
if (this.walletClient.account?.address !== step.action.fromAddress) {
let accountAddress = this.walletClient.account?.address
if (!accountAddress) {
const accountAddresses = await this.walletClient.getAddresses()
accountAddress = accountAddresses?.[0]
}
if (accountAddress !== step.action.fromAddress) {
let processToUpdate = process
if (!processToUpdate) {
// We need to create some process if we don't have one so we can show the error
Expand Down

0 comments on commit a1ea259

Please sign in to comment.