{"id":28186544,"url":"https://github.com/noahsaso/argus","last_synced_at":"2025-05-16T07:10:27.586Z","repository":{"id":64409946,"uuid":"573671546","full_name":"NoahSaso/argus","owner":"NoahSaso","description":"A state-based indexer and API builder for the Cosmos SDK, originally built for DAO DAO.","archived":false,"fork":false,"pushed_at":"2025-05-13T19:53:19.000Z","size":3900,"stargazers_count":13,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-13T19:55:35.331Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NoahSaso.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-12-03T03:48:41.000Z","updated_at":"2025-05-09T18:16:45.000Z","dependencies_parsed_at":"2024-09-22T13:04:10.748Z","dependency_job_id":"62ec9959-d63a-40fb-8b51-420c681b0f34","html_url":"https://github.com/NoahSaso/argus","commit_stats":null,"previous_names":["da0-da0/dao-dao-indexer","noahsaso/wasmd-indexer","noahsaso/argus"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoahSaso%2Fargus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoahSaso%2Fargus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoahSaso%2Fargus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoahSaso%2Fargus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NoahSaso","download_url":"https://codeload.github.com/NoahSaso/argus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254485042,"owners_count":22078767,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-16T07:10:26.512Z","updated_at":"2025-05-16T07:10:27.578Z","avatar_url":"https://github.com/NoahSaso.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Argus\n\nA state-based indexer and API builder for the Cosmos SDK, originally built for\n[DAO DAO](https://daodao.zone).\n\n## Setup\n\n1. Create `config.json` from example `config.json.example`.\n\n2. Install dependencies.\n\n   ```bash\n   npm install\n   ```\n\n3. Build the indexer.\n\n   ```bash\n   npm run build\n   ```\n\n4. Setup the database.\n\n   ```bash\n   # try migrating to generate the migrations table\n   # this should FAIL, but that is ok\n   npm run db:migrate:data\n\n   npm run db:setup\n   ```\n\n5. Run the exporter or server.\n\n   ```bash\n   npm run export:prod\n   # OR\n   npm run serve:prod\n   ```\n\n6. Tell pm2 to run on startup.\n\n   ```bash\n   pm2 startup\n   ```\n\n### Config\n\nConfig defaults to loading from `config.json` in the root of the project, though\nit supports loading from environment variables:\n\n`env:KEY_NAME` in a field inside `config.json` will be replaced with the value of\nthe `KEY_NAME` environment variable, erroring if the variable is not set.\n\n`envOptional:KEY_NAME` will not error if the variable is not set.\n\nEnvironment variables/secrets are managed via\n[Infisical](https://infisical.com) and used when deploying production servers.\n\n```bash\n# Log in via web browser (set INFISICAL_TOKEN in .env)\nnpx @infisical/cli login\n\n# Log in via Infisical Universal Auth and save the token to .env\necho \"INFISICAL_TOKEN=$(npx @infisical/cli login --method universal-auth --client-id \u003cclient-id\u003e --client-secret \u003cclient-secret\u003e --plain)\" \u003e\u003e .env\n# Save the project ID to .env\necho \"INFISICAL_PROJECT_ID=$(cat .infisical.json | jq -r '.workspaceId')\" \u003e\u003e .env\n# Save the environment to .env\necho \"INFISICAL_ENVIRONMENT=$(cat .infisical.json | jq -r '.defaultEnvironment')\" \u003e\u003e .env\n\n# Run a command with the environment variables set\nnpm run with-infisical -- \u003ccommand\u003e\n\n# e.g. run the server\nnpm run with-infisical -- npm run serve\n\n# if you need to run a command that uses inline env variables in the cmd, wrap\n# it in `bash -c '...'` to avoid eager shell expansion since the variables\n# aren't defined until the script is run\nnpm run with-infisical -- bash -c 'echo $INFISICAL_ENVIRONMENT'\n```\n\n## Usage\n\nTest the indexer:\n\n```bash\nnpm run docker:test\n```\n\nBuild the indexer:\n\n```bash\nnpm run build\n```\n\nRun the exporter:\n\n```bash\nnpm run export\n```\n\nRun the API server:\n\n```bash\nnpm run serve\n```\n\nSpawn a console to interact with the various database models and API formulas:\n\n```bash\nnpm run console\n```\n\n### Testing transformations with a dump file\n\nTo test transformations with a dump file:\n\n1. Place `dump.trace.pipe` in the root of the project.\n\n2. Create `config.dump-test.json`, making sure to set `rpc`, `bech32Prefix`, and\n   any `codeIds` you need to test:\n\n   ```bash\n   cp config.dump-test.json.example config.dump-test.json\n   ```\n\n3. Add your `*.test.ts` test files to `src/test/dump`.\n\n4. Run:\n\n```bash\nnpm run docker:test:dump\n```\n\n## Docker\n\nTo build the Docker image, run:\n\n```bash\nnpm run docker:build\n```\n\nTo tag and push to a container registry, run:\n\n```bash\ndocker tag argus:latest your-registry/argus:latest\ndocker push your-registry/argus:latest\n```\n\n## Documentation\n\nTo understand how this indexer works and why it exists, read through the\n[documentation](./docs/start.md).\n\n## Database utilities\n\n### Add read-only user in PostgreSQL\n\n```sql\nREVOKE ALL ON DATABASE db FROM readonly_user;\n-- revoke access from all databases\nSELECT format('REVOKE ALL ON DATABASE %I FROM readonly_user;', datname) FROM pg_database \\gexec\n-- grant connection access to all databases\nSELECT format('GRANT CONNECT, SELECT ON DATABASE %I TO readonly_user;', datname) FROM pg_database WHERE datname = 'accounts' OR datname LIKE '%_%net' \\gexec\n-- grant access to use SELECT on all tables\nGRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly_user;\n-- grant access to list tables\nGRANT USAGE ON SCHEMA public TO readonly_user;\n-- grant read access to future tables\nALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readonly_user;\n```\n\n### Find the code IDs for a given Event key\n\n```sql\nSELECT DISTINCT ON(\"codeId\") \"codeId\", \"value\" FROM \"WasmStateEvents\" INNER JOIN \"Contracts\" ON \"Contracts\".\"address\" = \"WasmStateEvents\".\"contractAddress\" WHERE \"key\" = '' ORDER BY \"codeId\" ASC;\n```\n\nFind by contract name (key is `contract_info`)\n\n```sql\nSELECT DISTINCT ON(\"codeId\") \"codeId\", \"value\" FROM \"WasmStateEvents\" INNER JOIN \"Contracts\" ON \"Contracts\".\"address\" = \"WasmStateEvents\".\"contractAddress\" WHERE \"key\" = '99,111,110,116,114,97,99,116,95,105,110,102,111' AND value LIKE '%CONTRACT_NAME%' ORDER BY \"codeId\" ASC;\n```\n\n## Attribution\n\nCredit to ekez for the initial idea and design of the state-based x/wasm\nindexer, and noah for the subsequent architecting, implementation, and\noptimization. Built for [DAO DAO](https://daodao.zone) and the CosmWasm\necosystem as a whole.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoahsaso%2Fargus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnoahsaso%2Fargus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoahsaso%2Fargus/lists"}