From 2297c28e24feca67552088ea8bcff83fdb8725e3 Mon Sep 17 00:00:00 2001 From: TrevorJTClarke Date: Tue, 19 Jul 2022 16:08:13 -0700 Subject: [PATCH] changing defaults to read dotenv --- package.json | 2 +- src/near.js | 3 ++- src/util.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index d94e587..e3a0e1e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "croncat", - "version": "1.8.2", + "version": "1.8.3", "description": "cron.cat CLI and Agent Runner", "main": "src/index.js", "scripts": { diff --git a/src/near.js b/src/near.js index 5037ceb..45166d4 100644 --- a/src/near.js +++ b/src/near.js @@ -1,5 +1,6 @@ import "core-js/stable" import "regenerator-runtime/runtime" +require('dotenv').config() import { connect, KeyPair, keyStores, Contract, utils, WalletConnection, WalletAccount } from 'near-api-js' // import fs from 'fs' import path from 'path' @@ -12,7 +13,7 @@ const credentialsBasePath = path.join(homedir(), CREDENTIALS_DIR) class NearProvider { constructor(options = {}) { - this.config = config.getConfig(options.networkId || 'testnet') + this.config = config.getConfig(options.networkId || process.env.NEAR_ENV || 'testnet') this.credentials = null this.client = null this.accountId = null diff --git a/src/util.js b/src/util.js index 7f1e489..63a339f 100644 --- a/src/util.js +++ b/src/util.js @@ -63,7 +63,7 @@ export const atob = (base64) => { // TODO: Multiple based on RPC providers export const Near = new NearProvider({ - networkId: config.NODE_ENV === 'production' ? 'mainnet' : config.NODE_ENV || 'testnet', + networkId: config.NODE_ENV === 'production' ? 'mainnet' : config.NEAR_ENV || process.env.NEAR_ENV || 'testnet', accountId: config.AGENT_ACCOUNT_ID, }) dbug('Near OBJ', Near);