diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cc4f0a29..42437950 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,10 +24,25 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + + - name: Prepare Release Variables + id: vars + uses: ignite/cli/actions/release/vars@v0.27.2 + + - name: Delete the "latest" Release + uses: dev-drprasad/delete-tag-and-release@v0.2.1 + if: ${{ steps.vars.outputs.is_release_type_latest == 'true' }} + with: + tag_name: ${{ steps.vars.outputs.tag_name }} + delete_release: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Publish the Release uses: softprops/action-gh-release@v1 + if: ${{ steps.vars.outputs.should_release == 'true' }} with: tag_name: ${{ steps.vars.outputs.tag_name }} - prerelease: true + prerelease: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/x/pep/module.go b/x/pep/module.go index 411b9f21..6d4a0fa1 100644 --- a/x/pep/module.go +++ b/x/pep/module.go @@ -3,13 +3,12 @@ package pep import ( "bytes" "context" + cosmosmath "cosmossdk.io/math" "encoding/hex" "encoding/json" "fmt" "github.com/cosmos/cosmos-sdk/telemetry" - cosmosmath "cosmossdk.io/math" - enc "github.com/FairBlock/DistributedIBE/encryption" "math" @@ -31,7 +30,6 @@ import ( "github.com/Fairblock/fairyring/x/pep/client/cli" "github.com/Fairblock/fairyring/x/pep/keeper" "github.com/Fairblock/fairyring/x/pep/types" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -235,6 +233,17 @@ func (am AppModule) processFailedEncryptedTx(ctx sdk.Context, tx types.Encrypted am.handleGasConsumption(ctx, creatorAddr, cosmosmath.NewIntFromUint64(actualGasConsumed), tx.ChargedGas) } +type UnderlyingTxEvent struct { + Type string `json:"type"` + Attributes []EventAttribute `json:"attributes"` +} + +type EventAttribute struct { + Key string `json:"key"` + Value string `json:"value"` + Index bool `json:"index"` +} + // BeginBlock contains the logic that is automatically triggered at the beginning of each block func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { strLastExecutedHeight := am.keeper.GetLastExecutedHeight(ctx) @@ -536,12 +545,31 @@ func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { } handler := am.msgServiceRouter.Handler(txMsgs[0]) - _, err = handler(ctx, txMsgs[0]) + handlerResult, err := handler(ctx, txMsgs[0]) if err != nil { am.processFailedEncryptedTx(ctx, eachTx, fmt.Sprintf("error when handling tx message: %s", err.Error()), startConsumedGas) continue } + underlyingTxEvents := make([]UnderlyingTxEvent, 0) + + for _, e := range handlerResult.Events { + eventAttributes := make([]EventAttribute, 0) + for _, ea := range e.Attributes { + eventAttributes = append(eventAttributes, EventAttribute{ + Key: ea.Key, + Value: ea.Value, + Index: ea.Index, + }) + } + underlyingTxEvents = append(underlyingTxEvents, UnderlyingTxEvent{ + Type: e.Type, + Attributes: eventAttributes, + }) + } + + eventStrArrJson, _ := json.Marshal(underlyingTxEvents) + am.keeper.Logger(ctx).Info("! Encrypted Tx Decrypted & Decoded & Executed successfully !") ctx.EventManager().EmitEvent( @@ -550,6 +578,8 @@ func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { sdk.NewAttribute(types.EncryptedTxExecutedEventHeight, strconv.FormatUint(eachTx.TargetHeight, 10)), sdk.NewAttribute(types.EncryptedTxExecutedEventData, eachTx.Data), sdk.NewAttribute(types.EncryptedTxExecutedEventIndex, strconv.FormatUint(eachTx.Index, 10)), + sdk.NewAttribute(types.EncryptedTxExecutedEventMemo, wrappedTx.GetTx().GetMemo()), + sdk.NewAttribute(types.EncryptedTxExecutedEventUnderlyingEvents, string(eventStrArrJson)), ), ) diff --git a/x/pep/types/keys.go b/x/pep/types/keys.go index 157312a9..8efa7c3d 100644 --- a/x/pep/types/keys.go +++ b/x/pep/types/keys.go @@ -33,26 +33,28 @@ var ( const ( SubmittedEncryptedTxEventType = "new-encrypted-tx-submitted" - SubmittedEncryptedTxEventCreator = "new-encrypted-tx-creator" - SubmittedEncryptedTxEventTargetHeight = "new-encrypted-tx-target-height" - SubmittedEncryptedTxEventIndex = "new-encrypted-tx-index" - SubmittedEncryptedTxEventData = "new-encrypted-tx-data" + SubmittedEncryptedTxEventCreator = "creator" + SubmittedEncryptedTxEventTargetHeight = "target-height" + SubmittedEncryptedTxEventIndex = "index" + SubmittedEncryptedTxEventData = "data" ) const ( - EncryptedTxExecutedEventType = "executed-encrypted-tx" - EncryptedTxExecutedEventCreator = "executed-encrypted-tx-creator" - EncryptedTxExecutedEventHeight = "executed-encrypted-tx-target-height" - EncryptedTxExecutedEventIndex = "executed-encrypted-tx-index" - EncryptedTxExecutedEventData = "executed-encrypted-tx-data" + EncryptedTxExecutedEventType = "executed-encrypted-tx" + EncryptedTxExecutedEventCreator = "creator" + EncryptedTxExecutedEventHeight = "target-height" + EncryptedTxExecutedEventIndex = "index" + EncryptedTxExecutedEventData = "data" + EncryptedTxExecutedEventMemo = "memo" + EncryptedTxExecutedEventUnderlyingEvents = "events" ) const ( EncryptedTxRevertedEventType = "reverted-encrypted-tx" - EncryptedTxRevertedEventCreator = "reverted-encrypted-tx-creator" - EncryptedTxRevertedEventHeight = "reverted-encrypted-tx-target-height" - EncryptedTxRevertedEventIndex = "reverted-encrypted-tx-index" - EncryptedTxRevertedEventReason = "reverted-encrypted-tx-reason" + EncryptedTxRevertedEventCreator = "creator" + EncryptedTxRevertedEventHeight = "height" + EncryptedTxRevertedEventIndex = "index" + EncryptedTxRevertedEventReason = "reason" ) const ( @@ -63,9 +65,9 @@ const ( const ( KeyShareVerificationType = "keyshare-verification" - KeyShareVerificationCreator = "keyshare-verification-creator" - KeyShareVerificationHeight = "keyshare-verification-height" - KeyShareVerificationReason = "keyshare-verification-reason" + KeyShareVerificationCreator = "creator" + KeyShareVerificationHeight = "height" + KeyShareVerificationReason = "reason" ) const (