Skip to content

Commit

Permalink
chore: expose data gas consumed and data gas price for 0.7 rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvkelawala authored and penovicp committed Apr 3, 2024
1 parent 4b83943 commit abf87d1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/account/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,8 @@ export class Account extends Provider implements AccountInterface {
unit: 'FRI',
suggestedMaxFee: ZERO,
resourceBounds: estimateFeeToBounds(ZERO),
data_gas_consumed: 0n,
data_gas_price: 0n,
};
break;
}
Expand Down
2 changes: 2 additions & 0 deletions src/types/provider/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ export interface EstimateFeeResponse {
unit: PRICE_UNIT;
suggestedMaxFee: bigint;
resourceBounds: ResourceBounds;
data_gas_consumed: bigint;
data_gas_price: bigint;
}

export type EstimateFeeResponseBulk = Array<EstimateFeeResponse>;
Expand Down
14 changes: 9 additions & 5 deletions src/utils/responseParser/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ import {
BlockWithTxHashes,
ContractClassPayload,
ContractClassResponse,
TransactionReceipt,
EstimateFeeResponse,
EstimateFeeResponseBulk,
GetBlockResponse,
FeeEstimate,
GetBlockResponse,
GetTxReceiptResponseWithoutHelper,
RpcProviderOptions,
SimulateTransactionResponse,
SimulatedTransaction,
RpcProviderOptions,
GetTxReceiptResponseWithoutHelper,
TransactionReceipt,
} from '../../types/provider';
import { toBigInt } from '../num';
import { isString } from '../shortString';
import { estimateFeeToBounds, estimatedFeeToMaxFee } from '../stark';
import { ResponseParser } from '.';
import { isString } from '../shortString';

export class RPCResponseParser
implements
Expand Down Expand Up @@ -80,6 +80,8 @@ export class RPCResponseParser
unit: val.unit,
suggestedMaxFee: this.estimatedFeeToMaxFee(val.overall_fee),
resourceBounds: this.estimateFeeToBounds(val),
data_gas_consumed: val.data_gas_consumed ? toBigInt(val.data_gas_consumed) : 0n,
data_gas_price: val.data_gas_price ? toBigInt(val.data_gas_price) : 0n,
};
}

Expand All @@ -91,6 +93,8 @@ export class RPCResponseParser
unit: val.unit,
suggestedMaxFee: this.estimatedFeeToMaxFee(val.overall_fee),
resourceBounds: this.estimateFeeToBounds(val),
data_gas_consumed: val.data_gas_consumed ? toBigInt(val.data_gas_consumed) : 0n,
data_gas_price: val.data_gas_price ? toBigInt(val.data_gas_price) : 0n,
}));
}

Expand Down

0 comments on commit abf87d1

Please sign in to comment.