Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Cosmos: Add support for the message handler #297

Merged
merged 2 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion chain/cosmos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,35 @@ export namespace cosmos {
}

export class EventData {
constructor(public event: Event, public block: HeaderOnlyBlock) {}
constructor(
public event: Event,
public block: HeaderOnlyBlock,
public tx: TransactionContext,
) {}
}

export class TransactionData {
constructor(public tx: TxResult, public block: HeaderOnlyBlock) {}
}

export class MessageData {
constructor(
public message: Any,
public block: HeaderOnlyBlock,
public tx: TransactionContext,
) {}
}

export class TransactionContext {
constructor(
public hash: Bytes,
public index: u32,
public code: u32,
public gasWanted: i64,
public gasUsed: i64,
) {}
}

export class Header {
constructor(
public version: Consensus,
Expand Down
10 changes: 8 additions & 2 deletions global/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,13 @@ export enum TypeId {
CosmosValidatorSetUpdates = 1559,
CosmosValidatorUpdate = 1560,
CosmosVersionParams = 1561,
CosmosMessageData = 1562,
CosmosTransactionContext = 1563,
/*
Continue to add more Cosmos type IDs here. e.g.:
```
NextCosmosType = 1562,
AnotherCosmosType = 1563,
NextCosmosType = 1564,
AnotherCosmosType = 1565,
...
LastCosmosType = 2499,
```
Expand Down Expand Up @@ -547,6 +549,10 @@ export function id_of_type(typeId: TypeId): usize {
return idof<cosmos.ValidatorUpdate>()
case TypeId.CosmosVersionParams:
return idof<cosmos.VersionParams>()
case TypeId.CosmosMessageData:
return idof<cosmos.MessageData>()
case TypeId.CosmosTransactionContext:
return idof<cosmos.TransactionContext>()
/**
* Arweave type ids
*/
Expand Down