Skip to content

Commit

Permalink
Merge pull request #277 from consensusnetworks/feature/event-schema-p…
Browse files Browse the repository at this point in the history
…roposal

Proposal: update the event table schema
  • Loading branch information
shanejearley authored Mar 6, 2023
2 parents 11cc684 + be88a17 commit db559c3
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 93 deletions.
83 changes: 32 additions & 51 deletions common/data/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,63 +22,44 @@ 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 }
})
}

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 }
export { eventSchema, aggSchema, operatorStore, validatorStore}
64 changes: 22 additions & 42 deletions common/data/src/schemas/event.schema.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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"
}
}
}

0 comments on commit db559c3

Please sign in to comment.