{"_id":"@alphscan/normalized-events","_rev":"2-ca563d07b0ab8827e58976ee8da7a168","name":"@alphscan/normalized-events","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@alphscan/normalized-events","version":"0.1.0","_id":"@alphscan/normalized-events@0.1.0","maintainers":[{"name":"minijudie","email":"minijudie@imsorry.dev"}],"dist":{"shasum":"ea26f9a928e27a579c757348f5abfbce106a0572","tarball":"https://registry.npmjs.org/@alphscan/normalized-events/-/normalized-events-0.1.0.tgz","fileCount":105,"integrity":"sha512-/YzU3oj9cQ0NXvIuCDC3rrrb4s9aITCU2BvYb0G2tzAUyR9ikk1lleO/N3QAzaX+hH6ulkKjt6YeaB4BX1zRsg==","signatures":[{"sig":"MEQCIBd/mHCqGbhK1gx78Wm6Dhq2JhFIntc7fEYm30GgukoBAiAvhWoFr8T/JpyxxKMVg6i8QbgY8JJWr2Z8doYsBhkWsw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":127523},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js"}},"gitHead":"4ecf410df398506dca2a0c53f8558ba234f72733","private":false,"scripts":{"build":"tsc","clean":"rm -rf dist","deploy":"npm run build && npm publish  --access public"},"_npmUser":{"name":"minijudie","email":"minijudie@imsorry.dev"},"_npmVersion":"10.8.2","description":"Normalized event types, categories, and factory for **Alephium** blockchain events. Used by the indexer to produce a consistent schema for RDS storage and complex queries.","directories":{},"_nodeVersion":"20.19.2","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.7.2","@types/node":"^22.10.1"},"_npmOperationalInternal":{"tmp":"tmp/normalized-events_0.1.0_1772688726495_0.011330356948570985","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@alphscan/normalized-events","version":"0.1.1","private":false,"type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js"},"./server":{"types":"./dist/load-dapps-config.d.ts","import":"./dist/load-dapps-config.js","default":"./dist/load-dapps-config.js"}},"scripts":{"build":"tsc","clean":"rm -rf dist","deploy":"npm run build && npm publish  --access public"},"devDependencies":{"@types/node":"^20.14.0","typescript":"~5.8.3"},"gitHead":"130f567cf167cfd8937ff895b683f11b0316fcff","_id":"@alphscan/normalized-events@0.1.1","description":"Normalized event types, categories, and factory for **Alephium** blockchain events. Used by the indexer to produce a consistent schema for RDS storage and complex queries.","_nodeVersion":"24.14.1","_npmVersion":"11.11.0","dist":{"integrity":"sha512-XN8owOBx0FZToCwPz5kwXzzGQ7V1U2azyTxJ4HG1AouxeG1mKwivU9EF5QTfp3IsOQYYF0Qv8NK4GGKCD/anHg==","shasum":"72a1b9a76ec5a5149d79d0d87d81ab776ca41bc4","tarball":"https://registry.npmjs.org/@alphscan/normalized-events/-/normalized-events-0.1.1.tgz","fileCount":121,"unpackedSize":138460,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCtumMjyyqBDrCIwEvYvLP6LuDAtAGwaPAMO5PJQ+3gygIhAK+0soud4lij5oq70qkSZ9tgDBt+7HRSN8H9FywQgLCk"}]},"_npmUser":{"name":"minijudie","email":"minijudie@imsorry.dev"},"directories":{},"maintainers":[{"name":"minijudie","email":"minijudie@imsorry.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/normalized-events_0.1.1_1776191080331_0.8819911052478242"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-05T05:32:06.410Z","modified":"2026-04-14T18:24:40.599Z","0.1.0":"2026-03-05T05:32:06.637Z","0.1.1":"2026-04-14T18:24:40.464Z"},"description":"Normalized event types, categories, and factory for **Alephium** blockchain events. Used by the indexer to produce a consistent schema for RDS storage and complex queries.","maintainers":[{"name":"minijudie","email":"minijudie@imsorry.dev"}],"readme":"# @alphscan/normalized-events\n\nNormalized event types, categories, and factory for **Alephium** blockchain events. Used by the indexer to produce a consistent schema for RDS storage and complex queries.\n\n## Schema versioning\n\n- **`NORMALIZED_EVENT_SCHEMA_VERSION`** – Bump when breaking changes require reindexing.\n- Every event has **`schema_version`** and a unique **`id`** (`chain:fromGroup:toGroup:block_number:tx_hash:log_index`) for idempotency.\n\n## Base fields (every event)\n\n| Field | Type | Description |\n|-------|------|-------------|\n| `chain` | string | Chain identifier (e.g. mainnet group) |\n| `fromGroup` | number | Alephium from-group index (0–3) |\n| `toGroup` | number | Alephium to-group index (0–3) |\n| `block_number` | number | Block number |\n| `tx_hash` | string | Transaction hash |\n| `log_index` | number | Event index within the tx |\n| `token_address` | string \\| null | Token/contract address when applicable |\n| `from` | string \\| null | Sender |\n| `to` | string \\| null | Recipient |\n| `amount` | string \\| null | Raw amount (smallest unit) |\n| `amount_usd` | string \\| null | USD value when available |\n| `lock_until` | number \\| null | Lock/vesting end timestamp |\n| `dapp` | string \\| null | Dapp/protocol id (e.g. \"alephium-dex\") |\n| `authoring` | string \\| null | Contract/address that emitted the event |\n| `plugin` | string \\| null | Plugin that generated this event |\n| `normalizer` | string \\| null | Normalizer that produced this event |\n| `normalizer_version` | number \\| null | Version of the normalizer |\n| `creationDate` | number \\| null | When this normalized event was first created (ms since epoch) |\n| `lastUpdate` | number \\| null | When this normalized event was last updated (ms since epoch) |\n| `onChainDate` | number \\| null | When the event occurred on chain (ms since epoch) |\n| `dateIndexationMetrics` | number | Date used for indexation metrics (ms since epoch); defaults to 1970-01-01 |\n\n## Categories and sub-kinds\n\n1. **Transfer** – `native_transfer`, `burn_native`, `token_transfer`, `send_to_bridge`, `received_from_bridge`, `send_to_cex`, `received_from_cex`, `genesis_release`, `treasury_mint`, `treasury_release`\n2. **Token** – `genesis_mint`, `genesis_distribution`, `genesis_emission`, `token_emission`, `token_mint`, `token_burn`, `nft_transfer`, `nft_collection_mint`, `nft_collection_burn`, `nft_mint`, `nft_burn`, `wrap`, `unwrap`\n3. **Chain** – `coinbase`, `burn_network_fees`, `pay_storage_fees`\n4. **DEX** – `pool_creation`, `pool_destruction`, `add_liquidity`, `remove_liquidity`, `swap`, `mint_nft_position`, `burn_nft_position`, `push_order`, `delete_order`, `execute_order`, `vote_for_pool`, `claim_vote_rewards`, `claim_trading_fees`, `collect_fees`\n5. **Lending** – `deposit_collateral`, `remove_collateral`, `borrow`, `repay`, `liquidation`, `liquidation_auction`, `redeem`, `open_trove`, `close_trove`, `adjust_trove`, `claim_collateral`, `supply`, `withdraw`\n6. **Yield** – `stake`, `unstake`, `claim_staking`, `claim_fees`, `deposit`, `withdraw`, `compound`, `claim_rewards`, `vest`, `claim_vested`\n7. **Governance** – `create_proposal`, `vote`, `vote_results`, `execute_proposal`, `cancel_proposal`, `queue_proposal`, `delegate`\n8. **Contract life** – `contract_creation`, `contract_destruction`, `contract_update`, `contract_upgrade`, `contract_pause`, `contract_unpause`\n9. **Game / prediction** – `create_game`, `create_market`, `bet`, `claim`, `add_to_pot`, `win`, `lose`, `resolve_market`, `cancel_market`, `refund`\n10. **Oracle** – `oracle_update`, `oracle_get_random_seed`, `oracle_request_randomness`, `oracle_fulfill_randomness`\n\n## Usage\n\n```ts\nimport {\n  createNormalizedEvent,\n  EventCategory,\n  TransferSubKind,\n  buildEventId,\n} from \"@alphscan/normalized-events\";\n\nconst event = createNormalizedEvent(\n  {\n    chain: \"mainnet\",\n    fromGroup: 0,\n    toGroup: 0,\n    block_number: 12345,\n    tx_hash: \"0x…\",\n    log_index: 0,\n    from: \"addr1\",\n    to: \"addr2\",\n    amount: \"1000000000000000000\",\n    timestamp: Date.now(),\n  },\n  {\n    category: \"transfer\",\n    sub_kind: TransferSubKind.NATIVE_TRANSFER,\n  }\n);\n```\n\n## Type guards\n\n- `isTransferEvent(e)`, `isTokenEvent(e)`, `isChainEvent(e)`, `isDexEvent(e)`, `isLendingEvent(e)`, `isYieldEvent(e)`, `isGovernanceEvent(e)`, `isContractLifeEvent(e)`, `isGameEvent(e)`, `isOracleEvent(e)`\n\n## Storage and export\n\n- **RDS**: Use `@alphscan/storage` – `createNormalizedEventStore({ relational })`, `CREATE_NORMALIZED_EVENTS_TABLE_SQL`, `eventToRow` / `rowToEvent`.\n- **Export**: `eventsToJson`, `eventsToSqlLiteral`, `eventsToCsv`, `writeEventsToJsonFile`, `writeEventsToSqlFile`, `writeEventsToCsvFile` from `@alphscan/storage`.\n","readmeFilename":"README.md"}