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

Complete Aurora CLI Engine methods #2

Merged
merged 22 commits into from
Dec 23, 2022
Merged
Show file tree
Hide file tree
Changes from 8 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
.DS_Store
2 changes: 2 additions & 0 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ aurora-engine = { git = "https://github.com/aurora-is-near/aurora-engine.git", t
aurora-engine-precompiles = { git = "https://github.com/aurora-is-near/aurora-engine.git", tag = "2.7.0", features = ["std"] }
aurora-engine-sdk = { git = "https://github.com/aurora-is-near/aurora-engine.git", tag = "2.7.0", features = ["std"] }
aurora-engine-transactions = { git = "https://github.com/aurora-is-near/aurora-engine.git", tag = "2.7.0", features = ["std"] }
aurora-engine-types = { git = "https://github.com/aurora-is-near/aurora-engine.git", tag = "2.7.0", features = ["std"] }
aurora-engine-types = { git = "https://github.com/aurora-is-near/aurora-engine.git", tag = "2.7.0", features = ["std", "serde"] }
rjson = { git = "https://github.com/aurora-is-near/rjson", rev = "cc3da949", default-features = false, features = ["integer"] }
hskang9 marked this conversation as resolved.
Show resolved Hide resolved
hskang9 marked this conversation as resolved.
Show resolved Hide resolved
base64 = "0.13.0"
borsh = "0.9.3"
bs58 = "0.4.0"
Expand Down
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# `aurora-cli-rs`
<p>&nbsp;</p>
<p align="center">
<img src="" width=500>
</p>

A command-line interface for interacting with [Aurora](https://aurora.dev/).
<p align="center">
<strong>An instant, zero-config Aurora blockspace operator</strong>
</p>

<br/>

## What is Aurora CLI?
Aurora CLI is a command line interface to bootstrap Aurora blockspace with rapid speed built with rust.

Aurora CLI comes preconfiguration with opinionated, sensible defaults for standard testing environments. If other projects mention testing on Aurora, they are referring to the settings defined in this repo.

**Aurora CLI has the following advantages over a public testnet:**

- Easily modifiable world states
- Quick to reset for rapid iterations
- Simple simulations of different scenarios

See also prior art [aurora-cli](https://github.com/aurora-is-near/aurora-cli).

## Prerequisites
- :crab: Rust (*yes, this is what you only need*)

## Quickstart

- 📦 Install `aurora-cli-rs` and start interacting with it:
*`cargo install aurora-cli-rs`*
hskang9 marked this conversation as resolved.
Show resolved Hide resolved
- 🔍 Check out what each command is for in the official Aurora [docs]()
- ✋ Have questions? Ask them at the official Aurora [forum]()

## Walkthrough
Binary file added src/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion src/cli/aurora.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub async fn execute_command<T: AsRef<str>>(
config: &Config,
) -> Result<(), Box<dyn std::error::Error>> {
match command {
// Command::Benchmark
Command::Read { subcommand } => match subcommand {
ReadCommand::GetResult { tx_hash_hex } => {
let tx_hash =
Expand Down Expand Up @@ -113,7 +114,6 @@ async fn send_transaction<T: AsRef<str>>(

let nonce = client.get_nonce(source).await?;
let chain_id = client.get_chain_id().await?;

let tx_hash = client
.eth_transaction(to, amount, sk, chain_id, nonce, input)
.await
Expand Down
88 changes: 88 additions & 0 deletions src/cli/borsh_io.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
use aurora_engine::{fungible_token::FungibleReferenceHash, admin_controlled::PausedMask};
use aurora_engine_types::types::{Address, RawU256, NEP141Wei};
use borsh::{BorshSerialize, BorshDeserialize};
use near_primitives::types::{AccountId, Balance};
use serde::{Serialize, Deserialize};


#[derive(BorshSerialize)]
pub struct GetStorageAtInput {
hskang9 marked this conversation as resolved.
Show resolved Hide resolved
pub address: Address,
pub key: Vec<u8>,
}

#[derive(BorshSerialize, BorshDeserialize)]
pub struct AccountBalance {
pub address: Address,
pub balance: RawU256,
}

#[derive(Serialize, Deserialize)]
pub struct AccountBalanceSerde {
pub address: Address,
pub balance: RawU256,
}

/// Borsh-encoded parameters for the `begin_chain` function.
#[derive(BorshSerialize, BorshDeserialize)]
pub struct BeginChainArgs {
pub chain_id: RawU256,
pub genesis_alloc: Vec<AccountBalance>,
}

/// Borsh-encoded parameters for the `begin_block` function.
#[derive(BorshSerialize, BorshDeserialize)]
pub struct BeginBlockArgs {
/// The current block's hash (for replayer use).
pub hash: RawU256,
/// The current block's beneficiary address.
pub coinbase: Address,
/// The current block's timestamp (in seconds since the Unix epoch).
pub timestamp: RawU256,
/// The current block's number (the genesis block is number zero).
pub number: RawU256,
/// The current block's difficulty.
pub difficulty: RawU256,
/// The current block's gas limit.
pub gaslimit: RawU256,
}

/// Borsh-encoded parameters for `deploy_erc20_token` function.
#[derive(BorshSerialize, BorshDeserialize, Debug, Eq, PartialEq, Clone)]
pub struct DeployErc20TokenArgs {
pub nep141: AccountId,
}

/// withdraw NEAR eth-connector call args
#[derive(Debug, Clone, BorshSerialize, BorshDeserialize, PartialEq, Eq)]
pub struct WithdrawCallArgs {
pub recipient_address: Address,
pub amount: NEP141Wei,
}

#[derive(Debug, Clone, BorshSerialize, BorshDeserialize, PartialEq, Eq)]
pub struct PauseEthConnectorCallArgs {
pub paused_mask: PausedMask,
}

/// Borsh-encoded parameters for the `ft_transfer_call` function
/// for regular NEP-141 tokens.
#[derive(Debug, Clone, BorshSerialize, BorshDeserialize, PartialEq, Eq)]
pub struct NEP141FtOnTransferArgs {
pub sender_id: AccountId,
/// Balance can be for Eth on Near and for Eth to Aurora
/// `ft_on_transfer` can be called with arbitrary NEP-141 tokens attached, therefore we do not specify a particular type Wei.
pub amount: Balance,
pub msg: String,
}

#[derive(Debug, BorshDeserialize, BorshSerialize, Clone, PartialEq, Eq)]
pub struct FungibleTokenMetadata {
pub spec: String,
pub name: String,
pub symbol: String,
pub icon: Option<String>,
pub reference: Option<String>,
pub reference_hash: Option<FungibleReferenceHash>,
pub decimals: u8,
}
Loading