Skip to content

Commit

Permalink
fixing cmds, adding params
Browse files Browse the repository at this point in the history
  • Loading branch information
TrevorJTClarke committed Jun 18, 2021
1 parent 30ad81e commit 6d084c7
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
3 changes: 2 additions & 1 deletion AGENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
4. croncat register agent-007.testnet your_account.testnet
5. croncat go agent-007.testnet
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Commands:
croncat withdraw <accountId> Withdraw all rewards earned for this account
croncat status <accountId> 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 <accountId> Run tasks that are available, if agent is registered and has balance
```
## Docker Installation & Setup
Expand Down
6 changes: 3 additions & 3 deletions bin/croncat.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ const tasks = {
};

const go = {
command: 'go',
command: 'go <accountId>',
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()
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
8 changes: 4 additions & 4 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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() {
Expand Down Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion src/configuration.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
function getConfigByType(networkId, config) {
console.log(networkId);
return {
networkId,
nodeUrl: `https://rpc.${networkId}.near.org`,
Expand Down

0 comments on commit 6d084c7

Please sign in to comment.