Skip to content

Commit

Permalink
fix: account estimate fee interface
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvkelawala committed Jun 11, 2022
1 parent 80a5aba commit 51e8cf6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
8 changes: 2 additions & 6 deletions src/account/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import assert from 'minimalistic-assert';

import { ZERO } from '../constants';
import { Provider, ProviderInterface } from '../provider';
import { BlockIdentifier } from '../provider/utils';
import { Signer, SignerInterface } from '../signer';
import {
Abi,
Expand All @@ -15,7 +14,7 @@ import {
Signature,
Transaction,
} from '../types';
import { EstimateFee } from '../types/account';
import { EstimateFee, EstimateFeeDetails } from '../types/account';
import { sign } from '../utils/ellipticCurve';
import {
computeHashOnElements,
Expand Down Expand Up @@ -56,10 +55,7 @@ export class Account extends Provider implements AccountInterface {

public async estimateFee(
calls: Call | Call[],
{
nonce: providedNonce,
blockIdentifier = 'pending',
}: { nonce?: BigNumberish; blockIdentifier?: BlockIdentifier } = {}
{ nonce: providedNonce, blockIdentifier = 'pending' }: EstimateFeeDetails = {}
): Promise<EstimateFee> {
const transactions = Array.isArray(calls) ? calls : [calls];
const nonce = providedNonce ?? (await this.getNonce());
Expand Down
8 changes: 5 additions & 3 deletions src/account/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import {
AddTransactionResponse,
Call,
DeployContractPayload,
Invocation,
InvocationsDetails,
Signature,
} from '../types';
import { EstimateFee } from '../types/account';
import { EstimateFee, EstimateFeeDetails } from '../types/account';
import { BigNumberish } from '../utils/number';
import { TypedData } from '../utils/typedData/types';

Expand Down Expand Up @@ -44,7 +43,10 @@ export abstract class AccountInterface extends ProviderInterface {
*
* @returns response from addTransaction
*/
public abstract estimateFee(invocation: Invocation): Promise<EstimateFee>;
public abstract estimateFee(
calls: Call | Call[],
estimateFeeDetails?: EstimateFeeDetails
): Promise<EstimateFee>;

/**
* Invoke execute function in account contract
Expand Down
7 changes: 7 additions & 0 deletions src/types/account.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import BN from 'bn.js';

import { BlockIdentifier } from '../provider/utils';
import { BigNumberish } from '../utils/number';
import { EstimateFeeResponse } from './api';

export interface EstimateFee extends EstimateFeeResponse {
suggestedMaxFee: BN;
}

export interface EstimateFeeDetails {
nonce?: BigNumberish;
blockIdentifier?: BlockIdentifier;
}
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './lib';
export * from './api';
export * from './signer';
export * from './contract';
export * from './account';

0 comments on commit 51e8cf6

Please sign in to comment.