-
Notifications
You must be signed in to change notification settings - Fork 648
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: use context.Context and appmodule.Environment in 08-wasm (#7880)
* core modules * fmt * fix broken tests * lint fix * actually, we can do wasm for now. this will work fine. * appmodulev2 -> appmodule * environment patch * ok most migrated now * use branch service isntead of query contexts * wip gas * migration complete * linter, error checks, etc etc * import ordering * linter * update queryHandler commentg * comment * fix gas check * make event emission functions methods on keeper * remove context argument from logger method * remove unwraps where possible * back to queyr router * fix * remove sdk.Context and height args from WasmSnapshotter functionality * restore height arg because thats an iface impl --------- Co-authored-by: Gjermund Garaba <[email protected]>
- Loading branch information
1 parent
70e7b6a
commit 98d7e75
Showing
16 changed files
with
209 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,45 @@ | ||
package keeper | ||
|
||
import ( | ||
"context" | ||
"encoding/hex" | ||
"errors" | ||
|
||
"cosmossdk.io/core/event" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types" | ||
) | ||
|
||
// emitStoreWasmCodeEvent emits a store wasm code event | ||
func emitStoreWasmCodeEvent(ctx sdk.Context, checksum types.Checksum) { | ||
ctx.EventManager().EmitEvents(sdk.Events{ | ||
sdk.NewEvent( | ||
func (k Keeper) emitStoreWasmCodeEvent(ctx context.Context, checksum types.Checksum) error { | ||
em := k.EventService.EventManager(ctx) | ||
return errors.Join( | ||
em.EmitKV( | ||
types.EventTypeStoreWasmCode, | ||
sdk.NewAttribute(types.AttributeKeyWasmChecksum, hex.EncodeToString(checksum)), | ||
event.NewAttribute(types.AttributeKeyWasmChecksum, hex.EncodeToString(checksum)), | ||
), | ||
sdk.NewEvent( | ||
em.EmitKV( | ||
sdk.EventTypeMessage, | ||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), | ||
event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), | ||
), | ||
}) | ||
) | ||
} | ||
|
||
// emitMigrateContractEvent emits a migrate contract event | ||
func emitMigrateContractEvent(ctx sdk.Context, clientID string, checksum, newChecksum types.Checksum) { | ||
ctx.EventManager().EmitEvents(sdk.Events{ | ||
sdk.NewEvent( | ||
func (k Keeper) emitMigrateContractEvent(ctx context.Context, clientID string, checksum, newChecksum types.Checksum) error { | ||
em := k.EventService.EventManager(ctx) | ||
return errors.Join( | ||
em.EmitKV( | ||
types.EventTypeMigrateContract, | ||
sdk.NewAttribute(types.AttributeKeyClientID, clientID), | ||
sdk.NewAttribute(types.AttributeKeyWasmChecksum, hex.EncodeToString(checksum)), | ||
sdk.NewAttribute(types.AttributeKeyNewChecksum, hex.EncodeToString(newChecksum)), | ||
event.NewAttribute(types.AttributeKeyClientID, clientID), | ||
event.NewAttribute(types.AttributeKeyWasmChecksum, hex.EncodeToString(checksum)), | ||
event.NewAttribute(types.AttributeKeyNewChecksum, hex.EncodeToString(newChecksum)), | ||
), | ||
sdk.NewEvent( | ||
em.EmitKV( | ||
sdk.EventTypeMessage, | ||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), | ||
event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), | ||
), | ||
}) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.