diff --git a/.env.example b/.env.example index 73085e0..cd88656 100644 --- a/.env.example +++ b/.env.example @@ -2,19 +2,34 @@ NODE_ENV=production NEAR_ENV=mainnet LOG_LEVEL=info +BETA_FEATURES=false NEAR_NO_LOGS=true -AGENT_ACCOUNT_ID=croncat-agent +AGENT_ACCOUNT_ID=croncat-agent.near AGENT_MIN_TASK_BALANCE=1 #NOTE: This is really only useful if the payout account is the same as the agent account AGENT_AUTO_REFILL=false +# Period between executing standard tasks, needs to be less than 60 seconds to be effective WAIT_INTERVAL_MS=25000 +# Period to check if a trigger needs executing, you should use a semi-fast value that doesnt break your RPC service. +VIEW_INTERVAL_MS=2000 + ## Extras SLACK_TOKEN= SLACK_CHANNEL=general # If you have an external heartbeat service that just needs a ping HEARTBEAT=false -HEARTBEAT_URL= \ No newline at end of file +HEARTBEAT_URL= + +## ------------------------------------------------------------------- +## RPC Providers +## Configure the following as CSV, in priority order, for RPC Failover +## ------------------------------------------------------------------- +# Example: RPC_MAINNET_PROVIDERS="https://rpc.mainnet.near.org,http://localhost:3030" +RPC_MAINNET_PROVIDERS="https://rpc.mainnet.near.org" +RPC_TESTNET_PROVIDERS="https://rpc.testnet.near.org" +RPC_GUILDNET_PROVIDERS="https://rpc.openshards.io" +RPC_BETANET_PROVIDERS="https://rpc.betanet.near.org" \ No newline at end of file diff --git a/package.json b/package.json index b6eeafa..87a9cf3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "croncat", - "version": "1.5.1", + "version": "1.5.2", "description": "cron.cat CLI and Agent Runner", "main": "src/index.js", "scripts": { diff --git a/src/actions.js b/src/actions.js index a503215..7b7c7dc 100644 --- a/src/actions.js +++ b/src/actions.js @@ -216,7 +216,7 @@ export async function runAgentTick(options = {}) { } totalTasks = parseInt(taskRes[0]) if (taskRes[1] === '0') log(`${chalk.gray(new Date().toISOString())} Available Tasks: ${chalk.red(totalTasks)}, Current Slot: ${chalk.red('Paused')}`) - else log(`${chalk.gray(new Date().toISOString())} Available Tasks: ${chalk.blueBright(totalTasks)}, Current Slot: ${chalk.yellow(taskRes[1])}`) + else log(`${chalk.gray(new Date().toISOString())} ${chalk.gray('[' + options.networkId.toUpperCase() + ']')} Available Tasks: ${chalk.blueBright(totalTasks)}, Current Slot: ${chalk.yellow(taskRes[1])}`) if (LOG_LEVEL === 'debug') console.log('taskRes', taskRes) if (totalTasks <= 0) skipThisIteration = true diff --git a/src/configuration.js b/src/configuration.js index 2c776f4..e76343e 100644 --- a/src/configuration.js +++ b/src/configuration.js @@ -1,5 +1,21 @@ +require('dotenv').config() + +export const RPC_MAINNET = process.env.RPC_MAINNET_PROVIDERS ? process.env.RPC_MAINNET_PROVIDERS.split(',') : 'https://rpc.mainnet.near.org' +export const RPC_TESTNET = process.env.RPC_TESTNET_PROVIDERS ? process.env.RPC_TESTNET_PROVIDERS.split(',') : 'https://rpc.testnet.near.org' +export const RPC_GUILDNET = process.env.RPC_GUILDNET_PROVIDERS ? process.env.RPC_GUILDNET_PROVIDERS.split(',') : 'https://rpc.openshards.io' +export const RPC_BETANET = process.env.RPC_BETANET_PROVIDERS ? process.env.RPC_BETANET_PROVIDERS.split(',') : 'https://rpc.betanet.near.org' + +const failoverRpcs = { + mainnet: RPC_MAINNET, + testnet: RPC_TESTNET, + guildnet: RPC_GUILDNET, + betanet: RPC_BETANET, +} + function getConfigByType(networkId, config) { return { + // Cache of available RPC nodes for failover + // rpcNodes: failoverRpcs[networkId] || [], networkId, nodeUrl: networkId !== 'guildnet' ? `https://rpc.${networkId}.near.org` : 'https://rpc.openshards.io', explorerUrl: `https://explorer.${networkId === 'mainnet' ? '' : networkId + '.'}near.org`,