Skip to content

chore: expose data gas consumed and data gas price for 0.7 rpc #1057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/account/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,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
2 changes: 1 addition & 1 deletion www/versioned_docs/version-5.24.3/guides/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ In this example, if you want to read the events recorded in the last 10 blocks,
```typescript
import { RpcProvider } from 'starknet';
const providerRPC = new RpcProvider({
nodeUrl: "{ nodeUrl: 'https://starknet-goerli.infura.io/v3/' + infuraKey }",
nodeUrl: 'https://starknet-goerli.infura.io/v3/' + infuraKey,
}); // for an Infura node on Testnet
const lastBlock = await providerRPC.getBlock('latest');
const keyFilter = [num.toHex(hash.starknetKeccak('EventPanic')), '0x8'];
Expand Down