Skip to content

Commit

Permalink
Merge branch 'master' into feat/add-linters
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger authored Jul 14, 2024
2 parents 6121ec8 + fc9b920 commit 5047d61
Show file tree
Hide file tree
Showing 28 changed files with 498 additions and 149 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-11]
os: [ubuntu-latest, macos-12]
toolchain: [stable, nightly]

steps:
Expand Down
26 changes: 25 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ members = [
all-features = true

[dependencies]
starknet-crypto = { version = "0.7.0", path = "./starknet-crypto" }
starknet-crypto = { version = "0.7.1", path = "./starknet-crypto" }
starknet-core = { version = "0.11.1", path = "./starknet-core", default-features = false }
starknet-providers = { version = "0.11.0", path = "./starknet-providers" }
starknet-contract = { version = "0.10.0", path = "./starknet-contract" }
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ starknet = { git = "https://github.com/xJonathanLEI/starknet-rs" }
- [x] Sequencer gateway / feeder gateway client
- [x] Full node JSON-RPC API client
- [x] Smart contract deployment
- [x] Signer for using [IAccount](https://github.com/OpenZeppelin/cairo-contracts/blob/main/src/openzeppelin/account/IAccount.cairo) account contracts
- [x] Signer for using [IAccount](https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.6.1/src/openzeppelin/account/IAccount.cairo) account contracts
- [ ] Strongly-typed smart contract binding code generation from ABI
- [x] Ledger hardware wallet support

Expand Down Expand Up @@ -100,9 +100,11 @@ Examples can be found in the [examples folder](./examples):

10. [Deploy an OpenZeppelin account with Ledger](./examples/deploy_account_with_ledger.rs)

11. [Parsing a JSON-RPC request on the server side](./examples/parse_jsonrpc_request.rs)
11. [Transfer ERC20 tokens with Ledger](./examples/transfer_with_ledger.rs)

12. [Inspecting a erased provider-specific error type](./examples/downcast_provider_error.rs)
12. [Parsing a JSON-RPC request on the server side](./examples/parse_jsonrpc_request.rs)

13. [Inspecting a erased provider-specific error type](./examples/downcast_provider_error.rs)

## License

Expand Down
3 changes: 2 additions & 1 deletion examples/declare_cairo0_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ async fn main() {
.await
.unwrap();

dbg!(result);
println!("Transaction hash: {:#064x}", result.transaction_hash);
println!("Class hash: {:#064x}", result.class_hash);
}
3 changes: 2 additions & 1 deletion examples/declare_cairo1_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@ async fn main() {
.await
.unwrap();

dbg!(result);
println!("Transaction hash: {:#064x}", result.transaction_hash);
println!("Class hash: {:#064x}", result.class_hash);
}
1 change: 1 addition & 0 deletions examples/deploy_account_with_ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ async fn main() {
match result {
Ok(tx) => {
println!("Transaction hash: {:#064x}", tx.transaction_hash);
println!("Account: {:#064x}", tx.contract_address);
}
Err(err) => {
eprintln!("Error: {err}");
Expand Down
1 change: 1 addition & 0 deletions examples/deploy_argent_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ async fn main() {
match result {
Ok(tx) => {
println!("Transaction hash: {:#064x}", tx.transaction_hash);
println!("Account: {:#064x}", tx.contract_address);
}
Err(err) => {
eprintln!("Error: {err}");
Expand Down
2 changes: 1 addition & 1 deletion examples/mint_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ async fn main() {
.await
.unwrap();

dbg!(result);
println!("Transaction hash: {:#064x}", result.transaction_hash);
}
2 changes: 1 addition & 1 deletion examples/starknet-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ crate-type = ["cdylib", "rlib"]
default = ["console_error_panic_hook"]

[dependencies]
starknet-crypto = { version = "0.7.0", path = "../../starknet-crypto" }
starknet-crypto = { version = "0.7.1", path = "../../starknet-crypto" }
console_error_panic_hook = { version = "0.1.7", optional = true }
wasm-bindgen = "0.2.84"
57 changes: 57 additions & 0 deletions examples/transfer_with_ledger.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
use starknet::{
accounts::{Account, Call, ExecutionEncoding, SingleOwnerAccount},
core::{
chain_id,
types::{BlockId, BlockTag, Felt},
utils::get_selector_from_name,
},
macros::felt,
providers::{
jsonrpc::{HttpTransport, JsonRpcClient},
Url,
},
signers::LedgerSigner,
};

#[tokio::main]
async fn main() {
let provider = JsonRpcClient::new(HttpTransport::new(
Url::parse("https://starknet-sepolia.public.blastapi.io/rpc/v0_7").unwrap(),
));

let signer = LedgerSigner::new(
"m/2645'/1195502025'/1470455285'/0'/0'/0"
.try_into()
.expect("unable to parse path"),
)
.await
.expect("failed to initialize Starknet Ledger app");
let address = Felt::from_hex("YOUR_ACCOUNT_CONTRACT_ADDRESS_IN_HEX_HERE").unwrap();
let eth_token_address =
Felt::from_hex("0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7")
.unwrap();

let mut account = SingleOwnerAccount::new(
provider,
signer,
address,
chain_id::SEPOLIA,
ExecutionEncoding::New,
);

// `SingleOwnerAccount` defaults to checking nonce and estimating fees against the latest
// block. Optionally change the target block to pending with the following line:
account.set_block_id(BlockId::Tag(BlockTag::Pending));

let result = account
.execute_v1(vec![Call {
to: eth_token_address,
selector: get_selector_from_name("transfer").unwrap(),
calldata: vec![felt!("0x1234"), felt!("100"), Felt::ZERO],
}])
.send()
.await
.unwrap();

println!("Transaction hash: {:#064x}", result.transaction_hash);
}
2 changes: 1 addition & 1 deletion starknet-accounts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exclude = ["test-data/**"]

[dependencies]
starknet-core = { version = "0.11.1", path = "../starknet-core" }
starknet-crypto = { version = "0.7.0", path = "../starknet-crypto" }
starknet-crypto = { version = "0.7.1", path = "../starknet-crypto" }
starknet-providers = { version = "0.11.0", path = "../starknet-providers" }
starknet-signers = { version = "0.9.0", path = "../starknet-signers" }
async-trait = "0.1.68"
Expand Down
Loading

0 comments on commit 5047d61

Please sign in to comment.