Skip to content

Commit

Permalink
feat: multiple denom support
Browse files Browse the repository at this point in the history
  • Loading branch information
johnletey committed Jul 24, 2024
1 parent 9a139f4 commit 4340c95
Show file tree
Hide file tree
Showing 30 changed files with 7,829 additions and 928 deletions.
11 changes: 7 additions & 4 deletions local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ if ! [ -f .florin/data/priv_validator_state.json ]; then
florind add-genesis-account blacklist-pending-owner 10000000uusdc --home .florin --keyring-backend test
BLACKLIST_ADMIN=$(florind keys add blacklist-admin --home .florin --keyring-backend test --output json | jq .address)
florind add-genesis-account blacklist-admin 10000000uusdc --home .florin --keyring-backend test
AUTHORITY=$(florind keys add authority --home .florin --keyring-backend test --output json | jq .address)
florind add-genesis-account authority 1000000uusdc --home .florin --keyring-backend test
OWNER=$(florind keys add owner --home .florin --keyring-backend test --output json | jq .address)
florind add-genesis-account owner 10000000uusdc --home .florin --keyring-backend test
PENDING_OWNER=$(florind keys add pending-owner --home .florin --keyring-backend test --output json | jq .address)
Expand All @@ -39,10 +41,11 @@ if ! [ -f .florin/data/priv_validator_state.json ]; then
touch $TEMP && jq '.app_state.florin.blacklist_state.owner = '$BLACKLIST_OWNER'' .florin/config/genesis.json > $TEMP && mv $TEMP .florin/config/genesis.json
touch $TEMP && jq '.app_state.florin.blacklist_state.admins = ['$BLACKLIST_ADMIN']' .florin/config/genesis.json > $TEMP && mv $TEMP .florin/config/genesis.json
touch $TEMP && jq '.app_state.florin.blacklist_state.adversaries = ['$BOB']' .florin/config/genesis.json > $TEMP && mv $TEMP .florin/config/genesis.json
touch $TEMP && jq '.app_state.florin.owner = '$OWNER'' .florin/config/genesis.json > $TEMP && mv $TEMP .florin/config/genesis.json
touch $TEMP && jq '.app_state.florin.systems = ['$SYSTEM']' .florin/config/genesis.json > $TEMP && mv $TEMP .florin/config/genesis.json
touch $TEMP && jq '.app_state.florin.admins = ['$ADMIN']' .florin/config/genesis.json > $TEMP && mv $TEMP .florin/config/genesis.json
touch $TEMP && jq '.app_state.florin.mint_allowances = {'$SYSTEM': "1000000000000000000000000"}' .florin/config/genesis.json > $TEMP && mv $TEMP .florin/config/genesis.json
touch $TEMP && jq '.app_state.florin.authority = '$AUTHORITY'' .florin/config/genesis.json > $TEMP && mv $TEMP .florin/config/genesis.json
touch $TEMP && jq '.app_state.florin.owners = { "ueure": '$OWNER' }' .florin/config/genesis.json > $TEMP && mv $TEMP .florin/config/genesis.json
touch $TEMP && jq '.app_state.florin.systems = [{ "denom": "ueure", "address": '$SYSTEM'}]' .florin/config/genesis.json > $TEMP && mv $TEMP .florin/config/genesis.json
touch $TEMP && jq '.app_state.florin.admins = [{ "denom": "ueure", "address": '$ADMIN'}]' .florin/config/genesis.json > $TEMP && mv $TEMP .florin/config/genesis.json
touch $TEMP && jq '.app_state.florin.mint_allowances = [{ "denom": "ueure", "address": '$SYSTEM', "allowance": "1000000000000"}]' .florin/config/genesis.json > $TEMP && mv $TEMP .florin/config/genesis.json

florind gentx validator 1000000ustake --chain-id "florin-1" --home .florin --keyring-backend test &> /dev/null
florind collect-gentxs --home .florin &> /dev/null
Expand Down
64 changes: 50 additions & 14 deletions proto/florin/v1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,79 +6,115 @@ import "gogoproto/gogo.proto";

option go_package = "github.com/noble-assets/florin/x/florin/types";

// Emitted when a denom is allowed.
message DenomAllowed {
// denom is the denom that was allowed.
string denom = 1;

// owner is the address of the initial owner.
string owner = 2;
}

// Emitted when allowance is set.
message MintAllowance {
// denom is the denom that was affected.
string denom = 1;

// account is the address whose allowance was set.
string account = 1;
string account = 2;

// amount is the allowance that was set.
string amount = 2 [
string amount = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}

// Emitted when max allowance is set.
message MaxMintAllowance {
// denom is the denom that was affected.
string denom = 1;

// amount is the max allowance that was set.
string amount = 1 [
string amount = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}

// Emitted when system account is added.
message SystemAccountAdded {
// denom is the denom that was affected.
string denom = 1;

// account is the address that was added.
string account = 1;
string account = 2;
}

// Emitted when system account is removed.
message SystemAccountRemoved {
// denom is the denom that was affected.
string denom = 1;

// account is the address that was removed.
string account = 1;
string account = 2;
}

// Emitted when admin account is added.
message AdminAccountAdded {
// denom is the denom that was affected.
string denom = 1;

// account is the address that was added.
string account = 1;
string account = 2;
}

// Emitted when admin account is removed.
message AdminAccountRemoved {
// denom is the denom that was affected.
string denom = 1;

// account is the address that was removed.
string account = 1;
string account = 2;
}

// Emitted when an ownership transfer is started.
message OwnershipTransferStarted {
// denom is the denom that was affected.
string denom = 1;

// previous_owner is the address of the previous owner.
string previous_owner = 1;
string previous_owner = 2;

// new_owner is the address of the new owner.
string new_owner = 2;
string new_owner = 3;
}

// Emitted when an ownership transfer is finalized.
message OwnershipTransferred {
// denom is the denom that was affected.
string denom = 1;

// previous_owner is the address of the previous owner.
string previous_owner = 1;
string previous_owner = 2;

// new_owner is the address of the new owner.
string new_owner = 2;
string new_owner = 3;
}

// Emitted when the module owner recovers tokens.
message Recovered {
// denom is the denom that was affected.
string denom = 1;

// from is the address that tokens were recovered from.
string from = 1;
string from = 2;

// to is the address the recovered tokens were sent to.
string to = 2;
string to = 3;

// amount is the amount of recovered tokens.
string amount = 3 [
string amount = 4 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
Expand Down
36 changes: 26 additions & 10 deletions proto/florin/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,36 @@ message GenesisState {
// blacklist_state is the genesis state of the blacklist submodule.
florin.blacklist.v1.GenesisState blacklist_state = 1 [(gogoproto.nullable) = false];

// owner is the address that can control this module.
string owner = 2;
// pending_owner is the address of the new owner during an ownership transfer.
string pending_owner = 3;
// authority is the address that controls allowed denoms of this module.
string authority = 2;
// allowed_denoms is a unique list of denoms that this module is allowed to burn / mint / etc.
repeated string allowed_denoms = 3;

// owners is a mapping between denoms and owner addresses for those tokens.
map<string, string> owners = 4;
// pending_owners is the mapping between denoms and pending owner addresses.
map<string, string> pending_owners = 5;

// systems is the list of addresses that can act as the system.
repeated string systems = 4;
repeated Account systems = 6 [(gogoproto.nullable) = false];
// admins is the list of addresses that can act as the admin.
repeated string admins = 5;
repeated Account admins = 7 [(gogoproto.nullable) = false];

// mint_allowances is a list of system accounts and their mint allowances.
repeated Allowance mint_allowances = 8 [(gogoproto.nullable) = false];
// max_mint_allowances is a mapping between denoms and max mint allowances.
map<string, string> max_mint_allowances = 9;
}

message Account {
string denom = 1;
string address = 2;
}

// mint_allowances is the mapping between system address and mint allowance.
map<string, string> mint_allowances = 6;
// max_mint_allowance is the maximum allowed mint allowance.
string max_mint_allowance = 7 [
message Allowance {
string denom = 1;
string address = 2;
string allowance = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
Expand Down
81 changes: 75 additions & 6 deletions proto/florin/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,71 @@ syntax = "proto3";

package florin.v1;

import "florin/v1/genesis.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";

option go_package = "github.com/noble-assets/florin/x/florin/types";

service Query {
rpc AllowedDenoms(QueryAllowedDenoms) returns (QueryAllowedDenomsResponse) {
option (google.api.http).get = "/florin/v1/allowed_denoms";
}

rpc Owners(QueryOwners) returns (QueryOwnersResponse) {
option (google.api.http).get = "/florin/v1/owners";
}
rpc Owner(QueryOwner) returns (QueryOwnerResponse) {
option (google.api.http).get = "/florin/v1/owner";
option (google.api.http).get = "/florin/v1/owner/{denom}";
}

rpc Systems(QuerySystems) returns (QuerySystemsResponse) {
option (google.api.http).get = "/florin/v1/systems";
}
rpc SystemsByDenom(QuerySystemsByDenom) returns (QuerySystemsByDenomResponse) {
option (google.api.http).get = "/florin/v1/systems/{denom}";
}

rpc Admins(QueryAdmins) returns (QueryAdminsResponse) {
option (google.api.http).get = "/florin/v1/admins";
}
rpc AdminsByDenom(QueryAdminsByDenom) returns (QueryAdminsByDenomResponse) {
option (google.api.http).get = "/florin/v1/admins/{denom}";
}

rpc MaxMintAllowances(QueryMaxMintAllowances) returns (QueryMaxMintAllowancesResponse) {
option (google.api.http).get = "/florin/v1/max_mint_allowances";
}
rpc MaxMintAllowance(QueryMaxMintAllowance) returns (QueryMaxMintAllowanceResponse) {
option (google.api.http).get = "/florin/v1/max_mint_allowance";
option (google.api.http).get = "/florin/v1/max_mint_allowance/{denom}";
}

rpc MintAllowances(QueryMintAllowances) returns (QueryMintAllowancesResponse) {
option (google.api.http).get = "/florin/v1/mint_allowances/{denom}";
}
rpc MintAllowance(QueryMintAllowance) returns (QueryMintAllowanceResponse) {
option (google.api.http).get = "/florin/v1/mint_allowance/{account}";
option (google.api.http).get = "/florin/v1/mint_allowance/{denom}/{account}";
}
}

//

message QueryOwner {}
message QueryAllowedDenoms {}

message QueryAllowedDenomsResponse {
repeated string allowed_denoms = 1;
}

message QueryOwners {}

message QueryOwnersResponse {
map<string, string> owners = 1;
map<string, string> pending_owners = 2;
}

message QueryOwner {
string denom = 1;
}

message QueryOwnerResponse {
string owner = 1;
Expand All @@ -40,16 +76,40 @@ message QueryOwnerResponse {
message QuerySystems {}

message QuerySystemsResponse {
repeated Account systems = 1 [(gogoproto.nullable) = false];
}

message QuerySystemsByDenom {
string denom = 1;
}

message QuerySystemsByDenomResponse {
repeated string systems = 1;
}

message QueryAdmins {}

message QueryAdminsResponse {
repeated Account admins = 1 [(gogoproto.nullable) = false];
}

message QueryAdminsByDenom {
string denom = 1;
}

message QueryAdminsByDenomResponse {
repeated string admins = 1;
}

message QueryMaxMintAllowance {}
message QueryMaxMintAllowances {}

message QueryMaxMintAllowancesResponse {
map<string, string> max_mint_allowances = 1;
}

message QueryMaxMintAllowance {
string denom = 1;
}

message QueryMaxMintAllowanceResponse {
string max_mint_allowance = 1 [
Expand All @@ -58,8 +118,17 @@ message QueryMaxMintAllowanceResponse {
];
}

message QueryMintAllowances {
string denom = 1;
}

message QueryMintAllowancesResponse {
map<string, string> allowances = 1;
}

message QueryMintAllowance {
string account = 1;
string denom = 1;
string account = 2;
}

message QueryMintAllowanceResponse {
Expand Down
Loading

0 comments on commit 4340c95

Please sign in to comment.