Skip to content

Commit

Permalink
feat: use typed events (#1030)
Browse files Browse the repository at this point in the history
- [x] switch to typed event for `blob` module'
- [ ] ~~Refactor integration test~~
- [x] Closes #968
  • Loading branch information
rahulghangas committed Dec 15, 2022
1 parent cc6f68d commit c16d6e7
Show file tree
Hide file tree
Showing 5 changed files with 393 additions and 24 deletions.
13 changes: 13 additions & 0 deletions proto/blob/event.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
syntax = "proto3";
package blob;

import "gogoproto/gogo.proto";

option go_package = "github.com/celestiaorg/celestia-app/x/blob/types";

// EventPayForBlob defines an event that is emitted with the signer and blob size
// at the end of a pay for blob txn
message EventPayForBlob {
string signer = 1;
uint64 blob_size = 2;
}
19 changes: 14 additions & 5 deletions x/blob/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,23 @@ The malleation process occurs during the PrepareProposal step.

## Events

- [`NewPayForBlobEvent`](https://github.com/celestiaorg/celestia-app/pull/213/files#diff-1ce55bda42cf160deca2e5ea1f4382b65f3b689c7e00c88085d7ce219e77303dR17-R21) is emitted with the signer's address and size of the blob that is paid for.
The blob module emits the following events:

### Blob Events

#### EventPayForBlob

| Attribute Key | Attribute Value |
|---------------|---------------------------------|
| signer | {bech32 encoded signer address} |
| blob_size | {size in bytes} |

## Parameters

Key | Type | Example
--- | --- | ---
MinSquareSize | uint32 | 1
MaxSquareSize | uint32 | 128
| Key | Type | Example |
|---------------|--------|---------|
| MinSquareSize | uint32 | 1 |
| MaxSquareSize | uint32 | 128 |

### Usage

Expand Down
5 changes: 4 additions & 1 deletion x/blob/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ func (k Keeper) PayForBlob(goCtx context.Context, msg *types.MsgPayForBlob) (*ty
gasToConsume := uint64(shares.BlobSharesUsed(int(msg.BlobSize)) * GasPerBlobShare)
ctx.GasMeter().ConsumeGas(gasToConsume, payForBlobGasDescriptor)

ctx.EventManager().EmitEvent(
err := ctx.EventManager().EmitTypedEvent(
types.NewPayForBlobEvent(sdk.AccAddress(msg.Signer).String(), msg.GetBlobSize()),
)
if err != nil {
return &types.MsgPayForBlobResponse{}, err
}

return &types.MsgPayForBlobResponse{}, nil
}
Loading

0 comments on commit c16d6e7

Please sign in to comment.