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: jsonrpc v0.7.1 and starknet v0.13.1 #577

Merged
merged 1 commit 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
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
**Complete Starknet library in Rust[™](https://www.reddit.com/r/rust/comments/12e7tdb/rust_trademark_policy_feedback_form/)**

![starknet-version-v0.13.0](https://img.shields.io/badge/Starknet_Version-v0.13.0-2ea44f?logo=ethereum)
[![jsonrpc-spec-v0.6.0](https://img.shields.io/badge/JSON--RPC-v0.6.0-2ea44f?logo=ethereum)](https://github.com/starkware-libs/starknet-specs/tree/v0.6.0)
[![jsonrpc-spec-v0.7.1](https://img.shields.io/badge/JSON--RPC-v0.7.1-2ea44f?logo=ethereum)](https://github.com/starkware-libs/starknet-specs/tree/v0.7.1)
[![linting-badge](https://github.com/xJonathanLEI/starknet-rs/actions/workflows/lint.yaml/badge.svg?branch=master)](https://github.com/xJonathanLEI/starknet-rs/actions/workflows/lint.yaml)
[![crates-badge](https://img.shields.io/crates/v/starknet.svg)](https://crates.io/crates/starknet)

Expand Down Expand Up @@ -74,21 +74,21 @@ For instructions on running the benchmark yourself, check [here](./BENCHMARK.md)

Examples can be found in the [examples folder](./examples):

1. [Get the latest block from `alpha-goerli` testnet](./examples/get_block.rs)
1. [Get the latest block from `alpha-sepolia` testnet](./examples/get_block.rs)

2. [Deploy contract to `alpha-goerli` testnet via UDC](./examples/deploy_contract.rs)
2. [Deploy contract to `alpha-sepolia` testnet via UDC](./examples/deploy_contract.rs)

3. [Mint yourself 1,000 TST tokens on `alpha-goerli`](./examples/mint_tokens.rs)
3. [Mint yourself 1,000 TST tokens on `alpha-sepolia`](./examples/mint_tokens.rs)

Make sure your account has some L2 Goerli ETH to pay for the transaction fee. You can use [this faucet](https://faucet.goerli.starknet.io/) to fund your account.
Make sure your account has some L2 Sepolia ETH to pay for the transaction fee.

4. [Declare Cairo 1 contract on `alpha-goerli` testnet](./examples/declare_cairo1_contract.rs)
4. [Declare Cairo 1 contract on `alpha-sepolia` testnet](./examples/declare_cairo1_contract.rs)

Make sure your account has some L2 Goerli ETH to pay for the transaction fee. You can use [this faucet](https://faucet.goerli.starknet.io/) to fund your account.
Make sure your account has some L2 Sepolia ETH to pay for the transaction fee.

5. [Declare legacy Cairo 0 contract on `alpha-goerli` testnet](./examples/declare_cairo0_contract.rs)
5. [Declare legacy Cairo 0 contract on `alpha-sepolia` testnet](./examples/declare_cairo0_contract.rs)

Make sure your account has some L2 Goerli ETH to pay for the transaction fee. You can use [this faucet](https://faucet.goerli.starknet.io/) to fund your account.
Make sure your account has some L2 Sepolia ETH to pay for the transaction fee.

6. [Query the latest block number with JSON-RPC](./examples/jsonrpc.rs)

Expand Down
4 changes: 2 additions & 2 deletions examples/declare_cairo0_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async fn main() {
serde_json::from_reader(std::fs::File::open("/path/to/contract/artifact.json").unwrap())
.unwrap();
let provider = JsonRpcClient::new(HttpTransport::new(
Url::parse("https://starknet-testnet.public.blastapi.io/rpc/v0_6").unwrap(),
Url::parse("https://starknet-sepolia.public.blastapi.io/rpc/v0_7").unwrap(),
));

let signer = LocalWallet::from(SigningKey::from_secret_scalar(
Expand All @@ -31,7 +31,7 @@ async fn main() {
provider,
signer,
address,
chain_id::TESTNET,
chain_id::SEPOLIA,
ExecutionEncoding::New,
);

Expand Down
4 changes: 2 additions & 2 deletions examples/declare_cairo1_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async fn main() {
FieldElement::from_hex_be("COMPILED_CASM_CLASS_HASH_IN_HEX_HERE").unwrap();

let provider = JsonRpcClient::new(HttpTransport::new(
Url::parse("https://starknet-testnet.public.blastapi.io/rpc/v0_6").unwrap(),
Url::parse("https://starknet-sepolia.public.blastapi.io/rpc/v0_7").unwrap(),
));

let signer = LocalWallet::from(SigningKey::from_secret_scalar(
Expand All @@ -37,7 +37,7 @@ async fn main() {
provider,
signer,
address,
chain_id::TESTNET,
chain_id::SEPOLIA,
ExecutionEncoding::New,
);

Expand Down
4 changes: 2 additions & 2 deletions examples/deploy_argent_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async fn main() {
let salt = felt!("12345678");

let provider = JsonRpcClient::new(HttpTransport::new(
Url::parse("https://starknet-testnet.public.blastapi.io/rpc/v0_6").unwrap(),
Url::parse("https://starknet-sepolia.public.blastapi.io/rpc/v0_7").unwrap(),
));

let signer = LocalWallet::from(SigningKey::from_secret_scalar(
Expand All @@ -27,7 +27,7 @@ async fn main() {

let factory = ArgentAccountFactory::new(
class_hash,
chain_id::TESTNET,
chain_id::SEPOLIA,
FieldElement::ZERO,
signer,
provider,
Expand Down
4 changes: 2 additions & 2 deletions examples/deploy_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async fn main() {
let class_hash = contract_artifact.class_hash().unwrap();

let provider = JsonRpcClient::new(HttpTransport::new(
Url::parse("https://starknet-testnet.public.blastapi.io/rpc/v0_6").unwrap(),
Url::parse("https://starknet-sepolia.public.blastapi.io/rpc/v0_7").unwrap(),
));

let signer = LocalWallet::from(SigningKey::from_secret_scalar(
Expand All @@ -35,7 +35,7 @@ async fn main() {
provider,
signer,
address,
chain_id::TESTNET,
chain_id::SEPOLIA,
ExecutionEncoding::New,
);

Expand Down
2 changes: 1 addition & 1 deletion examples/erc20_balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use starknet::{
#[tokio::main]
async fn main() {
let provider = JsonRpcClient::new(HttpTransport::new(
Url::parse("https://starknet-testnet.public.blastapi.io/rpc/v0_6").unwrap(),
Url::parse("https://starknet-sepolia.public.blastapi.io/rpc/v0_7").unwrap(),
));

let tst_token_address =
Expand Down
2 changes: 1 addition & 1 deletion examples/get_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use starknet::{
#[tokio::main]
async fn main() {
let provider = JsonRpcClient::new(HttpTransport::new(
Url::parse("https://starknet-testnet.public.blastapi.io/rpc/v0_6").unwrap(),
Url::parse("https://starknet-sepolia.public.blastapi.io/rpc/v0_7").unwrap(),
));

let latest_block = provider
Expand Down
2 changes: 1 addition & 1 deletion examples/jsonrpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use starknet::providers::{
#[tokio::main]
async fn main() {
let provider = JsonRpcClient::new(HttpTransport::new(
Url::parse("https://starknet-testnet.public.blastapi.io/rpc/v0_6").unwrap(),
Url::parse("https://starknet-sepolia.public.blastapi.io/rpc/v0_7").unwrap(),
));

let block_number = provider.block_number().await.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions examples/mint_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use starknet::{
#[tokio::main]
async fn main() {
let provider = JsonRpcClient::new(HttpTransport::new(
Url::parse("https://starknet-testnet.public.blastapi.io/rpc/v0_6").unwrap(),
Url::parse("https://starknet-sepolia.public.blastapi.io/rpc/v0_7").unwrap(),
));

let signer = LocalWallet::from(SigningKey::from_secret_scalar(
Expand All @@ -31,7 +31,7 @@ async fn main() {
provider,
signer,
address,
chain_id::TESTNET,
chain_id::SEPOLIA,
ExecutionEncoding::New,
);

Expand Down
4 changes: 2 additions & 2 deletions starknet-accounts/tests/single_owner_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ const CHAIN_ID: FieldElement = FieldElement::from_mont([
]);

fn create_sequencer_client() -> SequencerGatewayProvider {
SequencerGatewayProvider::starknet_alpha_goerli()
SequencerGatewayProvider::starknet_alpha_sepolia()
}

fn create_jsonrpc_client() -> JsonRpcClient<HttpTransport> {
let rpc_url = std::env::var("STARKNET_RPC")
.unwrap_or("https://pathfinder.rpc.sepolia.starknet.rs/rpc/v0_6".into());
.unwrap_or("https://pathfinder.rpc.sepolia.starknet.rs/rpc/v0_7".into());
JsonRpcClient::new(HttpTransport::new(url::Url::parse(&rpc_url).unwrap()))
}

Expand Down
4 changes: 2 additions & 2 deletions starknet-contract/src/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,13 @@ mod tests {
)
.unwrap(),
SingleOwnerAccount::new(
SequencerGatewayProvider::starknet_alpha_goerli(),
SequencerGatewayProvider::starknet_alpha_sepolia(),
LocalWallet::from_signing_key(SigningKey::from_random()),
FieldElement::from_hex_be(
"0xb1461de04c6a1aa3375bdf9b7723a8779c082ffe21311d683a0b15c078b5dc",
)
.unwrap(),
chain_id::TESTNET,
chain_id::SEPOLIA,
ExecutionEncoding::Legacy,
),
);
Expand Down
2 changes: 1 addition & 1 deletion starknet-contract/tests/contract_deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const CHAIN_ID: FieldElement = FieldElement::from_mont([
#[tokio::test]
async fn can_deploy_contract_to_alpha_sepolia() {
let rpc_url = std::env::var("STARKNET_RPC")
.unwrap_or("https://pathfinder.rpc.sepolia.starknet.rs/rpc/v0_6".into());
.unwrap_or("https://pathfinder.rpc.sepolia.starknet.rs/rpc/v0_7".into());
let provider = JsonRpcClient::new(HttpTransport::new(Url::parse(&rpc_url).unwrap()));
let signer = LocalWallet::from(SigningKey::from_secret_scalar(
FieldElement::from_hex_be(
Expand Down
3 changes: 3 additions & 0 deletions starknet-core/src/chain_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ pub const MAINNET: FieldElement = FieldElement::from_mont([
502562008147966918,
]);

#[deprecated = "The Goerli testnet has been shutdown"]
pub const TESTNET: FieldElement = FieldElement::from_mont([
3753493103916128178,
18446744073709548950,
18446744073709551615,
398700013197595345,
]);

#[deprecated = "The Goerli testnet has been shutdown"]
pub const TESTNET2: FieldElement = FieldElement::from_mont([
1663542769632127759,
18446744073708869172,
Expand All @@ -35,6 +37,7 @@ mod test {
use super::*;

#[test]
#[allow(deprecated)]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
fn test_chain_ids() {
for (text, felt) in [
Expand Down
Loading
Loading