-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/bianjieai/nft-transfer into…
… dreamer/fix-class-id
- Loading branch information
Showing
13 changed files
with
452 additions
and
36 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
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package keeper | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/bianjieai/nft-transfer/types" | ||
) | ||
|
||
// GetSendEnabled retrieves the send enabled boolean from the paramstore | ||
func (k Keeper) GetSendEnabled(ctx sdk.Context) bool { | ||
var res bool | ||
k.paramSpace.Get(ctx, types.KeySendEnabled, &res) | ||
return res | ||
} | ||
|
||
// GetReceiveEnabled retrieves the receive enabled boolean from the paramstore | ||
func (k Keeper) GetReceiveEnabled(ctx sdk.Context) bool { | ||
var res bool | ||
k.paramSpace.Get(ctx, types.KeyReceiveEnabled, &res) | ||
return res | ||
} | ||
|
||
// GetParams returns the total set of ibc-transfer parameters. | ||
func (k Keeper) GetParams(ctx sdk.Context) types.Params { | ||
return types.NewParams(k.GetSendEnabled(ctx), k.GetReceiveEnabled(ctx)) | ||
} | ||
|
||
// SetParams sets the total set of ibc-transfer parameters. | ||
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { | ||
k.paramSpace.SetParamSet(ctx, ¶ms) | ||
} |
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package types | ||
|
||
import ( | ||
"fmt" | ||
|
||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" | ||
) | ||
|
||
const ( | ||
// DefaultSendEnabled enabled | ||
DefaultSendEnabled = true | ||
// DefaultReceiveEnabled enabled | ||
DefaultReceiveEnabled = true | ||
) | ||
|
||
var ( | ||
// KeySendEnabled is store's key for SendEnabled Params | ||
KeySendEnabled = []byte("SendEnabled") | ||
// KeyReceiveEnabled is store's key for ReceiveEnabled Params | ||
KeyReceiveEnabled = []byte("ReceiveEnabled") | ||
) | ||
|
||
// ParamKeyTable type declaration for parameters | ||
func ParamKeyTable() paramtypes.KeyTable { | ||
return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) | ||
} | ||
|
||
// NewParams creates a new parameter configuration for the ibc transfer module | ||
func NewParams(enableSend, enableReceive bool) Params { | ||
return Params{ | ||
SendEnabled: enableSend, | ||
ReceiveEnabled: enableReceive, | ||
} | ||
} | ||
|
||
// DefaultParams is the default parameter configuration for the ibc-transfer module | ||
func DefaultParams() Params { | ||
return NewParams(DefaultSendEnabled, DefaultReceiveEnabled) | ||
} | ||
|
||
// Validate all ibc-transfer module parameters | ||
func (p Params) Validate() error { | ||
if err := validateEnabled(p.SendEnabled); err != nil { | ||
return err | ||
} | ||
|
||
return validateEnabled(p.ReceiveEnabled) | ||
} | ||
|
||
// ParamSetPairs implements params.ParamSet | ||
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { | ||
return paramtypes.ParamSetPairs{ | ||
paramtypes.NewParamSetPair(KeySendEnabled, p.SendEnabled, validateEnabled), | ||
paramtypes.NewParamSetPair(KeyReceiveEnabled, p.ReceiveEnabled, validateEnabled), | ||
} | ||
} | ||
|
||
func validateEnabled(i interface{}) error { | ||
_, ok := i.(bool) | ||
if !ok { | ||
return fmt.Errorf("invalid parameter type: %T", i) | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.