Skip to content

Commit

Permalink
Merge pull request #795 from laviniat1996/add_env
Browse files Browse the repository at this point in the history
Add `.env` file
  • Loading branch information
dfenstermaker authored Aug 8, 2023
2 parents 737a94e + 129a616 commit f5b6235
Show file tree
Hide file tree
Showing 155 changed files with 796 additions and 622 deletions.
18 changes: 18 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# public Avalanche API
IP = "api.avax.network"
PORT = 443
PROTOCOL = "https"
NETWORK_ID = 1

# localhost
LOCAL_IP= "127.0.0.1"
LOCAL_PORT = 9650
LOCAL_PROTOCOL = "http"
LOCAL_NETWORK_ID = 1337

# index API
IP_INDEXER = "indexer-demo.avax.network"

# socket
PROTOCOL_WS = "ws"
HOST = "localhost"
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ docsHTML/
# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

Expand Down
9 changes: 5 additions & 4 deletions examples/admin/alias.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import "dotenv/config"
import { Avalanche } from "../../src"
import { AdminAPI } from "../../src/apis/admin"

const ip: string = "localhost"
const port: number = 9650
const protocol: string = "http"
const networkID: number = 1337
const ip = process.env.LOCAL_IP
const port = Number(process.env.LOCAL_PORT)
const protocol = process.env.LOCAL_PROTOCOL
const networkID = Number(process.env.LOCAL_NETWORK_ID)
const avalanche: Avalanche = new Avalanche(ip, port, protocol, networkID)
const admin: AdminAPI = avalanche.Admin()

Expand Down
9 changes: 5 additions & 4 deletions examples/admin/aliasChain.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import "dotenv/config"
import { Avalanche } from "../../src"
import { AdminAPI } from "../../src/apis/admin"

const ip: string = "localhost"
const port: number = 9650
const protocol: string = "http"
const networkID: number = 1337
const ip = process.env.LOCAL_IP
const port = Number(process.env.LOCAL_PORT)
const protocol = process.env.LOCAL_PROTOCOL
const networkID = Number(process.env.LOCAL_NETWORK_ID)
const avalanche: Avalanche = new Avalanche(ip, port, protocol, networkID)
const admin: AdminAPI = avalanche.Admin()

Expand Down
9 changes: 5 additions & 4 deletions examples/admin/getChainAliases.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import "dotenv/config"
import { Avalanche } from "../../src"
import { AdminAPI } from "../../src/apis/admin"
import { Defaults } from "../../src/utils"

const ip: string = "localhost"
const port: number = 9650
const protocol: string = "http"
const networkID: number = 1337
const ip = process.env.LOCAL_IP
const port = Number(process.env.LOCAL_PORT)
const protocol = process.env.LOCAL_PROTOCOL
const networkID = Number(process.env.LOCAL_NETWORK_ID)
const avalanche: Avalanche = new Avalanche(ip, port, protocol, networkID)
const admin: AdminAPI = avalanche.Admin()

Expand Down
9 changes: 5 additions & 4 deletions examples/admin/getLoggerLevel.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import "dotenv/config"
import { Avalanche } from "../../src"
import { AdminAPI } from "../../src/apis/admin"
import { GetLoggerLevelResponse } from "../../src/apis/admin/interfaces"

const ip: string = "localhost"
const port: number = 9650
const protocol: string = "http"
const networkID: number = 1337
const ip = process.env.LOCAL_IP
const port = Number(process.env.LOCAL_PORT)
const protocol = process.env.LOCAL_PROTOCOL
const networkID = Number(process.env.LOCAL_NETWORK_ID)
const avalanche: Avalanche = new Avalanche(ip, port, protocol, networkID)
const admin: AdminAPI = avalanche.Admin()

Expand Down
9 changes: 5 additions & 4 deletions examples/admin/loadVMs.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import "dotenv/config"
import { Avalanche } from "../../src"
import { AdminAPI } from "../../src/apis/admin"
import { LoadVMsResponse } from "../../src/apis/admin/interfaces"

const ip: string = "localhost"
const port: number = 9650
const protocol: string = "http"
const networkID: number = 1337
const ip = process.env.LOCAL_IP
const port = Number(process.env.LOCAL_PORT)
const protocol = process.env.LOCAL_PROTOCOL
const networkID = Number(process.env.LOCAL_NETWORK_ID)
const avalanche: Avalanche = new Avalanche(ip, port, protocol, networkID)
const admin: AdminAPI = avalanche.Admin()

Expand Down
9 changes: 5 additions & 4 deletions examples/admin/lockProfile.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import "dotenv/config"
import { Avalanche } from "../../src"
import { AdminAPI } from "../../src/apis/admin"

const ip: string = "localhost"
const port: number = 9650
const protocol: string = "http"
const networkID: number = 1337
const ip = process.env.LOCAL_IP
const port = Number(process.env.LOCAL_PORT)
const protocol = process.env.LOCAL_PROTOCOL
const networkID = Number(process.env.LOCAL_NETWORK_ID)
const avalanche: Avalanche = new Avalanche(ip, port, protocol, networkID)
const admin: AdminAPI = avalanche.Admin()

Expand Down
9 changes: 5 additions & 4 deletions examples/admin/memoryProfile.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import "dotenv/config"
import { Avalanche } from "../../src"
import { AdminAPI } from "../../src/apis/admin"

const ip: string = "localhost"
const port: number = 9650
const protocol: string = "http"
const networkID: number = 1337
const ip = process.env.LOCAL_IP
const port = Number(process.env.LOCAL_PORT)
const protocol = process.env.LOCAL_PROTOCOL
const networkID = Number(process.env.LOCAL_NETWORK_ID)
const avalanche: Avalanche = new Avalanche(ip, port, protocol, networkID)
const admin: AdminAPI = avalanche.Admin()

Expand Down
9 changes: 5 additions & 4 deletions examples/admin/setLoggerLevel.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import "dotenv/config"
import { Avalanche } from "../../src"
import { AdminAPI } from "../../src/apis/admin"
import { SetLoggerLevelResponse } from "../../src/apis/admin/interfaces"

const ip: string = "localhost"
const port: number = 9650
const protocol: string = "http"
const networkID: number = 1337
const ip = process.env.LOCAL_IP
const port = Number(process.env.LOCAL_PORT)
const protocol = process.env.LOCAL_PROTOCOL
const networkID = Number(process.env.LOCAL_NETWORK_ID)
const avalanche: Avalanche = new Avalanche(ip, port, protocol, networkID)
const admin: AdminAPI = avalanche.Admin()

Expand Down
9 changes: 5 additions & 4 deletions examples/admin/startCPUProfiler.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import "dotenv/config"
import { Avalanche } from "../../src"
import { AdminAPI } from "../../src/apis/admin"

const ip: string = "localhost"
const port: number = 9650
const protocol: string = "http"
const networkID: number = 1337
const ip = process.env.LOCAL_IP
const port = Number(process.env.LOCAL_PORT)
const protocol = process.env.LOCAL_PROTOCOL
const networkID = Number(process.env.LOCAL_NETWORK_ID)
const avalanche: Avalanche = new Avalanche(ip, port, protocol, networkID)
const admin: AdminAPI = avalanche.Admin()

Expand Down
9 changes: 5 additions & 4 deletions examples/admin/stopCPUProfiler.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import "dotenv/config"
import { Avalanche } from "../../src"
import { AdminAPI } from "../../src/apis/admin"

const ip: string = "localhost"
const port: number = 9650
const protocol: string = "http"
const networkID: number = 1337
const ip = process.env.LOCAL_IP
const port = Number(process.env.LOCAL_PORT)
const protocol = process.env.LOCAL_PROTOCOL
const networkID = Number(process.env.LOCAL_NETWORK_ID)
const avalanche: Avalanche = new Avalanche(ip, port, protocol, networkID)
const admin: AdminAPI = avalanche.Admin()

Expand Down
9 changes: 5 additions & 4 deletions examples/auth/changePassword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
// which you can create based on "secrets.example" which is in the
// root of the `examples/` directory.
// Unlike "secrets.example", "secrets.json" should never be committed to git.
import "dotenv/config"
import { Avalanche } from "../../src"
import { AuthAPI } from "../../src/apis/auth"
import { readFile } from "fs"

const ip: string = "localhost"
const port: number = 9650
const protocol: string = "http"
const networkID: number = 1337
const ip = process.env.LOCAL_IP
const port = Number(process.env.LOCAL_PORT)
const protocol = process.env.LOCAL_PROTOCOL
const networkID = Number(process.env.LOCAL_NETWORK_ID)
const avalanche: Avalanche = new Avalanche(ip, port, protocol, networkID)
const auth: AuthAPI = avalanche.Auth()

Expand Down
9 changes: 5 additions & 4 deletions examples/auth/newToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
// which you can create based on "secrets.example" which is in the
// root of the `examples/` directory.
// Unlike "secrets.example", "secrets.json" should never be committed to git.
import "dotenv/config"
import { readFile } from "fs"
import { Avalanche } from "../../src"
import { AuthAPI } from "../../src/apis/auth"
import { ErrorResponseObject } from "../../src/utils"

const ip: string = "localhost"
const port: number = 9650
const protocol: string = "http"
const networkID: number = 1337
const ip = process.env.LOCAL_IP
const port = Number(process.env.LOCAL_PORT)
const protocol = process.env.LOCAL_PROTOCOL
const networkID = Number(process.env.LOCAL_NETWORK_ID)
const avalanche: Avalanche = new Avalanche(ip, port, protocol, networkID)
const auth: AuthAPI = avalanche.Auth()

Expand Down
9 changes: 5 additions & 4 deletions examples/auth/revokeToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
// which you can create based on "secrets.example" which is in the
// root of the `examples/` directory.
// Unlike "secrets.example", "secrets.json" should never be committed to git.
import "dotenv/config"
import { readFile } from "fs"
import { Avalanche } from "../../src"
import { AuthAPI } from "../../src/apis/auth"

const ip: string = "localhost"
const port: number = 9650
const protocol: string = "http"
const networkID: number = 1337
const ip = process.env.LOCAL_IP
const port = Number(process.env.LOCAL_PORT)
const protocol = process.env.LOCAL_PROTOCOL
const networkID = Number(process.env.LOCAL_NETWORK_ID)
const avalanche: Avalanche = new Avalanche(ip, port, protocol, networkID)
const auth: AuthAPI = avalanche.Auth()

Expand Down
12 changes: 7 additions & 5 deletions examples/avm/JSONXChainTx.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import "dotenv/config"
import { Avalanche, Buffer } from "../../src"
import { AVMAPI, Tx } from "../../src/apis/avm"

const ip: string = "api.avax.network"
const port: number = 443
const protocol: string = "https"
const networkID: number = 1
const ip = process.env.IP
const port = Number(process.env.PORT)
const protocol = process.env.PROTOCOL
const networkID = Number(process.env.NETWORK_ID)

const avalanche: Avalanche = new Avalanche(ip, port, protocol, networkID)
const xchain: AVMAPI = avalanche.XChain()

const main = async (): Promise<any> => {
const txID: string = "2fJer7o3HpPYxqyHXo23G4HoPvfEqcUXYojMULi2mbBEoBFqoM"
const txID: string = "Cgse9mcZeXrYsBGrF3SqjoDHoqxauiwxm6zrgkDa5kxSa5K85"
const hex = (await xchain.getTx(txID)) as string
const buf: Buffer = new Buffer(hex.slice(2), "hex")
const tx: Tx = new Tx()
Expand Down
1 change: 1 addition & 0 deletions examples/avm/addressFromBuffer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "dotenv/config"
import { Avalanche, Buffer } from "../../src"
import { AVMAPI } from "../../src/apis/avm"
import { UTXOSet, UTXO } from "../../src/apis/platformvm"
Expand Down
9 changes: 5 additions & 4 deletions examples/avm/baseEndpoint.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import "dotenv/config"
import { Avalanche } from "../../src"

const ip: string = "localhost"
const port: number = 9650
const protocol: string = "http"
const networkID: number = 1337
const ip = process.env.IP
const port = Number(process.env.PORT)
const protocol = process.env.PROTOCOL
const networkID = Number(process.env.NETWORK_ID)
const baseEndpoint: string = "rpc"
const avalanche: Avalanche = new Avalanche(ip, port, protocol, networkID)
avalanche.setAddress(ip, port, protocol, baseEndpoint)
Expand Down
9 changes: 5 additions & 4 deletions examples/avm/baseTx-ant.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "dotenv/config"
import { Avalanche, BinTools, BN, Buffer } from "../../src"
import {
AVMAPI,
Expand All @@ -19,10 +20,10 @@ import {
DefaultLocalGenesisPrivateKey
} from "../../src/utils"

const ip: string = "localhost"
const port: number = 9650
const protocol: string = "http"
const networkID: number = 1337
const ip = process.env.IP
const port = Number(process.env.PORT)
const protocol = process.env.PROTOCOL
const networkID = Number(process.env.NETWORK_ID)
const avalanche: Avalanche = new Avalanche(ip, port, protocol, networkID)
const xchain: AVMAPI = avalanche.XChain()
const bintools: BinTools = BinTools.getInstance()
Expand Down
9 changes: 5 additions & 4 deletions examples/avm/baseTx-avax-create-multisig.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "dotenv/config"
import { Avalanche, BinTools, BN, Buffer } from "../../src"
import {
AVMAPI,
Expand All @@ -21,10 +22,10 @@ import {
} from "../../src/utils"

const bintools: BinTools = BinTools.getInstance()
const ip: string = "localhost"
const port: number = 9650
const protocol: string = "http"
const networkID: number = 1337
const ip = process.env.IP
const port = Number(process.env.PORT)
const protocol = process.env.PROTOCOL
const networkID = Number(process.env.NETWORK_ID)
const xBlockchainID: string = Defaults.network[networkID].X.blockchainID
const xBlockchainIDBuf: Buffer = bintools.cb58Decode(xBlockchainID)
const avaxAssetID: string = Defaults.network[networkID].X.avaxAssetID
Expand Down
9 changes: 5 additions & 4 deletions examples/avm/baseTx-avax-send-multisig.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "dotenv/config"
import { Avalanche, BinTools, BN, Buffer } from "../../src"
import {
AVMAPI,
Expand All @@ -20,10 +21,10 @@ import {
} from "../../src/utils"

const bintools: BinTools = BinTools.getInstance()
const ip: string = "localhost"
const port: number = 9650
const protocol: string = "http"
const networkID: number = 1337
const ip = process.env.IP
const port = Number(process.env.PORT)
const protocol = process.env.PROTOCOL
const networkID = Number(process.env.NETWORK_ID)
const xBlockchainID: string = Defaults.network[networkID].X.blockchainID
const xBlockchainIDBuf: Buffer = bintools.cb58Decode(xBlockchainID)
const avaxAssetID: string = Defaults.network[networkID].X.avaxAssetID
Expand Down
9 changes: 5 additions & 4 deletions examples/avm/baseTx-avax.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "dotenv/config"
import createHash from "create-hash"
import { Avalanche, BinTools, BN, Buffer } from "../../src"
import {
Expand All @@ -21,10 +22,10 @@ import {
} from "../../src/utils"

const bintools: BinTools = BinTools.getInstance()
const ip: string = "localhost"
const port: number = 9650
const protocol: string = "http"
const networkID: number = 1337
const ip = process.env.IP
const port = Number(process.env.PORT)
const protocol = process.env.PROTOCOL
const networkID = Number(process.env.NETWORK_ID)

const xBlockchainID: string = Defaults.network[networkID].X.blockchainID
const avaxAssetID: string = Defaults.network[networkID].X.avaxAssetID
Expand Down
9 changes: 5 additions & 4 deletions examples/avm/buildBaseTx-ant.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "dotenv/config"
import { GetUTXOsResponse } from "../../src/apis/avm/interfaces"
import { Avalanche, BN, Buffer } from "../../src"
import { AVMAPI, KeyChain, UTXOSet, UnsignedTx, Tx } from "../../src/apis/avm"
Expand All @@ -7,10 +8,10 @@ import {
DefaultLocalGenesisPrivateKey
} from "../../src/utils"

const ip: string = "localhost"
const port: number = 9650
const protocol: string = "http"
const networkID: number = 1337
const ip = process.env.IP
const port = Number(process.env.PORT)
const protocol = process.env.PROTOCOL
const networkID = Number(process.env.NETWORK_ID)
const avalanche: Avalanche = new Avalanche(ip, port, protocol, networkID)
const xchain: AVMAPI = avalanche.XChain()
const xKeychain: KeyChain = xchain.keyChain()
Expand Down
Loading

0 comments on commit f5b6235

Please sign in to comment.