Skip to content
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

feat: add getGasPrice rpc provider method #1056

Merged
merged 6 commits into from
Apr 8, 2024

Conversation

princeibs
Copy link
Contributor

Motivation and Resolution

Closes #761

RPC version (if applicable)

...

Usage related changes

...

Development related changes

...

Checklist:

  • Performed a self-review of the code
  • Rebased to the last commit of the target branch (or merged it into my branch)
  • Linked the issues which this PR resolves
  • Documented the changes in code (API docs will be generated automatically)
  • Updated the tests
  • All tests are passing

@tabaktoni
Copy link
Collaborator

@PhilippeR26

src/provider/interface.ts Outdated Show resolved Hide resolved
__tests__/rpcProvider.test.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@PhilippeR26 PhilippeR26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just few improvements and variables naming.

__tests__/rpcProvider.test.ts Outdated Show resolved Hide resolved
@@ -100,6 +100,12 @@ export class RpcProvider implements ProviderInterface {
return this.channel.getBlockWithTxs(blockIdentifier);
}

public async getGasPrice(blockIdentifier?: BlockIdentifier) {
return this.channel
.getBlockWithTxs(blockIdentifier)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getBlockWithTxHashes should generate less amount of data to receive, and will nevertheless return the L1 gas price

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the response from BlastAPI but I couldn't find details of l1 gas price:
image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my side, with

const bl=await provider.getBlockWithTxHashes();

https://starknet-sepolia.public.blastapi.io/rpc/v0_7

{
  l1_da_mode: 'BLOB',
  l1_data_gas_price: { price_in_fri: '0x91acb74c302d3', price_in_wei: '0x14f44f92900' },
  l1_gas_price: { price_in_fri: '0x2d7f150f9892', price_in_wei: '0x68b5b1857' },
  parent_hash: '0x16cc570bf6841d72a650ac06eefe965f8325c01d80df0ed5de2d3b03d62c6ec',
  sequencer_address: '0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8',
  starknet_version: '0.13.1',
  status: 'PENDING',
  timestamp: 1712319031,
  transactions: [

https://starknet-sepolia.public.blastapi.io/rpc/v0_6

{
  l1_gas_price: { price_in_fri: '0x2782d833b2c3', price_in_wei: '0x5b07580b4' },
  parent_hash: '0x2ef3f69a56a90ca2864d4679aa64e857b72b7c9702fb3e3caaf07d863da79d1',
  sequencer_address: '0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8',
  starknet_version: '0.13.1',
  status: 'PENDING',
  timestamp: 1712319274,
  transactions: [

Same with mainnet, same with Nethermind.
So, it should work.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your problem is probably related to a connection to rpc v0.4 or v0.5 (as it's not described in your url)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed ✅. What caused the problem earlier was because I was using older RPC version. @PhilippeR26

src/utils/responseParser/rpc.ts Outdated Show resolved Hide resolved
@princeibs
Copy link
Contributor Author

@ivpavici @PhilippeR26

Copy link
Collaborator

@ivpavici ivpavici left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
let's see about @PhilippeR26 comment still

@ivpavici ivpavici changed the base branch from develop to next-version April 5, 2024 12:02
- change the helper method of `getL1GasPrice()` from `getBlockWithTxs()` to `getBlockWithTxHashes()`
Copy link
Collaborator

@tabaktoni tabaktoni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@tabaktoni tabaktoni added the done ready label Apr 8, 2024
@ivpavici ivpavici merged commit d396275 into starknet-io:next-version Apr 8, 2024
3 checks passed
github-actions bot pushed a commit that referenced this pull request Apr 23, 2024
# [6.8.0](v6.7.0...v6.8.0) (2024-04-23)

### Bug Fixes

* starkne types 0.7 ([#1087](#1087)) ([b038c76](b038c76))
* tslib ([#1068](#1068)) ([dd7dc10](dd7dc10))
* **utils:** fix block identifier ([#1076](#1076)) ([0a3499d](0a3499d))

### Features

* add getGasPrice rpc provider method ([#1056](#1056)) ([d396275](d396275))
* Export function parseCalldataField() ([4d59658](4d59658))
* rpc 0.7.1 ([#1071](#1071)) ([11dc600](11dc600))
Copy link

🎉 This PR is included in version 6.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

ivpavici added a commit that referenced this pull request Apr 25, 2024
* chore(release): 6.8.0 [skip ci]

# [6.8.0](v6.7.0...v6.8.0) (2024-04-23)

### Bug Fixes

* starkne types 0.7 ([#1087](#1087)) ([b038c76](b038c76))
* tslib ([#1068](#1068)) ([dd7dc10](dd7dc10))
* **utils:** fix block identifier ([#1076](#1076)) ([0a3499d](0a3499d))

### Features

* add getGasPrice rpc provider method ([#1056](#1056)) ([d396275](d396275))
* Export function parseCalldataField() ([4d59658](4d59658))
* rpc 0.7.1 ([#1071](#1071)) ([11dc600](11dc600))

* docs: add paragrapher for encode decode tool

* Update CHANGELOG.md

---------

Co-authored-by: Toni Tabak <tabaktoni@gmail.com>
Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net>
Co-authored-by: Ivan Pavičić <ivan.pavicic@live.com>
ivpavici pushed a commit that referenced this pull request May 2, 2024
* chore(release): 6.8.0 [skip ci]

# [6.8.0](v6.7.0...v6.8.0) (2024-04-23)

### Bug Fixes

* starkne types 0.7 ([#1087](#1087)) ([b038c76](b038c76))
* tslib ([#1068](#1068)) ([dd7dc10](dd7dc10))
* **utils:** fix block identifier ([#1076](#1076)) ([0a3499d](0a3499d))

### Features

* add getGasPrice rpc provider method ([#1056](#1056)) ([d396275](d396275))
* Export function parseCalldataField() ([4d59658](4d59658))
* rpc 0.7.1 ([#1071](#1071)) ([11dc600](11dc600))

* chore/add JsDoc for address.ts file

* update/ change address jsDoc

- Add quotes to address string
- Change address to get more zeros

* feat/ Add JSDoc for encode.ts

* update/ fix comments of encode.ts

* update/ Fix last comment

---------

Co-authored-by: Toni Tabak <tabaktoni@gmail.com>
Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

To have a method : provider.getGasprice()
4 participants