Skip to content

Commit

Permalink
feat: mint large amount of coins(gov mint) (#709)
Browse files Browse the repository at this point in the history
* feat: implement one time mint

* docs: add changelog

* chore: fix lint error

* chore: reflect pr review

* test: fix failed test case

* refactor: change oneTimeMaxCount to oneTimeLeftCount

* test: fix msg oneTimeMint server test

* refactor: change oneTimeMint to govMint

* docs: update statik

* feat: add govmint query

* feat: restore GovMint in tx.proto in foundation module

* chore: remove leftcount init from genesis.go

* apply pr review

* feat: add gov mint tx for cli

* test: set gov mint left count to 1 for cli test
  • Loading branch information
dudong2 committed Oct 17, 2022
1 parent a389b63 commit 66988a2
Show file tree
Hide file tree
Showing 35 changed files with 1,912 additions and 226 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/wasm) [\#649](https://github.com/line/lbm-sdk/pull/649) fix: wasm module's FIXME in the snapshotter.go file
* (x/ibc) [\#651](https://github.com/line/lbm-sdk/pull/651) feat: update x/ibc to support github.com/cosmos/ibc-go@v3.0.0
* (config) [\#665](https://github.com/line/lbm-sdk/pull/665) remove bech32-cache-size
* (x/foundation) [\#709](https://github.com/line/lbm-sdk/pull/709) add `gov mint` for x/foundation proposal

### Improvements

Expand Down
9 changes: 5 additions & 4 deletions client/docs/statik/statik.go

Large diffs are not rendered by default.

214 changes: 214 additions & 0 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34399,6 +34399,212 @@ paths:
type: string
tags:
- Query
/lbm/foundation/v1/gov_mint:
get:
summary: GovMint queries the left count of gov mint.
operationId: GovMint
responses:
'200':
description: A successful response.
schema:
type: object
properties:
leftCount:
type: integer
format: int64
description: leftCount is the left count of GovMint.
description: QueryGovMintResponse is the Query/GovMint response type.
default:
description: An unexpected error response
schema:
type: object
properties:
error:
type: string
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
type_url:
type: string
description: >-
A URL/resource name that uniquely identifies the type of
the serialized

protocol buffer message. This string must contain at
least

one "/" character. The last segment of the URL's path
must represent

the fully qualified name of the type (as in

`path/google.protobuf.Duration`). The name should be in
a canonical form

(e.g., leading "." is not accepted).


In practice, teams usually precompile into the binary
all types that they

expect it to use in the context of Any. However, for
URLs which use the

scheme `http`, `https`, or no scheme, one can optionally
set up a type

server that maps type URLs to message definitions as
follows:


* If no scheme is provided, `https` is assumed.

* An HTTP GET on the URL must yield a
[google.protobuf.Type][]
value in binary format, or produce an error.
* Applications are allowed to cache lookup results based
on the
URL, or have them precompiled into a binary to avoid any
lookup. Therefore, binary compatibility needs to be preserved
on changes to types. (Use versioned type names to manage
breaking changes.)

Note: this functionality is not currently available in
the official

protobuf release, and it is not used for type URLs
beginning with

type.googleapis.com.


Schemes other than `http`, `https` (or the empty scheme)
might be

used with implementation specific semantics.
value:
type: string
format: byte
description: >-
Must be a valid serialized protocol buffer of the above
specified type.
description: >-
`Any` contains an arbitrary serialized protocol buffer
message along with a

URL that describes the type of the serialized message.


Protobuf library provides support to pack/unpack Any values
in the form

of utility functions or additional generated methods of the
Any type.


Example 1: Pack and unpack a message in C++.

Foo foo = ...;
Any any;
any.PackFrom(foo);
...
if (any.UnpackTo(&foo)) {
...
}

Example 2: Pack and unpack a message in Java.

Foo foo = ...;
Any any = Any.pack(foo);
...
if (any.is(Foo.class)) {
foo = any.unpack(Foo.class);
}

Example 3: Pack and unpack a message in Python.

foo = Foo(...)
any = Any()
any.Pack(foo)
...
if any.Is(Foo.DESCRIPTOR):
any.Unpack(foo)
...

Example 4: Pack and unpack a message in Go

foo := &pb.Foo{...}
any, err := ptypes.MarshalAny(foo)
...
foo := &pb.Foo{}
if err := ptypes.UnmarshalAny(any, foo); err != nil {
...
}

The pack methods provided by protobuf library will by
default use

'type.googleapis.com/full.type.name' as the type URL and the
unpack

methods only use the fully qualified type name after the
last '/'

in the type URL, for example "foo.bar.com/x/y.z" will yield
type

name "y.z".



JSON

====

The JSON representation of an `Any` value uses the regular

representation of the deserialized, embedded message, with
an

additional field `@type` which contains the type URL.
Example:

package google.profile;
message Person {
string first_name = 1;
string last_name = 2;
}

{
"@type": "type.googleapis.com/google.profile.Person",
"firstName": <string>,
"lastName": <string>
}

If the embedded message type is well-known and has a custom
JSON

representation, that representation will be embedded adding
a field

`value` which holds the custom JSON in addition to the
`@type`

field. Example (for message [google.protobuf.Duration][]):

{
"@type": "type.googleapis.com/google.protobuf.Duration",
"value": "1.212s"
}
tags:
- Query
'/lbm/foundation/v1/grants/{grantee}/{msg_type_url}':
get:
summary: 'Returns list of authorizations, granted to the grantee.'
Expand Down Expand Up @@ -68994,6 +69200,14 @@ definitions:
Must be a valid serialized protocol buffer of the above
specified type.
description: QueryFoundationInfoResponse is the Query/FoundationInfo response type.
lbm.foundation.v1.QueryGovMintResponse:
type: object
properties:
leftCount:
type: integer
format: int64
description: leftCount is the left count of GovMint.
description: QueryGovMintResponse is the Query/GovMint response type.
lbm.foundation.v1.QueryGrantsResponse:
type: object
properties:
Expand Down
74 changes: 74 additions & 0 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,7 @@
- [lbm/foundation/v1/event.proto](#lbm/foundation/v1/event.proto)
- [EventExec](#lbm.foundation.v1.EventExec)
- [EventFundTreasury](#lbm.foundation.v1.EventFundTreasury)
- [EventGovMint](#lbm.foundation.v1.EventGovMint)
- [EventGrant](#lbm.foundation.v1.EventGrant)
- [EventLeaveFoundation](#lbm.foundation.v1.EventLeaveFoundation)
- [EventRevoke](#lbm.foundation.v1.EventRevoke)
Expand All @@ -1141,6 +1142,8 @@
- [lbm/foundation/v1/query.proto](#lbm/foundation/v1/query.proto)
- [QueryFoundationInfoRequest](#lbm.foundation.v1.QueryFoundationInfoRequest)
- [QueryFoundationInfoResponse](#lbm.foundation.v1.QueryFoundationInfoResponse)
- [QueryGovMintRequest](#lbm.foundation.v1.QueryGovMintRequest)
- [QueryGovMintResponse](#lbm.foundation.v1.QueryGovMintResponse)
- [QueryGrantsRequest](#lbm.foundation.v1.QueryGrantsRequest)
- [QueryGrantsResponse](#lbm.foundation.v1.QueryGrantsResponse)
- [QueryMemberRequest](#lbm.foundation.v1.QueryMemberRequest)
Expand Down Expand Up @@ -1169,6 +1172,8 @@
- [MsgExecResponse](#lbm.foundation.v1.MsgExecResponse)
- [MsgFundTreasury](#lbm.foundation.v1.MsgFundTreasury)
- [MsgFundTreasuryResponse](#lbm.foundation.v1.MsgFundTreasuryResponse)
- [MsgGovMint](#lbm.foundation.v1.MsgGovMint)
- [MsgGovMintResponse](#lbm.foundation.v1.MsgGovMintResponse)
- [MsgGrant](#lbm.foundation.v1.MsgGrant)
- [MsgGrantResponse](#lbm.foundation.v1.MsgGrantResponse)
- [MsgLeaveFoundation](#lbm.foundation.v1.MsgLeaveFoundation)
Expand Down Expand Up @@ -17094,6 +17099,21 @@ EventFundTreasury is an event emitted when one funds the treasury.



<a name="lbm.foundation.v1.EventGovMint"></a>

### EventGovMint
EventGovMint is an event emitted when the minter mint coins to the treasury.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | |






<a name="lbm.foundation.v1.EventGrant"></a>

### EventGrant
Expand Down Expand Up @@ -17281,6 +17301,7 @@ GenesisState defines the foundation module's genesis state.
| `votes` | [Vote](#lbm.foundation.v1.Vote) | repeated | votes is the list of votes. |
| `authorizations` | [GrantAuthorization](#lbm.foundation.v1.GrantAuthorization) | repeated | grants |
| `pool` | [Pool](#lbm.foundation.v1.Pool) | | pool |
| `govMintLeftCount` | [uint32](#uint32) | | govMintLeftCount is gov mint max count |



Expand Down Expand Up @@ -17344,6 +17365,31 @@ QueryFoundationInfoResponse is the Query/FoundationInfo response type.



<a name="lbm.foundation.v1.QueryGovMintRequest"></a>

### QueryGovMintRequest
QueryGovMintRequest is the Query/GovMint request type.






<a name="lbm.foundation.v1.QueryGovMintResponse"></a>

### QueryGovMintResponse
QueryGovMintResponse is the Query/GovMint response type.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `leftCount` | [uint32](#uint32) | | leftCount is the left count of GovMint. |






<a name="lbm.foundation.v1.QueryGrantsRequest"></a>

### QueryGrantsRequest
Expand Down Expand Up @@ -17668,6 +17714,7 @@ Query defines the gRPC querier service for foundation module.
| `Votes` | [QueryVotesRequest](#lbm.foundation.v1.QueryVotesRequest) | [QueryVotesResponse](#lbm.foundation.v1.QueryVotesResponse) | Votes queries a vote by proposal. | GET|/lbm/foundation/v1/proposals/{proposal_id}/votes|
| `TallyResult` | [QueryTallyResultRequest](#lbm.foundation.v1.QueryTallyResultRequest) | [QueryTallyResultResponse](#lbm.foundation.v1.QueryTallyResultResponse) | TallyResult queries the tally of a proposal votes. | GET|/lbm/foundation/v1/proposals/{proposal_id}/tally|
| `Grants` | [QueryGrantsRequest](#lbm.foundation.v1.QueryGrantsRequest) | [QueryGrantsResponse](#lbm.foundation.v1.QueryGrantsResponse) | Returns list of authorizations, granted to the grantee. | GET|/lbm/foundation/v1/grants/{grantee}/{msg_type_url}|
| `GovMint` | [QueryGovMintRequest](#lbm.foundation.v1.QueryGovMintRequest) | [QueryGovMintResponse](#lbm.foundation.v1.QueryGovMintResponse) | GovMint queries the left count of gov mint. | GET|/lbm/foundation/v1/gov_mint|

<!-- end services -->

Expand Down Expand Up @@ -17732,6 +17779,32 @@ MsgFundTreasuryResponse defines the Msg/FundTreasury response type.



<a name="lbm.foundation.v1.MsgGovMint"></a>

### MsgGovMint
MsgGovMint represents a message to mint coins to the treasury.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `operator` | [string](#string) | | |
| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | |






<a name="lbm.foundation.v1.MsgGovMintResponse"></a>

### MsgGovMintResponse
MsgGovMintResponse defines the Msg/GovMint response type.






<a name="lbm.foundation.v1.MsgGrant"></a>

### MsgGrant
Expand Down Expand Up @@ -18016,6 +18089,7 @@ Msg defines the foundation Msg service.
| `LeaveFoundation` | [MsgLeaveFoundation](#lbm.foundation.v1.MsgLeaveFoundation) | [MsgLeaveFoundationResponse](#lbm.foundation.v1.MsgLeaveFoundationResponse) | LeaveFoundation allows a member to leave the foundation. | |
| `Grant` | [MsgGrant](#lbm.foundation.v1.MsgGrant) | [MsgGrantResponse](#lbm.foundation.v1.MsgGrantResponse) | Grant grants the provided authorization to the grantee with authority of the foundation. If there is already a grant for the given (granter, grantee, Authorization) tuple, then the grant will be overwritten. | |
| `Revoke` | [MsgRevoke](#lbm.foundation.v1.MsgRevoke) | [MsgRevokeResponse](#lbm.foundation.v1.MsgRevokeResponse) | Revoke revokes any authorization corresponding to the provided method name on the granter that has been granted to the grantee. | |
| `GovMint` | [MsgGovMint](#lbm.foundation.v1.MsgGovMint) | [MsgGovMintResponse](#lbm.foundation.v1.MsgGovMintResponse) | GovMint defines a gov mint coins to the treasury. | |

<!-- end services -->

Expand Down
6 changes: 6 additions & 0 deletions proto/lbm/foundation/v1/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,9 @@ message EventRevoke {
// message type url for which an autorization is revoked.
string msg_type_url = 3;
}

// EventGovMint is an event emitted when the minter mint coins to the treasury.
message EventGovMint {
repeated cosmos.base.v1beta1.Coin amount = 1
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/line/lbm-sdk/types.Coins"];
}
3 changes: 3 additions & 0 deletions proto/lbm/foundation/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ message GenesisState {

// pool
Pool pool = 8 [(gogoproto.nullable) = false];

// govMintLeftCount is gov mint max count
uint32 govMintLeftCount = 9;
}

// GrantAuthorization defines authorization grant to grantee via route.
Expand Down
Loading

0 comments on commit 66988a2

Please sign in to comment.