starknet-io / starknet.js

JavaScript library for StarkNet
https://www.starknetjs.com
MIT License
1.22k stars 751 forks source link

Support for Multiple RPC Versions in Starknet.js #791

Closed mztacat closed 1 year ago

mztacat commented 1 year ago

Problem: Currently, Starknet.js is a powerful tool for developers in the StarkWare ecosystem. However, it lacks flexibility when it comes to handling different RPC specifications, causing complications for DApp developers. The StarkWare project has introduced new RPC versions like 0.3.0 and 0.4.0, but not all nodes have transitioned to the latest version, which can lead to compatibility issues.

Proposed Solution: To address this problem and enhance the usability of Starknet.js, I propose implementing a feature that allows creating a 'RpcProvider' with an optional 'rpcVersion'x parameter. This parameter will enable DApp developers to choose the RPC version they want to interact with, regardless of whether their favorite node has been updated to the latest specifcation

e.g

const providerAlchemyMainnet = new RpcProvider({ 
    nodeUrl: 'https://starknet-mainnet.g.alchemy.com/v2/' + alchemyKey, 
    rpcVersion: "0.3.0"
});

const providerInfuraMainnet = new RpcProvider({ 
    nodeUrl: 'https://starknet-mainnet.infura.io/v3/' + infuraKey,
    rpcVersion: "0.4.0"
}); 

Consideration of Alternatives: One alternative suggested is not to support multiple RPC versions in the same codebase due to concerns about maintainability. However, it's important to weigh this against the benefits for DApp developers, who might need to transition at their own pace. Additionally, it's suggested that supporting multiple versions might be reconsidered once the network matures.

ivpavici commented 1 year ago

Hello! Starknet will soon shut down the Sequencer for public use... and only the newer versions of RPC (5.0/6.0) will support all the features that the sequencer provided! All nodes will have to migrate to the newer version and older Dapps will have to adapt regardless...

katiasabate commented 11 months ago

okay good stuff

monu03 commented 11 months ago

Ok

Hello! Starknet will soon shut down the Sequencer for public use... and only the newer versions of RPC (5.0/6.0) will support all the features that the sequencer provided! All nodes will have to migrate to the newer version and older Dapps will have to adapt regardless...

Awesome

Farmercoach commented 11 months ago

This are quiet unimaginable, teamwork is all I see....welldone guys👍💎🌊

tabaktoni commented 11 months ago

As promised after deprecating Sequencer I added support for RPC 0.5 and RPC 0.6 in the same codebase with v2 and v3 tx. I will try not to introduce any additional flags, but we will see what RPC 0.7 will bring to us.

clbrts09 commented 9 months ago

Interdasting way to solve this existing issue!

FlokiNode commented 9 months ago

Awesome!

plumbmine commented 9 months ago

Nice one

Congrats bro