11/* eslint-disable class-methods-use-this */
22/* eslint-disable @typescript-eslint/no-unused-vars */
3- import { Interface } from 'ethers'
3+ import { Interface , ZeroAddress } from 'ethers'
4+
45import AmbireAccount from '../../../contracts/compiled/AmbireAccount.json'
56import AmbireFactory from '../../../contracts/compiled/AmbireFactory.json'
67import { ARBITRUM_CHAIN_ID } from '../../consts/networks'
@@ -13,9 +14,8 @@ import { BROADCAST_OPTIONS } from '../broadcast/broadcast'
1314import { FeePaymentOption , FullEstimation , FullEstimationSummary } from '../estimate/interfaces'
1415import { getBroadcastGas } from '../gasPrice/gasPrice'
1516import { TokenResult } from '../portfolio'
16- import { isNative } from '../portfolio/helpers'
17- import { BaseAccount } from './BaseAccount'
1817import { getSpoof } from './account'
18+ import { BaseAccount } from './BaseAccount'
1919
2020// this class describes a plain EOA that cannot transition
2121// to 7702 either because the network or the hardware wallet doesnt' support it
@@ -33,9 +33,21 @@ export class V1 extends BaseAccount {
3333 estimation : FullEstimationSummary ,
3434 feePaymentOptions : FeePaymentOption [ ]
3535 ) : FeePaymentOption [ ] {
36- return feePaymentOptions . filter (
37- ( opt ) => ( isNative ( opt . token ) && opt . paidBy === this . account . addr ) || opt . availableAmount > 0n
36+ const options = feePaymentOptions . filter (
37+ ( opt ) => opt . paidBy !== this . account . addr && opt . availableAmount > 0n
38+ )
39+ if ( options . length ) return options
40+
41+ // return the native only to display errors
42+ const native = feePaymentOptions . find (
43+ ( opt ) =>
44+ opt . paidBy === this . account . addr &&
45+ opt . token . address === ZeroAddress &&
46+ ! opt . token . flags . onGasTank
3847 )
48+ if ( ! native ) throw new Error ( 'no native fee payment option, it should not happen' )
49+ native . availableAmount = 0n
50+ return [ native ]
3951 }
4052
4153 getGasUsed (
0 commit comments