-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add fixed fee for creating a new credit class (#351)
- Loading branch information
Showing
23 changed files
with
797 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,3 +190,6 @@ build/ | |
/proto-tools-stamp | ||
/tools-stamp | ||
dist/ | ||
|
||
# pre-commit | ||
.pre-commit-config.yaml |
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
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,40 @@ | ||
syntax = "proto3"; | ||
package cosmos.base.v1beta1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
|
||
option go_package = "github.com/cosmos/cosmos-sdk/types"; | ||
option (gogoproto.goproto_stringer_all) = false; | ||
option (gogoproto.stringer_all) = false; | ||
|
||
// Coin defines a token with a denomination and an amount. | ||
// | ||
// NOTE: The amount field is an Int which implements the custom method | ||
// signatures required by gogoproto. | ||
message Coin { | ||
option (gogoproto.equal) = true; | ||
|
||
string denom = 1; | ||
string amount = 2 [(gogoproto.customtype) = "Int", (gogoproto.nullable) = false]; | ||
} | ||
|
||
// DecCoin defines a token with a denomination and a decimal amount. | ||
// | ||
// NOTE: The amount field is an Dec which implements the custom method | ||
// signatures required by gogoproto. | ||
message DecCoin { | ||
option (gogoproto.equal) = true; | ||
|
||
string denom = 1; | ||
string amount = 2 [(gogoproto.customtype) = "Dec", (gogoproto.nullable) = false]; | ||
} | ||
|
||
// IntProto defines a Protobuf wrapper around an Int object. | ||
message IntProto { | ||
string int = 1 [(gogoproto.customtype) = "Int", (gogoproto.nullable) = false]; | ||
} | ||
|
||
// DecProto defines a Protobuf wrapper around a Dec object. | ||
message DecProto { | ||
string dec = 1 [(gogoproto.customtype) = "Dec", (gogoproto.nullable) = false]; | ||
} |
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,10 @@ | ||
package ecocredit | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
type BankKeeper interface { | ||
BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error | ||
SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error | ||
} |
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,8 @@ | ||
package ecocredit | ||
|
||
const ( | ||
// ModuleName is the module name constant used in many places | ||
ModuleName = "ecocredit" | ||
|
||
DefaultParamspace = ModuleName | ||
) |
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,48 @@ | ||
package ecocredit | ||
|
||
import ( | ||
"fmt" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" | ||
) | ||
|
||
var ( | ||
// TODO: Decide a sensible default value | ||
DefaultCreditClassFeeTokens = sdk.NewInt(10000) | ||
KeyCreditClassFee = []byte("CreditClassFee") | ||
) | ||
|
||
func ParamKeyTable() paramtypes.KeyTable { | ||
return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) | ||
} | ||
|
||
// Implements params.ParamSet | ||
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { | ||
return paramtypes.ParamSetPairs{ | ||
paramtypes.NewParamSetPair(KeyCreditClassFee, &p.CreditClassFee, validateCreditClassFee), | ||
} | ||
} | ||
|
||
func validateCreditClassFee(i interface{}) error { | ||
v, ok := i.(sdk.Coins) | ||
if !ok { | ||
return fmt.Errorf("invalid parameter type: %T", i) | ||
} | ||
|
||
if err := v.Validate(); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func NewParams(creditClassFee sdk.Coins) Params { | ||
return Params{ | ||
CreditClassFee: creditClassFee, | ||
} | ||
} | ||
|
||
func DefaultParams() Params { | ||
return NewParams(sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, DefaultCreditClassFeeTokens))) | ||
} |
Oops, something went wrong.