Skip to content

Commit

Permalink
refactor: revisit foundation operator (#744)
Browse files Browse the repository at this point in the history
* Use more abstracted field name instead of operator

* Update the field names in the logic

* Remove operator field from FoundationInfo

* Remove operator from the state

* Update x/foundation/README.md

* Update CHANGELOG.md

* Lint

* Increase coverage

* Lint

* Mind consistency

* Chore
  • Loading branch information
0Tech authored Oct 21, 2022
1 parent 4fcf985 commit fee8f64
Show file tree
Hide file tree
Showing 32 changed files with 622 additions and 722 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/wasm) [\#695](https://github.com/line/lbm-sdk/pull/695) fix to prevent external filesystem dependency of simulation
* (x/foundation) [\#729](https://github.com/line/lbm-sdk/pull/729) add UpdateParams to x/foundation
* (amino) [\#736](https://github.com/line/lbm-sdk/pull/736) apply the missing amino codec registratoin of cosmos-sdk
* (x/foundation) [\#744](https://github.com/line/lbm-sdk/pull/744) revisit foundation operator

### Bug Fixes
* (x/wasm) [\#453](https://github.com/line/lbm-sdk/pull/453) modify wasm grpc query api path
Expand Down
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

11 changes: 0 additions & 11 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33584,11 +33584,6 @@ paths:
description: info is the FoundationInfo for the foundation.
type: object
properties:
operator:
type: string
description: >-
operator is the account address of the foundation's
operator.
version:
type: string
format: uint64
Expand Down Expand Up @@ -68691,9 +68686,6 @@ definitions:
lbm.foundation.v1.FoundationInfo:
type: object
properties:
operator:
type: string
description: operator is the account address of the foundation's operator.
version:
type: string
format: uint64
Expand Down Expand Up @@ -69116,9 +69108,6 @@ definitions:
description: info is the FoundationInfo for the foundation.
type: object
properties:
operator:
type: string
description: operator is the account address of the foundation's operator.
version:
type: string
format: uint64
Expand Down
19 changes: 9 additions & 10 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -16807,7 +16807,6 @@ FoundationInfo represents the high-level on-chain information for the foundation

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `operator` | [string](#string) | | operator is the account address of the foundation's operator. |
| `version` | [uint64](#uint64) | | version is used to track changes to the foundation's membership structure that would break existing proposals. Whenever any member is added or removed, this version is incremented and will cause proposals based on older versions of the foundation to fail |
| `total_weight` | [string](#string) | | total_weight is the number of the foundation members. |
| `decision_policy` | [google.protobuf.Any](#google.protobuf.Any) | | decision_policy specifies the foundation's decision policy. |
Expand Down Expand Up @@ -16857,7 +16856,7 @@ since this field cannot be set as part of requests.

### OutsourcingDecisionPolicy
OutsourcingDecisionPolicy is a dummy decision policy which is set after
the operator has been updated into x/group's group policy.
the proposal feature has been outsourced to x/group.


| Field | Type | Label | Description |
Expand Down Expand Up @@ -17242,7 +17241,7 @@ EventVote is an event emitted when a voter votes on a proposal.
<a name="lbm.foundation.v1.EventWithdrawFromTreasury"></a>

### EventWithdrawFromTreasury
EventWithdrawFromTreasury is an event emitted when the operator withdraws coins from the treasury.
EventWithdrawFromTreasury is an event emitted when coins are withdrawn from the treasury.


| Field | Type | Label | Description |
Expand Down Expand Up @@ -17788,7 +17787,7 @@ MsgGovMint is the Msg/GovMint request type.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `operator` | [string](#string) | | |
| `authority` | [string](#string) | | authority is the address of the privileged account. |
| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | |


Expand All @@ -17815,7 +17814,7 @@ on behalf of the foundation.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `operator` | [string](#string) | | |
| `authority` | [string](#string) | | authority is the address of the privileged account. |
| `grantee` | [string](#string) | | |
| `authorization` | [google.protobuf.Any](#google.protobuf.Any) | | |

Expand Down Expand Up @@ -17867,7 +17866,7 @@ MsgRevoke is the Msg/Revoke request type.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `operator` | [string](#string) | | |
| `authority` | [string](#string) | | authority is the address of the privileged account. |
| `grantee` | [string](#string) | | |
| `msg_type_url` | [string](#string) | | |

Expand Down Expand Up @@ -17927,7 +17926,7 @@ MsgUpdateDecisionPolicy is the Msg/UpdateDecisionPolicy request type.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `operator` | [string](#string) | | operator is the account address of the foundation operator. |
| `authority` | [string](#string) | | authority is the address of the privileged account. |
| `decision_policy` | [google.protobuf.Any](#google.protobuf.Any) | | decision_policy is the updated decision policy. |


Expand All @@ -17953,7 +17952,7 @@ MsgUpdateMembers is the Msg/UpdateMembers request type.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `operator` | [string](#string) | | operator is the account address of the foundation operator. |
| `authority` | [string](#string) | | authority is the address of the privileged account. |
| `member_updates` | [MemberRequest](#lbm.foundation.v1.MemberRequest) | repeated | member_updates is the list of members to update, set remove to true to remove a member. |


Expand All @@ -17979,7 +17978,7 @@ MsgUpdateParams is the Msg/UpdateParams request type.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `authority` | [string](#string) | | authority is the address of the operator account. |
| `authority` | [string](#string) | | authority is the address of the privileged account. |
| `params` | [Params](#lbm.foundation.v1.Params) | | params defines the x/foundation parameters to update.

NOTE: All parameters must be supplied. |
Expand Down Expand Up @@ -18036,7 +18035,7 @@ MsgWithdrawFromTreasury is the Msg/WithdrawFromTreasury request type.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `operator` | [string](#string) | | |
| `authority` | [string](#string) | | authority is the address of the privileged account. |
| `to` | [string](#string) | | |
| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | |

Expand Down
2 changes: 1 addition & 1 deletion proto/lbm/foundation/v1/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ message EventFundTreasury {
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/line/lbm-sdk/types.Coins"];
}

// EventWithdrawFromTreasury is an event emitted when the operator withdraws coins from the treasury.
// EventWithdrawFromTreasury is an event emitted when coins are withdrawn from the treasury.
message EventWithdrawFromTreasury {
string to = 1;
repeated cosmos.base.v1beta1.Coin amount = 2
Expand Down
11 changes: 4 additions & 7 deletions proto/lbm/foundation/v1/foundation.proto
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ message DecisionPolicyWindows {
}

// OutsourcingDecisionPolicy is a dummy decision policy which is set after
// the operator has been updated into x/group's group policy.
// the proposal feature has been outsourced to x/group.
message OutsourcingDecisionPolicy {
option (cosmos_proto.implements_interface) = "DecisionPolicy";

Expand All @@ -124,20 +124,17 @@ enum VoteOption {
message FoundationInfo {
option (gogoproto.goproto_getters) = false;

// operator is the account address of the foundation's operator.
string operator = 1;

// version is used to track changes to the foundation's membership structure that
// would break existing proposals. Whenever any member is added or removed,
// this version is incremented and will cause proposals based on older versions
// of the foundation to fail
uint64 version = 2;
uint64 version = 1;

// total_weight is the number of the foundation members.
string total_weight = 3 [(gogoproto.nullable) = false, (gogoproto.customtype) = "github.com/line/lbm-sdk/types.Dec"];
string total_weight = 2 [(gogoproto.nullable) = false, (gogoproto.customtype) = "github.com/line/lbm-sdk/types.Dec"];

// decision_policy specifies the foundation's decision policy.
google.protobuf.Any decision_policy = 4 [(cosmos_proto.accepts_interface) = "DecisionPolicy"];
google.protobuf.Any decision_policy = 3 [(cosmos_proto.accepts_interface) = "DecisionPolicy"];
}

// Proposal defines a foundation proposal. Any member of the foundation can submit a proposal
Expand Down
24 changes: 14 additions & 10 deletions proto/lbm/foundation/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ service Msg {

// MsgUpdateParams is the Msg/UpdateParams request type.
message MsgUpdateParams {
// authority is the address of the operator account.
// authority is the address of the privileged account.
string authority = 1;

// params defines the x/foundation parameters to update.
Expand All @@ -85,7 +85,8 @@ message MsgFundTreasuryResponse {}

// MsgWithdrawFromTreasury is the Msg/WithdrawFromTreasury request type.
message MsgWithdrawFromTreasury {
string operator = 1;
// authority is the address of the privileged account.
string authority = 1;
string to = 2;
repeated cosmos.base.v1beta1.Coin amount = 3
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/line/lbm-sdk/types.Coins"];
Expand All @@ -96,8 +97,8 @@ message MsgWithdrawFromTreasuryResponse {}

// MsgUpdateMembers is the Msg/UpdateMembers request type.
message MsgUpdateMembers {
// operator is the account address of the foundation operator.
string operator = 1;
// authority is the address of the privileged account.
string authority = 1;

// member_updates is the list of members to update,
// set remove to true to remove a member.
Expand All @@ -109,8 +110,8 @@ message MsgUpdateMembersResponse {}

// MsgUpdateDecisionPolicy is the Msg/UpdateDecisionPolicy request type.
message MsgUpdateDecisionPolicy {
// operator is the account address of the foundation operator.
string operator = 1;
// authority is the address of the privileged account.
string authority = 1;

// decision_policy is the updated decision policy.
google.protobuf.Any decision_policy = 2 [(cosmos_proto.accepts_interface) = "DecisionPolicy"];
Expand Down Expand Up @@ -214,8 +215,9 @@ message MsgLeaveFoundationResponse {}
// MsgGrant is the Msg/Grant request type.
// on behalf of the foundation.
message MsgGrant {
string operator = 1;
string grantee = 2;
// authority is the address of the privileged account.
string authority = 1;
string grantee = 2;

google.protobuf.Any authorization = 3
[(cosmos_proto.accepts_interface) = "github.com/line/lbm-sdk/x/foundation.Authorization"];
Expand All @@ -226,7 +228,8 @@ message MsgGrantResponse {}

// MsgRevoke is the Msg/Revoke request type.
message MsgRevoke {
string operator = 1;
// authority is the address of the privileged account.
string authority = 1;
string grantee = 2;
string msg_type_url = 3;
}
Expand All @@ -236,7 +239,8 @@ message MsgRevokeResponse {}

// MsgGovMint is the Msg/GovMint request type.
message MsgGovMint {
string operator = 1;
// authority is the address of the privileged account.
string authority = 1;
repeated cosmos.base.v1beta1.Coin amount = 2
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/line/lbm-sdk/types.Coins"];
}
Expand Down
4 changes: 2 additions & 2 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ var (
maccPerms = map[string][]string{
authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil,
foundation.ModuleName: nil,
foundation.TreasuryName: nil,
foundation.DefaultOperatorName: nil,
foundation.GovMinterName: {authtypes.Minter},
minttypes.ModuleName: {authtypes.Minter},
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
Expand Down Expand Up @@ -376,7 +376,7 @@ func NewSimApp(
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp)

foundationConfig := foundation.DefaultConfig()
app.FoundationKeeper = foundationkeeper.NewKeeper(appCodec, keys[foundation.StoreKey], app.BaseApp.MsgServiceRouter(), app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, foundationConfig)
app.FoundationKeeper = foundationkeeper.NewKeeper(appCodec, keys[foundation.StoreKey], app.BaseApp.MsgServiceRouter(), app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, foundationConfig, foundation.DefaultAuthority().String())

classKeeper := classkeeper.NewKeeper(appCodec, keys[class.StoreKey])
app.TokenKeeper = tokenkeeper.NewKeeper(appCodec, keys[token.StoreKey], app.AccountKeeper, classKeeper)
Expand Down
Loading

0 comments on commit fee8f64

Please sign in to comment.