Skip to content

Commit

Permalink
fix: changes in silo commands
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksuss committed Oct 24, 2023
1 parent 7a8551b commit e923603
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
script: scripts/simple-silo.sh
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install aurora-cli (Advanced CLI)
uses: actions-rs/cargo@v1
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Run rustfmt
uses: actions-rs/cargo@v1
with:
Expand All @@ -25,7 +25,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Run clippy simple
uses: actions-rs/clippy-check@v1
with:
Expand All @@ -52,7 +52,7 @@ jobs:
os: windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Run tests simple
uses: actions-rs/cargo@v1
with:
Expand Down
40 changes: 20 additions & 20 deletions Cargo.lock

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

17 changes: 7 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "aurora-cli-rs"
version = "0.1.0"
authors = ["Aurora Labs <[email protected]>"]
edition = "2021"
rust-version = "1.69.0"
rust-version = "1.70.0"
homepage = "https://github.com/aurora-is-near/aurora-cli-rs"
repository = "https://github.com/aurora-is-near/aurora-cli-rs"
description = "Aurora CLI is a command line interface to bootstrap Aurora engine"
Expand All @@ -19,10 +19,10 @@ simple = []
advanced = []

[dependencies]
aurora-engine-precompiles = { git = "https://github.com/aurora-is-near/aurora-engine.git", tag = "silo-2.10.2", features = ["std"] }
aurora-engine-sdk = { git = "https://github.com/aurora-is-near/aurora-engine.git", tag = "silo-2.10.2", features = ["std"] }
aurora-engine-transactions = { git = "https://github.com/aurora-is-near/aurora-engine.git", tag = "silo-2.10.2", features = ["std"] }
aurora-engine-types = { git = "https://github.com/aurora-is-near/aurora-engine.git", tag = "silo-2.10.2", features = ["std", "impl-serde"] }
aurora-engine-precompiles = { git = "https://github.com/aurora-is-near/aurora-engine.git", tag = "3.3.0", features = ["std"] }
aurora-engine-sdk = { git = "https://github.com/aurora-is-near/aurora-engine.git", tag = "3.3.0", features = ["std"] }
aurora-engine-transactions = { git = "https://github.com/aurora-is-near/aurora-engine.git", tag = "3.3.0", features = ["std"] }
aurora-engine-types = { git = "https://github.com/aurora-is-near/aurora-engine.git", tag = "3.3.0", features = ["std", "impl-serde"] }

anyhow = "1"
bs58 = "0.5"
Expand All @@ -41,12 +41,9 @@ rand = "0.8"
rlp = "0.5.0"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
shadow-rs = "0.23"
shadow-rs = "0.24"
thiserror = "1"
tokio = { version = "1", features = ["full"] }

[dev-dependencies]
rand = "0.8"

[build-dependencies]
shadow-rs = "0.23"
shadow-rs = "0.24"
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<br />

[![CI](https://github.com/aurora-is-near/aurora-cli-rs/actions/workflows/rust.yml/badge.svg?branch=main)](https://github.com/aurora-is-near/aurora-cli-rs/actions/workflows/rust.yml)
![rust 1.68.2+ required](https://img.shields.io/badge/rust-1.68.2+-blue.svg?label=MSRV)
![rust 1.70.0+ required](https://img.shields.io/badge/rust-1.70.0+-blue.svg?label=MSRV)

## What is Engine?

Expand Down Expand Up @@ -188,13 +188,13 @@ aurora-cli --engine aurora.node0 get-storage-at --address 0x53a9fed853e02a39bf8d

### **Silo methods**

Retrieves the current fixed gas cost set in the Silo contract.
Retrieves the current fixed gas set in the Silo contract.
```shell
aurora-cli --engine aurora.node0 get-fixed-gas-cost
aurora-cli --engine aurora.node0 get-fixed-gas
```
Sets the fixed gas cost in the Silo contract to a specific value.
Sets the fixed gas in the Silo contract to a specific value.
```shell
aurora-cli --engine aurora.node0 set-fixed-gas-cost 0
aurora-cli --engine aurora.node0 set-fixed-gas 0
```
Check whitelists statuses
```shell
Expand Down Expand Up @@ -324,8 +324,8 @@ Commands:
call Call a modified method of the smart contract
encode-address Encode address
key-pair Return Public and Secret ED25519 keys
get-fixed-gas-cost Return fixed gas cost
set-fixed-gas-cost Set fixed gas cost
get-fixed-gas Return fixed gas per transaction
set-fixed-gas Set fixed gas per transaction
get-whitelist-status Return a status of the whitelist
set-whitelist-status Set a status for the whitelist
add-entry-to-whitelist Add entry into the whitelist
Expand Down
Binary file modified docs/res/aurora-mainnet-silo.wasm
Binary file not shown.
10 changes: 5 additions & 5 deletions scripts/simple-silo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ aurora-cli --engine $ENGINE_ACCOUNT init \
sleep 2

# Silo methods
# Get fixed gas cost
result=$(aurora-cli --engine $ENGINE_ACCOUNT get-fixed-gas-cost || error_exit)
# Get fixed gas
result=$(aurora-cli --engine $ENGINE_ACCOUNT get-fixed-gas || error_exit)
assert_eq "none" "$result"
# Set fixed gas cost
# Set fixed gas
aurora-cli --engine $ENGINE_ACCOUNT set-silo-params --cost 0 --rollback-address \
0x7e5f4552091a69125d5dfcb7b8c2659029395bdf || error_exit
sleep 1
# Get fixed gas cost
result=$(aurora-cli --engine $ENGINE_ACCOUNT get-fixed-gas-cost || error_exit)
# Get fixed gas
result=$(aurora-cli --engine $ENGINE_ACCOUNT get-fixed-gas || error_exit)
assert_eq "0" "$result"

# Check whitelists statuses
Expand Down
32 changes: 16 additions & 16 deletions src/cli/simple/command/silo.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use aurora_engine_types::borsh::{BorshDeserialize, BorshSerialize};
use aurora_engine_types::parameters::silo::{
FixedGasCostArgs, SiloParamsArgs, WhitelistAccountArgs, WhitelistAddressArgs, WhitelistArgs,
FixedGasArgs, SiloParamsArgs, WhitelistAccountArgs, WhitelistAddressArgs, WhitelistArgs,
WhitelistKind, WhitelistKindArgs, WhitelistStatusArgs,
};
use aurora_engine_types::types::Wei;
use aurora_engine_types::types::EthGas;
use near_primitives::views::CallResult;
use std::fmt::{Display, Formatter};

Expand All @@ -15,32 +15,32 @@ use crate::utils::hex_to_address;

/// Return fixed gas cost.
pub async fn get_fixed_gas_cost(client: Client) -> anyhow::Result<()> {
get_value::<FixedGasCost>(client, "get_fixed_gas_cost", None).await
get_value::<FixedGas>(client, "get_fixed_gas", None).await
}

/// Set fixed gas cost.
pub async fn set_fixed_gas_cost(client: Client, cost: u128) -> anyhow::Result<()> {
let args = FixedGasCostArgs {
cost: Some(Wei::new_u128(cost)),
pub async fn set_fixed_gas(client: Client, cost: u64) -> anyhow::Result<()> {
let args = FixedGasArgs {
fixed_gas: Some(EthGas::new(cost)),
}
.try_to_vec()?;

contract_call!(
"set_fixed_gas_cost",
"The fixed gas cost: {cost} has been set successfully",
"Error while setting gas cost"
"set_fixed_gas",
"The fixed gas: {cost} has been set successfully",
"Error while setting fixed gas"
)
.proceed(client, args)
.await
}

pub async fn set_silo_params(
client: Client,
cost: u128,
cost: u64,
rollback_address: String,
) -> anyhow::Result<()> {
let args = Some(SiloParamsArgs {
fixed_gas_cost: Wei::new_u128(cost),
fixed_gas: EthGas::new(cost),
erc20_fallback_address: hex_to_address(&rollback_address)?,
})
.try_to_vec()?;
Expand Down Expand Up @@ -177,20 +177,20 @@ impl Display for WhitelistStatus {
}
}

struct FixedGasCost(FixedGasCostArgs);
struct FixedGas(FixedGasArgs);

impl FromCallResult for FixedGasCost {
impl FromCallResult for FixedGas {
fn from_result(result: CallResult) -> anyhow::Result<Self> {
let args = FixedGasCostArgs::try_from_slice(&result.result)?;
let args = FixedGasArgs::try_from_slice(&result.result)?;
Ok(Self(args))
}
}

impl Display for FixedGasCost {
impl Display for FixedGas {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let value = self
.0
.cost
.fixed_gas
.map_or("none".to_string(), |cost| cost.to_string());
f.write_str(&value)
}
Expand Down
22 changes: 11 additions & 11 deletions src/cli/simple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,18 @@ pub enum Command {
/// Key type: ed25519 or secp256k1
key_type: KeyType,
},
/// Return fixed gas cost
GetFixedGasCost,
/// Set fixed gas cost
SetFixedGasCost {
/// Fixed gas cost in Wei.
cost: u128,
/// Return fixed gas
GetFixedGas,
/// Set fixed gas
SetFixedGas {
/// Fixed gas in EthGas.
cost: u64,
},
/// Set SILO params.
SetSiloParams {
/// Fixed gas cost in Wei.
/// Fixed gas in EthGas.
#[arg(long, short)]
cost: u128,
cost: u64,
/// Rollback EVM address.
#[arg(long, short)]
rollback_address: String,
Expand Down Expand Up @@ -405,9 +405,9 @@ pub async fn run(args: Cli) -> anyhow::Result<()> {
key_type,
} => command::gen_near_key(&account_id, key_type)?,
// Silo Specific Methods
Command::GetFixedGasCost => command::silo::get_fixed_gas_cost(client).await?,
Command::SetFixedGasCost { cost } => {
command::silo::set_fixed_gas_cost(client, cost).await?;
Command::GetFixedGas => command::silo::get_fixed_gas_cost(client).await?,
Command::SetFixedGas { cost } => {
command::silo::set_fixed_gas(client, cost).await?;
}
Command::SetSiloParams {
cost,
Expand Down

0 comments on commit e923603

Please sign in to comment.