-
Notifications
You must be signed in to change notification settings - Fork 15
Implement NEAR CLI using aurora-sdk-rs #97
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
Open
Qjawko
wants to merge
39
commits into
main
Choose a base branch
from
new-cli
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
b6ef2c1
Implement NEAR CLI using aurora-sdk-rs
Qjawko 52d1375
feat: add output formatting
Qjawko ffdd366
feat: add missing commands
Qjawko 07dfafc
feat: add missing methods, fix ci
Qjawko 2affc36
fix: review fixes, remove 'expect' calls, fix typos
Qjawko 2127357
simplify and split command and handle logic
Qjawko 05eb850
fix: code rabbit issues
Qjawko 2a52c46
fix: simplify output formatting for latest hashchain
Qjawko f5c80f0
fix get nonce method and readme
Qjawko debc44d
chore: add clone for aurora client
aleksuss 0e431ae
chore: non-contract-usage for near-sdk
aleksuss ef83098
Merge branch 'main' into new-cli
aleksuss 2981c12
feat: view method with block number
aleksuss 6465bd0
Merge branch 'main' into new-cli
aleksuss 1fc3c7d
chore: update dependencies and features in Cargo.toml files
Qjawko edbc259
fix: update tokio features and aurora-engine-types dependency configu…
Qjawko 35b550a
fix: update CLI paths in workflow configuration
Qjawko 806efc8
fix: add missing binary configuration for aurora-cli in Cargo.toml
Qjawko 33523fa
fix: enhance CLI configuration and error handling for NEAR signer
Qjawko c60a322
fix: clean up unused imports and enhance NearGas default configuration
Qjawko c639010
fix: change default network from Mainnet to Localnet in CLI configura…
Qjawko 7c4f629
fix: add debug output for command execution in CLI
Qjawko 0f934cc
fix: add debug output for command execution in run function
Qjawko e08cd2a
fix: improve error handling for signer file reading and update output…
Qjawko ad7317d
fix: update create_account function to return SecretKey and adjust ou…
Qjawko a2854d0
feat: split cli and handlers
Qjawko 94e21d2
chore: get neard version from rpc
aleksuss a35e7a9
chore: cargo fmt
aleksuss 5823922
chore: use macros for code clarity and less bloatness
Qjawko ed67d00
refactor: simplify handle_near_call macro by removing outdated syntax
Qjawko 60b45f2
fix: enhance error handling in deploy_aurora function and update outp…
Qjawko 0b21a2a
refactor: introduce read_wasm_file function and ability to parse sig…
Qjawko 3b6f495
chore: remove println!
aleksuss 8aec8db
fix: trim "0x" prefix from address input in parse_address function
Qjawko d15196a
fix: change bridge_prover_id to optional in init and update handling …
Qjawko 7b6ac06
fix: specify gas for contract calls
Qjawko 45a885d
fix: adjust create_account function to convert balance to near
Qjawko 8c3a366
fix: change default output format to plain and update CLI command usage
Qjawko 9d29667
fix: update init function to return FinalExecutionOutcomeView and han…
Qjawko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| [package] | ||
| name = "newcli" | ||
| version.workspace = true | ||
| authors.workspace = true | ||
| edition.workspace = true | ||
| rust-version.workspace = true | ||
| homepage.workspace = true | ||
| repository.workspace = true | ||
| readme.workspace = true | ||
|
|
||
| [dependencies] | ||
| anyhow.workspace = true | ||
| aurora-sdk-rs = {path = "../sdk" } | ||
| base64.workspace = true | ||
| clap = { workspace = true, features = ["derive"] } | ||
| libsecp256k1 = { workspace = true, features = ["std"] } | ||
| rlp.workspace = true | ||
| hex.workspace = true | ||
| serde.workspace = true | ||
| serde_json.workspace = true | ||
| tokio.workspace = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| use std::{path::PathBuf, str::FromStr}; | ||
|
|
||
| use aurora_sdk_rs::near::{ | ||
| crypto::{InMemorySigner, Signer}, | ||
| primitives::types::AccountId, | ||
| }; | ||
| use clap::{Parser, ValueEnum, command}; | ||
|
|
||
| use crate::command::Command; | ||
|
|
||
| #[derive(Debug, Clone, ValueEnum)] | ||
| pub enum Network { | ||
| Localnet, | ||
| Mainnet, | ||
| Testnet, | ||
| } | ||
| impl Network { | ||
| pub fn rpc_url(&self) -> &str { | ||
| match self { | ||
| Network::Localnet => "http://localhost:3030", | ||
| Network::Mainnet => "https://rpc.mainnet.near.org", | ||
| Network::Testnet => "https://rpc.testnet.near.org", | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[derive(Parser)] | ||
| #[command(author, long_about = None)] | ||
| pub struct Cli { | ||
| /// Near network ID | ||
| #[arg(long, value_enum, default_value_t = Network::Localnet)] | ||
| pub network: Network, | ||
| /// Aurora EVM account | ||
| #[arg(long, value_name = "ACCOUNT_ID", default_value = "aurora")] | ||
| pub engine: AccountId, | ||
| /// The way output of a command would be formatted | ||
| #[arg(long, default_value = "plain")] | ||
| pub output_format: OutputFormat, | ||
| /// Path to file with NEAR account id and secret key in JSON format | ||
| #[arg(long)] | ||
| pub near_key_path: PathBuf, | ||
| /// Block height to use for the view command | ||
| #[arg(short, long)] | ||
| pub block_height: Option<u64>, | ||
| #[clap(subcommand)] | ||
| pub command: Command, | ||
| } | ||
|
|
||
| impl Cli { | ||
| pub(crate) fn signer(&self) -> anyhow::Result<Signer> { | ||
| InMemorySigner::from_file(&self.near_key_path).map_err(Into::into) | ||
| } | ||
|
|
||
| pub(crate) fn root_contract_id(&self) -> anyhow::Result<AccountId> { | ||
| let account = match self.network { | ||
| Network::Testnet => "testnet", | ||
| Network::Mainnet => "near", | ||
| Network::Localnet => { | ||
| anyhow::bail!("Account creation is only supported for mainnet or testnet") | ||
| } | ||
| }; | ||
|
|
||
| account.parse().map_err(Into::into) | ||
| } | ||
| } | ||
|
|
||
| #[derive(Default, Clone, ValueEnum)] | ||
| pub enum OutputFormat { | ||
| #[default] | ||
| Plain, | ||
| Json, | ||
| } | ||
|
|
||
| impl FromStr for OutputFormat { | ||
| type Err = anyhow::Error; | ||
|
|
||
| fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
| match s { | ||
| "plain" => Ok(Self::Plain), | ||
| "json" => Ok(Self::Json), | ||
| _ => anyhow::bail!("unknown output format: {s}"), | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.