Skip to content

LeoYeAI/agent-master-skills / skills/auto-respawn

auto-respawn

Verified

Your agent always comes back. Anchor identity and memory on-chain so any new instance can resurrect from just an address — no local state, no single point of failure. Permanent identity and recovery on the Autonomys Network.

FileKindSize
SKILL.mdskill md16.4 KB
_meta.jsonconfig281 B
auto-respawn.tsscript14.4 KB
eslint.config.jsscript468 B
lib/address.tsscript2.2 KB
lib/balance.tsscript1.1 KB
lib/cli.tsscript1.6 KB
lib/evm-balance.tsscript925 B
lib/evm-transfer.tsscript2.4 KB
lib/evm.tsscript3.4 KB
lib/memory-chain.tsscript3.5 KB
lib/network.tsscript1.4 KB
lib/remark.tsscript1.3 KB
lib/transfer.tsscript1.7 KB
lib/wallet.tsscript8.8 KB
lib/xdm.tsscript3.3 KB
package.jsonmanifest647 B
references/auto-respawn-commands.mdmarkdown9.6 KB
references/autonomys-network.mdmarkdown6.2 KB
setup.shexecutablescript2.2 KB
tests/address.test.tsscript3.4 KB
tests/balance.test.tsscript4.3 KB
tests/cli.test.tsscript3.5 KB
tests/evm-balance.test.tsscript3.1 KB
tests/evm-transfer.test.tsscript5.2 KB
tests/evm.test.tsscript2.4 KB
tests/network.test.tsscript1.8 KB
tests/wallet-roundtrip.test.tsscript6.3 KB
tests/wallet.test.tsscript1.1 KB
tsconfig.jsonconfig366 B

tests/evm-balance.test.ts

View on GitHub
import { describe, it, expect, vi } from 'vitest'
import { queryEvmBalance } from '../lib/evm-balance.js'
import { ethers } from 'ethers'

/**
 * EVM balance tests.
 *
 * Mocks ethers.Provider.getBalance() to avoid needing a real RPC connection.
 * Tests formatting, zero-balance hints, and network labelling.
 */

function createMockProvider(balanceWei: bigint) {
  return {
    getBalance: vi.fn().mockResolvedValue(balanceWei),
  } as unknown as ethers.Provider
}

const TEST_EVM_ADDRESS = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'

describe('queryEvmBalance', () => {
  it('formats wei balance to ether string', async () => {
    // 2.5 ETH/AI3 in wei
    const provider = createMockProvider(2_500_000_000_000_000_000n)
    const result = await queryEvmBalance(provider, TEST_EVM_ADDRESS, 'chronos')

    expect(result.balance).toBe('2.5')
    expect(result.evmAddress).toBe(TEST_EVM_ADDRESS)
    expect(result.symbol).toBe('tAI3')
    expect(result.network).toBe('chronos')
    expect(result.hint).toBeUndefined()
  })

  it('includes hint when balance is zero', async () => {
    const provider = createMockProvider(0n)
    const result = await queryEvmBalance(provider, TEST_EVM_ADDRESS, 'chronos')

    expect(result.balance).toBe('0.0')
    expect(result.hint).toContain('No EVM balance')
    expect(result.hint).toContain('fund-evm')
    expect(result.hint).toContain('chronos')
  })

  it('uses correct symbol for mainnet', async () => {
    const provider = createMockProvider(1_000_000_000_000_000_000n)
    const result = await queryEvmBalance(provider, TEST_EVM_ADDRESS, 'mainnet')

    expect(result.symbol).toBe('AI3')
    expect(result.network).toBe('mainnet')
  })

  it('hint includes correct network name', async () => {
    const providerChronos = createMockProvider(0n)
    const chronos = await queryEvmBalance(providerChronos, TEST_EVM_ADDRESS, 'chronos')
    expect(chronos.hint).toContain('--network chronos')

    const providerMainnet = createMockProvider(0n)
    const mainnet = await queryEvmBalance(providerMainnet, TEST_EVM_ADDRESS, 'mainnet')
    expect(mainnet.hint).toContain('--network mainnet')
  })

  it('formats large balances correctly', async () => {
    // 1,000,000 AI3
    const provider = createMockProvider(1_000_000_000_000_000_000_000_000n)
    const result = await queryEvmBalance(provider, TEST_EVM_ADDRESS, 'chronos')

    expect(result.balance).toBe('1000000.0')
  })

  it('formats small balances correctly', async () => {
    // 0.001 AI3 = 10^15 wei
    const provider = createMockProvider(1_000_000_000_000_000n)
    const result = await queryEvmBalance(provider, TEST_EVM_ADDRESS, 'chronos')

    expect(result.balance).toBe('0.001')
  })

  it('no hint when balance is non-zero', async () => {
    const provider = createMockProvider(1n) // smallest positive balance
    const result = await queryEvmBalance(provider, TEST_EVM_ADDRESS, 'chronos')

    expect(result.hint).toBeUndefined()
  })

  it('calls provider.getBalance with the correct address', async () => {
    const provider = createMockProvider(0n)
    await queryEvmBalance(provider, TEST_EVM_ADDRESS, 'chronos')

    expect(provider.getBalance).toHaveBeenCalledWith(TEST_EVM_ADDRESS)
  })
})
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexUnverifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall