Added metadata to connector events, dsa events and casts

This commit is contained in:
Juan Manuel Rodriguez Defago 2020-06-10 12:17:49 -03:00
parent 6498fb0512
commit 1afc9c7de6
4 changed files with 66 additions and 1 deletions

View File

@ -171,5 +171,11 @@ type ConnectorEvent @entity {
eventCode: Bytes! eventCode: Bytes!
eventData: Bytes! eventData: Bytes!
tx_hash: String!
block: BigInt!
logIndex: BigInt!
} }
``` ```

View File

@ -130,6 +130,12 @@ type Cast @entity {
sender: Bytes! sender: Bytes!
value: BigInt! value: BigInt!
tx_hash: String!
block: BigInt!
logIndex: BigInt!
} }
interface SmartAccountEvent { interface SmartAccountEvent {
@ -137,6 +143,12 @@ interface SmartAccountEvent {
"Account scope of the event" "Account scope of the event"
account: SmartAccount! account: SmartAccount!
tx_hash: String!
block: BigInt!
logIndex: BigInt!
} }
type CastEvent implements SmartAccountEvent @entity { type CastEvent implements SmartAccountEvent @entity {
@ -149,6 +161,12 @@ type CastEvent implements SmartAccountEvent @entity {
sender: Bytes! sender: Bytes!
value: BigInt! value: BigInt!
tx_hash: String!
block: BigInt!
logIndex: BigInt!
} }
type DisableEvent implements SmartAccountEvent @entity { type DisableEvent implements SmartAccountEvent @entity {
@ -157,6 +175,12 @@ type DisableEvent implements SmartAccountEvent @entity {
account: SmartAccount! account: SmartAccount!
user: User! user: User!
tx_hash: String!
block: BigInt!
logIndex: BigInt!
} }
type EnableEvent implements SmartAccountEvent @entity { type EnableEvent implements SmartAccountEvent @entity {
@ -165,6 +189,12 @@ type EnableEvent implements SmartAccountEvent @entity {
account: SmartAccount! account: SmartAccount!
user: User! user: User!
tx_hash: String!
block: BigInt!
logIndex: BigInt!
} }
type SwitchShieldEvent implements SmartAccountEvent @entity { type SwitchShieldEvent implements SmartAccountEvent @entity {
@ -173,6 +203,12 @@ type SwitchShieldEvent implements SmartAccountEvent @entity {
account: SmartAccount! account: SmartAccount!
shield: Boolean! shield: Boolean!
tx_hash: String!
block: BigInt!
logIndex: BigInt!
} }
type ConnectorEvent @entity { type ConnectorEvent @entity {
@ -185,4 +221,10 @@ type ConnectorEvent @entity {
eventCode: Bytes! eventCode: Bytes!
eventData: Bytes! eventData: Bytes!
tx_hash: String!
block: BigInt!
logIndex: BigInt!
} }

View File

@ -42,11 +42,17 @@ export function handleLogCast(event: LogCast): void {
castEvent.origin = event.params.origin; castEvent.origin = event.params.origin;
castEvent.sender = event.params.sender; castEvent.sender = event.params.sender;
castEvent.value = event.params.value; castEvent.value = event.params.value;
castEvent.tx_hash = event.transaction.hash.toHexString();
castEvent.block = event.block.number;
castEvent.logIndex = event.logIndex;
cast.account = account.id; cast.account = account.id;
cast.origin = event.params.origin; cast.origin = event.params.origin;
cast.sender = event.params.sender; cast.sender = event.params.sender;
cast.value = event.params.value; cast.value = event.params.value;
cast.tx_hash = event.transaction.hash.toHexString();
cast.block = event.block.number;
cast.logIndex = event.logIndex;
castEvent.save(); castEvent.save();
cast.save(); cast.save();
@ -74,6 +80,9 @@ export function handleLogDisableSmartAccountOwner(event: LogDisable): void {
let disableEvent = getOrCreateDisableEvent(eventId); let disableEvent = getOrCreateDisableEvent(eventId);
disableEvent.account = account.id; disableEvent.account = account.id;
disableEvent.user = user.id; disableEvent.user = user.id;
disableEvent.tx_hash = event.transaction.hash.toHexString();
disableEvent.block = event.block.number;
disableEvent.logIndex = event.logIndex;
account.owner = user.id; account.owner = user.id;
account.isEnabled = false; account.isEnabled = false;
@ -104,6 +113,9 @@ export function handleLogEnableSmartAccountOwner(event: LogEnable): void {
let enableEvent = getOrCreateEnableEvent(eventId); let enableEvent = getOrCreateEnableEvent(eventId);
enableEvent.account = account.id; enableEvent.account = account.id;
enableEvent.user = user.id; enableEvent.user = user.id;
enableEvent.tx_hash = event.transaction.hash.toHexString();
enableEvent.block = event.block.number;
enableEvent.logIndex = event.logIndex;
account.owner = user.id; account.owner = user.id;
account.isEnabled = true; account.isEnabled = true;
@ -132,9 +144,11 @@ export function handleLogSwitchShield(event: LogSwitchShield): void {
.concat("-") .concat("-")
.concat(event.logIndex.toString()); .concat(event.logIndex.toString());
let switchEvent = getOrCreateSwitchShieldEvent(eventId); let switchEvent = getOrCreateSwitchShieldEvent(eventId);
switchEvent.account = account.id; switchEvent.account = account.id;
switchEvent.shield = event.params._shield; switchEvent.shield = event.params._shield;
switchEvent.tx_hash = event.transaction.hash.toHexString();
switchEvent.block = event.block.number;
switchEvent.logIndex = event.logIndex;
account.shield = event.params._shield; account.shield = event.params._shield;

View File

@ -132,6 +132,9 @@ export function handleLogEvent(event: LogEvent): void {
connectorEvent.connector = connector.id; connectorEvent.connector = connector.id;
connectorEvent.eventCode = event.params.eventCode; connectorEvent.eventCode = event.params.eventCode;
connectorEvent.eventData = event.params.eventData; connectorEvent.eventData = event.params.eventData;
connectorEvent.tx_hash = event.transaction.hash.toHexString();
connectorEvent.block = event.block.number;
connectorEvent.logIndex = event.logIndex;
connectorEvent.save(); connectorEvent.save();
} }