Skip to content

Commit

Permalink
add gotenv and get env variables from .env file
Browse files Browse the repository at this point in the history
  • Loading branch information
vipulsharma21 committed Mar 22, 2023
1 parent 5606bc9 commit 87b0007
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VALIDATOR_PRIVATE_KEY=31b571bf6894a248831ff937bb49f7754509fe93bbd2517c9c73c4144c0e97dc
FOO=BAR
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ contract-examples/dynamic_rpc.json
plugins/evm/hubble.db

*.bin

local_status.sh
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ require (
github.com/influxdata/influxdb-client-go/v2 v2.4.0 // indirect
github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mattn/go-sqlite3 v1.14.16 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7Bd
github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
Expand Down
2 changes: 0 additions & 2 deletions local_status.sh

This file was deleted.

6 changes: 6 additions & 0 deletions plugin/evm/limitorders/limit_order_tx_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/ava-labs/subnet-evm/core"
"github.com/ava-labs/subnet-evm/core/types"
"github.com/ava-labs/subnet-evm/eth"
"github.com/joho/godotenv"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
Expand Down Expand Up @@ -73,6 +74,11 @@ func NewLimitOrderTxProcessor(txPool *core.TxPool, memoryDb LimitOrderDatabase,
if err != nil {
panic(err)
}
err = godotenv.Load()
if err != nil {
panic(err)
}

validatorPrivateKey := os.Getenv("VALIDATOR_PRIVATE_KEY")
if validatorPrivateKey == "" {
panic("private key is not supplied")
Expand Down
6 changes: 0 additions & 6 deletions scripts/run_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ if ! [[ "$0" =~ scripts/run_local.sh ]]; then
exit 255
fi

export VALIDATOR_PRIVATE_KEY="31b571bf6894a248831ff937bb49f7754509fe93bbd2517c9c73c4144c0e97dc"
if [[ -z "${VALIDATOR_PRIVATE_KEY}" ]]; then
echo "VALIDATOR_PRIVATE_KEY must be set"
exit 255
fi

avalanche network clean

./scripts/build.sh custom_evm.bin
Expand Down

0 comments on commit 87b0007

Please sign in to comment.