Skip to content

Commit

Permalink
feat: minter controller (#16)
Browse files Browse the repository at this point in the history
Co-authored-by: Eric Bolten <[email protected]>
  • Loading branch information
fadeev and EricBolten authored Oct 10, 2022
1 parent 8f01de1 commit 29f4c6d
Show file tree
Hide file tree
Showing 59 changed files with 4,808 additions and 301 deletions.
31 changes: 31 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ accounts:
- name: masterminter
coins: ['10000token', '100000000stake']
mnemonic: peanut humble castle coin diet spy idea raven candy ice electric walnut fuel lizard depart owner kid piano cram slow session fancy page deposit
- name: mintercontroller
coins: ['10000token', '100000000stake']
mnemonic: dress offer practice nut usual thing prevent indoor hobby capable sketch speak chest destroy layer fatal silk blur salad kitchen zebra wild illness zebra
- name: blacklister
coins: ['10000token', '100000000stake']
mnemonic: cradle change member under cycle soul liquid figure develop digital risk dream render want nice purse spawn simple entry steel average dutch recall census
Expand All @@ -27,3 +30,31 @@ accounts:
validator:
name: alice
staked: '100000000stake'
genesis:
app_state:
bank:
denom_metadata:
- display: 'usdc'
base: 'uusdc'
name: 'USDC'
symbol: 'USDC'
denom_units:
- denom: 'uusdc'
aliases:
- 'microusdc'
exponent: '0'
- denom: 'musdc'
aliases:
- 'milliusdc'
exponent: '3'
- denom: 'usdc'
exponent: '6'
tokenfactory:
owner:
address: cosmos1rde4hcxtztnzdzkta5xergke5yzsf877xzfxdh
admin:
address: cosmos1qqj305p7vhzfcxku8wp7eh64he452nerwlw93k
paused:
paused: false
mintingDenom:
denom: 'uusdc'
36 changes: 12 additions & 24 deletions play.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,43 @@
sleep 2
nobled tx tokenfactory update-master-minter $(nobled keys show masterminter -a) --from owner -y
sleep 2
nobled tx tokenfactory configure-minter $(nobled keys show minter -a) 1000usdc --from masterminter -y
nobled tx tokenfactory configure-minter-controller $(nobled keys show mintercontroller -a) $(nobled keys show minter -a) --from masterminter -y
sleep 2
nobled tx tokenfactory mint $(nobled keys show user -a) 100usdc --from minter -y
nobled tx tokenfactory configure-minter $(nobled keys show minter -a) 1000uusdc --from mintercontroller -y
sleep 2
nobled q bank balances $(nobled keys show user -a)
sleep 2
nobled q tokenfactory list-minters
nobled tx tokenfactory mint $(nobled keys show user -a) 100uusdc --from minter -y
sleep 2
nobled tx tokenfactory mint $(nobled keys show user -a) 99999999999999usdc --from minter -y
nobled q bank balances $(nobled keys show user -a)
sleep 2
nobled tx tokenfactory update-blacklister $(nobled keys show blacklister -a) --from owner -y
sleep 2
nobled tx tokenfactory blacklist $(nobled keys show minter -a) --from blacklister -y
sleep 2
nobled tx tokenfactory mint $(nobled keys show user -a) 100usdc --from minter -y
sleep 2
nobled tx tokenfactory unblacklist $(nobled keys show minter -a) --from blacklister -y
sleep 2
nobled tx tokenfactory mint $(nobled keys show user -a) 100usdc --from minter -y
sleep 2
nobled q bank balances $(nobled keys show user -a)
sleep 2
nobled tx tokenfactory blacklist $(nobled keys show user -a) --from blacklister -y
sleep 2
nobled tx tokenfactory mint $(nobled keys show user -a) 100usdc --from minter -y
nobled tx tokenfactory mint $(nobled keys show user -a) 100uusdc --from minter -y
sleep 2
nobled tx tokenfactory unblacklist $(nobled keys show user -a) --from blacklister -y
sleep 2
nobled tx tokenfactory mint $(nobled keys show user -a) 100usdc --from minter -y
nobled tx tokenfactory mint $(nobled keys show user -a) 100uusdc --from minter -y
sleep 2
nobled tx tokenfactory update-pauser $(nobled keys show pauser -a) --from owner -y
sleep 2
nobled tx tokenfactory pause --from pauser -y
sleep 2
nobled tx tokenfactory mint $(nobled keys show user -a) 100usdc --from minter -y
nobled tx tokenfactory mint $(nobled keys show user -a) 100uusdc --from minter -y
sleep 2
nobled tx bank send $(nobled keys show user -a) $(nobled keys show alice -a) 100usdc --from user -y
nobled tx bank send $(nobled keys show user -a) $(nobled keys show alice -a) 100uusdc --from user -y
sleep 2
nobled tx tokenfactory unpause --from pauser -y
sleep 2
nobled tx bank send $(nobled keys show user -a) $(nobled keys show alice -a) 100usdc --from user -y
nobled tx bank send $(nobled keys show user -a) $(nobled keys show alice -a) 100uusdc --from user -y

# nobled tx tokenfactory mint $(nobled keys show user -a) 100usdc --from minter -y
# nobled tx tokenfactory mint $(nobled keys show user -a) 100uusdc --from minter -y
# sleep 2
# nobled q bank balances $(nobled keys show user -a)
# sleep 2
# nobled tx tokenfactory mint $(nobled keys show minter -a) 100usdc --from minter -y
# nobled tx tokenfactory mint $(nobled keys show minter -a) 100uusdc --from minter -y
# sleep 2
# nobled tx tokenfactory burn 100usdc --from minter -y
# nobled tx tokenfactory burn 100uusdc --from minter -y
# sleep 2
# nobled q bank balances $(nobled keys show user -a)

Expand Down
4 changes: 4 additions & 0 deletions proto/tokenfactory/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import "tokenfactory/pauser.proto";
import "tokenfactory/blacklister.proto";
import "tokenfactory/owner.proto";
import "tokenfactory/admin.proto";
import "tokenfactory/minter_controller.proto";
import "tokenfactory/minting_denom.proto";
// this line is used by starport scaffolding # genesis/proto/import

option go_package = "noble/x/tokenfactory/types";
Expand All @@ -26,5 +28,7 @@ message GenesisState {
Blacklister blacklister = 7;
Owner owner = 8;
Admin admin = 9;
repeated MinterController minterControllerList = 10 [(gogoproto.nullable) = false];
MintingDenom mintingDenom = 11;
// this line is used by starport scaffolding # genesis/proto/state
}
11 changes: 11 additions & 0 deletions proto/tokenfactory/minter_controller.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";
package noble.tokenfactory;

option go_package = "noble/x/tokenfactory/types";

message MinterController {
string minter = 1;
string controller = 2;

}

9 changes: 9 additions & 0 deletions proto/tokenfactory/minting_denom.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
syntax = "proto3";
package noble.tokenfactory;

option go_package = "noble/x/tokenfactory/types";

message MintingDenom {
string denom = 1;

}
51 changes: 45 additions & 6 deletions proto/tokenfactory/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import "tokenfactory/pauser.proto";
import "tokenfactory/blacklister.proto";
import "tokenfactory/owner.proto";
import "tokenfactory/admin.proto";
import "tokenfactory/minter_controller.proto";
import "tokenfactory/minting_denom.proto";
// this line is used by starport scaffolding # 1
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
Expand Down Expand Up @@ -68,6 +70,20 @@ service Query {
rpc Admin(QueryGetAdminRequest) returns (QueryGetAdminResponse) {
option (google.api.http).get = "/noble/tokenfactory/admin";
}
// Queries a MinterController by index.
rpc MinterController(QueryGetMinterControllerRequest) returns (QueryGetMinterControllerResponse) {
option (google.api.http).get = "/noble/tokenfactory/minter_controller/{controllerAddress}";
}

// Queries a list of MinterController items.
rpc MinterControllerAll(QueryAllMinterControllerRequest) returns (QueryAllMinterControllerResponse) {
option (google.api.http).get = "/noble/tokenfactory/minter_controller";
}

// Queries a MintingDenom by index.
rpc MintingDenom(QueryGetMintingDenomRequest) returns (QueryGetMintingDenomResponse) {
option (google.api.http).get = "/noble/tokenfactory/minting_denom";
}
// this line is used by starport scaffolding # 2
}

Expand Down Expand Up @@ -101,12 +117,12 @@ message QueryAllBlacklistedResponse {
message QueryGetPausedRequest {}

message QueryGetPausedResponse {
Paused Paused = 1 [(gogoproto.nullable) = false];
Paused paused = 1 [(gogoproto.nullable) = false];
}
message QueryGetMasterMinterRequest {}

message QueryGetMasterMinterResponse {
MasterMinter MasterMinter = 1 [(gogoproto.nullable) = false];
MasterMinter masterMinter = 1 [(gogoproto.nullable) = false];
}
message QueryGetMintersRequest {
string address = 1;
Expand All @@ -129,21 +145,44 @@ message QueryAllMintersResponse {
message QueryGetPauserRequest {}

message QueryGetPauserResponse {
Pauser Pauser = 1 [(gogoproto.nullable) = false];
Pauser pauser = 1 [(gogoproto.nullable) = false];
}
message QueryGetBlacklisterRequest {}

message QueryGetBlacklisterResponse {
Blacklister Blacklister = 1 [(gogoproto.nullable) = false];
Blacklister blacklister = 1 [(gogoproto.nullable) = false];
}
message QueryGetOwnerRequest {}

message QueryGetOwnerResponse {
Owner Owner = 1 [(gogoproto.nullable) = false];
Owner owner = 1 [(gogoproto.nullable) = false];
}
message QueryGetAdminRequest {}

message QueryGetAdminResponse {
Admin Admin = 1 [(gogoproto.nullable) = false];
Admin admin = 1 [(gogoproto.nullable) = false];
}
message QueryGetMinterControllerRequest {
string controllerAddress = 1;

}

message QueryGetMinterControllerResponse {
MinterController minterController = 1 [(gogoproto.nullable) = false];
}

message QueryAllMinterControllerRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

message QueryAllMinterControllerResponse {
repeated MinterController minterController = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

message QueryGetMintingDenomRequest {}

message QueryGetMintingDenomResponse {
MintingDenom mintingDenom = 1 [(gogoproto.nullable) = false];
}
// this line is used by starport scaffolding # 3
19 changes: 19 additions & 0 deletions proto/tokenfactory/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ service Msg {
rpc Unblacklist(MsgUnblacklist) returns (MsgUnblacklistResponse);
rpc Pause(MsgPause) returns (MsgPauseResponse);
rpc Unpause(MsgUnpause) returns (MsgUnpauseResponse);
rpc ConfigureMinterController(MsgConfigureMinterController) returns (MsgConfigureMinterControllerResponse);
rpc RemoveMinterController(MsgRemoveMinterController) returns (MsgRemoveMinterControllerResponse);
// this line is used by starport scaffolding # proto/tx/rpc
}

Expand Down Expand Up @@ -129,4 +131,21 @@ message MsgUnpause {
message MsgUnpauseResponse {
}

message MsgConfigureMinterController {
string from = 1;
string controller = 2;
string minter = 3;
}

message MsgConfigureMinterControllerResponse {
}

message MsgRemoveMinterController {
string from = 1;
string controller = 2;
}

message MsgRemoveMinterControllerResponse {
}

// this line is used by starport scaffolding # proto/tx/message
3 changes: 3 additions & 0 deletions x/tokenfactory/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ func GetQueryCmd(queryRoute string) *cobra.Command {
cmd.AddCommand(CmdShowBlacklister())
cmd.AddCommand(CmdShowOwner())
cmd.AddCommand(CmdShowAdmin())
cmd.AddCommand(CmdListMinterController())
cmd.AddCommand(CmdShowMinterController())
cmd.AddCommand(CmdShowMintingDenom())
// this line is used by starport scaffolding # 1

return cmd
Expand Down
74 changes: 74 additions & 0 deletions x/tokenfactory/client/cli/query_minter_controller.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package cli

import (
"context"

"noble/x/tokenfactory/types"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/spf13/cobra"
)

func CmdListMinterController() *cobra.Command {
cmd := &cobra.Command{
Use: "list-minter-controller",
Short: "list all minter-controller",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

pageReq, err := client.ReadPageRequest(cmd.Flags())
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)

params := &types.QueryAllMinterControllerRequest{
Pagination: pageReq,
}

res, err := queryClient.MinterControllerAll(context.Background(), params)
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddPaginationFlagsToCmd(cmd, cmd.Use)
flags.AddQueryFlagsToCmd(cmd)

return cmd
}

func CmdShowMinterController() *cobra.Command {
cmd := &cobra.Command{
Use: "show-minter-controller [minter-address]",
Short: "shows a minter-controller",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)

argControllerAddress := args[0]

params := &types.QueryGetMinterControllerRequest{
ControllerAddress: argControllerAddress,
}

res, err := queryClient.MinterController(context.Background(), params)
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}
Loading

0 comments on commit 29f4c6d

Please sign in to comment.