Skip to content

Commit

Permalink
Add Avalanche-cli package
Browse files Browse the repository at this point in the history
  • Loading branch information
Angel Valkov committed Aug 15, 2023
1 parent 3326bed commit 00d5260
Show file tree
Hide file tree
Showing 5 changed files with 1,629 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@

# Polkadot
inherit polkadot polkadot-fast;

avalanche-cli = callPackage ./avalanche-cli/default.nix {};
}
// lib.optionalAttrs hostPlatform.isLinux rec {
wasmd = callPackage ./wasmd/default.nix {};
Expand Down
23 changes: 23 additions & 0 deletions packages/avalanche-cli/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{pkgs}:
with pkgs;
buildGoModule rec {
pname = "avalanche-cli";
version = "1.2.6";

src = fetchFromGitHub {
rev = "v${version}";
sha256 = "sha256-j4Sh+YeLefWllaMNvfu/t253DCvdDpRY6tmrmuttSm0=";
owner = "ava-labs";
repo = "avalanche-cli";
};

doCheck = false;
proxyVendor = true;
vendorSha256 = "sha256-tWitBzhkg8l4qesiFXHBW0j4FWw85tMtDLq2DsriGfc=";

meta = with lib; {
description = "Avalanche CLI is a command line tool that gives developers access to everything Avalanche.";
homepage = "https://github.com/ava-labs/avalanche-cli";
license = licenses.lgpl3;
};
}
56 changes: 56 additions & 0 deletions run_near_chain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
HOME=$PWD'/.near/localnet_multi'
SHARDS_COUNT=3
GENESIS_VALIDATORS_COUNT=2
NETWORK_PORT=24567
RPC_PORT=3030

echo "Killing previous validators instances..."
kill $(ps aux | grep 'neard' | grep 'localnet_multi' | awk '{print $2}')

# Wait for node sync port to be free
while nc -z localhost $NETWORK_PORT; do
sleep 0.1
done

if [ -d "$HOME" ];
then
echo "Clearing previous state..."
rm -rf $HOME
fi

echo "Starting blockchain in: $HOME"

trim_json() {
data=$(echo "$1" | tr -d '[:blank:]' | tr -d '\r\n')
echo "$data"
}

read_json() {
data=`cat $1`
data=$(trim_json "$data")
echo "$data"
}

neard --home $HOME localnet --shards $SHARDS_COUNT --v $GENESIS_VALIDATORS_COUNT

NODE0_KEY_JSON=$(read_json "$HOME"'/node0/node_key.json')
NODE0_PUBLIC_KEY=$(echo $NODE0_KEY_JSON | jq -r '.public_key')

neard --home $HOME'/node0' run > $HOME'/node0.log' 2>&1 &

# Wait for node to be listening on sync port
while ! nc -z localhost $NETWORK_PORT; do
sleep 0.1
done

CURRENT_NETWORK_PORT=NETWORK_PORT
for (( i=1; i<$GENESIS_VALIDATORS_COUNT; i++ ))
do
CURRENT_NETWORK_PORT=$(($CURRENT_NETWORK_PORT+1))
RPC_PORT=$(($RPC_PORT+1))
neard --home $HOME'/node'$i run --boot-nodes $NODE0_PUBLIC_KEY@127.0.0.1:$NETWORK_PORT --network-addr='127.0.0.1:'$CURRENT_NETWORK_PORT --rpc-addr='127.0.0.1:'$RPC_PORT > $HOME'/node'$i'.log' 2>&1 &
done

# alias localnet_near='NEAR_ENV="local" NEAR_CLI_LOCALNET_NETWORK_ID="localnet" NEAR_NODE_URL="http://127.0.0.1:3030" NEAR_CLI_LOCALNET_KEY_PATH="/home/avalkov/.near/node0/validator_key.json" near'

# Deploy contracts
3 changes: 3 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ in
# noir
self'.legacyPackages.noir.noir-native
self'.legacyPackages.noir.noir-wasm

# avalanche cli
metacraft-labs.avalanche-cli
]
++ lib.optionals (stdenv.hostPlatform.isx86) [
metacraft-labs.rapidsnark
Expand Down
Loading

0 comments on commit 00d5260

Please sign in to comment.