diff --git a/changelog.md b/changelog.md index 3a760276bc..36922eade2 100644 --- a/changelog.md +++ b/changelog.md @@ -10,14 +10,16 @@ ### Changes +- [#3993](https://github.com/ignite/cli/pull/3993) Oracle scaffolding was deprecated and has been removed - [#3959](https://github.com/ignite/cli/pull/3959) Remove app name prefix from the `.gitignore` file -- [#3962](https://github.com/ignite/cli/pull/3962) Rename all RPC endpoints and autocli commands generated for `map`/`list`/`single` types +- [#3962](https://github.com/ignite/cli/pull/3962) Rename all RPC endpoints and autocli commands generated for `map`/`list`/`single` types - [#3972](https://github.com/ignite/cli/pull/3972) Skip Ignite app loading for some base commands that don't allow apps - [#3976](https://github.com/ignite/cli/pull/3976) Remove error checks for Cobra command value get calls - [#3983](https://github.com/ignite/cli/pull/3983) Bump `cosmos-sdk` to `v0.50.4` and `ibc-go` to `v8.1.0` ### Fixes +- [#3995](https://github.com/ignite/cli/pull/3995) Fix interface check for ibc modules - [#3953](https://github.com/ignite/cli/pull/3953) Fix apps `Stdout` is redirected to `Stderr` - [#3863](https://github.com/ignite/cli/pull/3963) Fix breaking issue for app client API when reading app chain info - [#3969](https://github.com/ignite/cli/pull/3969) Get first config validator using a getter to avoid index errors diff --git a/docs/docs/08-references/01-cli.md b/docs/docs/08-references/01-cli.md index 2df2138722..44c0ed5bea 100644 --- a/docs/docs/08-references/01-cli.md +++ b/docs/docs/08-references/01-cli.md @@ -3023,11 +3023,13 @@ with an "--ibc" flag. Note that the default module is not IBC-enabled. * [ignite](#ignite) - Ignite CLI offers everything you need to scaffold, test, build, and launch your blockchain * [ignite scaffold chain](#ignite-scaffold-chain) - New Cosmos SDK blockchain +* [ignite scaffold configs](#ignite-scaffold-configs) - Configs for a custom Cosmos SDK module * [ignite scaffold list](#ignite-scaffold-list) - CRUD for data stored as an array * [ignite scaffold map](#ignite-scaffold-map) - CRUD for data stored as key-value pairs * [ignite scaffold message](#ignite-scaffold-message) - Message to perform state transition on the blockchain * [ignite scaffold module](#ignite-scaffold-module) - Custom Cosmos SDK module * [ignite scaffold packet](#ignite-scaffold-packet) - Message for sending an IBC packet +* [ignite scaffold params](#ignite-scaffold-params) - Parameters for a custom Cosmos SDK module * [ignite scaffold query](#ignite-scaffold-query) - Query for fetching data from a blockchain * [ignite scaffold react](#ignite-scaffold-react) - React web app template * [ignite scaffold single](#ignite-scaffold-single) - CRUD for data stored in a single location @@ -3090,14 +3092,53 @@ ignite scaffold chain [name] [flags] **Options** ``` - --address-prefix string account address prefix (default "cosmos") - --clear-cache clear the build cache (advanced) - -h, --help help for chain - --minimal create a minimal blockchain (with the minimum required Cosmos SDK modules) - --no-module create a project without a default module - --params strings add default module parameters - -p, --path string create a project in a specific path - --skip-git skip Git repository initialization + --address-prefix string account address prefix (default "cosmos") + --clear-cache clear the build cache (advanced) + -h, --help help for chain + --minimal create a minimal blockchain (with the minimum required Cosmos SDK modules) + --module-configs strings add module configs + --no-module create a project without a default module + --params strings add default module parameters + -p, --path string create a project in a specific path + --skip-git skip Git repository initialization +``` + +**SEE ALSO** + +* [ignite scaffold](#ignite-scaffold) - Create a new blockchain, module, message, query, and more + + +## ignite scaffold configs + +Configs for a custom Cosmos SDK module + +**Synopsis** + +Scaffold a new config for a Cosmos SDK module. + +A Cosmos SDK module can have configurations. An example of a config is "address prefix" of the +"auth" module. A config can be scaffolded into a module using the "--module-configs" into +the scaffold module command or using the "scaffold configs" command. By default +configs are of type "string", but you can specify a type for each config. For example: + + ignite scaffold configs foo baz:uint bar:bool + +Refer to Cosmos SDK documentation to learn more about modules, dependencies and +configs. + + +``` +ignite scaffold configs [configs]... [flags] +``` + +**Options** + +``` + --clear-cache clear the build cache (advanced) + -h, --help help for configs + --module string module to add the query into (default: app's main module) + -p, --path string path of the app (default ".") + -y, --yes answers interactive yes/no questions with yes ``` **SEE ALSO** @@ -3438,15 +3479,16 @@ ignite scaffold module [name] [flags] **Options** ``` - --clear-cache clear the build cache (advanced) - --dep strings add a dependency on another module - -h, --help help for module - --ibc add IBC functionality - --ordering string channel ordering of the IBC module [none|ordered|unordered] (default "none") - --params strings add module parameters - -p, --path string path of the app (default ".") - --require-registration fail if module can't be registered - -y, --yes answers interactive yes/no questions with yes + --clear-cache clear the build cache (advanced) + --dep strings add a dependency on another module + -h, --help help for module + --ibc add IBC functionality + --module-configs strings add module configs + --ordering string channel ordering of the IBC module [none|ordered|unordered] (default "none") + --params strings add module parameters + -p, --path string path of the app (default ".") + --require-registration fail if module can't be registered + -y, --yes answers interactive yes/no questions with yes ``` **SEE ALSO** @@ -3484,6 +3526,46 @@ ignite scaffold packet [packetName] [field1] [field2] ... --module [moduleName] * [ignite scaffold](#ignite-scaffold) - Create a new blockchain, module, message, query, and more +## ignite scaffold params + +Parameters for a custom Cosmos SDK module + +**Synopsis** + +Scaffold a new parameter for a Cosmos SDK module. + +A Cosmos SDK module can have parameters (or "params"). Params are values that +can be set at the genesis of the blockchain and can be modified while the +blockchain is running. An example of a param is "Inflation rate change" of the +"mint" module. A params can be scaffolded into a module using the "--params" into +the scaffold module command or using the "scaffold params" command. By default +params are of type "string", but you can specify a type for each param. For example: + + ignite scaffold params foo baz:uint bar:bool + +Refer to Cosmos SDK documentation to learn more about modules, dependencies and +params. + + +``` +ignite scaffold params [param]... [flags] +``` + +**Options** + +``` + --clear-cache clear the build cache (advanced) + -h, --help help for params + --module string module to add the query into. Default: app's main module + -p, --path string path of the app (default ".") + -y, --yes answers interactive yes/no questions with yes +``` + +**SEE ALSO** + +* [ignite scaffold](#ignite-scaffold) - Create a new blockchain, module, message, query, and more + + ## ignite scaffold query Query for fetching data from a blockchain diff --git a/ignite/cmd/scaffold.go b/ignite/cmd/scaffold.go index ad0695efd0..850ed5d98f 100644 --- a/ignite/cmd/scaffold.go +++ b/ignite/cmd/scaffold.go @@ -129,7 +129,6 @@ with an "--ibc" flag. Note that the default module is not IBC-enabled. NewScaffoldMessage(), NewScaffoldQuery(), NewScaffoldPacket(), - NewScaffoldBandchain(), NewScaffoldVue(), NewScaffoldReact(), ) diff --git a/ignite/cmd/scaffold_band.go b/ignite/cmd/scaffold_band.go deleted file mode 100644 index 458ad24a25..0000000000 --- a/ignite/cmd/scaffold_band.go +++ /dev/null @@ -1,88 +0,0 @@ -package ignitecmd - -import ( - "github.com/spf13/cobra" - - "github.com/ignite/cli/v28/ignite/pkg/cliui" - "github.com/ignite/cli/v28/ignite/pkg/errors" - "github.com/ignite/cli/v28/ignite/pkg/placeholder" - "github.com/ignite/cli/v28/ignite/pkg/xgenny" - "github.com/ignite/cli/v28/ignite/services/scaffolder" -) - -const tplScaffoldBandSuccess = ` -🎉 Created a Band oracle query "%[1]v". -Note: BandChain module uses version "bandchain-1". -Make sure to update the keys.go file accordingly. -// x/%[2]v/types/keys.go -const Version = "bandchain-1" -` - -// NewScaffoldBandchain creates a new BandChain oracle in the module. -func NewScaffoldBandchain() *cobra.Command { - c := &cobra.Command{ - Use: "band [queryName] --module [moduleName]", - Short: "Scaffold an IBC BandChain query oracle to request real-time data", - Long: "Scaffold an IBC BandChain query oracle to request real-time data from BandChain scripts in a specific IBC-enabled Cosmos SDK module", - Args: cobra.MinimumNArgs(1), - PreRunE: migrationPreRunHandler, - RunE: createBandchainHandler, - Hidden: true, - } - - flagSetPath(c) - flagSetClearCache(c) - - c.Flags().AddFlagSet(flagSetYes()) - c.Flags().String(flagModule, "", "IBC module to add the packet into") - c.Flags().String(flagSigner, "", "label for the message signer (default: creator)") - - return c -} - -func createBandchainHandler(cmd *cobra.Command, args []string) error { - var ( - oracle = args[0] - appPath = flagGetPath(cmd) - signer = flagGetSigner(cmd) - ) - - session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) - defer session.End() - - module, _ := cmd.Flags().GetString(flagModule) - if module == "" { - return errors.New("please specify a module to create the BandChain oracle into: --module ") - } - - cacheStorage, err := newCache(cmd) - if err != nil { - return err - } - - var options []scaffolder.OracleOption - if signer != "" { - options = append(options, scaffolder.OracleWithSigner(signer)) //nolint: staticcheck - } - - sc, err := scaffolder.New(appPath) - if err != nil { - return err - } - - //nolint: staticcheck - sm, err := sc.AddOracle(cmd.Context(), cacheStorage, placeholder.New(), module, oracle, options...) - if err != nil { - return err - } - - modificationsStr, err := xgenny.SourceModificationToString(sm) - if err != nil { - return err - } - - session.Println(modificationsStr) - session.Printf(tplScaffoldBandSuccess, oracle, module) - - return nil -} diff --git a/ignite/services/scaffolder/component.go b/ignite/services/scaffolder/component.go index b9b3588d5f..e1a20cdbe7 100644 --- a/ignite/services/scaffolder/component.go +++ b/ignite/services/scaffolder/component.go @@ -130,7 +130,6 @@ func checkForbiddenComponentName(name multiformatname.Name) error { // Check with names already used from the scaffolded code switch name.LowerCase { case - "oracle", "logger", "keeper", "query", @@ -199,32 +198,6 @@ func checkGoReservedWord(name string) error { return nil } -// checkForbiddenOracleFieldName returns true if the name is forbidden as an oracle field name. -// -// Deprecated: This function is no longer maintained. -func checkForbiddenOracleFieldName(name string) error { - mfName, err := multiformatname.NewName(name, multiformatname.NoNumber) - if err != nil { - return err - } - - // Check with names already used from the scaffolded code - switch mfName.UpperCase { - case - "CLIENTID", - "ORACLESCRIPTID", - "SOURCECHANNEL", - "CALLDATA", - "ASKCOUNT", - "MINCOUNT", - "FEELIMIT", - "PREPAREGAS", - "EXECUTEGAS": - return errors.Errorf("%s is used by Ignite scaffolder", name) - } - return nil -} - // containsCustomTypes returns true if the list of fields contains at least one custom type. func containsCustomTypes(fields []string) bool { for _, field := range fields { diff --git a/ignite/services/scaffolder/component_test.go b/ignite/services/scaffolder/component_test.go index e154432b7c..8976a7f239 100644 --- a/ignite/services/scaffolder/component_test.go +++ b/ignite/services/scaffolder/component_test.go @@ -21,7 +21,7 @@ func TestCheckForbiddenComponentName(t *testing.T) { }, { name: "should prevent forbidden name", - compName: "oracle", + compName: "genesis", shouldError: true, }, } diff --git a/ignite/services/scaffolder/oracle.go b/ignite/services/scaffolder/oracle.go deleted file mode 100644 index 73f659d5e0..0000000000 --- a/ignite/services/scaffolder/oracle.go +++ /dev/null @@ -1,127 +0,0 @@ -package scaffolder - -import ( - "context" - - "github.com/gobuffalo/genny/v2" - - "github.com/ignite/cli/v28/ignite/pkg/cache" - "github.com/ignite/cli/v28/ignite/pkg/cmdrunner" - "github.com/ignite/cli/v28/ignite/pkg/cmdrunner/step" - "github.com/ignite/cli/v28/ignite/pkg/errors" - "github.com/ignite/cli/v28/ignite/pkg/gocmd" - "github.com/ignite/cli/v28/ignite/pkg/multiformatname" - "github.com/ignite/cli/v28/ignite/pkg/placeholder" - "github.com/ignite/cli/v28/ignite/pkg/xgenny" - "github.com/ignite/cli/v28/ignite/templates/ibc" -) - -const ( - bandImport = "github.com/bandprotocol/bandchain-packet" - bandVersion = "v0.0.2" -) - -// OracleOption configures options for AddOracle. -type OracleOption func(*oracleOptions) - -type oracleOptions struct { - signer string -} - -// newOracleOptions returns a oracleOptions with default options -// -// Deprecated: This function is no longer maintained. -func newOracleOptions() oracleOptions { - return oracleOptions{ - signer: "creator", - } -} - -// OracleWithSigner provides a custom signer name for the message -// -// Deprecated: This function is no longer maintained. -func OracleWithSigner(signer string) OracleOption { - return func(m *oracleOptions) { - m.signer = signer - } -} - -// AddOracle adds a new BandChain oracle envtest. -// -// Deprecated: This function is no longer maintained. -func (s *Scaffolder) AddOracle( - ctx context.Context, - cacheStorage cache.Storage, - tracer *placeholder.Tracer, - moduleName, - queryName string, - options ...OracleOption, -) (sm xgenny.SourceModification, err error) { - if err := s.installBandPacket(); err != nil { - return sm, err - } - - o := newOracleOptions() - for _, apply := range options { - apply(&o) - } - - mfName, err := multiformatname.NewName(moduleName, multiformatname.NoNumber) - if err != nil { - return sm, err - } - moduleName = mfName.LowerCase - - name, err := multiformatname.NewName(queryName) - if err != nil { - return sm, err - } - - if err := checkComponentValidity(s.path, moduleName, name, false); err != nil { - return sm, err - } - - mfSigner, err := multiformatname.NewName(o.signer, checkForbiddenOracleFieldName) - if err != nil { - return sm, err - } - - // Module must implement IBC - ok, err := isIBCModule(s.path, moduleName) - if err != nil { - return sm, err - } - if !ok { - return sm, errors.Errorf("the module %s doesn't implement IBC module interface", moduleName) - } - - // Generate the packet - var ( - g *genny.Generator - opts = &ibc.OracleOptions{ - AppName: s.modpath.Package, - AppPath: s.path, - ModulePath: s.modpath.RawPath, - ModuleName: moduleName, - QueryName: name, - MsgSigner: mfSigner, - } - ) - g, err = ibc.NewOracle(tracer, opts) - if err != nil { - return sm, err - } - sm, err = xgenny.RunWithValidation(tracer, g) - if err != nil { - return sm, err - } - return sm, finish(ctx, cacheStorage, opts.AppPath, s.modpath.RawPath) -} - -// Deprecated: This function is no longer maintained. -func (s Scaffolder) installBandPacket() error { - return cmdrunner.New(). - Run(context.Background(), - step.New(step.Exec(gocmd.Name(), "get", gocmd.PackageLiteral(bandImport, bandVersion))), - ) -} diff --git a/ignite/templates/app/files/app/ibc.go.plush b/ignite/templates/app/files/app/ibc.go.plush index 472a6c3870..cd3e156664 100644 --- a/ignite/templates/app/files/app/ibc.go.plush +++ b/ignite/templates/app/files/app/ibc.go.plush @@ -4,6 +4,7 @@ import ( "cosmossdk.io/core/appmodule" storetypes "cosmossdk.io/store/types" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/types/module" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" @@ -196,12 +197,8 @@ func RegisterIBC(registry cdctypes.InterfaceRegistry) map[string]appmodule.AppMo solomachine.ModuleName: solomachine.AppModule{}, } - for _, module := range modules { - if mod, ok := module.(interface { - RegisterInterfaces(registry cdctypes.InterfaceRegistry) - }); ok { - mod.RegisterInterfaces(registry) - } + for name, m := range modules { + module.CoreAppModuleBasicAdaptor(name, m).RegisterInterfaces(registry) } return modules diff --git a/ignite/templates/ibc/files/oracle/proto/{{appName}}/{{moduleName}}/{{queryName}}.proto.plush b/ignite/templates/ibc/files/oracle/proto/{{appName}}/{{moduleName}}/{{queryName}}.proto.plush deleted file mode 100644 index 2ef679f28a..0000000000 --- a/ignite/templates/ibc/files/oracle/proto/{{appName}}/{{moduleName}}/{{queryName}}.proto.plush +++ /dev/null @@ -1,13 +0,0 @@ -syntax = "proto3"; -package <%= protoPkgName %>; - -option go_package = "<%= ModulePath %>/x/<%= moduleName %>/types"; - -message <%= queryName.UpperCamel %>CallData { - repeated string symbols = 1; - uint64 multiplier = 2; -} - -message <%= queryName.UpperCamel %>Result { - repeated uint64 rates = 1; -} diff --git a/ignite/templates/ibc/files/oracle/x/{{moduleName}}/keeper/msg_{{queryName}}.go.plush b/ignite/templates/ibc/files/oracle/x/{{moduleName}}/keeper/msg_{{queryName}}.go.plush deleted file mode 100644 index c74f33a225..0000000000 --- a/ignite/templates/ibc/files/oracle/x/{{moduleName}}/keeper/msg_{{queryName}}.go.plush +++ /dev/null @@ -1,69 +0,0 @@ -package keeper - -import ( - "context" - "time" - - errorsmod "cosmossdk.io/errors" - "github.com/bandprotocol/bandchain-packet/obi" - "github.com/bandprotocol/bandchain-packet/packet" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" - host "github.com/cosmos/ibc-go/v8/modules/core/24-host" - "<%= ModulePath %>/x/<%= moduleName %>/types" -) - -// <%= queryName.UpperCamel %>Data creates the <%= queryName.UpperCamel %> packet -// data with obi encoded and send it to the channel -func (k msgServer) <%= queryName.UpperCamel %>Data(goCtx context.Context, msg *types.Msg<%= queryName.UpperCamel %>Data) (*types.Msg<%= queryName.UpperCamel %>DataResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - sourcePort := types.PortID - sourceChannelEnd, found := k.ibcKeeperFn().ChannelKeeper.GetChannel(ctx, sourcePort, msg.SourceChannel) - if !found { - return nil, errorsmod.Wrapf( - sdkerrors.ErrUnknownRequest, - "unknown channel %s port %s", - msg.SourceChannel, - sourcePort, - ) - } - destinationPort := sourceChannelEnd.GetCounterparty().GetPortID() - destinationChannel := sourceChannelEnd.GetCounterparty().GetChannelID() - - // get the next sequence - sequence, found := k.ibcKeeperFn().ChannelKeeper.GetNextSequenceSend(ctx, sourcePort, msg.SourceChannel) - if !found { - return nil, errorsmod.Wrapf( - channeltypes.ErrSequenceSendNotFound, - - "source port: %s, source channel: %s", sourcePort, msg.SourceChannel) - } - - channelCap, ok := k.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(sourcePort, msg.SourceChannel)) - if !ok { - return nil, errorsmod.Wrap(channeltypes.ErrChannelCapabilityNotFound, - "module does not own channel capability") - } - - encodedCalldata := obi.MustEncode(*msg.Calldata) - packetData := packet.NewOracleRequestPacketData( - msg.ClientID, - msg.OracleScriptID, - encodedCalldata, - msg.AskCount, - msg.MinCount, - msg.FeeLimit, - msg.PrepareGas, - msg.ExecuteGas, - ) - - packetBytes, err := packetData.GetBytes() - if err != nil { - return errorsmod.Wrap(sdkerrors.ErrJSONMarshal, "cannot marshal the packet: " + err.Error()) - } - - return k.ibcKeeperFn().ChannelKeeper.SendPacket(ctx, channelCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, packetBytes) -} diff --git a/ignite/templates/ibc/files/oracle/x/{{moduleName}}/keeper/query_{{queryName}}.go.plush b/ignite/templates/ibc/files/oracle/x/{{moduleName}}/keeper/query_{{queryName}}.go.plush deleted file mode 100644 index 7b6bf1ef8e..0000000000 --- a/ignite/templates/ibc/files/oracle/x/{{moduleName}}/keeper/query_{{queryName}}.go.plush +++ /dev/null @@ -1,25 +0,0 @@ -package keeper - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - "<%= ModulePath %>/x/<%= moduleName %>/types" -) - -// <%= queryName.UpperCamel %>Result returns the <%= queryName.UpperCamel %> result by RequestId -func (k Keeper) <%= queryName.UpperCamel %>Result(c context.Context, req *types.Query<%= queryName.UpperCamel %>Request) (*types.Query<%= queryName.UpperCamel %>Response, error) { - ctx := sdk.UnwrapSDKContext(c) - result, err := k.Get<%= queryName.UpperCamel %>Result(ctx, types.OracleRequestID(req.RequestId)) - if err != nil { - return nil, err - } - return &types.Query<%= queryName.UpperCamel %>Response{Result: &result}, nil -} - -// Last<%= queryName.UpperCamel %>Id returns the last <%= queryName.UpperCamel %> request Id -func (k Keeper) Last<%= queryName.UpperCamel %>Id(c context.Context, req *types.QueryLast<%= queryName.UpperCamel %>IdRequest) (*types.QueryLast<%= queryName.UpperCamel %>IdResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - id := k.GetLast<%= queryName.UpperCamel %>ID(ctx) - return &types.QueryLast<%= queryName.UpperCamel %>IdResponse{RequestId: id}, nil -} diff --git a/ignite/templates/ibc/files/oracle/x/{{moduleName}}/keeper/{{queryName}}.go.plush b/ignite/templates/ibc/files/oracle/x/{{moduleName}}/keeper/{{queryName}}.go.plush deleted file mode 100644 index f5bf0e2c40..0000000000 --- a/ignite/templates/ibc/files/oracle/x/{{moduleName}}/keeper/{{queryName}}.go.plush +++ /dev/null @@ -1,46 +0,0 @@ -package keeper - -import ( - "context" - - errorsmod "cosmossdk.io/errors" - "github.com/cosmos/cosmos-sdk/runtime" - gogotypes "github.com/cosmos/gogoproto/types" - "<%= ModulePath %>/x/<%= moduleName %>/types" -) - -// Set<%= queryName.UpperCamel %>Result saves the <%= queryName.UpperCamel %> result -func (k Keeper) Set<%= queryName.UpperCamel %>Result(ctx context.Context, requestID types.OracleRequestID, result types.<%= queryName.UpperCamel %>Result) { - store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) - store.Set(types.<%= queryName.UpperCamel %>ResultStoreKey(requestID), k.cdc.MustMarshal(&result)) -} - -// Get<%= queryName.UpperCamel %>Result returns the <%= queryName.UpperCamel %> by requestId -func (k Keeper) Get<%= queryName.UpperCamel %>Result(ctx context.Context, id types.OracleRequestID) (types.<%= queryName.UpperCamel %>Result, error) { - store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) - bz := store.Get(types.<%= queryName.UpperCamel %>ResultStoreKey(id)) - if bz == nil { - return types.<%= queryName.UpperCamel %>Result{}, errorsmod.Wrapf(types.ErrSample, - "GetResult: Result for request ID %d is not available.", id, - ) - } - var result types.<%= queryName.UpperCamel %>Result - k.cdc.MustUnmarshal(bz, &result) - return result, nil -} - -// GetLast<%= queryName.UpperCamel %>ID return the id from the last <%= queryName.UpperCamel %> request -func (k Keeper) GetLast<%= queryName.UpperCamel %>ID(ctx context.Context) int64 { - store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) - bz := store.Get(types.KeyPrefix(types.Last<%= queryName.UpperCamel %>IDKey)) - intV := gogotypes.Int64Value{} - k.cdc.MustUnmarshalLengthPrefixed(bz, &intV) - return intV.GetValue() -} - -// SetLast<%= queryName.UpperCamel %>ID saves the id from the last <%= queryName.UpperCamel %> request -func (k Keeper) SetLast<%= queryName.UpperCamel %>ID(ctx context.Context, id types.OracleRequestID) { - store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) - store.Set(types.KeyPrefix(types.Last<%= queryName.UpperCamel %>IDKey), - k.cdc.MustMarshalLengthPrefixed(&gogotypes.Int64Value{Value: int64(id)})) -} diff --git a/ignite/templates/ibc/files/oracle/x/{{moduleName}}/oracle.go.plush b/ignite/templates/ibc/files/oracle/x/{{moduleName}}/oracle.go.plush deleted file mode 100644 index 4df0f257aa..0000000000 --- a/ignite/templates/ibc/files/oracle/x/{{moduleName}}/oracle.go.plush +++ /dev/null @@ -1,73 +0,0 @@ -package <%= moduleName %> - -import ( - errorsmod "cosmossdk.io/errors" - "github.com/bandprotocol/bandchain-packet/obi" - "github.com/bandprotocol/bandchain-packet/packet" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" - "<%= ModulePath %>/x/<%= moduleName %>/types" -) - -// handleOraclePacket handles the result of the received BandChain oracles -// packet and saves the data into the KV database -func (im IBCModule) handleOraclePacket( - ctx sdk.Context, - modulePacket channeltypes.Packet, -) (channeltypes.Acknowledgement, error) { - var ack channeltypes.Acknowledgement - var modulePacketData packet.OracleResponsePacketData - if err := types.ModuleCdc.UnmarshalJSON(modulePacket.GetData(), &modulePacketData); err != nil { - return ack, nil - } - - switch modulePacketData.GetClientID() { - // this line is used by starport scaffolding # oracle/module/recv - - default: - err := errorsmod.Wrapf(sdkerrors.ErrJSONUnmarshal, - "oracle received packet not found: %s", modulePacketData.GetClientID()) - ack = channeltypes.NewErrorAcknowledgement(err) - return ack, err - - } - ack = channeltypes.NewResultAcknowledgement( - types.ModuleCdc.MustMarshalJSON( - packet.NewOracleRequestPacketAcknowledgement(modulePacketData.RequestID), - ), - ) - return ack, nil -} - -// handleOracleAcknowledgment handles the acknowledgment result from the BandChain -// request and saves the request-id into the KV database -func (im IBCModule) handleOracleAcknowledgment( - ctx sdk.Context, - ack channeltypes.Acknowledgement, - modulePacket channeltypes.Packet, -) (*sdk.Result, error) { - switch resp := ack.Response.(type) { - case *channeltypes.Acknowledgement_Result: - var oracleAck packet.OracleRequestPacketAcknowledgement - err := types.ModuleCdc.UnmarshalJSON(resp.Result, &oracleAck) - if err != nil { - return nil, nil - } - - var data packet.OracleRequestPacketData - if err = types.ModuleCdc.UnmarshalJSON(modulePacket.GetData(), &data); err != nil { - return nil, nil - } - requestID := types.OracleRequestID(oracleAck.RequestID) - - switch data.GetClientID() { - // this line is used by starport scaffolding # oracle/module/ack - - default: - return nil, errorsmod.Wrapf(sdkerrors.ErrJSONUnmarshal, - "oracle acknowledgment packet not found: %s", data.GetClientID()) - } - } - return nil, nil -} diff --git a/ignite/templates/ibc/files/oracle/x/{{moduleName}}/types/oracle.go.plush b/ignite/templates/ibc/files/oracle/x/{{moduleName}}/types/oracle.go.plush deleted file mode 100644 index 88fe147c5a..0000000000 --- a/ignite/templates/ibc/files/oracle/x/{{moduleName}}/types/oracle.go.plush +++ /dev/null @@ -1,18 +0,0 @@ -package types - -import "encoding/binary" - -type ( - // OracleScriptID is the type-safe unique identifier type for oracle scripts. - OracleScriptID uint64 - - // OracleRequestID is the type-safe unique identifier type for data requests. - OracleRequestID int64 -) - -// int64ToBytes convert int64 to a byte slice -func int64ToBytes(num int64) []byte { - result := make([]byte, 8) - binary.BigEndian.PutUint64(result, uint64(num)) - return result -} diff --git a/ignite/templates/ibc/files/oracle/x/{{moduleName}}/types/{{queryName}}.go.plush b/ignite/templates/ibc/files/oracle/x/{{moduleName}}/types/{{queryName}}.go.plush deleted file mode 100644 index 9c0dad7aae..0000000000 --- a/ignite/templates/ibc/files/oracle/x/{{moduleName}}/types/{{queryName}}.go.plush +++ /dev/null @@ -1,63 +0,0 @@ -package types - -import ( - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) - -var ( - _ sdk.Msg = &Msg<%= queryName.UpperCamel %>Data{} - - // <%= queryName.UpperCamel %>ResultStoreKeyPrefix is a prefix for storing result - <%= queryName.UpperCamel %>ResultStoreKeyPrefix = "<%= queryName.Snake %>_result" - - // Last<%= queryName.UpperCamel %>IDKey is the key for the last request id - Last<%= queryName.UpperCamel %>IDKey = "<%= queryName.Snake %>_last_id" - - // <%= queryName.UpperCamel %>ClientIDKey is query request identifier - <%= queryName.UpperCamel %>ClientIDKey = "<%= queryName.Snake %>_id" -) - -// NewMsg<%= queryName.UpperCamel %>Data creates a new <%= queryName.UpperCamel %> message -func NewMsg<%= queryName.UpperCamel %>Data( - <%= MsgSigner.LowerCamel %> string, - oracleScriptID OracleScriptID, - sourceChannel string, - calldata *<%= queryName.UpperCamel %>CallData, - askCount uint64, - minCount uint64, - feeLimit sdk.Coins, - prepareGas uint64, - executeGas uint64, -) *Msg<%= queryName.UpperCamel %>Data { - return &Msg<%= queryName.UpperCamel %>Data{ - ClientID: <%= queryName.UpperCamel %>ClientIDKey, - <%= MsgSigner.UpperCamel %>: <%= MsgSigner.LowerCamel %>, - OracleScriptID: uint64(oracleScriptID), - SourceChannel: sourceChannel, - Calldata: calldata, - AskCount: askCount, - MinCount: minCount, - FeeLimit: feeLimit, - PrepareGas: prepareGas, - ExecuteGas: executeGas, - } -} - -// ValidateBasic check the basic message validation -func (m *Msg<%= queryName.UpperCamel %>Data) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(m.<%= MsgSigner.UpperCamel %>) - if err != nil { - return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid <%= MsgSigner.LowerCamel %> address (%s)", err) - } - if m.SourceChannel == "" { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "invalid source channel") - } - return nil -} - -// <%= queryName.UpperCamel %>ResultStoreKey is a function to generate key for each result in store -func <%= queryName.UpperCamel %>ResultStoreKey(requestID OracleRequestID) []byte { - return append(KeyPrefix(<%= queryName.UpperCamel %>ResultStoreKeyPrefix), int64ToBytes(int64(requestID))...) -} diff --git a/ignite/templates/ibc/files/oracle/x/{{moduleName}}/types/{{queryName}}_test.go.plush b/ignite/templates/ibc/files/oracle/x/{{moduleName}}/types/{{queryName}}_test.go.plush deleted file mode 100644 index 1c0c6cfabb..0000000000 --- a/ignite/templates/ibc/files/oracle/x/{{moduleName}}/types/{{queryName}}_test.go.plush +++ /dev/null @@ -1,49 +0,0 @@ -package types - -import ( - "testing" - - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" - "<%= ModulePath %>/testutil/sample" -) - -func TestMsg<%= queryName.UpperCamel %>Data_ValidateBasic(t *testing.T) { - tests := []struct { - name string - msg Msg<%= queryName.UpperCamel %>Data - err error - }{ - { - name: "invalid address", - msg: Msg<%= queryName.UpperCamel %>Data{ - <%= MsgSigner.UpperCamel %>: "invalid_address", - SourceChannel: "channel-0", - }, - err: sdkerrors.ErrInvalidAddress, - }, { - name: "invalid source channel", - msg: Msg<%= queryName.UpperCamel %>Data{ - <%= MsgSigner.UpperCamel %>: sample.AccAddress(), - SourceChannel: "", - }, - err: sdkerrors.ErrInvalidRequest, - }, { - name: "valid message", - msg: Msg<%= queryName.UpperCamel %>Data{ - <%= MsgSigner.UpperCamel %>: sample.AccAddress(), - SourceChannel: "channel-0", - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - err := tt.msg.ValidateBasic() - if tt.err != nil { - require.ErrorIs(t, err, tt.err) - return - } - require.NoError(t, err) - }) - } -} diff --git a/ignite/templates/ibc/oracle.go b/ignite/templates/ibc/oracle.go deleted file mode 100644 index 1e88ebe1d3..0000000000 --- a/ignite/templates/ibc/oracle.go +++ /dev/null @@ -1,374 +0,0 @@ -package ibc - -import ( - "embed" - "fmt" - "path/filepath" - "strings" - - "github.com/gobuffalo/genny/v2" - "github.com/gobuffalo/plush/v4" - - "github.com/ignite/cli/v28/ignite/pkg/gomodulepath" - "github.com/ignite/cli/v28/ignite/pkg/multiformatname" - "github.com/ignite/cli/v28/ignite/pkg/placeholder" - "github.com/ignite/cli/v28/ignite/pkg/xgenny" - "github.com/ignite/cli/v28/ignite/templates/field/plushhelpers" - "github.com/ignite/cli/v28/ignite/templates/module" - "github.com/ignite/cli/v28/ignite/templates/testutil" -) - -//go:embed files/oracle/* files/oracle/**/* -var fsOracle embed.FS - -// OracleOptions are options to scaffold an oracle query in a IBC module. -type OracleOptions struct { - AppName string - AppPath string - ModuleName string - ModulePath string - QueryName multiformatname.Name - MsgSigner multiformatname.Name -} - -// NewOracle returns the generator to scaffold the implementation of the Oracle interface inside a module -// -// Deprecated: This function is no longer maintained. -func NewOracle(replacer placeholder.Replacer, opts *OracleOptions) (*genny.Generator, error) { - g := genny.New() - - template := xgenny.NewEmbedWalker(fsOracle, "files/oracle/", opts.AppPath) - - g.RunFn(moduleOracleModify(replacer, opts)) - g.RunFn(protoQueryOracleModify(replacer, opts)) - g.RunFn(protoTxOracleModify(replacer, opts)) - g.RunFn(clientCliQueryOracleModify(replacer, opts)) - g.RunFn(clientCliTxOracleModify(replacer, opts)) - g.RunFn(codecOracleModify(replacer, opts)) - - appModulePath := gomodulepath.ExtractAppPath(opts.ModulePath) - - ctx := plush.NewContext() - ctx.Set("moduleName", opts.ModuleName) - ctx.Set("ModulePath", opts.ModulePath) - ctx.Set("appName", opts.AppName) - ctx.Set("queryName", opts.QueryName) - ctx.Set("MsgSigner", opts.MsgSigner) - ctx.Set("protoPkgName", module.ProtoPackageName(appModulePath, opts.ModuleName)) - - plushhelpers.ExtendPlushContext(ctx) - g.Transformer(xgenny.Transformer(ctx)) - g.Transformer(genny.Replace("{{appName}}", opts.AppName)) - g.Transformer(genny.Replace("{{moduleName}}", opts.ModuleName)) - g.Transformer(genny.Replace("{{queryName}}", opts.QueryName.Snake)) - - // Create the 'testutil' package with the test helpers - if err := testutil.Register(g, opts.AppPath); err != nil { - return g, err - } - - if err := xgenny.Box(g, template); err != nil { - return g, err - } - - g.RunFn(packetHandlerOracleModify(replacer, opts)) - - return g, nil -} - -// Deprecated: This function is no longer maintained. -func moduleOracleModify(replacer placeholder.Replacer, opts *OracleOptions) genny.RunFn { - return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, "x", opts.ModuleName, "module/module_ibc.go") - f, err := r.Disk.Find(path) - if err != nil { - return err - } - - // Recv packet dispatch - templateRecv := `oracleAck, err := im.handleOraclePacket(ctx, modulePacket) - if err != nil { - return channeltypes.NewErrorAcknowledgement(errorsmod.Wrap(sdkerrors.ErrUnknownRequest, "cannot unmarshal packet data: "+err.Error())) - } else if ack != oracleAck { - return oracleAck - } - %[1]v` - replacementRecv := fmt.Sprintf(templateRecv, PlaceholderOraclePacketModuleRecv) - content := replacer.ReplaceOnce(f.String(), PlaceholderOraclePacketModuleRecv, replacementRecv) - - // Ack packet dispatch - templateAck := `sdkResult, err := im.handleOracleAcknowledgment(ctx, ack, modulePacket) - if err != nil { - return err - } - if sdkResult != nil { - sdkResult.Events = ctx.EventManager().Events().ToABCIEvents() - return nil - } - %[1]v` - replacementAck := fmt.Sprintf(templateAck, PlaceholderOraclePacketModuleAck) - content = replacer.ReplaceOnce(content, PlaceholderOraclePacketModuleAck, replacementAck) - - newFile := genny.NewFileS(path, content) - return r.File(newFile) - } -} - -// Deprecated: This function is no longer maintained. -func protoQueryOracleModify(replacer placeholder.Replacer, opts *OracleOptions) genny.RunFn { - return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, "proto", opts.AppName, opts.ModuleName, "query.proto") - f, err := r.Disk.Find(path) - if err != nil { - return err - } - - // Import the type - templateImport := `import "%[2]v/%[3]v/%[4]v.proto"; -%[1]v` - replacementImport := fmt.Sprintf(templateImport, Placeholder, opts.AppName, opts.ModuleName, opts.QueryName.Snake) - content := replacer.Replace(f.String(), Placeholder, replacementImport) - - // Add the service - templateService := ` - // %[2]vResult defines a rpc handler method for Msg%[2]vData. - rpc %[2]vResult(Query%[2]vRequest) returns (Query%[2]vResponse) { - option (google.api.http).get = "/%[3]v/%[4]v/%[5]v_result/{request_id}"; - } - - // Last%[2]vId query the last %[2]v result id - rpc Last%[2]vId(QueryLast%[2]vIdRequest) returns (QueryLast%[2]vIdResponse) { - option (google.api.http).get = "/%[3]v/%[4]v/last_%[5]v_id"; - } -%[1]v` - replacementService := fmt.Sprintf(templateService, Placeholder2, - opts.QueryName.UpperCamel, - opts.AppName, - opts.ModuleName, - opts.QueryName.Snake, - ) - content = replacer.Replace(content, Placeholder2, replacementService) - - // Add the service messages - templateMessage := `message Query%[2]vRequest {int64 request_id = 1;} - -message Query%[2]vResponse { - %[2]vResult result = 1; -} - -message QueryLast%[2]vIdRequest {} - -message QueryLast%[2]vIdResponse {int64 request_id = 1;} - -%[1]v` - replacementMessage := fmt.Sprintf(templateMessage, Placeholder3, opts.QueryName.UpperCamel) - content = replacer.Replace(content, Placeholder3, replacementMessage) - - newFile := genny.NewFileS(path, content) - return r.File(newFile) - } -} - -// Deprecated: This function is no longer maintained. -func protoTxOracleModify(replacer placeholder.Replacer, opts *OracleOptions) genny.RunFn { - return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, "proto", opts.AppName, opts.ModuleName, "tx.proto") - f, err := r.Disk.Find(path) - if err != nil { - return err - } - - content := strings.ReplaceAll(f.String(), ` -import "gogoproto/gogo.proto";`, "") - content = strings.ReplaceAll(content, ` -import "cosmos/base/v1beta1/coin.proto";`, "") - - // Import - templateImport := `import "gogoproto/gogo.proto"; -import "cosmos/base/v1beta1/coin.proto"; -import "%[2]v/%[3]v/%[4]v.proto"; -%[1]v` - replacementImport := fmt.Sprintf(templateImport, PlaceholderProtoTxImport, opts.AppName, opts.ModuleName, opts.QueryName.Snake) - content = replacer.Replace(content, PlaceholderProtoTxImport, replacementImport) - - // RPC - templateRPC := ` rpc %[2]vData(Msg%[2]vData) returns (Msg%[2]vDataResponse); -%[1]v` - replacementRPC := fmt.Sprintf(templateRPC, PlaceholderProtoTxRPC, opts.QueryName.UpperCamel) - content = replacer.Replace(content, PlaceholderProtoTxRPC, replacementRPC) - - templateMessage := `message Msg%[2]vData { - string %[3]v = 1; - uint64 oracle_script_id = 2 [ - (gogoproto.customname) = "OracleScriptID", - (gogoproto.moretags) = "yaml:\"oracle_script_id\"" - ]; - string source_channel = 3; - %[2]vCallData calldata = 4; - uint64 ask_count = 5; - uint64 min_count = 6; - repeated cosmos.base.v1beta1.Coin fee_limit = 7 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; - uint64 prepare_gas = 8; - uint64 execute_gas = 9; - string client_id = 10 [(gogoproto.customname) = "ClientID"]; -} - -message Msg%[2]vDataResponse { -} - -%[1]v` - replacementMessage := fmt.Sprintf(templateMessage, PlaceholderProtoTxMessage, - opts.QueryName.UpperCamel, - opts.MsgSigner.LowerCamel, - ) - content = replacer.Replace(content, PlaceholderProtoTxMessage, replacementMessage) - - newFile := genny.NewFileS(path, content) - return r.File(newFile) - } -} - -// Deprecated: This function is no longer maintained. -func clientCliQueryOracleModify(replacer placeholder.Replacer, opts *OracleOptions) genny.RunFn { - return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, "x", opts.ModuleName, "module/autocli.go") - f, err := r.Disk.Find(path) - if err != nil { - return err - } - - template := `{ - RpcMethod: "%[2]vResult", - Use: "%[3]v-result [request-id]", - Short: "Query the %[2]v result data by id", - PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "request_id"}}, - }, - { - RpcMethod: "Last%[2]vId", - Use: "last-%[3]v-id", - Short: "Query the last request id returned by %[2]v ack packet", - }, - %[1]v` - - replacement := fmt.Sprintf(template, - PlaceholderAutoCLIQuery, - opts.QueryName.UpperCamel, - opts.QueryName.Kebab, - ) - content := replacer.Replace(f.String(), PlaceholderAutoCLIQuery, replacement) - newFile := genny.NewFileS(path, content) - return r.File(newFile) - } -} - -// Deprecated: This function is no longer maintained. -func clientCliTxOracleModify(replacer placeholder.Replacer, opts *OracleOptions) genny.RunFn { - return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, "x", opts.ModuleName, "module/autocli.go") - f, err := r.Disk.Find(path) - if err != nil { - return err - } - - template := `{ - RpcMethod: "%[2]v", - Use: "%[3]v-data [oracle-script-id] [requested-validator-count] [sufficient-validator-count]", - Short: "Make a new %[2]v query request via an existing BandChain oracle script", - PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "oracle_script_id"}, {ProtoField: "ask_count"}, {ProtoField: "min_count"}}, - FlagOptions: map[string]*autocliv1.FlagOptions{ - "source_channel": {Name: "channel", Usage: "The channel id"}, - "calldata": {Name: "calldata", DefaultValue: '{"multiplier": 1000000, symbols: []}', Usage: "Symbols and multiplier used in calling the oracle script"}, - "fee_limit": {Name: "fee-limit", Usage: "The maximum tokens that will be paid to all data source providers"}, - "prepare_gas": {Name: "prepare-gas", DefaultValue: "200000", Usage: "Prepare gas used in fee counting for prepare request"}, - "execute_gas": {Name: "execute-gas", DefaultValue: "200000", Usage: "Execute gas used in fee counting for execute request"}, - }, - }, - -%[1]v` - - replacement := fmt.Sprintf( - template, - PlaceholderAutoCLITx, - opts.QueryName.UpperCamel, - opts.QueryName.Kebab, - ) - content := replacer.Replace(f.String(), PlaceholderAutoCLITx, replacement) - newFile := genny.NewFileS(path, content) - return r.File(newFile) - } -} - -// Deprecated: This function is no longer maintained. -func codecOracleModify(replacer placeholder.Replacer, opts *OracleOptions) genny.RunFn { - return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, "x", opts.ModuleName, "types/codec.go") - f, err := r.Disk.Find(path) - if err != nil { - return err - } - - // Set import if not set yet - replacement := `sdk "github.com/cosmos/cosmos-sdk/types"` - content := replacer.ReplaceOnce(f.String(), Placeholder, replacement) - - // Register the module packet interface - templateInterface := `registry.RegisterImplementations((*sdk.Msg)(nil), - &Msg%[2]vData{}, -) -%[1]v` - replacementInterface := fmt.Sprintf(templateInterface, Placeholder3, opts.QueryName.UpperCamel) - content = replacer.Replace(content, Placeholder3, replacementInterface) - - newFile := genny.NewFileS(path, content) - return r.File(newFile) - } -} - -// Deprecated: This function is no longer maintained. -func packetHandlerOracleModify(replacer placeholder.Replacer, opts *OracleOptions) genny.RunFn { - return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, "x", opts.ModuleName, "oracle.go") - f, err := r.Disk.Find(path) - if err != nil { - return err - } - - // Register the module packet - templateRecv := ` - case types.%[3]vClientIDKey: - var %[2]vResult types.%[3]vResult - if err := obi.Decode(modulePacketData.Result, &%[2]vResult); err != nil { - ack = channeltypes.NewErrorAcknowledgement(err) - return ack, errorsmod.Wrap(sdkerrors.ErrUnknownRequest, - "cannot decode the %[2]v received packet") - } - im.keeper.Set%[3]vResult(ctx, types.OracleRequestID(modulePacketData.RequestID), %[2]vResult) - - // TODO: %[3]v oracle data reception logic -%[1]v` - replacementRegistry := fmt.Sprintf(templateRecv, PlaceholderOracleModuleRecv, - opts.QueryName.LowerCamel, opts.QueryName.UpperCamel) - content := replacer.Replace(f.String(), PlaceholderOracleModuleRecv, replacementRegistry) - - // Register the module packet interface - templateAck := ` - case types.%[3]vClientIDKey: - var %[2]vData types.%[3]vCallData - if err = obi.Decode(data.GetCalldata(), &%[2]vData); err != nil { - return nil, errorsmod.Wrap(err, - "cannot decode the %[2]v oracle acknowledgment packet") - } - im.keeper.SetLast%[3]vID(ctx, requestID) - return &sdk.Result{}, nil -%[1]v` - replacementInterface := fmt.Sprintf(templateAck, PlaceholderOracleModuleAck, - opts.QueryName.LowerCamel, opts.QueryName.UpperCamel) - content = replacer.Replace(content, PlaceholderOracleModuleAck, replacementInterface) - - newFile := genny.NewFileS(path, content) - return r.File(newFile) - } -} diff --git a/ignite/templates/ibc/placeholders.go b/ignite/templates/ibc/placeholders.go index 3b25117e28..ea2fc9077c 100644 --- a/ignite/templates/ibc/placeholders.go +++ b/ignite/templates/ibc/placeholders.go @@ -16,13 +16,6 @@ const ( PlaceholderProtoTxRPC = "// this line is used by starport scaffolding # proto/tx/rpc" PlaceholderProtoTxMessage = "// this line is used by starport scaffolding # proto/tx/message" - // Placeholders for Oracle - PlaceholderProtoTxImport = "// this line is used by starport scaffolding # proto/tx/import" - PlaceholderOraclePacketModuleRecv = "// this line is used by starport scaffolding # oracle/packet/module/recv" - PlaceholderOraclePacketModuleAck = "// this line is used by starport scaffolding # oracle/packet/module/ack" - PlaceholderOracleModuleRecv = "// this line is used by starport scaffolding # oracle/module/recv" - PlaceholderOracleModuleAck = "// this line is used by starport scaffolding # oracle/module/ack" - // Placeholders AutoCLI PlaceholderAutoCLIQuery = "// this line is used by ignite scaffolding # autocli/query" PlaceholderAutoCLITx = "// this line is used by ignite scaffolding # autocli/tx" diff --git a/ignite/templates/module/create/files/ibc/x/{{moduleName}}/module/module_ibc.go.plush b/ignite/templates/module/create/files/ibc/x/{{moduleName}}/module/module_ibc.go.plush index 1cbfc83552..7a2df626ea 100644 --- a/ignite/templates/module/create/files/ibc/x/{{moduleName}}/module/module_ibc.go.plush +++ b/ignite/templates/module/create/files/ibc/x/{{moduleName}}/module/module_ibc.go.plush @@ -149,8 +149,6 @@ func (im IBCModule) OnRecvPacket( ) ibcexported.Acknowledgement { var ack channeltypes.Acknowledgement - // this line is used by starport scaffolding # oracle/packet/module/recv - var modulePacketData types.<%= title(moduleName) %>PacketData if err := modulePacketData.Unmarshal(modulePacket.GetData()); err != nil { return channeltypes.NewErrorAcknowledgement(errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal packet data: %s", err.Error())) @@ -180,8 +178,6 @@ func (im IBCModule) OnAcknowledgementPacket( return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal packet acknowledgement: %v", err) } - // this line is used by starport scaffolding # oracle/packet/module/ack - var modulePacketData types.<%= title(moduleName) %>PacketData if err := modulePacketData.Unmarshal(modulePacket.GetData()); err != nil { return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal packet data: %s", err.Error()) diff --git a/integration/ibc/cmd_ibc_test.go b/integration/ibc/cmd_ibc_test.go index e9c65d33b4..bcb95c2a00 100644 --- a/integration/ibc/cmd_ibc_test.go +++ b/integration/ibc/cmd_ibc_test.go @@ -106,86 +106,6 @@ func TestCreateModuleWithIBC(t *testing.T) { app.EnsureSteady() } -// Deprecated: Oracle functionality is no longer tested. -func TestCreateIBCOracle(t *testing.T) { - t.Skip() // TODO remove in future - var ( - env = envtest.New(t) - app = env.Scaffold("github.com/test/ibcoracle") - ) - - env.Must(env.Exec("create an IBC module", - step.NewSteps(step.New( - step.Exec(envtest.IgniteApp, "s", "module", "--yes", "foo", "--ibc", "--require-registration"), - step.Workdir(app.SourcePath()), - )), - )) - - env.Must(env.Exec("create an IBC module with params", - step.NewSteps(step.New( - step.Exec( - envtest.IgniteApp, - "s", - "module", - "--yes", - "paramsFoo", - "--ibc", - "--params", - "defaultName,isLaunched:bool,minLaunch:uint,maxLaunch:int", - "--require-registration", - ), - step.Workdir(app.SourcePath()), - )), - )) - - env.Must(env.Exec("create the first BandChain oracle integration", - step.NewSteps(step.New( - step.Exec(envtest.IgniteApp, "s", "band", "--yes", "oracleone", "--module", "foo"), - step.Workdir(app.SourcePath()), - )), - )) - - env.Must(env.Exec("create the second BandChain oracle integration", - step.NewSteps(step.New( - step.Exec(envtest.IgniteApp, "s", "band", "--yes", "oracletwo", "--module", "foo"), - step.Workdir(app.SourcePath()), - )), - )) - - env.Must(env.Exec("should prevent creating a BandChain oracle with no module specified", - step.NewSteps(step.New( - step.Exec(envtest.IgniteApp, "s", "band", "--yes", "invalidOracle"), - step.Workdir(app.SourcePath()), - )), - envtest.ExecShouldError(), - )) - - env.Must(env.Exec("should prevent creating a BandChain oracle in a non existent module", - step.NewSteps(step.New( - step.Exec(envtest.IgniteApp, "s", "band", "--yes", "invalidOracle", "--module", "nomodule"), - step.Workdir(app.SourcePath()), - )), - envtest.ExecShouldError(), - )) - - env.Must(env.Exec("create a non-IBC module", - step.NewSteps(step.New( - step.Exec(envtest.IgniteApp, "s", "module", "--yes", "bar", "--params", "name,minLaunch:uint,maxLaunch:int", "--require-registration"), - step.Workdir(app.SourcePath()), - )), - )) - - env.Must(env.Exec("should prevent creating a BandChain oracle in a non IBC module", - step.NewSteps(step.New( - step.Exec(envtest.IgniteApp, "s", "band", "--yes", "invalidOracle", "--module", "bar"), - step.Workdir(app.SourcePath()), - )), - envtest.ExecShouldError(), - )) - - app.EnsureSteady() -} - func TestCreateIBCPacket(t *testing.T) { var ( env = envtest.New(t) diff --git a/readme.md b/readme.md index 5d21467766..80c14f727d 100644 --- a/readme.md +++ b/readme.md @@ -24,7 +24,7 @@ Test Status Lint Status - Discord + Discord ![Ignite CLI](./assets/ignite-cli.png)