From be88a17b5bd1f21ffd14d9b9c66dbf531b44b285 Mon Sep 17 00:00:00 2001 From: hawyar Date: Sat, 4 Mar 2023 23:32:32 -0500 Subject: [PATCH] Update event table schema --- common/data/src/index.ts | 83 +++++++++-------------- common/data/src/schemas/event.schema.json | 64 ++++++----------- 2 files changed, 54 insertions(+), 93 deletions(-) diff --git a/common/data/src/index.ts b/common/data/src/index.ts index 7b4da28fc..395c54bd7 100644 --- a/common/data/src/index.ts +++ b/common/data/src/index.ts @@ -22,18 +22,9 @@ export function schemaToGlueColumns(jsonSchema: JsonSchema): glue.Column[] { let type: glue.Type = glue.Schema[typeKey] if (name.endsWith('_at')) type = glue.Schema.TIMESTAMP - - if (name.endsWith('_list')) type = glue.Schema.array(glue.Schema.STRING) - - if (name.endsWith('amount')) type = glue.Schema.BIG_INT - - if (name === 'gas_used') type = glue.Schema.BIG_INT - - if (name === 'gas_limit') type = glue.Schema.BIG_INT - - if (name === 'base_fee') type = glue.Schema.BIG_INT - - if (name === 'burnt_fee') type = glue.Schema.FLOAT + if (name.endsWith('_balance')) type = glue.Schema.BIG_INT + if (name == 'amount') type = glue.Schema.BIG_INT + if (name === 'price') type = glue.Schema.FLOAT const comment = property.description return { name, type, comment } @@ -41,44 +32,34 @@ export function schemaToGlueColumns(jsonSchema: JsonSchema): glue.Column[] { } export type EventTableSchema = { - /** Name of the chain (e.g. iotex, ethereum) */ - chain: string - /** Name of the network (e.g. mainnet, testnet) */ - network: string - /** "Name of the provider (e.g. casimir, infura, alchemy) */ - provider: string - /** The type of event (e.g. block, transaction, deposit) */ - type: string - /** The block height */ - height: number - /** The block hash */ - block: string - /** The transaction hash */ - transaction: string - /** The date timestamp of the event in ISO 8601 format (e.g. 2015-03-04T22:44:30.652Z) */ - created_at: string - /** The address which initiated the event, a miner in case of block and a caller in case of other events */ - address: string - /** The recipient's address */ - to_address: string - /** The amount value associated with the transaction */ - amount: string - /** The total amount of gas used */ - gasUsed: string - /** The gas limit provided by transactions in the block */ - gasLimit: string - /** Post-London upgrade this represents the minimum gasUsed multiplier required for a transaction to be included in a block */ - baseFee: string - /** Post-London Upgrade, this represents the part of the tx fee that is burnt */ - burntFee: string - /** The validator's address */ - validator: string - /** The list of validators' addresses */ - validator_list: string[] - /** The duration of the event */ - duration: number - /** Is auto staking enabled */ - auto_stake: boolean + // The chain which the event belongs to (e.g. iotex, ethereum) + chain:'etheruem' | 'iotex'; + // The network which the event was received on (e.g. mainnet, testnet) + network: 'mainnet' | 'testnet' | 'goerli'; + // The provider used to source the event (e.g. infura, consensus) + provider: 'alchemy' | 'consensus'; + // The type of event (e.g. block, transaction) + type: 'block' | 'transaction'; + // The height of the block the event belongs to + height: number; + // The block hash + block: string; + // The transaction hash + transaction: string; + // The timestamp of the event recieved by the blockchain (format: Modified ISO 8601 e.g. 2015-03-04 22:44:30.652)" + receivedAt: string; + // The sender's address + sender: string; + // The recipient's address + recipient: string; + // The sender's balance at the time of the event + senderBalance: string; + // The recipient's balance at the time of the event + recipientBalance: string; + // The amount transferred in the event + amount: string; + // The exchange price of the coin at the time of the event + price: number; } -export { eventSchema, aggSchema, operatorStore, validatorStore } \ No newline at end of file +export { eventSchema, aggSchema, operatorStore, validatorStore} \ No newline at end of file diff --git a/common/data/src/schemas/event.schema.json b/common/data/src/schemas/event.schema.json index 9ba6cad74..a2ef324ce 100644 --- a/common/data/src/schemas/event.schema.json +++ b/common/data/src/schemas/event.schema.json @@ -1,28 +1,28 @@ { - "$id": "https://casimir.co/event.schema.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Event", - "type": "object", + "$id": "https://casimir.co/event.schema.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Event", + "type": "object", "properties": { "chain": { "type": "string", - "description": "Name of the chain (e.g. iotex, ethereum)" + "description": "The chain which the event belongs to (e.g. iotex, ethereum)" }, "network": { "type": "string", - "description": "Name of the network (e.g. mainnet, testnet)" + "description": "The network which the event was received on (e.g. mainnet, testnet)" }, "provider": { "type": "string", - "description": "Name of the provider (e.g. casimir, infura, alchemy)" + "description": "The provider used to source the event (e.g. infura, consensus)" }, "type": { "type": "string", - "description": "Type of the event" + "description": "The type of event (e.g. block, transaction)" }, "height": { "type": "integer", - "description": "The height of the event" + "description": "The height of the block the event belongs to" }, "block": { "type": "string", @@ -32,53 +32,33 @@ "type": "string", "description": "The transaction hash" }, - "created_at": { + "received_at": { "type": "string", - "description": "The date and time of the event in ISO 8601 format e.g. 2015-03-04T22:44:30.652Z" + "description": "The timestamp of the event recieved by the blockchain (format: Modified ISO 8601 e.g. 2015-03-04 22:44:30.652)" }, - "address": { + "sender": { "type": "string", - "description": "The address which initiated the event" + "description": "The sender's address" }, - "to_address": { + "recipient": { "type": "string", "description": "The recipient's address" }, - "amount": { - "type": "string", - "description": "The amount of currency associated with the event" - }, - "gas_used": { - "type": "string", - "description": "The total amount of gas used" - }, - "gas_limit": { + "sender_balance": { "type": "string", - "description": "The gas limit provided by transactions in the block" + "description": "The sender's balance at the time of the event" }, - "base_fee": { + "recipient_balance": { "type": "string", - "description": "Post-London upgrade this represents the minimum gasUsed multiplier required for a transaction to be included in a block" + "description": "The recipient's balance at the time of the event" }, - "burnt_fee": { + "amount": { "type": "string", - "description": "Post-London Upgrade, this represents the part of the tx fee that is burnt" + "description": "The amount transferred in the event" }, - "validator": { + "price": { "type": "string", - "description": "The validator's address" - }, - "validator_list": { - "type": "array", - "description": "The list of validators in stake action" - }, - "duration":{ - "type": "string", - "description": "The duration of the event" - }, - "auto_stake": { - "type": "boolean", - "description": "Is auto staking enabled" + "description": "The exchange price of the coin at the time of the event" } } } \ No newline at end of file