Skip to content

Commit

Permalink
addevents
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantani committed Aug 22, 2024
1 parent 49a76cd commit 7e54933
Show file tree
Hide file tree
Showing 12 changed files with 2,310 additions and 70 deletions.
1,154 changes: 1,154 additions & 0 deletions api/modules/claim/v1/events.pulsar.go

Large diffs are not rendered by default.

47 changes: 19 additions & 28 deletions api/modules/mint/v1/events.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 28 additions & 25 deletions api/modules/mint/v1/genesis.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/static/openapi.yml

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions proto/modules/claim/v1/events.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
syntax = "proto3";

package modules.claim.v1;

option go_package = "github.com/ignite/modules/x/claim/types";

message EventMissionCompleted {
uint64 missionID = 1;
string address = 2;
}

message EventMissionClaimed {
uint64 missionID = 1;
string claimer = 2;
}
32 changes: 32 additions & 0 deletions proto/modules/mint/v1/events.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
syntax = "proto3";

package modules.mint.v1;

import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";

option go_package = "github.com/ignite/modules/x/mint/types";

// EventMint is emitted when new coins are minted by the minter
message EventMint {
string bondedRatio = 1 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(cosmos_proto.scalar) = "cosmos.Dec"
];
string inflation = 2 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(cosmos_proto.scalar) = "cosmos.Dec"
];
string annualProvisions = 3 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(cosmos_proto.scalar) = "cosmos.Dec"
];
string amount = 4 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(cosmos_proto.scalar) = "cosmos.Int"
];
}
1 change: 1 addition & 0 deletions proto/modules/mint/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ syntax = "proto3";
package modules.mint.v1;

import "amino/amino.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "modules/mint/v1/minter.proto";
import "modules/mint/v1/params.proto";
Expand Down
19 changes: 16 additions & 3 deletions x/claim/keeper/mission.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,17 @@ func (k Keeper) CompleteMission(
return claimed, err
}

sdkCtx := sdk.UnwrapSDKContext(ctx)
err = sdkCtx.EventManager().EmitTypedEvent(&types.EventMissionCompleted{
MissionID: missionID,
Address: address,
})
if err != nil {
return claimed, err
}

// try to claim the mission if airdrop start is reached
blockTime := sdk.UnwrapSDKContext(ctx).BlockTime()
blockTime := sdkCtx.BlockTime()
params, err := k.Params.Get(ctx)
if err != nil {
return claimed, err
Expand Down Expand Up @@ -105,7 +114,8 @@ func (k Keeper) ClaimMission(
return claimed, err
}
decayInfo := params.DecayInformation
blockTime := sdk.UnwrapSDKContext(ctx).BlockTime()
sdkCtx := sdk.UnwrapSDKContext(ctx)
blockTime := sdkCtx.BlockTime()
claimable = decayInfo.ApplyDecayFactor(claimable, blockTime)

// check final claimable non-zero
Expand Down Expand Up @@ -137,7 +147,10 @@ func (k Keeper) ClaimMission(
return claimed, err
}

return claimed, nil
return claimed, sdkCtx.EventManager().EmitTypedEvent(&types.EventMissionClaimed{
MissionID: missionID,
Claimer: claimRecord.Address,
})
}

// SetMission add a mission id and store the Mission.
Expand Down
Loading

0 comments on commit 7e54933

Please sign in to comment.