Skip to content

Commit

Permalink
feat: change estimate fee response on rpc provider
Browse files Browse the repository at this point in the history
  • Loading branch information
badurinantun committed Jul 14, 2022
1 parent 591caf6 commit 942f4f2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion __tests__/rpcProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ describe('RPCProvider', () => {
});

test('estimate fee', async () => {
const { overall_fee } = await account.estimateFee({
const { overall_fee, gas_consumed, gas_price } = await account.estimateFee({
contractAddress: erc20Address,
entrypoint: 'transfer',
calldata: [erc20.address, '10'],
});

expect(isBN(overall_fee)).toBe(true);
expect(isBN(gas_consumed)).toBe(true);
expect(isBN(gas_price)).toBe(true);
});

test('execute by wallet owner', async () => {
Expand Down
2 changes: 2 additions & 0 deletions src/types/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export type DeclareTransactionReceiptResponse = CommonTransactionReceiptResponse

export interface EstimateFeeResponse {
overall_fee: BigNumberish;
gas_consumed?: BigNumberish;
gas_price?: BigNumberish;
}

export interface InvokeFunctionResponse {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/responseParser/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export class RPCResponseParser extends ResponseParser {
public parseFeeEstimateResponse(res: RPC.EstimateFeeResponse): EstimateFeeResponse {
return {
overall_fee: toBN(res.overall_fee),
gas_consumed: toBN(res.gas_consumed),
gas_price: toBN(res.gas_price),
};
}

Expand Down

0 comments on commit 942f4f2

Please sign in to comment.