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/use ledger #35

Draft
wants to merge 31 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b8fe49b
adding silo methods
lempire123 May 8, 2023
dfa8e9a
Cleanup
lempire123 May 8, 2023
11b3c4b
WIP
lempire123 May 9, 2023
a10526e
WIP
lempire123 May 9, 2023
3864afb
Merge branch 'main' into lempire123/silo-methods
aleksuss May 11, 2023
6eb1bed
Add silo methods to simple.sh script
lempire123 May 11, 2023
a5288b2
change command to kebab-case
lempire123 May 13, 2023
5e44eb7
read JSON input
lempire123 May 15, 2023
8985d81
fixes
lempire123 May 15, 2023
712601e
feat: add support xcc operations
aleksuss May 16, 2023
7267f4d
feat: fix advanced part
aleksuss May 16, 2023
036e4ed
feat: use version 2 of new arguments struct
aleksuss May 16, 2023
d66c4e2
Merge branch 'main' into lempire123/silo-methods
aleksuss May 16, 2023
95f580b
feat: add shell script for test silo's methods
aleksuss May 17, 2023
15378d1
chore: improve CI script
aleksuss May 17, 2023
d3630ec
feat: increase timeout
aleksuss May 17, 2023
51d8cd5
chore: add description to the silo subcommands
aleksuss May 24, 2023
6b48971
feat: allow NEAR transfer with Ledger
Jun 23, 2023
6d80bf6
fix: `creat_account()` using ledger ONLY for testnet and mainnet
Jun 26, 2023
df30dab
minor fixes in the scripts
Jul 4, 2023
d560f74
merge main to the current branch and fix conflicts
Jul 4, 2023
e185fcb
fix minor conflict in `simple-silo.sh`
Jul 4, 2023
2857810
Update Cargo.toml
Jul 4, 2023
c129bbe
fix some clippy errors
Jul 4, 2023
865c6d7
fix: minor conflict in `simple-silo.sh`
Jul 4, 2023
191712e
fix: clippy errors
Jul 4, 2023
100081f
fix: setup linux dependencies
Jul 4, 2023
88a41de
fix: advanced tests
Jul 4, 2023
941cc3f
fix: minor lint error
Jul 4, 2023
59b0424
fix: more issues with linux dep accros all linting and testing
Jul 4, 2023
f196ac2
fix: simple and advanced conflicts
Jul 5, 2023
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
135 changes: 132 additions & 3 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ serde_json = "1"
shadow-rs = "0.23"
thiserror = "1"
tokio = { version = "1", features = ["full"] }
slip10 = "0.4.3"
near-ledger = { version = "0.2.0" }
0x3bfc marked this conversation as resolved.
Show resolved Hide resolved

[dev-dependencies]
rand = "0.8"
Expand Down
112 changes: 112 additions & 0 deletions scripts/simple-ledger.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/usr/bin/env bash

export NEARCORE_HOME="/tmp/localnet"

AURORA_PREV_VERSION="2.9.1"
AURORA_LAST_VERSION="2.9.1"
EVM_CODE=$(cat docs/res/HelloWorld.hex)
ABI_PATH="docs/res/HelloWorld.abi"
ENGINE_PREV_WASM_URL="https://github.com/aurora-is-near/aurora-engine/releases/download/$AURORA_PREV_VERSION/aurora-mainnet.wasm"
ENGINE_LAST_WASM_URL="https://github.com/aurora-is-near/aurora-engine/releases/download/$AURORA_LAST_VERSION/aurora-mainnet.wasm"
XCC_ROUTER_LAST_WASM_URL="https://github.com/aurora-is-near/aurora-engine/releases/download/$AURORA_LAST_VERSION/aurora-factory-mainnet.wasm"
ENGINE_WASM_PATH="/tmp/aurora-mainnet.wasm"
XCC_ROUTER_WASM_PATH="/tmp/aurora-factory-mainnet.wasm"
USER_BASE_BIN=$(python3 -m site --user-base)/bin
NODE_KEY_PATH=$NEARCORE_HOME/node0/validator_key.json
AURORA_KEY_PATH=$NEARCORE_HOME/node0/aurora_key.json
AURORA_SECRET_KEY=27cb3ddbd18037b38d7fb9ae3433a9d6f5cd554a4ba5768c8a15053f688ee167
ENGINE_ACCOUNT=aurora.node0
## CHANGE ME FOR TESTNET
NEW_NAMED_ACCOUNT_FOR_LEDGER_TESTNET=xyz1123456781.testnet
NEW_NAMED_ACCOUNT_FOR_LEDGER_LOCALNET=xyz1123456781.node0
## USE YOUR OWN LEDGER PUB KEY HERE
LEDGER_ACCOUNT_ID=3f6ab82e37adf3e6c91c9aa8f23ecfbb80d54e624ea56b0a619b0d94d6ee732c

export PATH="$PATH:$USER_BASE_BIN:$HOME/.cargo/bin"

# Install `nearup` utility if not installed before.
pip3 list | grep nearup > /dev/null || pip3 install --user nearup

start_node() {
cmd="nearup run localnet --home $NEARCORE_HOME"

if [[ $(uname -m) == "arm64" ]]; then # Check for local execution
cmd="$cmd --binary-path $HOME/.nearup/near/localnet"
fi

$cmd > /dev/null 2>&1
}

stop_node() {
nearup stop > /dev/null 2>&1
}

finish() {
# Stop NEAR node.
stop_node
# Cleanup
rm -rf $NEARCORE_HOME

if [[ -z "$1" ]]; then
exit 0
else
exit "$1"
fi
}

error_exit() {
finish 1
}

assert_eq() {
if [[ $1 != $2 ]]; then
echo "Unexpected result, should be $1 but actual is $2"
finish 1
fi
}

# Start NEAR node.
start_node
sleep 1

# Download Aurora EVM 2.8.1.
curl -sL $ENGINE_PREV_WASM_URL -o $ENGINE_WASM_PATH || error_exit

export NEAR_KEY_PATH=$NODE_KEY_PATH


## TESTNET ONLY

# Balance of Ledger account.
echo "View Ledger account: $LEDGER_ACCOUNT_ID (was already funded by another account)"
aurora-cli --network testnet view-account $LEDGER_ACCOUNT_ID || error_exit
sleep 1

# Create named account for the current ledger signe pub key.
echo "creating account $NEW_NAMED_ACCOUNT_FOR_LEDGER_TESTNET using ledger on testnet"
aurora-cli -u --network testnet create-account --account $NEW_NAMED_ACCOUNT_FOR_LEDGER_TESTNET --balance 1
sleep 2

# Balance of Ledger account.
echo "View Ledger account: $NEW_NAMED_ACCOUNT_FOR_LEDGER_TESTNET on testnet"
aurora-cli --network testnet view-account $NEW_NAMED_ACCOUNT_FOR_LEDGER_TESTNET || error_exit
sleep 2

## LOCALNET ONLY

# Create an account for Aurora EVM.
aurora-cli create-account --account $ENGINE_ACCOUNT --balance 100 > $AURORA_KEY_PATH || error_exit
sleep 1

# Fund the ledger account
echo "sending money to ledger account: $LEDGER_ACCOUNT_ID on localnet"
aurora-cli send-money --to $LEDGER_ACCOUNT_ID --amount 500
sleep 1

# Balance of Ledger account.
echo "View Ledger account: $LEDGER_ACCOUNT_ID on localnet"
aurora-cli view-account $LEDGER_ACCOUNT_ID || error_exit
sleep 2

# Stop NEAR node and clean up.
finish
8 changes: 8 additions & 0 deletions scripts/simple-silo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ sleep 1
# Deploy Aurora EVM.
export NEAR_KEY_PATH=$AURORA_KEY_PATH
aurora-cli deploy-aurora $ENGINE_WASM_PATH || error_exit
<<<<<<< HEAD
sleep 2
=======
sleep 4
>>>>>>> main
# Init Aurora EVM.
aurora-cli --engine $ENGINE_ACCOUNT init \
--chain-id 1313161556 \
Expand All @@ -79,7 +83,11 @@ aurora-cli --engine $ENGINE_ACCOUNT init \
--upgrade-delay-blocks 1 \
--custodian-address 0x1B16948F011686AE64BB2Ba0477aeFA2Ea97084D \
--ft-metadata-path docs/res/ft_metadata.json || error_exit
<<<<<<< HEAD
sleep 1
=======
sleep 2
>>>>>>> main

# Silo methods
# Get fixed gas cost
Expand Down
9 changes: 9 additions & 0 deletions src/cli/simple/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,15 @@ pub async fn set_owner(client: Client, account_id: String) -> anyhow::Result<()>
.await
}

/// Fund Near account
pub async fn send_money(client: Client, account: String, amount: f64) -> anyhow::Result<()> {
match client.near().send_money(&account, amount).await {
Ok(result) => println!("{result}"),
Err(e) => eprintln!("{e:?}"),
}
Ok(())
}

/// Register relayer address.
pub async fn register_relayer(client: Client, address: String) -> anyhow::Result<()> {
let args = hex_to_vec(&address)?;
Expand Down
Loading