diff --git a/AGENT.md b/AGENT.md index 7233c8c..333863a 100644 --- a/AGENT.md +++ b/AGENT.md @@ -4,4 +4,5 @@ To be expanded on: 1. near generate-key agent-007.testnet 2. Copy the public key 3. near add-key your_account.testnet ed25519:EkiM... -4. croncat register agent-007.testnet your_account.testnet \ No newline at end of file +4. croncat register agent-007.testnet your_account.testnet +5. croncat go agent-007.testnet \ No newline at end of file diff --git a/README.md b/README.md index b74f658..3273d90 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Commands: croncat withdraw Withdraw all rewards earned for this account croncat status Check agent status and balance for this account croncat tasks Check how many tasks are available - croncat go Run tasks that are available, if agent is registered and has balance + croncat go Run tasks that are available, if agent is registered and has balance ``` ## Docker Installation & Setup diff --git a/bin/croncat.js b/bin/croncat.js index a0a52b2..738e2ae 100644 --- a/bin/croncat.js +++ b/bin/croncat.js @@ -94,11 +94,11 @@ const tasks = { }; const go = { - command: 'go', + command: 'go ', desc: 'Run tasks that are available, if agent is registered and has balance', builder: (yargs) => yargs, - handler: async () => { - await bootstrapAgent() + handler: async options => { + await bootstrapAgent(options.accountId) // MAIN AGENT LOOP runAgentTick() diff --git a/package.json b/package.json index e3cb643..d1efc2a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "croncat", - "version": "1.0.8", + "version": "1.0.9", "description": "cron.cat CLI and Agent Runner", "main": "src/index.js", "scripts": { diff --git a/src/actions.js b/src/actions.js index 4f32e27..8e2d65c 100644 --- a/src/actions.js +++ b/src/actions.js @@ -48,7 +48,7 @@ export async function registerAgent() { // NOTE: Optional "payable_account_id" here try { - await manager.register_agent({ accountId: AGENT_ACCOUNT_ID }, BASE_GAS_FEE, BASE_ATTACHED_PAYMENT) + await manager.register_agent({ agent_account_id: AGENT_ACCOUNT_ID }, BASE_GAS_FEE, BASE_ATTACHED_PAYMENT) log(`Registered Agent: ${chalk.white(AGENT_ACCOUNT_ID)}`) } catch (e) { if(e.type === 'KeyNotFound') { @@ -62,7 +62,7 @@ export async function registerAgent() { export async function getAgent() { const manager = await getCronManager() - return manager.get_agent({ pk: agentAccount }) + return manager.get_agent({ account: agentAccount }) } export async function checkAgentBalance() { @@ -144,11 +144,11 @@ export async function agentFunction(method, args, isView) { } } -export async function bootstrapAgent() { +export async function bootstrapAgent(agentId) { await connect() // 1. Check for local signing keys, if none - generate new and halt until funded - agentAccount = `${await Near.getAccountCredentials(AGENT_ACCOUNT_ID)}` + agentAccount = `${await Near.getAccountCredentials(agentId || AGENT_ACCOUNT_ID)}` // 2. Check for balance, if enough to execute txns, start main tasks await checkAgentBalance() diff --git a/src/configuration.js b/src/configuration.js index 668d6e2..bc233ed 100644 --- a/src/configuration.js +++ b/src/configuration.js @@ -1,5 +1,4 @@ function getConfigByType(networkId, config) { - console.log(networkId); return { networkId, nodeUrl: `https://rpc.${networkId}.near.org`,