Skip to content

Commit

Permalink
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/add-msg-s…
Browse files Browse the repository at this point in the history
…rvr-code
  • Loading branch information
atheeshp committed Nov 15, 2023
2 parents da671f1 + e269c6d commit fe857a2
Show file tree
Hide file tree
Showing 7 changed files with 4,375 additions and 257 deletions.
2,859 changes: 2,783 additions & 76 deletions api/cosmos/protocolpool/v1/tx.pulsar.go

Large diffs are not rendered by default.

78 changes: 78 additions & 0 deletions api/cosmos/protocolpool/v1/tx_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
## [Unreleased]

* [#18379](https://github.com/cosmos/cosmos-sdk/pull/18379) Add branch service.
* [#18457](https://github.com/cosmos/cosmos-sdk/pull/18457) Add branch.ExecuteWithGasLimit.

## [v0.12.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.11.0)

Expand Down
17 changes: 16 additions & 1 deletion core/branch/branch.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
// Package branch contains the core branch service interface.
package branch

import "context"
import (
"context"
"errors"
)

// ErrGasLimitExceeded is returned when the gas limit is exceeded in a
// Service.ExecuteWithGasLimit call.
var ErrGasLimitExceeded = errors.New("branch: gas limit exceeded")

// Service is the branch service interface. It can be used to execute
// code paths in an isolated execution context that can be reverted.
Expand All @@ -16,4 +23,12 @@ type Service interface {
// passed to the Execute function, and is what should be used with other
// core services in order to ensure the execution remains isolated.
Execute(ctx context.Context, f func(ctx context.Context) error) error
// ExecuteWithGasLimit executes the given function `f` in an isolated context,
// with the provided gas limit, this is advanced usage and is used to disallow
// an execution path to consume an indefinite amount of gas.
// If the execution fails or succeeds the gas limit is still applied to the
// parent context, the function returns a gasUsed value which is the amount
// of gas used by the execution path. If the execution path exceeds the gas
// ErrGasLimitExceeded is returned.
ExecuteWithGasLimit(ctx context.Context, gasLimit uint64, f func(ctx context.Context) error) (gasUsed uint64, err error)
}
73 changes: 66 additions & 7 deletions proto/cosmos/protocolpool/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ service Msg {

// ClaimBudget defines a method to claim the distributed budget.
rpc ClaimBudget(MsgClaimBudget) returns (MsgClaimBudgetResponse);

// CreateContinuousFund defines a method to add funds continuously.
rpc CreateContinuousFund(MsgCreateContinuousFund) returns (MsgCreateContinuousFundResponse);

// CancelContinuousFund defines a method for cancelling continuous fund.
rpc CancelContinuousFund(MsgCancelContinuousFund) returns (MsgCancelContinuousFundResponse);
}

// MsgFundCommunityPool allows an account to directly
Expand All @@ -52,7 +58,7 @@ message MsgFundCommunityPoolResponse {}
message MsgCommunityPoolSpend {
option (cosmos.msg.v1.signer) = "authority";

// authority is the address that controls the module (defaults to x/gov unless overwritten).
// Authority is the address that controls the module (defaults to x/gov unless overwritten).
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string recipient = 2;
repeated cosmos.base.v1beta1.Coin amount = 3
Expand All @@ -67,16 +73,16 @@ message MsgCommunityPoolSpendResponse {}
message MsgSubmitBudgetProposal {
option (cosmos.msg.v1.signer) = "authority";

// authority is the address that controls the module (defaults to x/gov unless overwritten).
// Authority is the address that controls the module (defaults to x/gov unless overwritten).
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// recipient_address is the address of the recipient who can claim the budget.
// RecipientAddress is the address of the recipient who can claim the budget.
string recipient_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// total_budget is the total amount allocated for the budget.
// TotalBudget is the total amount allocated for the budget.
cosmos.base.v1beta1.Coin total_budget = 3;
// start_time is the time when the budget becomes claimable.
// If start_time is less than the current block time, proposal will not be accepted.
// StartTime is the time when the budget becomes claimable.
// If StartTime is less than the current block time, proposal will not be accepted.
google.protobuf.Timestamp start_time = 4 [(gogoproto.stdtime) = true];
// tranches is the number of times the total budget amount is to be distributed.
// Tranches is the number of times the total budget amount is to be distributed.
uint64 tranches = 5;
// Period is the time interval(number of seconds) at which funds distribution should be performed.
// For example, if a period is set to 3600, it represents an action that
Expand All @@ -101,3 +107,56 @@ message MsgClaimBudgetResponse {
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
;
}

// MsgCreateContinuousFund defines a message for adding continuous funds.
message MsgCreateContinuousFund {
option (cosmos.msg.v1.signer) = "authority";

// Title is the title of the funds.
string title = 1;
// Description of the funds.
string description = 2;
// Authority is the address that controls the module (defaults to x/gov unless overwritten).
string authority = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Recipient address of the account receiving funds.
string recipient = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Metadata is any arbitrary metadata attached.
string metadata = 5;
// Percentage is the percentage of funds to be allocated from Community pool share on block by block,
// till the `cap` is reached or expired.
string percentage = 6 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
// Cap is the capital amount, which when its met funds are no longer distributed.
repeated cosmos.base.v1beta1.Coin cap = 7
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
// Optional, if expiry is set, removes the state object when expired.
google.protobuf.Timestamp expiry = 8 [(gogoproto.stdtime) = true];
}

// MsgCreateContinuousFundResponse defines the response to executing a
// MsgCreateContinuousFund message.
message MsgCreateContinuousFundResponse {}

// MsgCancelContinuousFund defines a message to cancel continuous funds for a specific recipient.
message MsgCancelContinuousFund {
option (cosmos.msg.v1.signer) = "authority";

// Authority is the account address of authority.
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// RecipientAddress is the account address of recipient whose funds are to be cancelled.
string recipient_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgCancelContinuousFundResponse defines the response to executing a
// MsgCancelContinuousFund message.
message MsgCancelContinuousFundResponse {
// CanceledTime is the canceled time.
google.protobuf.Timestamp canceled_time = 1 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
// CanceledHeight defines the canceled block height.
uint64 canceled_height = 2;
// RecipientAddress is the account address of recipient whose funds are cancelled.
string recipient_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
8 changes: 8 additions & 0 deletions x/protocolpool/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ func (k MsgServer) CommunityPoolSpend(ctx context.Context, msg *types.MsgCommuni
return &types.MsgCommunityPoolSpendResponse{}, nil
}

func (k MsgServer) CreateContinuousFund(ctx context.Context, msg *types.MsgCreateContinuousFund) (*types.MsgCreateContinuousFundResponse, error) {
return &types.MsgCreateContinuousFundResponse{}, nil
}

func (k MsgServer) CancelContinuousFund(ctx context.Context, msg *types.MsgCancelContinuousFund) (*types.MsgCancelContinuousFundResponse, error) {
return &types.MsgCancelContinuousFundResponse{}, nil
}

func (k *Keeper) validateAuthority(authority string) error {
if _, err := k.authKeeper.AddressCodec().StringToBytes(authority); err != nil {
return sdkerrors.ErrInvalidAddress.Wrapf("invalid authority address: %s", err)
Expand Down
Loading

0 comments on commit fe857a2

Please sign in to comment.