forked from xrplevm/node
-
Notifications
You must be signed in to change notification settings - Fork 0
feat(poa): added minting and burning messages #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
JordiParraCrespo
merged 17 commits into
main
from
x/poa/feat/add-minting-burning-messages
Jun 8, 2026
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
9a2d81e
feat(poa): added minting and burning messages
aluque-peersyst 798109a
fix(minting): correct linting error
aluque-peersyst c9f6317
fix(poa): change address declaration
aluque-peersyst 14c3b7c
feat: ensure gas price is 0
aluque-peersyst 5e777f0
fix: extract mint and burn into separate package
aluque-peersyst d5857c3
fix(cbdc): guard against nil amount in mint/burn
aluque-peersyst 1092949
fix(cbdc): address review feedback on mint/burn module
aluque-peersyst 46ae86f
fix: lint error
aluque-peersyst 74dd1d0
fix: change address type for burn and mint
aluque-peersyst 059a5ce
refactor: rename mint and burn operations
aluque-peersyst 2c5bd07
feat(cbdc): make mint/burn owner an on-chain rotatable param
aluque-peersyst 9136339
feat(cbdc): add owner-valid invariant for params owner
aluque-peersyst 1539125
feat(cbdc): guard mint with BlockedAddr and IsSendEnabledCoin checks
aluque-peersyst f1048d3
feat(cbdc): require non-empty mint/burn owner in params
aluque-peersyst 0a851ac
refactor(cbdc): extract mintingAllowed/burningAllowed pre-flight checks
aluque-peersyst fb466c7
feat(cbdc): add gov-controlled issuance_paused switch
aluque-peersyst e9eaff7
fix(cbdc): re-check owner inside keeper mint/burn
aluque-peersyst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 @@ | ||
| syntax = "proto3"; | ||
| package cbdc; | ||
|
|
||
| import "gogoproto/gogo.proto"; | ||
| import "cbdc/params.proto"; | ||
|
|
||
| option go_package = "github.com/peersyst/cbdc-node/x/cbdc/types"; | ||
|
|
||
| // GenesisState defines the cbdc module's genesis state. | ||
| message GenesisState { Params params = 1 [ (gogoproto.nullable) = false ]; } |
This file contains hidden or 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,19 @@ | ||
| syntax = "proto3"; | ||
| package cbdc; | ||
|
|
||
| import "cosmos_proto/cosmos.proto"; | ||
|
|
||
| option go_package = "github.com/peersyst/cbdc-node/x/cbdc/types"; | ||
|
|
||
| // Params defines the parameters for the module. | ||
| message Params { | ||
| // owner is the address allowed to mint/burn CBDC tokens. It can be rotated | ||
| // on-chain via a governance MsgUpdateParams proposal. | ||
| string owner = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
| // issuance_paused, when true, stops both minting and burning. It is a | ||
| // gov-controlled emergency switch independent of the owner: only the gov | ||
| // authority can toggle it (via MsgUpdateParams), so mint/burn can be halted | ||
| // even if the owner key is compromised. It does not affect params updates or | ||
| // queries. | ||
| bool issuance_paused = 2; | ||
| } |
This file contains hidden or 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,25 @@ | ||
| syntax = "proto3"; | ||
| package cbdc; | ||
|
|
||
| import "gogoproto/gogo.proto"; | ||
| import "google/api/annotations.proto"; | ||
| import "cbdc/params.proto"; | ||
|
|
||
| option go_package = "github.com/peersyst/cbdc-node/x/cbdc/types"; | ||
|
|
||
| // Query defines the gRPC querier service. | ||
| service Query { | ||
|
JordiParraCrespo marked this conversation as resolved.
|
||
| // Parameters queries the parameters of the module. | ||
| rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { | ||
| option (google.api.http).get = "/cbdc/cbdc/params"; | ||
| } | ||
| } | ||
|
|
||
| // QueryParamsRequest is request type for the Query/Params RPC method. | ||
| message QueryParamsRequest {} | ||
|
|
||
| // QueryParamsResponse is response type for the Query/Params RPC method. | ||
| message QueryParamsResponse { | ||
| // params holds all the parameters of this module. | ||
| Params params = 1 [ (gogoproto.nullable) = false ]; | ||
| } | ||
This file contains hidden or 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,61 @@ | ||
| syntax = "proto3"; | ||
| package cbdc; | ||
|
|
||
| import "gogoproto/gogo.proto"; | ||
| import "cosmos_proto/cosmos.proto"; | ||
| import "cosmos/msg/v1/msg.proto"; | ||
| import "cosmos/base/v1beta1/coin.proto"; | ||
| import "amino/amino.proto"; | ||
|
JordiParraCrespo marked this conversation as resolved.
|
||
| import "cbdc/params.proto"; | ||
|
|
||
| option go_package = "github.com/peersyst/cbdc-node/x/cbdc/types"; | ||
|
|
||
| // Msg defines the Msg service. | ||
| service Msg { | ||
|
aluque-peersyst marked this conversation as resolved.
|
||
| option (cosmos.msg.v1.service) = true; | ||
|
|
||
| // Mints CBDC tokens and sends them to an address | ||
| rpc Mint(MsgMint) returns (MsgMintResponse); | ||
| // Burns CBDC tokens from an address | ||
| rpc Burn(MsgBurn) returns (MsgBurnResponse); | ||
| // Updates the module params. Only the governance authority can call it. | ||
| rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); | ||
| } | ||
|
|
||
| // MsgMint defines a message to mint CBDC tokens and send them to an address | ||
| message MsgMint { | ||
|
aluque-peersyst marked this conversation as resolved.
|
||
| option (cosmos.msg.v1.signer) = "owner"; | ||
|
|
||
| string owner = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
| string address = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
| cosmos.base.v1beta1.Coin amount = 3 | ||
| [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; | ||
| } | ||
| // MsgMintResponse defines the response for minting CBDC tokens | ||
| message MsgMintResponse {} | ||
|
|
||
| // MsgBurn defines a message to burn CBDC tokens from an address | ||
| message MsgBurn { | ||
| option (cosmos.msg.v1.signer) = "owner"; | ||
|
|
||
| string owner = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
| string address = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
| cosmos.base.v1beta1.Coin amount = 3 | ||
| [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; | ||
| } | ||
| // MsgBurnResponse defines the response for burning CBDC tokens | ||
| message MsgBurnResponse {} | ||
|
|
||
| // MsgUpdateParams defines a message to update the module params | ||
| message MsgUpdateParams { | ||
| option (cosmos.msg.v1.signer) = "authority"; | ||
|
|
||
| // authority is the address that controls the module params (defaults to the | ||
| // gov module account) | ||
| string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
| // params defines the module parameters to update | ||
| Params params = 2 | ||
| [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; | ||
| } | ||
| // MsgUpdateParamsResponse defines the response for updating the module params | ||
| message MsgUpdateParamsResponse {} | ||
This file contains hidden or 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 hidden or 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 hidden or 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,56 @@ | ||
| package keeper | ||
|
|
||
| import ( | ||
| sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
|
||
| "github.com/peersyst/cbdc-node/x/cbdc/types" | ||
| ) | ||
|
|
||
| // burningAllowed performs all pre-flight gating for a burn, including the owner | ||
| // authorization check so the keeper cannot be burned from by any caller that | ||
| // bypasses the msg server. The address param is kept for symmetry with | ||
| // mintingAllowed and for future address-based gating. | ||
| func (k Keeper) burningAllowed(ctx sdk.Context, owner string, _ sdk.AccAddress, amount sdk.Coin) error { | ||
| params := k.GetParams(ctx) | ||
| if owner != params.Owner { | ||
| return types.ErrUnauthorized | ||
| } | ||
| if params.IssuancePaused { | ||
| return types.ErrIssuancePaused | ||
| } | ||
| if err := amount.Validate(); err != nil { | ||
| return err | ||
| } | ||
| if amount.Denom != k.cbdcDenom { | ||
| return types.ErrInvalidDenom | ||
| } | ||
| if !amount.IsPositive() { | ||
| return types.ErrInvalidAmount | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (k Keeper) BurnCoins(ctx sdk.Context, owner string, address sdk.AccAddress, amount sdk.Coin) error { | ||
| if err := k.burningAllowed(ctx, owner, address, amount); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| coins := sdk.NewCoins(amount) | ||
| if err := k.bk.SendCoinsFromAccountToModule(ctx, address, types.ModuleName, coins); err != nil { | ||
| return err | ||
| } | ||
| if err := k.bk.BurnCoins(ctx, types.ModuleName, coins); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| ctx.EventManager().EmitEvent( | ||
| sdk.NewEvent( | ||
| types.EventTypeBurn, | ||
| sdk.NewAttribute(types.AttributeOwner, owner), | ||
| sdk.NewAttribute(types.AttributeAddress, address.String()), | ||
| sdk.NewAttribute(types.AttributeAmount, amount.String()), | ||
| ), | ||
| ) | ||
|
|
||
| return nil | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.