diff --git a/.vscode/extensions.json b/.vscode/extensions.json old mode 100644 new mode 100755 diff --git a/.vscode/go.code-snippets b/.vscode/go.code-snippets new file mode 100755 index 000000000..c5a6d6f55 --- /dev/null +++ b/.vscode/go.code-snippets @@ -0,0 +1,33 @@ +{ + // Place your uni_tmp_work workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and + // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope + // is left empty or omitted, the snippet gets applied to all languages. The prefix is what is + // used to trigger the snippet and the body will be expanded and inserted. Possible variables are: + // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. + // Placeholders with the same ids are connected. + // Example: + "print clipborad for debugging": { + "scope": "go", + "prefix": [ + "fmtl", + "log" + ], + "body": [ + "fmt.Println(\"$CLIPBOARD\");", + "fmt.Println($CLIPBOARD);", + ], + "description": "print clipboard" + }, + "print current number": { + "scope": "go", + "prefix": [ + "ll", + "logLine", + "trace" + ], + "body": [ + "fmt.Println(\"$TM_FILENAME:$TM_LINE_NUMBER\");", + ], + "description": "print line number" + } +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..eb7dfa246 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,49 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "build then Launch and auto throw Tx", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "./cmd/ununifid/main.go", + "args": [ + "start", + "--home", + "./data/test-1" + ], + "cwd": "${workspaceFolder}", + "preLaunchTask": "prepare tx", + }, + { + "name": "just Launch", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "./cmd/ununifid/main.go", + "args": [ + "start", + "--home", + "./data/test-1" + ], + "cwd": "${workspaceFolder}", + }, + { + "name": "build then Launch", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "./cmd/ununifid/main.go", + "args": [ + "start", + "--home", + "./data/test-1" + ], + "cwd": "${workspaceFolder}", + "preLaunchTask": "init config", + }, + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json old mode 100644 new mode 100755 index 4494457fa..6d7081a83 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -14,11 +14,12 @@ } }, "[go]": { - "editor.snippetSuggestions": "none", + "editor.snippetSuggestions": "top", "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.organizeImports": true - } + }, + "editor.suggest.snippetsPreventQuickSuggestions": true }, "gopls": { "local": "github.com/UnUniFi/chain" diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..7f2447ba5 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,37 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "type": "shell", + "cwd": "${workspaceFolder}", + "command": "make build -B", + "problemMatcher": [ + "$go" + ] + }, + { + "label": "init config", + "type": "shell", + "cwd": "${workspaceFolder}", + "command": "scripts/setup/init.sh", + "problemMatcher": [ + "$go" + ], + "dependsOn": [ + "build", + ] + }, + { + "label": "prepare tx", + "type": "shell", + "cwd": "${workspaceFolder}", + "command": "nohup scripts/commands/prepare.sh sleep ... & sleep 0.1", + "dependsOn": [ + "init config", + ], + }, + ] +} \ No newline at end of file diff --git a/app/app.go b/app/app.go index acdc338cc..3460b3cf2 100644 --- a/app/app.go +++ b/app/app.go @@ -709,7 +709,7 @@ func NewApp( incentive.NewAppModule(appCodec, app.incentiveKeeper, app.AccountKeeper, app.BankKeeper, app.cdpKeeper), ununifidist.NewAppModule(appCodec, app.ununifidistKeeper, app.AccountKeeper, app.BankKeeper), pricefeed.NewAppModule(appCodec, app.pricefeedKeeper, app.AccountKeeper), - nftmint.NewAppModule(appCodec, app.NftmintKeeper, app.AccountKeeper), + nftmint.NewAppModule(appCodec, app.NftmintKeeper, app.NFTKeeper), nftmarket.NewAppModule(appCodec, app.NftmarketKeeper, app.AccountKeeper, app.BankKeeper), // wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper), ) diff --git a/docs/client/swagger.yaml b/docs/client/swagger.yaml index 0806e6f3f..705613822 100644 --- a/docs/client/swagger.yaml +++ b/docs/client/swagger.yaml @@ -4619,6 +4619,53 @@ paths: type: string tags: - Query + /ununifi/ecosystem_incentive/incentive_unit_ids_by_addr/{address}: + get: + operationId: IncentiveUnitIdsByAddr + responses: + '200': + description: A successful response. + schema: + type: object + properties: + incentive_unit_ids_by_addr: + type: object + properties: + address: + type: string + incentive_unit_ids: + type: array + items: + type: string + 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 + value: + type: string + format: byte + parameters: + - name: address + in: path + required: true + type: string + tags: + - Query /ununifi/ecosystem_incentive/params: get: summary: Parameters queries the parameters of the module. @@ -10328,6 +10375,15 @@ definitions: type: string weight: type: string + ununifi.ecosystemincentive.IncentiveUnitIdsByAddr: + type: object + properties: + address: + type: string + incentive_unit_ids: + type: array + items: + type: string ununifi.ecosystemincentive.Params: type: object properties: @@ -10401,6 +10457,18 @@ definitions: method signatures required by gogoproto. + ununifi.ecosystemincentive.QueryIncentiveUnitIdsByAddrResponse: + type: object + properties: + incentive_unit_ids_by_addr: + type: object + properties: + address: + type: string + incentive_unit_ids: + type: array + items: + type: string ununifi.ecosystemincentive.QueryIncentiveUnitResponse: type: object properties: diff --git a/proto/derivatives/derivatives.proto b/proto/derivatives/derivatives.proto index 0ca158543..d4084cea2 100644 --- a/proto/derivatives/derivatives.proto +++ b/proto/derivatives/derivatives.proto @@ -92,8 +92,7 @@ message Pool { (gogoproto.nullable) = false ]; repeated Asset accepted_assets = 6 [ - (gogoproto.moretags) = "yaml:\"accepted_assets\"", - (gogoproto.nullable) = false + (gogoproto.moretags) = "yaml:\"accepted_assets\"" ]; } @@ -154,8 +153,7 @@ message PerpetualFuturesParams { (gogoproto.nullable) = false ]; repeated Market markets = 4 [ - (gogoproto.moretags) = "yaml:\"markets\"", - (gogoproto.nullable) = false + (gogoproto.moretags) = "yaml:\"markets\"" ]; } @@ -181,10 +179,11 @@ message PerpetualOptionsParams { (gogoproto.nullable) = false ]; repeated Market markets = 5 [ - (gogoproto.moretags) = "yaml:\"markets\"", - (gogoproto.nullable) = false + (gogoproto.moretags) = "yaml:\"markets\"" ]; } +// (gogoproto.nullable) = false + message Params { Pool pool = 1 [ diff --git a/proto/ecosystem-incentive/ecosystem_incentive.proto b/proto/ecosystem-incentive/ecosystem_incentive.proto index 4c954c14d..e4ed59d03 100644 --- a/proto/ecosystem-incentive/ecosystem_incentive.proto +++ b/proto/ecosystem-incentive/ecosystem_incentive.proto @@ -41,3 +41,12 @@ message RewardStore { (gogoproto.nullable) = false ]; } + +message IncentiveUnitIdsByAddr { + string address = 1 [ + (gogoproto.moretags) = "yaml:\"address\"", + (gogoproto.customtype) = "github.com/UnUniFi/chain/types.StringAccAddress", + (gogoproto.nullable) = false + ]; + repeated string incentive_unit_ids = 2 [ (gogoproto.moretags) = "yaml:\"incentive_unit_ids\"" ]; +} diff --git a/proto/ecosystem-incentive/event.proto b/proto/ecosystem-incentive/event.proto index c541c47b9..63b88894e 100644 --- a/proto/ecosystem-incentive/event.proto +++ b/proto/ecosystem-incentive/event.proto @@ -17,9 +17,7 @@ message EventRegister { message EventWithdrawAllRewards { string sender = 1 [ - (gogoproto.moretags) = "yaml:\"sender\"", - (gogoproto.customtype) = "github.com/UnUniFi/chain/types.StringAccAddress", - (gogoproto.nullable) = false + (gogoproto.moretags) = "yaml:\"sender\"" ]; repeated cosmos.base.v1beta1.Coin all_withdrawn_rewards = 2 [ (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", @@ -30,9 +28,7 @@ message EventWithdrawAllRewards { message EventWithdrawReward { string sender = 1 [ - (gogoproto.moretags) = "yaml:\"sender\"", - (gogoproto.customtype) = "github.com/UnUniFi/chain/types.StringAccAddress", - (gogoproto.nullable) = false + (gogoproto.moretags) = "yaml:\"sender\"" ]; cosmos.base.v1beta1.Coin withdrawn_reward = 2 [ (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin", diff --git a/proto/ecosystem-incentive/query.proto b/proto/ecosystem-incentive/query.proto index f765c3f0f..bdba9a020 100644 --- a/proto/ecosystem-incentive/query.proto +++ b/proto/ecosystem-incentive/query.proto @@ -32,6 +32,10 @@ service Query { rpc RecordedIncentiveUnitId(QueryRecordedIncentiveUnitIdRequest) returns (QueryRecordedIncentiveUnitIdResponse) { option (google.api.http).get = "/ununifi/ecosystem_incentive/recorded_incentive_unit_id/{class_id}/{nft_id}"; } + + rpc IncentiveUnitIdsByAddr(QueryIncentiveUnitIdsByAddrRequest) returns (QueryIncentiveUnitIdsByAddrResponse) { + option (google.api.http).get = "/ununifi/ecosystem_incentive/incentive_unit_ids_by_addr/{address}"; + } } message QueryParamsRequest {} @@ -84,3 +88,16 @@ message QueryRecordedIncentiveUnitIdRequest { message QueryRecordedIncentiveUnitIdResponse { string incentive_unit_id = 1 [ (gogoproto.moretags) = "yaml:\"incentive_unit_id\"" ]; } + +message QueryIncentiveUnitIdsByAddrRequest { + string address = 1 [ + (gogoproto.moretags) = "yaml:\"address\"" + ]; +} + +message QueryIncentiveUnitIdsByAddrResponse { + IncentiveUnitIdsByAddr incentive_unit_ids_by_addr = 1 [ + (gogoproto.moretags) = "yaml:\"incentive_unit_ids_by_addr\"", + (gogoproto.nullable) = false + ]; +} diff --git a/proto/nftmint/genesis.proto b/proto/nftmint/genesis.proto index de9cb0deb..2d14d8253 100644 --- a/proto/nftmint/genesis.proto +++ b/proto/nftmint/genesis.proto @@ -12,5 +12,5 @@ message GenesisState { (gogoproto.moretags) = "yaml:\"params\"", (gogoproto.nullable) = false ]; + repeated ClassAttributes class_attributes_list = 2 [ (gogoproto.moretags) = "yaml:\"class_attributes_list\"" ]; } - \ No newline at end of file diff --git a/scripts/commands/derivatives/setup_pricefeed.sh b/scripts/commands/derivatives/setup_pricefeed.sh index 45d92e936..69483b57e 100755 --- a/scripts/commands/derivatives/setup_pricefeed.sh +++ b/scripts/commands/derivatives/setup_pricefeed.sh @@ -1,8 +1,9 @@ #!/bin/bash +SCRIPT_DIR=$(cd $(dirname $0); pwd) mkdir pricefeed cd pricefeed curl -O https://raw.githubusercontent.com/ununifi/utils/main/projects/pricefeed/docker-compose.yml -cp ../.env.pricefeed .env +cp $SCRIPT_DIR/.env.pricefeed .env docker-compose up -d diff --git a/scripts/commands/derivatives/start.sh b/scripts/commands/derivatives/start.sh index 0851411ca..9f15788a6 100755 --- a/scripts/commands/derivatives/start.sh +++ b/scripts/commands/derivatives/start.sh @@ -1,7 +1,8 @@ -#!/bin/sh +#!/bin/bash # Script to start network with pricefeed # just run ./start.sh +SCRIPT_DIR=$(cd $(dirname $0); pwd) rm -rf ~/.ununifi @@ -9,11 +10,11 @@ set -o errexit -o nounset # Build genesis ununifid init --chain-id=test test -ununifid keys mnemonic >& validator.txt -ununifid keys mnemonic >& debug.txt +ununifid keys mnemonic 2> validator.txt +ununifid keys mnemonic 2> debug.txt ununifid keys add validator --recover < validator.txt ununifid keys add debug --recover < debug.txt -ununifid keys add pricefeed --recover < pricefeed.txt +ununifid keys add pricefeed --recover < $SCRIPT_DIR/pricefeed.txt ununifid add-genesis-account $(ununifid keys show validator --address) 100000000000000uguu,100000000000000ubtc,100000000000000uusd ununifid add-genesis-account $(ununifid keys show debug --address) 100000000000000uguu,100000000000000ubtc,100000000000000uusd ununifid add-genesis-account $(ununifid keys show pricefeed --address) 100000000000000uguu,100000000000000ubtc,100000000000000uusd @@ -21,11 +22,22 @@ ununifid gentx validator 100000000uguu --chain-id=test ununifid collect-gentxs # Edit app.toml to enable unsafe-cors and set pruning everything to reduce disk usage. -sed -E -i '' "s/enabled-unsafe-cors = false/enabled-unsafe-cors = true/" ~/.ununifi/config/app.toml; -sed -E -i '' "s/pruning = \".*\"/pruning = \"everything\"/" ~/.ununifi/config/app.toml; -sed -i '' 's/mode = "full"/mode = "validator"/' ~/.ununifi/config/config.toml; -sed -i '' 's/minimum-gas-prices = ""/minimum-gas-prices = "0uguu"/' ~/.ununifi/config/app.toml; -sed -i '' 's/stake/uguu/g' ~/.ununifi/config/genesis.json; +OS=$(uname -s) +if [ "$OS" == "Darwin" ]; then + echo $OS + sleep 1 + sed_i="sed -i ''" +elif [ "$OS" == "Linux" ]; then + echo $OS + sleep 1 + sed_i="sed -i" +fi + +$sed_i "s/enabled-unsafe-cors = false/enabled-unsafe-cors = true/" ~/.ununifi/config/app.toml; +$sed_i "s/pruning = \".*\"/pruning = \"everything\"/" ~/.ununifi/config/app.toml; +$sed_i 's/mode = "full"/mode = "validator"/' ~/.ununifi/config/config.toml; +$sed_i 's/minimum-gas-prices = ""/minimum-gas-prices = "0uguu"/' ~/.ununifi/config/app.toml; +$sed_i 's/stake/uguu/g' ~/.ununifi/config/genesis.json; # modify genesis.json PRICEFEED=$(ununifid keys show pricefeed --address) @@ -42,7 +54,7 @@ jq '.app_state.derivatives.params.perpetual_futures.markets = [{"base_denom": "u jq '.app_state.bank.denom_metadata = [{"base" : "ubtc" , "symbol": "ubtc"}, {"base" : "uusd", "symbol": "usd"}]' ~/.ununifi/config/genesis.json > temp.json ; mv temp.json ~/.ununifi/config/genesis.json; # run pricefeed -# ./setup_pricefeed.sh +$SCRIPT_DIR/setup_pricefeed.sh # Start node ununifid start diff --git a/scripts/commands/prepare.sh b/scripts/commands/prepare.sh new file mode 100755 index 000000000..d05a9d71a --- /dev/null +++ b/scripts/commands/prepare.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +SCRIPT_DIR=$(cd $(dirname $0); pwd) +. $SCRIPT_DIR/../setup/variables.sh + +echo "execute tx" +# SCRIPT_DIR/nftmarket.sh \ No newline at end of file diff --git a/scripts/setup/init.sh b/scripts/setup/init.sh new file mode 100755 index 000000000..78b8db73f --- /dev/null +++ b/scripts/setup/init.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +# Load shell variables +SCRIPT_DIR=$(cd $(dirname $0); pwd) +. $SCRIPT_DIR/variables.sh + +# Stop if it is already running +if pgrep -x "$BINARY" >/dev/null; then + echo "Terminating $BINARY..." + killall $BINARY +fi + +echo "Removing previous data..." +rm -rf $CHAIN_DIR/$CHAINID_1 &> /dev/null + +# Add directories for both chains, exit if an error occurs +if ! mkdir -p $CHAIN_DIR/$CHAINID_1 2>/dev/null; then + echo "Failed to create chain folder. Aborting..." + exit 1 +fi + +echo "Initializing $CHAINID_1..." +$BINARY init test --home $CHAIN_DIR/$CHAINID_1 --chain-id=$CHAINID_1 + +# change main token +sed -i -e 's/\bstake\b/'$BINARY_MAIN_TOKEN'/g' $CHAIN_DIR/$CHAINID_1/config/genesis.json + +echo "Adding genesis accounts..." +echo $VAL_MNEMONIC_1 | $BINARY keys add $VAL1 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test +echo $USER_MNEMONIC_1 | $BINARY keys add $USER1 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test +echo $USER_MNEMONIC_2 | $BINARY keys add $USER2 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test +echo $USER_MNEMONIC_3 | $BINARY keys add $USER3 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test +echo $USER_MNEMONIC_4 | $BINARY keys add $USER4 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test +echo $PRICEFEED_MNEMONIC | $BINARY keys add $PRICEFEED --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test + +$BINARY add-genesis-account $($BINARY --home $CHAIN_DIR/$CHAINID_1 keys show $VAL1 --keyring-backend test -a) 100000000000$BINARY_MAIN_TOKEN --home $CHAIN_DIR/$CHAINID_1 +$BINARY add-genesis-account $($BINARY --home $CHAIN_DIR/$CHAINID_1 keys show $USER1 --keyring-backend test -a) 100000000000$BINARY_MAIN_TOKEN --home $CHAIN_DIR/$CHAINID_1 +$BINARY add-genesis-account $($BINARY --home $CHAIN_DIR/$CHAINID_1 keys show $USER2 --keyring-backend test -a) 100000000000$BINARY_MAIN_TOKEN --home $CHAIN_DIR/$CHAINID_1 +$BINARY add-genesis-account $($BINARY --home $CHAIN_DIR/$CHAINID_1 keys show $USER3 --keyring-backend test -a) 100000000000$BINARY_MAIN_TOKEN --home $CHAIN_DIR/$CHAINID_1 +$BINARY add-genesis-account $($BINARY --home $CHAIN_DIR/$CHAINID_1 keys show $USER4 --keyring-backend test -a) 100000000000$BINARY_MAIN_TOKEN --home $CHAIN_DIR/$CHAINID_1 +$BINARY add-genesis-account $($BINARY --home $CHAIN_DIR/$CHAINID_1 keys show $PRICEFEED --keyring-backend test -a) 100000000000$BINARY_MAIN_TOKEN,100000000000000ubtc,100000000000000uusd --home $CHAIN_DIR/$CHAINID_1 + +echo "Creating and collecting gentx..." +$BINARY gentx $VAL1 7000000000$BINARY_MAIN_TOKEN --home $CHAIN_DIR/$CHAINID_1 --chain-id $CHAINID_1 --keyring-backend test +$BINARY collect-gentxs --home $CHAIN_DIR/$CHAINID_1 + +echo "Changing defaults config files..." +OS=$(uname -s) +if [ "$OS" == "Darwin" ]; then + echo $OS + sleep 1 + sed_i="sed -i ''" +elif [ "$OS" == "Linux" ]; then + echo $OS + sleep 1 + sed_i="sed -i" +fi + +sed -i '/\[api\]/,+3 s/enable = false/enable = true/' $CHAIN_DIR/$CHAINID_1/config/app.toml; +sed -i -e 's/minimum-gas-prices = ""/minimum-gas-prices = '\"0$BINARY_MAIN_TOKEN\"/'' $CHAIN_DIR/$CHAINID_1/config/app.toml; +$sed_i 's/mode = "full"/mode = "validator"/' $CHAIN_DIR/$CHAINID_1/config/config.toml; +$sed_i "s/enabled-unsafe-cors = false/enabled-unsafe-cors = true/" $CHAIN_DIR/$CHAINID_1/config/app.toml; +$sed_i 's/mode = "full"/mode = "validator"/' $CHAIN_DIR/$CHAINID_1/config/config.toml; +$sed_i 's/minimum-gas-prices = ""/minimum-gas-prices = "0uguu"/' $CHAIN_DIR/$CHAINID_1/config/app.toml; +$sed_i 's/stake/uguu/g' $CHAIN_DIR/$CHAINID_1/config/genesis.json; + + +# PRICEFEED=$(ununifid keys show pricefeed --address) +jq '.app_state.pricefeed.params.markets = [{ "market_id": "ubtc:usd", "base_asset": "ubtc", "quote_asset": "usd", "oracles": [ "'$PRICEFEED_ADDRESS'" ], "active": true }, { "market_id": "ubtc:usd:30", "base_asset": "ubtc", "quote_asset": "usd", "oracles": [ "'$PRICEFEED_ADDRESS'" ], "active": true }]' $CHAIN_DIR/$CHAINID_1/config/genesis.json > temp.json ; mv temp.json $CHAIN_DIR/$CHAINID_1/config/genesis.json; +jq '.app_state.derivatives.params.pool.base_lpt_mint_fee = "0.001"' $CHAIN_DIR/$CHAINID_1/config/genesis.json > temp.json ; mv temp.json $CHAIN_DIR/$CHAINID_1/config/genesis.json; +jq '.app_state.derivatives.params.pool.base_lpt_redeem_fee = "0.001"' $CHAIN_DIR/$CHAINID_1/config/genesis.json > temp.json ; mv temp.json $CHAIN_DIR/$CHAINID_1/config/genesis.json; +jq '.app_state.derivatives.params.pool.accepted_assets = [{"denom":"ubtc", "target_weight": "0.6"}, {"denom":"uusd", "target_weight":"0.4"}]' $CHAIN_DIR/$CHAINID_1/config/genesis.json > temp.json ; mv temp.json $CHAIN_DIR/$CHAINID_1/config/genesis.json; +jq '.app_state.derivatives.params.perpetual_futures.commission_rate = "0.001"' $CHAIN_DIR/$CHAINID_1/config/genesis.json > temp.json ; mv temp.json $CHAIN_DIR/$CHAINID_1/config/genesis.json; +jq '.app_state.derivatives.params.perpetual_futures.margin_maintenance_rate = "0.5"' $CHAIN_DIR/$CHAINID_1/config/genesis.json > temp.json ; mv temp.json $CHAIN_DIR/$CHAINID_1/config/genesis.json; +jq '.app_state.derivatives.params.perpetual_futures.imaginary_funding_rate_proportional_coefficient = "0.0005"' $CHAIN_DIR/$CHAINID_1/config/genesis.json > temp.json ; mv temp.json $CHAIN_DIR/$CHAINID_1/config/genesis.json; +jq '.app_state.derivatives.params.perpetual_futures.markets = [{"base_denom": "ubtc", "quote_denom": "uusd" }]' $CHAIN_DIR/$CHAINID_1/config/genesis.json > temp.json ; mv temp.json $CHAIN_DIR/$CHAINID_1/config/genesis.json; +jq '.app_state.bank.denom_metadata = [{"base" : "ubtc" , "symbol": "ubtc"}, {"base" : "uusd", "symbol": "usd"}]' $CHAIN_DIR/$CHAINID_1/config/genesis.json > temp.json ; mv temp.json $CHAIN_DIR/$CHAINID_1/config/genesis.json; \ No newline at end of file diff --git a/scripts/setup/variables.sh b/scripts/setup/variables.sh new file mode 100755 index 000000000..8b6672a22 --- /dev/null +++ b/scripts/setup/variables.sh @@ -0,0 +1,20 @@ +BINARY=./build/ununifid +CHAIN_DIR=./data +CHAINID_1=test-1 +BINARY_MAIN_TOKEN=uguu +# BINARY_MAIN_TOKEN=stake +VAL1=val +USER1=user1 +USER2=user2 +USER3=user3 +USER4=user4 +PRICEFEED=pricefeed + +VAL_MNEMONIC_1="figure web rescue rice quantum sustain alert citizen woman cable wasp eyebrow monster teach hockey giant monitor hero oblige picnic ball never lamp distance" +USER_MNEMONIC_1="supply release type ostrich rib inflict increase bench wealth course enter pond spare neutral exact retire thing update inquiry atom health number lava taste" +USER_MNEMONIC_2="canyon second appear story film people resist slam waste again race rifle among room hip icon marriage sea quality prepare only liquid column click" +USER_MNEMONIC_3="among follow tooth egg unhappy city road expire solution visit visa skate allow network tissue slogan rose toddler develop utility negative peasant ostrich toward" +USER_MNEMONIC_4="charge split umbrella day gauge two orphan random human clerk buzz funny cabin purse fluid lecture blouse keen twist loud animal supply hat scare" +PRICEFEED_MNEMONIC="jelly fortune hire delay impose daughter praise amazing patch gesture easy achieve intact genre swamp gossip aisle arrest item seek inherit cradle hover involve" + +PRICEFEED_ADDRESS=ununifi1h7ulktk5p2gt7tnxwhqzlq0yegq47hum0fahcr \ No newline at end of file diff --git a/x/derivatives/abci.go b/x/derivatives/abci.go index 93f4a3757..3298c15f1 100644 --- a/x/derivatives/abci.go +++ b/x/derivatives/abci.go @@ -15,9 +15,9 @@ func levyImaginaryFundingRate(ctx sdk.Context, k keeper.Keeper) { perpetualFuturesImaginaryFundingRates := make(map[types.Market]sdk.Dec) for _, perpetualFuturesMarket := range perpetualFuturesMarkets { - netPosition := k.GetPerpetualFuturesNetPositionOfMarket(ctx, perpetualFuturesMarket) + netPosition := k.GetPerpetualFuturesNetPositionOfMarket(ctx, *perpetualFuturesMarket) imaginaryFundingRate := netPosition.Mul(params.PerpetualFutures.ImaginaryFundingRateProportionalCoefficient) - perpetualFuturesImaginaryFundingRates[perpetualFuturesMarket] = imaginaryFundingRate + perpetualFuturesImaginaryFundingRates[*perpetualFuturesMarket] = imaginaryFundingRate } for _, position := range positions { diff --git a/x/derivatives/simulation/genesis.go b/x/derivatives/simulation/genesis.go index bfab45e6e..f4fa6012e 100644 --- a/x/derivatives/simulation/genesis.go +++ b/x/derivatives/simulation/genesis.go @@ -28,7 +28,7 @@ func RandomizedGenState(simState *module.SimulationState) { BaseLptRedeemFee: sdk.NewDecWithPrec(1, 2), BorrowingFeeRatePerHour: sdk.NewDecWithPrec(1, 6), LiquidationNeededReportRewardRate: sdk.NewDecWithPrec(1, 6), - AcceptedAssets: []types.Pool_Asset{ + AcceptedAssets: []*types.Pool_Asset{ { Denom: "btc", TargetWeight: sdk.NewDecWithPrec(1, 2), @@ -43,7 +43,7 @@ func RandomizedGenState(simState *module.SimulationState) { CommissionRate: sdk.NewDecWithPrec(1, 6), MarginMaintenanceRate: sdk.NewDecWithPrec(5, 1), ImaginaryFundingRateProportionalCoefficient: sdk.NewDecWithPrec(1, 4), - Markets: []types.Market{ + Markets: []*types.Market{ { BaseDenom: "btc", QuoteDenom: "usd", diff --git a/x/derivatives/types/derivatives.pb.go b/x/derivatives/types/derivatives.pb.go index b49712907..43665df6b 100644 --- a/x/derivatives/types/derivatives.pb.go +++ b/x/derivatives/types/derivatives.pb.go @@ -160,7 +160,7 @@ type Pool struct { BaseLptRedeemFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=base_lpt_redeem_fee,json=baseLptRedeemFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"base_lpt_redeem_fee" yaml:"base_lpt_redeem_fee"` BorrowingFeeRatePerHour github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=borrowing_fee_rate_per_hour,json=borrowingFeeRatePerHour,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"borrowing_fee_rate_per_hour" yaml:"borrowing_fee_rate_per_hour"` LiquidationNeededReportRewardRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=liquidation_needed_report_reward_rate,json=liquidationNeededReportRewardRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"liquidation_needed_report_reward_rate" yaml:"liquidation_needed_report_reward_rate"` - AcceptedAssets []Pool_Asset `protobuf:"bytes,6,rep,name=accepted_assets,json=acceptedAssets,proto3" json:"accepted_assets" yaml:"accepted_assets"` + AcceptedAssets []*Pool_Asset `protobuf:"bytes,6,rep,name=accepted_assets,json=acceptedAssets,proto3" json:"accepted_assets,omitempty" yaml:"accepted_assets"` } func (m *Pool) Reset() { *m = Pool{} } @@ -203,7 +203,7 @@ func (m *Pool) GetQuoteTicker() string { return "" } -func (m *Pool) GetAcceptedAssets() []Pool_Asset { +func (m *Pool) GetAcceptedAssets() []*Pool_Asset { if m != nil { return m.AcceptedAssets } @@ -410,7 +410,7 @@ type PerpetualFuturesParams struct { CommissionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=commission_rate,json=commissionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"commission_rate" yaml:"commission_rate"` MarginMaintenanceRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=margin_maintenance_rate,json=marginMaintenanceRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"margin_maintenance_rate" yaml:"margin_maintenance_rate"` ImaginaryFundingRateProportionalCoefficient github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=imaginary_funding_rate_proportional_coefficient,json=imaginaryFundingRateProportionalCoefficient,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"imaginary_funding_rate_proportional_coefficient" yaml:"imaginary_funding_rate_proportonal_coefficient"` - Markets []Market `protobuf:"bytes,4,rep,name=markets,proto3" json:"markets" yaml:"markets"` + Markets []*Market `protobuf:"bytes,4,rep,name=markets,proto3" json:"markets,omitempty" yaml:"markets"` } func (m *PerpetualFuturesParams) Reset() { *m = PerpetualFuturesParams{} } @@ -446,7 +446,7 @@ func (m *PerpetualFuturesParams) XXX_DiscardUnknown() { var xxx_messageInfo_PerpetualFuturesParams proto.InternalMessageInfo -func (m *PerpetualFuturesParams) GetMarkets() []Market { +func (m *PerpetualFuturesParams) GetMarkets() []*Market { if m != nil { return m.Markets } @@ -458,7 +458,7 @@ type PerpetualOptionsParams struct { StrikeCommissionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=strike_commission_rate,json=strikeCommissionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"strike_commission_rate" yaml:"premium_commission_rate"` MarginMaintenanceRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=margin_maintenance_rate,json=marginMaintenanceRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"margin_maintenance_rate" yaml:"margin_maintenance_rate"` ImaginaryFundingRateProportionalCoefficient github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=imaginary_funding_rate_proportional_coefficient,json=imaginaryFundingRateProportionalCoefficient,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"imaginary_funding_rate_proportional_coefficient" yaml:"imaginary_funding_rate_proportonal_coefficient"` - Markets []Market `protobuf:"bytes,5,rep,name=markets,proto3" json:"markets" yaml:"markets"` + Markets []*Market `protobuf:"bytes,5,rep,name=markets,proto3" json:"markets,omitempty" yaml:"markets"` } func (m *PerpetualOptionsParams) Reset() { *m = PerpetualOptionsParams{} } @@ -494,7 +494,7 @@ func (m *PerpetualOptionsParams) XXX_DiscardUnknown() { var xxx_messageInfo_PerpetualOptionsParams proto.InternalMessageInfo -func (m *PerpetualOptionsParams) GetMarkets() []Market { +func (m *PerpetualOptionsParams) GetMarkets() []*Market { if m != nil { return m.Markets } @@ -577,98 +577,97 @@ func init() { func init() { proto.RegisterFile("derivatives/derivatives.proto", fileDescriptor_c5fa11d50d3fed76) } var fileDescriptor_c5fa11d50d3fed76 = []byte{ - // 1441 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0x4b, 0x6f, 0x5b, 0xc5, - 0x17, 0xcf, 0x4d, 0x6c, 0x27, 0x9e, 0x3c, 0xea, 0xdc, 0xbc, 0xdc, 0xf4, 0x5f, 0x3b, 0x1d, 0xe9, - 0x5f, 0x45, 0xb4, 0xd8, 0x6a, 0x01, 0x21, 0x2a, 0x01, 0x8a, 0x53, 0x85, 0xa4, 0xe4, 0xa5, 0x69, - 0xa2, 0x4a, 0x2c, 0xb8, 0x9a, 0xdc, 0x3b, 0x76, 0x46, 0xf1, 0x9d, 0xb9, 0x9d, 0x3b, 0x37, 0x21, - 0xb0, 0x87, 0x2e, 0x2b, 0xd6, 0x7c, 0x08, 0x36, 0x7c, 0x03, 0x16, 0xdd, 0x20, 0x75, 0x85, 0x10, - 0x0b, 0x83, 0xd2, 0x2d, 0x2b, 0x7f, 0x02, 0x34, 0x8f, 0xeb, 0xd8, 0x79, 0xb4, 0x75, 0x01, 0x09, - 0x56, 0xf1, 0xcc, 0x39, 0xe7, 0x77, 0x1e, 0xf3, 0x3b, 0x67, 0xe6, 0x06, 0x5c,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x3c, 0x3b, 0x29, 0x39, 0xcf, 0x4f, 0x4a, - 0xce, 0xef, 0x27, 0x25, 0xe7, 0xe9, 0x8b, 0xd2, 0xc0, 0xf3, 0x17, 0xa5, 0x81, 0x5f, 0x5e, 0x94, - 0x06, 0x3e, 0xbb, 0x7d, 0xe9, 0x87, 0xf1, 0x17, 0xdd, 0xff, 0x79, 0x30, 0x14, 0xdc, 0xcb, 0xe9, - 0xcf, 0xa1, 0x77, 0xfe, 0x0c, 0x00, 0x00, 0xff, 0xff, 0xa4, 0xa3, 0xf6, 0xf3, 0xa1, 0x10, 0x00, - 0x00, + // 1440 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0x5b, 0x6f, 0x1b, 0xc5, + 0x17, 0xcf, 0x26, 0xb6, 0x13, 0x4f, 0x2e, 0x75, 0x36, 0x37, 0x37, 0xfd, 0xd7, 0x9b, 0x8e, 0xf4, + 0xaf, 0x22, 0x5a, 0x6c, 0xb5, 0x80, 0x10, 0x95, 0x00, 0xc5, 0xa9, 0x42, 0x52, 0x72, 0xd3, 0x34, + 0x51, 0x25, 0x1e, 0x58, 0x4d, 0x76, 0xc7, 0xce, 0x28, 0xde, 0x99, 0xed, 0xee, 0x6c, 0x42, 0xe0, + 0x11, 0x09, 0xf5, 0xb1, 0xe2, 0x99, 0x0f, 0x01, 0xdf, 0x81, 0x87, 0xbe, 0x20, 0x55, 0x3c, 0x21, + 0x1e, 0x0c, 0x4a, 0x5f, 0x79, 0xf2, 0x27, 0x40, 0x73, 0x59, 0xdf, 0x92, 0xb4, 0x75, 0x2b, 0x24, + 0x78, 0x8a, 0x67, 0xce, 0x39, 0xbf, 0x73, 0x99, 0xdf, 0x39, 0x33, 0x1b, 0x70, 0xdd, 0x27, 0x11, + 0x3d, 0xc6, 0x82, 0x1e, 0x93, 0xb8, 0xd2, 0xf5, 0xbb, 0x1c, 0x46, 0x5c, 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, 0x5a, 0xf1, 0x0e, 0x31, 0x65, 0x15, 0x71, 0x1a, 0x92, 0xb8, 0xfc, 0x50, 0x44, 0x94, + 0xd5, 0x57, 0x3c, 0x6f, 0x45, 0x9b, 0xb7, 0x9a, 0xce, 0x94, 0x76, 0x61, 0xf0, 0x20, 0x4a, 0x91, + 0xed, 0x7d, 0x90, 0xe7, 0x21, 0x61, 0xc4, 0x77, 0xb1, 0x28, 0x66, 0x54, 0xcc, 0x8b, 0x65, 0x5d, + 0xcc, 0x72, 0x5a, 0xcc, 0xf2, 0x5e, 0x5a, 0xcc, 0xea, 0xff, 0x4c, 0xc8, 0x05, 0x8d, 0xd7, 0x36, + 0x85, 0x4f, 0xff, 0x70, 0x2c, 0x34, 0xa6, 0xd7, 0x2b, 0xc2, 0xfe, 0x18, 0x4c, 0x1a, 0xd9, 0x21, + 0xa1, 0xf5, 0x43, 0x51, 0xcc, 0x2e, 0x59, 0xcb, 0x99, 0x6a, 0xb1, 0xd5, 0x74, 0x66, 0x7b, 0x4c, + 0xb5, 0x18, 0xa2, 0x09, 0xbd, 0x5e, 0x57, 0x4b, 0x9b, 0x80, 0x71, 0x23, 0x8f, 0xb0, 0x20, 0xc5, + 0x9c, 0x4a, 0xff, 0xbe, 0x49, 0xff, 0x66, 0x57, 0xfa, 0xe6, 0x54, 0xf5, 0x9f, 0x77, 0x63, 0xff, + 0xc8, 0x94, 0xe0, 0x3e, 0xf1, 0x5a, 0x4d, 0xc7, 0xee, 0x71, 0x25, 0xa1, 0x20, 0x02, 0x7a, 0x85, + 0xb0, 0x20, 0x36, 0x01, 0x85, 0x88, 0x04, 0x98, 0x32, 0xca, 0xea, 0x6e, 0x80, 0xa3, 0x3a, 0x65, + 0xc5, 0x51, 0x55, 0x83, 0xab, 0x65, 0x43, 0x01, 0xc9, 0x97, 0xb2, 0xe1, 0x4b, 0x79, 0x95, 0x53, + 0x56, 0x75, 0x4c, 0x09, 0x16, 0x34, 0x78, 0x3f, 0x00, 0x44, 0x57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xf6, 0xa2, 0x34, 0xf4, + 0xc5, 0xed, 0x4b, 0x3f, 0x86, 0xbf, 0xea, 0xfe, 0x6f, 0x83, 0xa6, 0xdf, 0x41, 0x4e, 0x7d, 0x02, + 0xbd, 0xf7, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x30, 0xbd, 0x4e, 0x53, 0x95, 0x10, 0x00, 0x00, } func (m *Position) Marshal() (dAtA []byte, err error) { @@ -1997,7 +1996,7 @@ func (m *Pool) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.AcceptedAssets = append(m.AcceptedAssets, Pool_Asset{}) + m.AcceptedAssets = append(m.AcceptedAssets, &Pool_Asset{}) if err := m.AcceptedAssets[len(m.AcceptedAssets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2713,7 +2712,7 @@ func (m *PerpetualFuturesParams) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Markets = append(m.Markets, Market{}) + m.Markets = append(m.Markets, &Market{}) if err := m.Markets[len(m.Markets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2933,7 +2932,7 @@ func (m *PerpetualOptionsParams) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Markets = append(m.Markets, Market{}) + m.Markets = append(m.Markets, &Market{}) if err := m.Markets[len(m.Markets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/derivatives/types/genesis_test.go b/x/derivatives/types/genesis_test.go index 0a6130b8d..ced0033cd 100644 --- a/x/derivatives/types/genesis_test.go +++ b/x/derivatives/types/genesis_test.go @@ -4,37 +4,30 @@ import ( "testing" "github.com/stretchr/testify/require" + "github.com/UnUniFi/chain/x/derivatives/types" ) func TestGenesisState_Validate(t *testing.T) { - for _, tc := range []struct { - desc string - genState *types.GenesisState - valid bool - } { - { - desc: "default is valid", - genState: types.DefaultGenesis(), - valid: true, - }, - { - desc: "valid genesis state", - genState: &types.GenesisState{ - - // this line is used by starport scaffolding # types/genesis/validField - }, - valid: true, - }, - // this line is used by starport scaffolding # types/genesis/testcase - } { - t.Run(tc.desc, func(t *testing.T) { - err := tc.genState.Validate() - if tc.valid { - require.NoError(t, err) - } else { - require.Error(t, err) - } - }) - } -} \ No newline at end of file + for _, tc := range []struct { + desc string + genState *types.GenesisState + valid bool + }{ + { + desc: "default is valid", + genState: types.DefaultGenesis(), + valid: true, + }, + // this line is used by starport scaffolding # types/genesis/testcase + } { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} diff --git a/x/derivatives/types/params.go b/x/derivatives/types/params.go index 4f3215e35..ff8e4276e 100644 --- a/x/derivatives/types/params.go +++ b/x/derivatives/types/params.go @@ -1,11 +1,51 @@ package types import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) var _ paramtypes.ParamSet = (*Params)(nil) +var ( + KeyPool = []byte("Pool") + keyPerpetualFutures = []byte("PerpetualFutures") + KeyPerpetualOptions = []byte("PerpetualOptions") +) + +func DefaultPool() Pool { + return Pool{ + QuoteTicker: "", + BaseLptMintFee: sdk.MustNewDecFromStr("0.001"), + BaseLptRedeemFee: sdk.MustNewDecFromStr("0.001"), + BorrowingFeeRatePerHour: sdk.ZeroDec(), + LiquidationNeededReportRewardRate: sdk.ZeroDec(), + AcceptedAssets: []*Pool_Asset{}, + } +} + +func DefaultPerpetualFuturesParams() PerpetualFuturesParams { + return PerpetualFuturesParams{ + CommissionRate: sdk.MustNewDecFromStr("0.001"), + MarginMaintenanceRate: sdk.MustNewDecFromStr("0.5"), + ImaginaryFundingRateProportionalCoefficient: sdk.MustNewDecFromStr("0.0005"), + Markets: []*Market{}, + } +} + +func DefaultPerpetualOptionsParams() PerpetualOptionsParams { + return PerpetualOptionsParams{ + PremiumCommissionRate: sdk.ZeroDec(), + StrikeCommissionRate: sdk.MustNewDecFromStr("0.001"), + MarginMaintenanceRate: sdk.ZeroDec(), + ImaginaryFundingRateProportionalCoefficient: sdk.ZeroDec(), + Markets: []*Market{}, + } +} + // ParamKeyTable the param key table for launch module func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) @@ -13,20 +53,94 @@ func ParamKeyTable() paramtypes.KeyTable { // NewParams creates a new Params instance func NewParams() Params { - return Params{} + return DefaultParams() } // DefaultParams returns a default set of parameters func DefaultParams() Params { - return NewParams() + return Params{ + Pool: DefaultPool(), + PerpetualFutures: DefaultPerpetualFuturesParams(), + PerpetualOptions: DefaultPerpetualOptionsParams(), + } } // ParamSetPairs get the params.ParamSet func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{} + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyPool, &p.Pool, validatePool), + paramtypes.NewParamSetPair(keyPerpetualFutures, &p.PerpetualFutures, validatePerpetualFutures), + paramtypes.NewParamSetPair(KeyPerpetualOptions, &p.PerpetualOptions, validatePerpetualOptions), + } } // Validate validates the set of params func (p Params) Validate() error { + if err := validatePool(p.Pool); err != nil { + return err + } + + if err := validatePerpetualFutures(p.PerpetualFutures); err != nil { + return err + } + + if err := validatePerpetualOptions(p.PerpetualOptions); err != nil { + return err + } + + return nil +} + +func validatePool(i interface{}) error { + // check type + pool, ok := i.(Pool) + if !ok { + return fmt.Errorf("invalid paramter type: %T", i) + } + + if !pool.BaseLptMintFee.LTE(sdk.OneDec()) { + return fmt.Errorf("invalid base lpt mint fee: %s", pool.BaseLptMintFee) + } + + if !pool.BaseLptRedeemFee.LTE(sdk.OneDec()) { + return fmt.Errorf("invalid base lpt redeem fee: %s", pool.BaseLptRedeemFee) + } + + if !pool.BorrowingFeeRatePerHour.LTE(sdk.OneDec()) { + return fmt.Errorf("invalid borrowing fee rate per hour: %s", pool.BorrowingFeeRatePerHour) + } + + if !pool.LiquidationNeededReportRewardRate.LTE(sdk.OneDec()) { + return fmt.Errorf("invalid liquidation needed report reward rate: %s", pool.LiquidationNeededReportRewardRate) + } + + return nil +} + +func validatePerpetualFutures(i interface{}) error { + // check type + perpetualFuturesParams, ok := i.(PerpetualFuturesParams) + if !ok { + return fmt.Errorf("invalid paramter type: %T", i) + } + + if !perpetualFuturesParams.CommissionRate.LTE(sdk.OneDec()) { + return fmt.Errorf("invalid commission rate: %s", perpetualFuturesParams.CommissionRate) + } + + if !perpetualFuturesParams.MarginMaintenanceRate.LTE(sdk.OneDec()) { + return fmt.Errorf("invalid margin maintenance rate: %s", perpetualFuturesParams.MarginMaintenanceRate) + } + + return nil +} + +func validatePerpetualOptions(i interface{}) error { + // check type + _, ok := i.(PerpetualOptionsParams) + if !ok { + return fmt.Errorf("invalid paramter type: %T", i) + } + return nil } diff --git a/x/ecosystem-incentive/client/cli/query.go b/x/ecosystem-incentive/client/cli/query.go index d54da60f7..30a44f5a8 100644 --- a/x/ecosystem-incentive/client/cli/query.go +++ b/x/ecosystem-incentive/client/cli/query.go @@ -28,6 +28,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { CmdQueryRecordedIncentiveUnitId(), CmdQueryAllRewards(), CmdQueryIncentiveUnit(), + CmdQueryIncentiveUnitIdsByAddr(), ) return cmd @@ -111,3 +112,29 @@ func CmdQueryIncentiveUnit() *cobra.Command { flags.AddQueryFlagsToCmd(cmd) return cmd } + +func CmdQueryIncentiveUnitIdsByAddr() *cobra.Command { + cmd := &cobra.Command{ + Use: "incentive-unit-ids-by-addr [address]", + Short: "shows incentive-unit-ids to which the address belongs", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + req := &types.QueryIncentiveUnitIdsByAddrRequest{ + Address: args[0], + } + + res, err := queryClient.IncentiveUnitIdsByAddr(context.Background(), req) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + return cmd +} diff --git a/x/ecosystem-incentive/genesis.go b/x/ecosystem-incentive/genesis.go index 75592a296..058d16ecb 100644 --- a/x/ecosystem-incentive/genesis.go +++ b/x/ecosystem-incentive/genesis.go @@ -3,21 +3,44 @@ package ecosystemincentive import ( sdk "github.com/cosmos/cosmos-sdk/types" + ununifitypes "github.com/UnUniFi/chain/types" "github.com/UnUniFi/chain/x/ecosystem-incentive/keeper" "github.com/UnUniFi/chain/x/ecosystem-incentive/types" ) -// InitGenesis initializes the capability module's state from a provided genesis -// state. +// InitGenesis initializes the capability module's state from a provided genesis state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { - // this line is used by starport scaffolding # genesis/module/init k.SetParams(ctx, genState.Params) + for _, incentiveUnit := range genState.IncentiveUnits { + var subjectAddrs []ununifitypes.StringAccAddress + var weights []sdk.Dec + for i := 0; i < len(incentiveUnit.SubjectInfoLists); i++ { + subjectAddrs = append(subjectAddrs, incentiveUnit.SubjectInfoLists[i].SubjectAddr) + weights = append(weights, incentiveUnit.SubjectInfoLists[i].Weight) + } + + if _, err := k.Register(ctx, &types.MsgRegister{ + IncentiveUnitId: incentiveUnit.Id, + SubjectAddrs: subjectAddrs, + Weights: weights, + }); err != nil { + panic(err) + } + } + + for _, rewardStore := range genState.RewardStores { + if err := k.SetRewardStore(ctx, rewardStore); err != nil { + panic(err) + } + } } // ExportGenesis returns the capability module's exported genesis. func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis := types.DefaultGenesis() genesis.Params = k.GetParams(ctx) + genesis.IncentiveUnits = k.GetAllIncentiveUnits(ctx) + genesis.RewardStores = k.GetAllRewardStores(ctx) return genesis } diff --git a/x/ecosystem-incentive/keeper/grpc_query.go b/x/ecosystem-incentive/keeper/grpc_query.go index c05bb40b7..5a9c90039 100644 --- a/x/ecosystem-incentive/keeper/grpc_query.go +++ b/x/ecosystem-incentive/keeper/grpc_query.go @@ -43,6 +43,30 @@ func (k Keeper) AllRewards(c context.Context, req *types.QueryAllRewardsRequest) return &types.QueryAllRewardsResponse{Rewards: allRewards}, nil } +func (k Keeper) Reward(c context.Context, req *types.QueryRewardRequest) (*types.QueryRewardResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid argument") + } + ctx := sdk.UnwrapSDKContext(c) + + accAddr, err := sdk.AccAddressFromBech32(req.SubjectAddr) + if err != nil { + return nil, err + } + + allRewards, exists := k.GetRewardStore(ctx, accAddr) + if !exists { + return nil, types.ErrAddressNotHaveReward + } + + exists, reward := allRewards.Rewards.Find(req.Denom) + if !exists { + return nil, types.ErrDenomRewardNotExists + } + + return &types.QueryRewardResponse{Reward: reward}, nil +} + func (k Keeper) IncentiveUnit(c context.Context, req *types.QueryIncentiveUnitRequest) (*types.QueryIncentiveUnitResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid argument") @@ -57,11 +81,6 @@ func (k Keeper) IncentiveUnit(c context.Context, req *types.QueryIncentiveUnitRe return &types.QueryIncentiveUnitResponse{IncentiveUnit: &incentiveUnit}, nil } -func (k Keeper) Reward(c context.Context, req *types.QueryRewardRequest) (*types.QueryRewardResponse, error) { - - return &types.QueryRewardResponse{}, nil -} - func (k Keeper) RecordedIncentiveUnitId(c context.Context, req *types.QueryRecordedIncentiveUnitIdRequest) (*types.QueryRecordedIncentiveUnitIdResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid argument") @@ -79,3 +98,22 @@ func (k Keeper) RecordedIncentiveUnitId(c context.Context, req *types.QueryRecor } return &types.QueryRecordedIncentiveUnitIdResponse{IncentiveUnitId: incentiveUnitid}, nil } + +func (k Keeper) IncentiveUnitIdsByAddr(c context.Context, req *types.QueryIncentiveUnitIdsByAddrRequest) (*types.QueryIncentiveUnitIdsByAddrResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid argument") + } + ctx := sdk.UnwrapSDKContext(c) + + addr, err := sdk.AccAddressFromBech32(req.Address) + if err != nil { + return nil, err + } + incentiveUnitIdsByAddr := k.GetIncentiveUnitIdsByAddr(ctx, addr) + + if incentiveUnitIdsByAddr.Address.AccAddress().Empty() { + return nil, types.ErrAddressNotHasIncentiveUnitId + } + + return &types.QueryIncentiveUnitIdsByAddrResponse{IncentiveUnitIdsByAddr: incentiveUnitIdsByAddr}, nil +} diff --git a/x/ecosystem-incentive/keeper/incentive_unit_service.go b/x/ecosystem-incentive/keeper/incentive_unit_service.go index 6d6c54c4e..80f278768 100644 --- a/x/ecosystem-incentive/keeper/incentive_unit_service.go +++ b/x/ecosystem-incentive/keeper/incentive_unit_service.go @@ -37,6 +37,18 @@ func (k Keeper) Register(ctx sdk.Context, msg *types.MsgRegister) (*[]types.Subj return nil, err } + // operation related to IncentiveUnitIdsByAddr + // if exists already, add incentuve unit id in msg into data + // if not, newly create and set + for _, addr := range msg.SubjectAddrs { + incentiveUnitIdsByAddr := k.GetIncentiveUnitIdsByAddr(ctx, addr.AccAddress()) + incentiveUnitIdsByAddr = incentiveUnitIdsByAddr.CreateOrUpdate(addr, msg.IncentiveUnitId) + + if err := k.SetIncentiveUnitIdsByAddr(ctx, incentiveUnitIdsByAddr); err != nil { + return nil, err + } + } + return &subjectInfoList, nil } @@ -53,12 +65,25 @@ func (k Keeper) SetIncentiveUnit(ctx sdk.Context, incentiveUnit types.IncentiveU return nil } +func (k Keeper) SetIncentiveUnitIdsByAddr(ctx sdk.Context, incentiveUnitIdsByAddr types.IncentiveUnitIdsByAddr) error { + bz, err := k.cdc.Marshal(&incentiveUnitIdsByAddr) + if err != nil { + return err + } + + store := ctx.KVStore(k.storeKey) + prefixStore := prefix.NewStore(store, []byte(types.KeyPrefixIncentiveUnitIdsByAddr)) + prefixStore.Set(incentiveUnitIdsByAddr.Address.AccAddress().Bytes(), bz) + + return nil +} + func (k Keeper) GetIncentiveUnit(ctx sdk.Context, id string) (types.IncentiveUnit, bool) { store := ctx.KVStore(k.storeKey) prefixStore := prefix.NewStore(store, []byte(types.KeyPrefixIncentiveUnit)) bz := prefixStore.Get([]byte(id)) - if len(bz) == 0 { + if bz == nil { return types.IncentiveUnit{}, false } @@ -67,9 +92,62 @@ func (k Keeper) GetIncentiveUnit(ctx sdk.Context, id string) (types.IncentiveUni return incentiveUnit, true } +func (k Keeper) GetIncentiveUnitIdsByAddr(ctx sdk.Context, address sdk.AccAddress) types.IncentiveUnitIdsByAddr { + store := ctx.KVStore(k.storeKey) + prefixStore := prefix.NewStore(store, []byte(types.KeyPrefixIncentiveUnitIdsByAddr)) + + bz := prefixStore.Get(address) + if bz == nil { + return types.IncentiveUnitIdsByAddr{} + } + + var incentiveUnitIdsByAddr types.IncentiveUnitIdsByAddr + k.cdc.MustUnmarshal(bz, &incentiveUnitIdsByAddr) + return incentiveUnitIdsByAddr +} + +func (k Keeper) GetAllIncentiveUnits(ctx sdk.Context) []types.IncentiveUnit { + store := ctx.KVStore(k.storeKey) + it := sdk.KVStorePrefixIterator(store, []byte(types.KeyPrefixIncentiveUnit)) + defer it.Close() + + allIncentiveUnits := []types.IncentiveUnit{} + for ; it.Valid(); it.Next() { + var incentiveUnit types.IncentiveUnit + k.cdc.MustUnmarshal(it.Value(), &incentiveUnit) + + allIncentiveUnits = append(allIncentiveUnits, incentiveUnit) + } + + return allIncentiveUnits +} + +func (k Keeper) GetAllIncentiveUnitIdsByAddrs(ctx sdk.Context) []types.IncentiveUnitIdsByAddr { + store := ctx.KVStore(k.storeKey) + it := sdk.KVStorePrefixIterator(store, []byte(types.KeyPrefixIncentiveUnitIdsByAddr)) + defer it.Close() + + allIncentiveUnitIdsByAddrs := []types.IncentiveUnitIdsByAddr{} + for ; it.Valid(); it.Next() { + var incentiveUnitIdsByAddr types.IncentiveUnitIdsByAddr + k.cdc.MustUnmarshal(it.Value(), &incentiveUnitIdsByAddr) + + allIncentiveUnitIdsByAddrs = append(allIncentiveUnitIdsByAddrs, incentiveUnitIdsByAddr) + } + + return allIncentiveUnitIdsByAddrs +} + func (k Keeper) DeleteIncentiveUnit(ctx sdk.Context, id string) { store := ctx.KVStore(k.storeKey) prefixStore := prefix.NewStore(store, []byte(types.KeyPrefixIncentiveUnit)) prefixStore.Delete([]byte(id)) } + +func (k Keeper) DeleteIncentiveUnitIdsByAddr(ctx sdk.Context, address sdk.AccAddress) { + store := ctx.KVStore(k.storeKey) + prefixStore := prefix.NewStore(store, []byte(types.KeyPrefixIncentiveUnitIdsByAddr)) + + prefixStore.Delete(address) +} diff --git a/x/ecosystem-incentive/keeper/incentive_unit_service_test.go b/x/ecosystem-incentive/keeper/incentive_unit_service_test.go index c07d936d7..7d198fcb3 100644 --- a/x/ecosystem-incentive/keeper/incentive_unit_service_test.go +++ b/x/ecosystem-incentive/keeper/incentive_unit_service_test.go @@ -74,6 +74,9 @@ func (suite *KeeperTestSuite) TestRegister() { for i, subject := range *subjectInfo { suite.Require().Equal(subject.SubjectAddr, tc.subjectAddrs[i]) suite.Require().Equal(subject.Weight, tc.weights[i]) + + incentiveUnitIdsByAddr := suite.app.EcosystemincentiveKeeper.GetIncentiveUnitIdsByAddr(suite.ctx, subject.SubjectAddr.AccAddress()) + suite.Require().Contains(incentiveUnitIdsByAddr.IncentiveUnitIds, tc.incentiveUnitId) } } else { suite.Require().Error(err) diff --git a/x/ecosystem-incentive/keeper/msg_server.go b/x/ecosystem-incentive/keeper/msg_server.go index c50f8e9b7..6a8d7e4d2 100644 --- a/x/ecosystem-incentive/keeper/msg_server.go +++ b/x/ecosystem-incentive/keeper/msg_server.go @@ -49,7 +49,7 @@ func (k msgServer) WithdrawAllRewards(c context.Context, msg *types.MsgWithdrawA } if err := ctx.EventManager().EmitTypedEvent(&types.EventWithdrawAllRewards{ - Sender: msg.Sender, + Sender: msg.Sender.AccAddress().String(), AllWithdrawnRewards: rewards, }); err != nil { return nil, err @@ -67,7 +67,7 @@ func (k msgServer) WithdrawReward(c context.Context, msg *types.MsgWithdrawRewar } if err := ctx.EventManager().EmitTypedEvent(&types.EventWithdrawReward{ - Sender: msg.Sender, + Sender: msg.Sender.AccAddress().String(), WithdrawnReward: reward, }); err != nil { return nil, err diff --git a/x/ecosystem-incentive/keeper/nftmarket_frontend_service.go b/x/ecosystem-incentive/keeper/nftmarket_frontend_service.go index 8cb3a00d5..17fab23b5 100644 --- a/x/ecosystem-incentive/keeper/nftmarket_frontend_service.go +++ b/x/ecosystem-incentive/keeper/nftmarket_frontend_service.go @@ -81,7 +81,7 @@ func (k Keeper) GetIncentiveUnitIdByNftId(ctx sdk.Context, nftId nftmarkettypes. prefixStore := prefix.NewStore(store, []byte(types.KeyPrefixIncentiveUnitIdByNftId)) bz := prefixStore.Get(nftId.IdBytes()) - if len(bz) == 0 { + if bz == nil { return "", false } diff --git a/x/ecosystem-incentive/keeper/reward_service.go b/x/ecosystem-incentive/keeper/reward_service.go index 5d884d7ff..b2fed6d19 100644 --- a/x/ecosystem-incentive/keeper/reward_service.go +++ b/x/ecosystem-incentive/keeper/reward_service.go @@ -77,7 +77,7 @@ func (k Keeper) SetRewardStore(ctx sdk.Context, rewardStore types.RewardStore) e store := ctx.KVStore(k.storeKey) prefixStore := prefix.NewStore(store, []byte(types.KeyPrefixRewardStore)) - prefixStore.Set(rewardStore.SubjectAddr.AccAddress(), bz) + prefixStore.Set(rewardStore.SubjectAddr.AccAddress().Bytes(), bz) return nil } @@ -87,7 +87,7 @@ func (k Keeper) GetRewardStore(ctx sdk.Context, subject sdk.AccAddress) (types.R prefixStore := prefix.NewStore(store, []byte(types.KeyPrefixRewardStore)) bz := prefixStore.Get(subject) - if len(bz) == 0 { + if bz == nil { return types.RewardStore{}, false } @@ -96,6 +96,22 @@ func (k Keeper) GetRewardStore(ctx sdk.Context, subject sdk.AccAddress) (types.R return reward, true } +func (k Keeper) GetAllRewardStores(ctx sdk.Context) []types.RewardStore { + store := ctx.KVStore(k.storeKey) + it := sdk.KVStorePrefixIterator(store, []byte(types.KeyPrefixRewardStore)) + defer it.Close() + + allRewardStores := []types.RewardStore{} + for ; it.Valid(); it.Next() { + var rewardStore types.RewardStore + k.cdc.MustUnmarshal(it.Value(), &rewardStore) + + allRewardStores = append(allRewardStores, rewardStore) + } + + return allRewardStores +} + func (k Keeper) DeleteRewardStore(ctx sdk.Context, subject sdk.AccAddress) { store := ctx.KVStore(k.storeKey) prefixStore := prefix.NewStore(store, []byte(types.KeyPrefixRewardStore)) diff --git a/x/ecosystem-incentive/spec/02_state.md b/x/ecosystem-incentive/spec/02_state.md index 08426c67b..a2e09c33f 100644 --- a/x/ecosystem-incentive/spec/02_state.md +++ b/x/ecosystem-incentive/spec/02_state.md @@ -80,13 +80,10 @@ message Params { } message RewardParams { - string module_name = 1 [ - (gogoproto.moretags) = "yaml:\"module_name\"" - ]; - repeated RewardRate reward_rate = 2 [ - (gogoproto.moretags) = "yaml:\"reward_rate\"", - (gogoproto.nullable) = false - ]; + string module_name = 1 [(gogoproto.nullable) = false]; + repeated IncentiveUnit incentive_units = 2 [(gogoproto.nullable) = false]; + repeated RewardStore reward_stores = 3 [(gogoproto.nullable) = false]; + repeated IncentiveUnitIdsByAddr incentive_unit_ids_by_addr = 4 [(gogoproto.nullable) = false]; } // RewardRate defines the ratio to take reward for a specific reward_type. @@ -122,3 +119,21 @@ At first, we support frontend creator. But, the reward will be able to distribut ### MaxIncentiveUnitIdLen The length of `IncentiveUnitId` must be between `MaxIncentiveUnitIdLen` and 0. + +## IncentiveUnitIdsByAddr + +IncentiveUnitIdsByAddr is the collection of the incentive unit ids for each address. + +```protobuf +message IncentiveUnitIdsByAddr { + string address = 1 [ + (gogoproto.moretags) = "yaml:\"address\"", + (gogoproto.customtype) = "github.com/UnUniFi/chain/types.StringAccAddress", + (gogoproto.nullable) = false + ]; + repeated string incentive_unit_ids = 2 [ + (gogoproto.moretags) = "yaml:\"incentive_unit_ids\"", + (gogoproto.nullable) = false + ]; +} +``` diff --git a/x/ecosystem-incentive/spec/03_msgs_and_queries.md b/x/ecosystem-incentive/spec/03_msgs_and_queries.md index c25c5305b..ca5a367d3 100644 --- a/x/ecosystem-incentive/spec/03_msgs_and_queries.md +++ b/x/ecosystem-incentive/spec/03_msgs_and_queries.md @@ -147,3 +147,19 @@ message QueryRewardResponse { } ``` +### IncentiveUnitIdsByAddr + +```protobuf +message QueryIncentiveUnitIdsByAddrRequest { + string address = 1 [ + (gogoproto.moretags) = "yaml:\"address\"" + ]; +} + +message QueryIncentiveUnitIdsByAddrResponse { + IncentiveUnitIdsByAddr incentive_unit_ids_by_addr = 1 [ + (gogoproto.moretags) = "yaml:\"incentive_unit_ids_by_addr\"", + (gogoproto.nullable) = false + ]; +} +``` diff --git a/x/ecosystem-incentive/types/ecosystem_incentive.pb.go b/x/ecosystem-incentive/types/ecosystem_incentive.pb.go index 81bf7dea9..35694aa6f 100644 --- a/x/ecosystem-incentive/types/ecosystem_incentive.pb.go +++ b/x/ecosystem-incentive/types/ecosystem_incentive.pb.go @@ -161,10 +161,56 @@ func (m *RewardStore) GetRewards() github_com_cosmos_cosmos_sdk_types.Coins { return nil } +type IncentiveUnitIdsByAddr struct { + Address github_com_UnUniFi_chain_types.StringAccAddress `protobuf:"bytes,1,opt,name=address,proto3,customtype=github.com/UnUniFi/chain/types.StringAccAddress" json:"address" yaml:"address"` + IncentiveUnitIds []string `protobuf:"bytes,2,rep,name=incentive_unit_ids,json=incentiveUnitIds,proto3" json:"incentive_unit_ids,omitempty" yaml:"incentive_unit_ids"` +} + +func (m *IncentiveUnitIdsByAddr) Reset() { *m = IncentiveUnitIdsByAddr{} } +func (m *IncentiveUnitIdsByAddr) String() string { return proto.CompactTextString(m) } +func (*IncentiveUnitIdsByAddr) ProtoMessage() {} +func (*IncentiveUnitIdsByAddr) Descriptor() ([]byte, []int) { + return fileDescriptor_b09f3079d309ee36, []int{3} +} +func (m *IncentiveUnitIdsByAddr) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IncentiveUnitIdsByAddr) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IncentiveUnitIdsByAddr.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *IncentiveUnitIdsByAddr) XXX_Merge(src proto.Message) { + xxx_messageInfo_IncentiveUnitIdsByAddr.Merge(m, src) +} +func (m *IncentiveUnitIdsByAddr) XXX_Size() int { + return m.Size() +} +func (m *IncentiveUnitIdsByAddr) XXX_DiscardUnknown() { + xxx_messageInfo_IncentiveUnitIdsByAddr.DiscardUnknown(m) +} + +var xxx_messageInfo_IncentiveUnitIdsByAddr proto.InternalMessageInfo + +func (m *IncentiveUnitIdsByAddr) GetIncentiveUnitIds() []string { + if m != nil { + return m.IncentiveUnitIds + } + return nil +} + func init() { proto.RegisterType((*IncentiveUnit)(nil), "ununifi.ecosystemincentive.IncentiveUnit") proto.RegisterType((*SubjectInfo)(nil), "ununifi.ecosystemincentive.SubjectInfo") proto.RegisterType((*RewardStore)(nil), "ununifi.ecosystemincentive.RewardStore") + proto.RegisterType((*IncentiveUnitIdsByAddr)(nil), "ununifi.ecosystemincentive.IncentiveUnitIdsByAddr") } func init() { @@ -172,36 +218,39 @@ func init() { } var fileDescriptor_b09f3079d309ee36 = []byte{ - // 454 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x93, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0xc7, 0x9b, 0x22, 0x0d, 0xcd, 0xa5, 0x08, 0x05, 0x0e, 0x5d, 0x25, 0x92, 0xe1, 0x03, 0xf4, - 0x52, 0x5b, 0x03, 0x4e, 0x5c, 0xd0, 0x02, 0x42, 0x9a, 0x84, 0x76, 0x48, 0x55, 0x21, 0x71, 0xa9, - 0x12, 0xdb, 0x4d, 0x1f, 0xac, 0xf6, 0x88, 0xdd, 0x75, 0xfd, 0x16, 0x7c, 0x0c, 0xc4, 0x27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 0x6b, 0x9f, 0xe7, 0xf4, 0x5f, - 0x17, 0xa7, 0xc2, 0xa7, 0x3b, 0xd5, 0x66, 0x3f, 0xf9, 0x15, 0x00, 0x00, 0xff, 0xff, 0x47, 0xf2, - 0x54, 0x40, 0x5c, 0x03, 0x00, 0x00, + // 512 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x94, 0x41, 0x6f, 0xd3, 0x30, + 0x14, 0xc7, 0x9b, 0x22, 0x6d, 0xaa, 0x4b, 0xd1, 0x14, 0x10, 0xea, 0x2a, 0x2d, 0x19, 0x3e, 0x40, + 0x2f, 0xb5, 0x35, 0xe0, 0xc4, 0x05, 0x2d, 0x20, 0xa4, 0x0a, 0xb4, 0x43, 0xaa, 0x0a, 0x89, 0x4b, + 0x95, 0xda, 0x6e, 0xfb, 0x60, 0xb5, 0x47, 0xec, 0xae, 0xeb, 0xb7, 0xe0, 0x63, 0x20, 0x3e, 0xc9, + 0xc4, 0x69, 0x47, 0xe0, 0x10, 0x50, 0xfb, 0x0d, 0x7a, 0xe3, 0x86, 0x12, 0xbb, 0xdd, 0xc6, 0x98, + 0x84, 0xb8, 0x70, 0x4a, 0xf2, 0xf2, 0xde, 0xef, 0xff, 0x7f, 0xcf, 0x2f, 0x41, 0x2d, 0xc1, 0x94, + 0x9e, 0x69, 0x23, 0xc6, 0x2d, 0x90, 0x4c, 0x48, 0x03, 0xc7, 0x82, 0xae, 0x63, 0xbd, 0x75, 0x8c, + 0x1c, 0xa5, 0xca, 0x28, 0xbf, 0x31, 0x91, 0x13, 0x09, 0x03, 0x20, 0xeb, 0x94, 0x75, 0x46, 0xe3, + 0xce, 0x50, 0x0d, 0x55, 0x91, 0x46, 0xf3, 0x3b, 0x5b, 0xd1, 0x08, 0x98, 0xd2, 0x63, 0xa5, 0x69, + 0x3f, 0xd1, 0x82, 0x1e, 0xef, 0xf5, 0x85, 0x49, 0xf6,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shal() (dAtA []byte, err error) { @@ -338,6 +387,48 @@ func (m *RewardStore) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *IncentiveUnitIdsByAddr) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *IncentiveUnitIdsByAddr) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IncentiveUnitIdsByAddr) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.IncentiveUnitIds) > 0 { + for iNdEx := len(m.IncentiveUnitIds) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.IncentiveUnitIds[iNdEx]) + copy(dAtA[i:], m.IncentiveUnitIds[iNdEx]) + i = encodeVarintEcosystemIncentive(dAtA, i, uint64(len(m.IncentiveUnitIds[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + { + size := m.Address.Size() + i -= size + if _, err := m.Address.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintEcosystemIncentive(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func encodeVarintEcosystemIncentive(dAtA []byte, offset int, v uint64) int { offset -= sovEcosystemIncentive(v) base := offset @@ -398,6 +489,23 @@ func (m *RewardStore) Size() (n int) { return n } +func (m *IncentiveUnitIdsByAddr) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Address.Size() + n += 1 + l + sovEcosystemIncentive(uint64(l)) + if len(m.IncentiveUnitIds) > 0 { + for _, s := range m.IncentiveUnitIds { + l = len(s) + n += 1 + l + sovEcosystemIncentive(uint64(l)) + } + } + return n +} + func sovEcosystemIncentive(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -756,6 +864,122 @@ func (m *RewardStore) Unmarshal(dAtA []byte) error { } return nil } +func (m *IncentiveUnitIdsByAddr) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEcosystemIncentive + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: IncentiveUnitIdsByAddr: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IncentiveUnitIdsByAddr: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEcosystemIncentive + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEcosystemIncentive + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEcosystemIncentive + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Address.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IncentiveUnitIds", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEcosystemIncentive + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEcosystemIncentive + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEcosystemIncentive + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.IncentiveUnitIds = append(m.IncentiveUnitIds, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEcosystemIncentive(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEcosystemIncentive + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipEcosystemIncentive(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/ecosystem-incentive/types/errors.go b/x/ecosystem-incentive/types/errors.go index 307bec56e..71c8cd2c7 100644 --- a/x/ecosystem-incentive/types/errors.go +++ b/x/ecosystem-incentive/types/errors.go @@ -19,4 +19,5 @@ var ( ErrUnknownMemoVersion = sdkerrors.Register(ModuleName, 12, "the version in the memo inputs is unknown") ErrInvalidIncentiveUnitIdLen = sdkerrors.Register(ModuleName, 13, "the length of incentive unit id is invalid") ErrInvalidSubjectInfoNumInUnit = sdkerrors.Register(ModuleName, 14, "the number of subject info in a incentive unit is invalid") + ErrAddressNotHasIncentiveUnitId = sdkerrors.Register(ModuleName, 15, "the address deosn't have any incentive unit id") ) diff --git a/x/ecosystem-incentive/types/event.pb.go b/x/ecosystem-incentive/types/event.pb.go index 0981a3d65..cca4a9e81 100644 --- a/x/ecosystem-incentive/types/event.pb.go +++ b/x/ecosystem-incentive/types/event.pb.go @@ -5,7 +5,6 @@ package types import ( fmt "fmt" - github_com_UnUniFi_chain_types "github.com/UnUniFi/chain/types" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" @@ -79,8 +78,8 @@ func (m *EventRegister) GetSubjectInfoLists() []SubjectInfo { } type EventWithdrawAllRewards struct { - Sender github_com_UnUniFi_chain_types.StringAccAddress `protobuf:"bytes,1,opt,name=sender,proto3,customtype=github.com/UnUniFi/chain/types.StringAccAddress" json:"sender" yaml:"sender"` - AllWithdrawnRewards github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=all_withdrawn_rewards,json=allWithdrawnRewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"all_withdrawn_rewards" yaml:"all_withdrawn_rewards"` + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + AllWithdrawnRewards github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=all_withdrawn_rewards,json=allWithdrawnRewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"all_withdrawn_rewards" yaml:"all_withdrawn_rewards"` } func (m *EventWithdrawAllRewards) Reset() { *m = EventWithdrawAllRewards{} } @@ -116,6 +115,13 @@ func (m *EventWithdrawAllRewards) XXX_DiscardUnknown() { var xxx_messageInfo_EventWithdrawAllRewards proto.InternalMessageInfo +func (m *EventWithdrawAllRewards) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + func (m *EventWithdrawAllRewards) GetAllWithdrawnRewards() github_com_cosmos_cosmos_sdk_types.Coins { if m != nil { return m.AllWithdrawnRewards @@ -124,8 +130,8 @@ func (m *EventWithdrawAllRewards) GetAllWithdrawnRewards() github_com_cosmos_cos } type EventWithdrawReward struct { - Sender github_com_UnUniFi_chain_types.StringAccAddress `protobuf:"bytes,1,opt,name=sender,proto3,customtype=github.com/UnUniFi/chain/types.StringAccAddress" json:"sender" yaml:"sender"` - WithdrawnReward types.Coin `protobuf:"bytes,2,opt,name=withdrawn_reward,json=withdrawnReward,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coin" json:"withdrawn_reward" yaml:"withdrawn_reward"` + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + WithdrawnReward types.Coin `protobuf:"bytes,2,opt,name=withdrawn_reward,json=withdrawnReward,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coin" json:"withdrawn_reward" yaml:"withdrawn_reward"` } func (m *EventWithdrawReward) Reset() { *m = EventWithdrawReward{} } @@ -161,6 +167,13 @@ func (m *EventWithdrawReward) XXX_DiscardUnknown() { var xxx_messageInfo_EventWithdrawReward proto.InternalMessageInfo +func (m *EventWithdrawReward) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + func (m *EventWithdrawReward) GetWithdrawnReward() types.Coin { if m != nil { return m.WithdrawnReward @@ -592,55 +605,53 @@ func init() { func init() { proto.RegisterFile("ecosystem-incentive/event.proto", fileDescriptor_c2b67b0578f1794f) } var fileDescriptor_c2b67b0578f1794f = []byte{ - // 763 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0x41, 0x4f, 0x1b, 0x39, - 0x14, 0xce, 0x84, 0x5d, 0x76, 0xd7, 0x2c, 0x0a, 0x0c, 0x20, 0x02, 0x42, 0x19, 0xf0, 0x1e, 0x88, - 0x56, 0x62, 0x46, 0xec, 0xf6, 0xd4, 0x1b, 0x69, 0x9b, 0x92, 0xaa, 0x45, 0x68, 0x50, 0x5a, 0xa9, - 0x97, 0xe9, 0x64, 0xec, 0x24, 0x6e, 0x67, 0xec, 0x74, 0xec, 0x24, 0xf0, 0x0b, 0x2a, 0xf5, 0xc4, - 0x1f, 0x40, 0xbd, 0xf7, 0x37, 0xf4, 0xd4, 0x4b, 0x39, 0x22, 0xf5, 0x52, 0xf5, 0x90, 0x56, 0x70, - 0xe9, 0x39, 0xbf, 0xa0, 0x1a, 0xdb, 0x49, 0x80, 0x00, 0x02, 0x09, 0x2a, 0x71, 0xc2, 0xbc, 0xf7, - 0xfc, 0xbd, 0xf7, 0x7d, 0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 0x4c, 0x31, 0xba, 0xf4, 0x96, 0x79, 0xa8, 0xb7, 0xcc, - 0xb4, 0xca, 0x72, 0xe2, 0xf6, 0x95, 0x56, 0xcc, 0xdf, 0xea, 0xaa, 0xde, 0x2f, 0x1f, 0x0c, 0x2d, - 0xef, 0x53, 0x1c, 0x73, 0xc2, 0x68, 0x99, 0x46, 0xbe, 0x08, 0xea, 0x18, 0x99, 0x25, 0x30, 0xd9, - 0xec, 0xfd, 0xe3, 0xb5, 0x94, 0x77, 0x98, 0xed, 0x50, 0x08, 0x74, 0x27, 0xfa, 0x36, 0x8d, 0x79, - 0x73, 0x8f, 0xa3, 0xb0, 0xb1, 0x7f, 0x98, 0x33, 0x0e, 0x0e, 0x73, 0xc6, 0xf7, 0xc3, 0x9c, 0xb1, - 0x7b, 0x94, 0x4b, 0x1d, 0x1c, 0xe5, 0x52, 0x5f, 0x8e, 0x72, 0xa9, 0xe7, 0x77, 0xce, 0xfd, 0x55, - 0xd8, 0x76, 0xce, 0xfa, 0x76, 0x91, 0x0a, 0x55, 0x46, 0xe5, 0x87, 0xc7, 0xff, 0x3f, 0x03, 0x00, - 0x00, 0xff, 0xff, 0x6f, 0x72, 0x1a, 0x9b, 0x1c, 0x09, 0x00, 0x00, + // 729 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x96, 0x41, 0x4f, 0x13, 0x4d, + 0x18, 0xc7, 0x3b, 0xe5, 0x7d, 0x79, 0x5f, 0x07, 0x49, 0x61, 0x81, 0x50, 0x08, 0xe9, 0xc2, 0x7a, + 0xa0, 0x9a, 0xb0, 0x1b, 0xd4, 0x93, 0x37, 0xab, 0x56, 0x6b, 0x94, 0x90, 0x35, 0xd5, 0xc4, 0xcb, + 0x66, 0xbb, 0x33, 0x6d, 0x47, 0x77, 0x67, 0xea, 0xce, 0xb4, 0x85, 0x4f, 0xe0, 0x95, 0x2f, 0x60, + 0xbc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cc, 0xaa, 0x5b, 0x8e, 0x9d, 0x3e, 0xd7, 0x88, 0xb9, 0xae, 0x8e, + 0xea, 0xf9, 0xf2, 0x19, 0xe8, 0xf4, 0xbe, 0xc4, 0x31, 0x27, 0x8c, 0x56, 0x69, 0xe4, 0x8b, 0xa0, + 0x89, 0x91, 0x51, 0x81, 0xd3, 0xed, 0xc1, 0x3f, 0x5e, 0x47, 0xed, 0x8e, 0xd2, 0x8e, 0x84, 0x58, + 0xee, 0x54, 0xaa, 0x69, 0xcf, 0xcb, 0x6b, 0x8e, 0xd2, 0xc6, 0xee, 0x7e, 0x01, 0xec, 0xed, 0x17, + 0xc0, 0xcf, 0xfd, 0x02, 0xd8, 0x39, 0x28, 0x64, 0xf6, 0x0e, 0x0a, 0x99, 0xef, 0x07, 0x85, 0xcc, + 0xeb, 0xbb, 0x47, 0xf2, 0x51, 0xa5, 0x55, 0x4a, 0xca, 0xc4, 0x09, 0x9a, 0x3e, 0xa1, 0xce, 0x96, + 0x73, 0xd2, 0xd7, 0x84, 0xcc, 0x50, 0x6d, 0x5c, 0x7e, 0x0a, 0xdc, 0xf9, 0x13, 0x00, 0x00, 0xff, + 0xff, 0x01, 0xa0, 0xa4, 0xff, 0xae, 0x08, 0x00, 0x00, } func (m *EventRegister) Marshal() (dAtA []byte, err error) { @@ -721,16 +732,13 @@ func (m *EventWithdrawAllRewards) MarshalToSizedBuffer(dAtA []byte) (int, error) dAtA[i] = 0x12 } } - { - size := m.Sender.Size() - i -= size - if _, err := m.Sender.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintEvent(dAtA, i, uint64(size)) + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -764,16 +772,13 @@ func (m *EventWithdrawReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x12 - { - size := m.Sender.Size() - i -= size - if _, err := m.Sender.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintEvent(dAtA, i, uint64(size)) + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -1110,8 +1115,10 @@ func (m *EventWithdrawAllRewards) Size() (n int) { } var l int _ = l - l = m.Sender.Size() - n += 1 + l + sovEvent(uint64(l)) + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } if len(m.AllWithdrawnRewards) > 0 { for _, e := range m.AllWithdrawnRewards { l = e.Size() @@ -1127,8 +1134,10 @@ func (m *EventWithdrawReward) Size() (n int) { } var l int _ = l - l = m.Sender.Size() - n += 1 + l + sovEvent(uint64(l)) + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } l = m.WithdrawnReward.Size() n += 1 + l + sovEvent(uint64(l)) return n @@ -1452,9 +1461,7 @@ func (m *EventWithdrawAllRewards) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Sender.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Sender = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -1570,9 +1577,7 @@ func (m *EventWithdrawReward) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Sender.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Sender = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { diff --git a/x/ecosystem-incentive/types/incentive_unit.go b/x/ecosystem-incentive/types/incentive_unit.go index 4cfe812a3..c6291df39 100644 --- a/x/ecosystem-incentive/types/incentive_unit.go +++ b/x/ecosystem-incentive/types/incentive_unit.go @@ -19,3 +19,27 @@ func NewSubjectInfo(subjectAddr ununifitypes.StringAccAddress, weight sdk.Dec) S Weight: weight, } } + +func NewIncentiveUnitIdsByAddr(address ununifitypes.StringAccAddress, incentiveUnitId string) IncentiveUnitIdsByAddr { + var incentiveUnitIds []string + incentiveUnitIds = append(incentiveUnitIds, incentiveUnitId) + + return IncentiveUnitIdsByAddr{ + Address: address, + IncentiveUnitIds: incentiveUnitIds, + } +} + +func (m IncentiveUnitIdsByAddr) AddIncentiveUnitId(incentiveUnitId string) []string { + return append(m.IncentiveUnitIds, incentiveUnitId) +} + +func (m IncentiveUnitIdsByAddr) CreateOrUpdate(address ununifitypes.StringAccAddress, incentiveUnitId string) IncentiveUnitIdsByAddr { + if m.Address.AccAddress().Empty() { + m = NewIncentiveUnitIdsByAddr(address, incentiveUnitId) + } else { + m.IncentiveUnitIds = m.AddIncentiveUnitId(incentiveUnitId) + } + + return m +} diff --git a/x/ecosystem-incentive/types/incentive_unit_test.go b/x/ecosystem-incentive/types/incentive_unit_test.go new file mode 100644 index 000000000..2f6042ffe --- /dev/null +++ b/x/ecosystem-incentive/types/incentive_unit_test.go @@ -0,0 +1,36 @@ +package types_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/ed25519" + + "github.com/UnUniFi/chain/x/ecosystem-incentive/types" +) + +func TestAddIncentiveUnitid(t *testing.T) { + addr := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + + incentiveUnitIdsByAddr := types.NewIncentiveUnitIdsByAddr(addr.Bytes(), "test") + addingId := "added_id" + newIncentiveUnitIdsByAddr := incentiveUnitIdsByAddr.AddIncentiveUnitId(addingId) + require.Equal(t, 2, len(newIncentiveUnitIdsByAddr)) + require.Contains(t, newIncentiveUnitIdsByAddr, addingId) +} + +func TestCreateOrUpdate(t *testing.T) { + addr := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + + // in case for creating new one + incentiveUnitIdsByAddr := types.IncentiveUnitIdsByAddr{} + incentiveUnitIdsByAddr = incentiveUnitIdsByAddr.CreateOrUpdate(addr.Bytes(), "test") + require.Equal(t, 1, len(incentiveUnitIdsByAddr.IncentiveUnitIds)) + + // in case for the update by adding new id + addingId := "added_id" + incentiveUnitIdsByAddr = incentiveUnitIdsByAddr.CreateOrUpdate(addr.Bytes(), addingId) + require.Equal(t, 2, len(incentiveUnitIdsByAddr.IncentiveUnitIds)) + require.Contains(t, incentiveUnitIdsByAddr.IncentiveUnitIds, addingId) +} diff --git a/x/ecosystem-incentive/types/keys.go b/x/ecosystem-incentive/types/keys.go index 886f627ab..e6db910c2 100644 --- a/x/ecosystem-incentive/types/keys.go +++ b/x/ecosystem-incentive/types/keys.go @@ -26,4 +26,7 @@ var ( // KeyPrefixIncentiveUnitIdByNftId defines prefix key for nft_id with incentive_id KeyPrefixIncentiveUnitIdByNftId = []byte{0x03} + + // KeyPrefixIncentiveUnitIdByAddr defines prefix key for incentiveUnitIdsByAddr with address + KeyPrefixIncentiveUnitIdsByAddr = []byte{0x04} ) diff --git a/x/ecosystem-incentive/types/query.pb.go b/x/ecosystem-incentive/types/query.pb.go index 71a63f976..63af7d2b5 100644 --- a/x/ecosystem-incentive/types/query.pb.go +++ b/x/ecosystem-incentive/types/query.pb.go @@ -480,6 +480,94 @@ func (m *QueryRecordedIncentiveUnitIdResponse) GetIncentiveUnitId() string { return "" } +type QueryIncentiveUnitIdsByAddrRequest struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` +} + +func (m *QueryIncentiveUnitIdsByAddrRequest) Reset() { *m = QueryIncentiveUnitIdsByAddrRequest{} } +func (m *QueryIncentiveUnitIdsByAddrRequest) String() string { return proto.CompactTextString(m) } +func (*QueryIncentiveUnitIdsByAddrRequest) ProtoMessage() {} +func (*QueryIncentiveUnitIdsByAddrRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_fea249937a184eac, []int{10} +} +func (m *QueryIncentiveUnitIdsByAddrRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryIncentiveUnitIdsByAddrRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryIncentiveUnitIdsByAddrRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryIncentiveUnitIdsByAddrRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryIncentiveUnitIdsByAddrRequest.Merge(m, src) +} +func (m *QueryIncentiveUnitIdsByAddrRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryIncentiveUnitIdsByAddrRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryIncentiveUnitIdsByAddrRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryIncentiveUnitIdsByAddrRequest proto.InternalMessageInfo + +func (m *QueryIncentiveUnitIdsByAddrRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +type QueryIncentiveUnitIdsByAddrResponse struct { + IncentiveUnitIdsByAddr IncentiveUnitIdsByAddr `protobuf:"bytes,1,opt,name=incentive_unit_ids_by_addr,json=incentiveUnitIdsByAddr,proto3" json:"incentive_unit_ids_by_addr" yaml:"incentive_unit_ids_by_addr"` +} + +func (m *QueryIncentiveUnitIdsByAddrResponse) Reset() { *m = QueryIncentiveUnitIdsByAddrResponse{} } +func (m *QueryIncentiveUnitIdsByAddrResponse) String() string { return proto.CompactTextString(m) } +func (*QueryIncentiveUnitIdsByAddrResponse) ProtoMessage() {} +func (*QueryIncentiveUnitIdsByAddrResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_fea249937a184eac, []int{11} +} +func (m *QueryIncentiveUnitIdsByAddrResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryIncentiveUnitIdsByAddrResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryIncentiveUnitIdsByAddrResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryIncentiveUnitIdsByAddrResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryIncentiveUnitIdsByAddrResponse.Merge(m, src) +} +func (m *QueryIncentiveUnitIdsByAddrResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryIncentiveUnitIdsByAddrResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryIncentiveUnitIdsByAddrResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryIncentiveUnitIdsByAddrResponse proto.InternalMessageInfo + +func (m *QueryIncentiveUnitIdsByAddrResponse) GetIncentiveUnitIdsByAddr() IncentiveUnitIdsByAddr { + if m != nil { + return m.IncentiveUnitIdsByAddr + } + return IncentiveUnitIdsByAddr{} +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "ununifi.ecosystemincentive.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "ununifi.ecosystemincentive.QueryParamsResponse") @@ -491,65 +579,74 @@ func init() { proto.RegisterType((*QueryRewardResponse)(nil), "ununifi.ecosystemincentive.QueryRewardResponse") proto.RegisterType((*QueryRecordedIncentiveUnitIdRequest)(nil), "ununifi.ecosystemincentive.QueryRecordedIncentiveUnitIdRequest") proto.RegisterType((*QueryRecordedIncentiveUnitIdResponse)(nil), "ununifi.ecosystemincentive.QueryRecordedIncentiveUnitIdResponse") + proto.RegisterType((*QueryIncentiveUnitIdsByAddrRequest)(nil), "ununifi.ecosystemincentive.QueryIncentiveUnitIdsByAddrRequest") + proto.RegisterType((*QueryIncentiveUnitIdsByAddrResponse)(nil), "ununifi.ecosystemincentive.QueryIncentiveUnitIdsByAddrResponse") } func init() { proto.RegisterFile("ecosystem-incentive/query.proto", fileDescriptor_fea249937a184eac) } var fileDescriptor_fea249937a184eac = []byte{ - // 844 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4f, 0x4f, 0x1b, 0x47, - 0x14, 0xf7, 0x22, 0x61, 0xda, 0xe1, 0x5f, 0x19, 0xfe, 0xaf, 0x90, 0x17, 0x0d, 0x6d, 0xa1, 0xad, - 0xd8, 0x11, 0xd0, 0x3f, 0x2a, 0xaa, 0x04, 0xb8, 0x52, 0x5b, 0xab, 0x6a, 0x15, 0x96, 0x70, 0x48, - 0x2e, 0xd6, 0x7a, 0x77, 0x30, 0x13, 0xec, 0x19, 0xb3, 0xbb, 0x26, 0x58, 0x96, 0x15, 0x29, 0xb7, - 0xe4, 0x14, 0x29, 0x52, 0x3e, 0x44, 0xa4, 0x5c, 0xf3, 0x15, 0xe0, 0x88, 0x94, 0x4b, 0x4e, 0x4e, - 0x04, 0xf9, 0x02, 0xf1, 0x27, 0x88, 0x3c, 0x33, 0x6b, 0xbc, 0xb1, 0x59, 0x4c, 0xc4, 0xc9, 0xbb, - 0x33, 0xef, 0xfd, 0xfe, 0x3c, 0xbf, 0xf7, 0xb4, 0xc0, 0x20, 0x0e, 0xf7, 0x2b, 0x7e, 0x40, 0x8a, - 0xcb, 0x94, 0x39, 0x84, 0x05, 0xf4, 0x88, 0xe0, 0xc3, 0x32, 0xf1, 0x2a, 0x66, 0xc9, 0xe3, 0x01, - 0x87, 0x7a, 0x99, 0x95, 0x19, 0xdd, 0xa3, 0x66, 0x2b, 0xb0, 0x15, 0xa7, 0x4f, 0xe4, 0x79, 0x9e, - 0x8b, 0x30, 0xdc, 0x7c, 0x92, 0x19, 0xfa, 0x5c, 0x9e, 0xf3, 0x7c, 0x81, 0x60, 0xbb, 0x44, 0xb1, - 0xcd, 0x18, 0x0f, 0xec, 0x80, 0x72, 0xe6, 0xab, 0xdb, 0x1f, 0x1d, 0xee, 0x17, 0xb9, 0x8f, 0x73, - 0xb6, 0xaf, 0x88, 0xf0, 0xd1, 0x4a, 0x8e, 0x04, 0xf6, 0x0a, 0x2e, 0xd9, 0x79, 0xca, 0x44, 0xb0, - 0x8a, 0x9d, 0xef, 0x26, 0xae, 0x64, 0x7b, 0x76, 0x31, 0x44, 0x5b, 0xee, 0x16, 0xd1, 0x3a, 0xcb, - 0xb6, 0xce, 0x54, 0x78, 0xaa, 0x9d, 0x3c, 0xa4, 0x75, 0x38, 0x55, 0x84, 0x68, 0x02, 0xc0, 0xed, - 0xa6, 0xa4, 0x3b, 0x82, 0xc3, 0x22, 0x87, 0x65, 0xe2, 0x07, 0x68, 0x1f, 0x8c, 0x47, 0x4e, 0xfd, - 0x12, 0x67, 0x3e, 0x81, 0xdb, 0x20, 0x29, 0xb5, 0xcc, 0x68, 0xf3, 0xda, 0xd2, 0xe0, 0x2a, 0x32, - 0xaf, 0x2e, 0x95, 0x29, 0x73, 0xd3, 0x93, 0xa7, 0x75, 0x23, 0xd1, 0xa8, 0x1b, 0xc3, 0x15, 0xbb, - 0x58, 0x58, 0x47, 0x32, 0x1f, 0x59, 0x0a, 0x08, 0x11, 0x30, 0x2b, 0x98, 0x32, 0x61, 0xde, 0x2e, - 0xa3, 0x81, 0x92, 0x01, 0xff, 0x01, 0x63, 0x2d, 0xbc, 0x6c, 0x99, 0xd1, 0x20, 0x4b, 0x5d, 0x41, - 0xfd, 0x75, 0x7a, 0xae, 0x51, 0x37, 0x66, 0x24, 0x64, 0x47, 0x08, 0xb2, 0x46, 0x69, 0x3b, 0x5c, - 0xc6, 0x45, 0x4f, 0x34, 0xa0, 0x77, 0xe3, 0x51, 0xc6, 0x0e, 0xc0, 0x48, 0x14, 0x45, 0x19, 0xfc, - 0x21, 0xce, 0x60, 0x04, 0x2a, 0x3d, 0xdb, 0xa8, 0x1b, 0x93, 0xdd, 0x04, 0x21, 0x6b, 0x38, 0xa2, - 0x06, 0xdd, 0x05, 0x53, 0x42, 0xca, 0x56, 0xa1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xb8, 0x1e, 0x2b, 0x56, 0x0a, 0xfd, 0x4c, 0x27, 0xae, 0x8a, 0xa5, 0x52, 0x83, - 0x1f, 0x35, 0x30, 0x7d, 0xc5, 0x0c, 0xc1, 0x8d, 0x1e, 0x04, 0xc5, 0x8d, 0xbf, 0xbe, 0xf9, 0xe5, - 0x00, 0xca, 0xe2, 0x8e, 0xb0, 0xf8, 0x1f, 0xfc, 0xf7, 0x1a, 0x8b, 0x12, 0x25, 0xdb, 0xd1, 0x49, - 0xb8, 0x1a, 0x6e, 0x99, 0x1a, 0xae, 0xca, 0x15, 0x52, 0x4b, 0xff, 0x7f, 0x7a, 0x9e, 0xd2, 0xce, - 0xce, 0x53, 0xda, 0xfb, 0xf3, 0x94, 0xf6, 0xec, 0x22, 0x95, 0x38, 0xbb, 0x48, 0x25, 0xde, 0x5e, - 0xa4, 0x12, 0xf7, 0x7f, 0x6e, 0xdb, 0x83, 0xbb, 0x6c, 0x97, 0xd1, 0xbf, 0x28, 0x76, 0xf6, 0x6d, - 0xca, 0xf0, 0x31, 0xee, 0xf6, 0x19, 0x22, 0x36, 0x63, 0x2e, 0x29, 0xbe, 0x2c, 0xd6, 0x3e, 0x05, - 0x00, 0x00, 0xff, 0xff, 0xcd, 0x8f, 0xfc, 0x52, 0x69, 0x09, 0x00, 0x00, + // 959 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xce, 0x56, 0x8a, 0x43, 0x27, 0x4d, 0x4b, 0x27, 0x6d, 0x7e, 0xac, 0x2a, 0x6f, 0x99, 0x02, + 0x6d, 0x81, 0xec, 0xa8, 0x2e, 0x3f, 0x44, 0x84, 0x48, 0xb3, 0x95, 0x00, 0x0b, 0x81, 0xe8, 0x96, + 0x1c, 0xe0, 0x62, 0xad, 0x77, 0x27, 0xce, 0x50, 0x7b, 0xc6, 0xf5, 0xac, 0x4b, 0x2d, 0xcb, 0x42, + 0xe2, 0x06, 0x27, 0x24, 0x24, 0x24, 0xfe, 0x05, 0x24, 0x38, 0x72, 0xe7, 0x44, 0x8f, 0x95, 0xb8, + 0x70, 0x32, 0x28, 0xe9, 0x3f, 0x80, 0xff, 0x02, 0xe4, 0x99, 0xb7, 0xb6, 0xb7, 0xde, 0x6c, 0xec, + 0xaa, 0x27, 0xdb, 0x33, 0xef, 0x7d, 0xef, 0xfb, 0xde, 0xbe, 0xf7, 0xad, 0x91, 0xc3, 0x42, 0xa9, + 0x3a, 0x2a, 0x66, 0x8d, 0x2d, 0x2e, 0x42, 0x26, 0x62, 0xfe, 0x80, 0xd1, 0xfb, 0x6d, 0xd6, 0xea, + 0xb8, 0xcd, 0x96, 0x8c, 0x25, 0xb6, 0xdb, 0xa2, 0x2d, 0xf8, 0x3e, 0x77, 0x47, 0x81, 0xa3, 0x38, + 0xfb, 0x42, 0x4d, 0xd6, 0xa4, 0x0e, 0xa3, 0xc3, 0x6f, 0x26, 0xc3, 0xbe, 0x54, 0x93, 0xb2, 0x56, + 0x67, 0x34, 0x68, 0x72, 0x1a, 0x08, 0x21, 0xe3, 0x20, 0xe6, 0x52, 0x28, 0xb8, 0x7d, 0x2d, 0x94, + 0xaa, 0x21, 0x15, 0xad, 0x06, 0x0a, 0x0a, 0xd1, 0x07, 0x37, 0xaa, 0x2c, 0x0e, 0x6e, 0xd0, 0x66, + 0x50, 0xe3, 0x42, 0x07, 0x43, 0xec, 0xe5, 0x2c, 0x72, 0xcd, 0xa0, 0x15, 0x34, 0x12, 0xb4, 0xad, + 0xac, 0x88, 0xd1, 0x59, 0x65, 0x74, 0x06, 0xe1, 0xc5, 0xc9, 0xe2, 0x49, 0xd9, 0x50, 0x72, 0x28, + 0x48, 0x2e, 0x20, 0x7c, 0x67, 0x48, 0xe9, 0x33, 0x5d, 0xc3, 0x67, 0xf7, 0xdb, 0x4c, 0xc5, 0xe4, + 0x00, 0xad, 0xa6, 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, 0xca, 0x5c, 0x67, 0x98, 0x8d, 0xb4, 0x23, 0x12, 0x4f, 0x93, 0x7d, + 0x0f, 0x6f, 0xe7, 0x92, 0x35, 0x44, 0x9f, 0xe2, 0x49, 0xbb, 0xda, 0x6c, 0x7b, 0xf8, 0x3f, 0x0b, + 0xad, 0x1f, 0xe3, 0x2d, 0x78, 0x67, 0x06, 0x42, 0x79, 0xb6, 0x68, 0xdf, 0x7a, 0x76, 0x00, 0x90, + 0x78, 0x57, 0x4b, 0xfc, 0x04, 0x7f, 0x7c, 0x82, 0x44, 0x83, 0x52, 0x99, 0x9a, 0x24, 0xda, 0x4d, + 0xdc, 0xb7, 0x47, 0xbb, 0xc6, 0x5a, 0x7b, 0xf8, 0x89, 0x85, 0xd6, 0xb2, 0x7d, 0x02, 0xbf, 0x3f, + 0xdf, 0xe0, 0x3f, 0x6d, 0x8b, 0xf6, 0xce, 0x33, 0xe7, 0x83, 0xe0, 0xb2, 0x16, 0x7c, 0x1b, 0xef, + 0xce, 0xb1, 0x41, 0x93, 0xfe, 0x45, 0xbb, 0xe0, 0xb9, 0x3d, 0xef, 0xd3, 0x47, 0x87, 0x45, 0xeb, + 0xf1, 0x61, 0xd1, 0xfa, 0xf7, 0xb0, 0x68, 0xfd, 0x70, 0x54, 0x5c, 0x78, 0x7c, 0x54, 0x5c, 0xf8, + 0xfb, 0xa8, 0xb8, 0xf0, 0xe5, 0x9b, 0x13, 0xaf, 0xc1, 0x3d, 0xb1, 0x27, 0xf8, 0x07, 0x9c, 0x86, + 0x07, 0x01, 0x17, 0xf4, 0x21, 0xcd, 0xfa, 0x17, 0xaa, 0x5f, 0x8c, 0xd5, 0x82, 0xfe, 0x63, 0x79, + 0xf3, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4b, 0xf9, 0x4a, 0x2d, 0x68, 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -570,6 +667,7 @@ type QueryClient interface { AllRewards(ctx context.Context, in *QueryAllRewardsRequest, opts ...grpc.CallOption) (*QueryAllRewardsResponse, error) Reward(ctx context.Context, in *QueryRewardRequest, opts ...grpc.CallOption) (*QueryRewardResponse, error) RecordedIncentiveUnitId(ctx context.Context, in *QueryRecordedIncentiveUnitIdRequest, opts ...grpc.CallOption) (*QueryRecordedIncentiveUnitIdResponse, error) + IncentiveUnitIdsByAddr(ctx context.Context, in *QueryIncentiveUnitIdsByAddrRequest, opts ...grpc.CallOption) (*QueryIncentiveUnitIdsByAddrResponse, error) } type queryClient struct { @@ -625,6 +723,15 @@ func (c *queryClient) RecordedIncentiveUnitId(ctx context.Context, in *QueryReco return out, nil } +func (c *queryClient) IncentiveUnitIdsByAddr(ctx context.Context, in *QueryIncentiveUnitIdsByAddrRequest, opts ...grpc.CallOption) (*QueryIncentiveUnitIdsByAddrResponse, error) { + out := new(QueryIncentiveUnitIdsByAddrResponse) + err := c.cc.Invoke(ctx, "/ununifi.ecosystemincentive.Query/IncentiveUnitIdsByAddr", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. @@ -633,6 +740,7 @@ type QueryServer interface { AllRewards(context.Context, *QueryAllRewardsRequest) (*QueryAllRewardsResponse, error) Reward(context.Context, *QueryRewardRequest) (*QueryRewardResponse, error) RecordedIncentiveUnitId(context.Context, *QueryRecordedIncentiveUnitIdRequest) (*QueryRecordedIncentiveUnitIdResponse, error) + IncentiveUnitIdsByAddr(context.Context, *QueryIncentiveUnitIdsByAddrRequest) (*QueryIncentiveUnitIdsByAddrResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -654,6 +762,9 @@ func (*UnimplementedQueryServer) Reward(ctx context.Context, req *QueryRewardReq func (*UnimplementedQueryServer) RecordedIncentiveUnitId(ctx context.Context, req *QueryRecordedIncentiveUnitIdRequest) (*QueryRecordedIncentiveUnitIdResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RecordedIncentiveUnitId not implemented") } +func (*UnimplementedQueryServer) IncentiveUnitIdsByAddr(ctx context.Context, req *QueryIncentiveUnitIdsByAddrRequest) (*QueryIncentiveUnitIdsByAddrResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method IncentiveUnitIdsByAddr not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -749,6 +860,24 @@ func _Query_RecordedIncentiveUnitId_Handler(srv interface{}, ctx context.Context return interceptor(ctx, in, info, handler) } +func _Query_IncentiveUnitIdsByAddr_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryIncentiveUnitIdsByAddrRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).IncentiveUnitIdsByAddr(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ununifi.ecosystemincentive.Query/IncentiveUnitIdsByAddr", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).IncentiveUnitIdsByAddr(ctx, req.(*QueryIncentiveUnitIdsByAddrRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "ununifi.ecosystemincentive.Query", HandlerType: (*QueryServer)(nil), @@ -773,6 +902,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "RecordedIncentiveUnitId", Handler: _Query_RecordedIncentiveUnitId_Handler, }, + { + MethodName: "IncentiveUnitIdsByAddr", + Handler: _Query_IncentiveUnitIdsByAddr_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "ecosystem-incentive/query.proto", @@ -1099,6 +1232,69 @@ func (m *QueryRecordedIncentiveUnitIdResponse) MarshalToSizedBuffer(dAtA []byte) return len(dAtA) - i, nil } +func (m *QueryIncentiveUnitIdsByAddrRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryIncentiveUnitIdsByAddrRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryIncentiveUnitIdsByAddrRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryIncentiveUnitIdsByAddrResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryIncentiveUnitIdsByAddrResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryIncentiveUnitIdsByAddrResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.IncentiveUnitIdsByAddr.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -1238,6 +1434,30 @@ func (m *QueryRecordedIncentiveUnitIdResponse) Size() (n int) { return n } +func (m *QueryIncentiveUnitIdsByAddrRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryIncentiveUnitIdsByAddrResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.IncentiveUnitIdsByAddr.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2103,6 +2323,171 @@ func (m *QueryRecordedIncentiveUnitIdResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryIncentiveUnitIdsByAddrRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryIncentiveUnitIdsByAddrRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryIncentiveUnitIdsByAddrRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryIncentiveUnitIdsByAddrResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryIncentiveUnitIdsByAddrResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryIncentiveUnitIdsByAddrResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IncentiveUnitIdsByAddr", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.IncentiveUnitIdsByAddr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/ecosystem-incentive/types/query.pb.gw.go b/x/ecosystem-incentive/types/query.pb.gw.go index 2d398e0da..fc13e4697 100644 --- a/x/ecosystem-incentive/types/query.pb.gw.go +++ b/x/ecosystem-incentive/types/query.pb.gw.go @@ -311,6 +311,60 @@ func local_request_Query_RecordedIncentiveUnitId_0(ctx context.Context, marshale } +func request_Query_IncentiveUnitIdsByAddr_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryIncentiveUnitIdsByAddrRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := client.IncentiveUnitIdsByAddr(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_IncentiveUnitIdsByAddr_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryIncentiveUnitIdsByAddrRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := server.IncentiveUnitIdsByAddr(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -432,6 +486,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_IncentiveUnitIdsByAddr_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_IncentiveUnitIdsByAddr_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_IncentiveUnitIdsByAddr_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -573,6 +650,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_IncentiveUnitIdsByAddr_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_IncentiveUnitIdsByAddr_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_IncentiveUnitIdsByAddr_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -586,6 +683,8 @@ var ( pattern_Query_Reward_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"ununifi", "ecosystem_incentive", "reward", "subject_addr", "denom"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_RecordedIncentiveUnitId_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"ununifi", "ecosystem_incentive", "recorded_incentive_unit_id", "class_id", "nft_id"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_IncentiveUnitIdsByAddr_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"ununifi", "ecosystem_incentive", "incentive_unit_ids_by_addr", "address"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -598,4 +697,6 @@ var ( forward_Query_Reward_0 = runtime.ForwardResponseMessage forward_Query_RecordedIncentiveUnitId_0 = runtime.ForwardResponseMessage + + forward_Query_IncentiveUnitIdsByAddr_0 = runtime.ForwardResponseMessage ) diff --git a/x/nftmint/genesis.go b/x/nftmint/genesis.go index be385edec..ecafb847d 100644 --- a/x/nftmint/genesis.go +++ b/x/nftmint/genesis.go @@ -1,19 +1,70 @@ package nftmint import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + nfttypes "github.com/cosmos/cosmos-sdk/x/nft" + "github.com/UnUniFi/chain/x/nftmint/keeper" "github.com/UnUniFi/chain/x/nftmint/types" - sdk "github.com/cosmos/cosmos-sdk/types" ) // InitGenesis initializes the store state from a genesis state. -func InitGenesis(ctx sdk.Context, k keeper.Keeper, accountKeeper types.AccountKeeper, gs types.GenesisState) { +func InitGenesis(ctx sdk.Context, k keeper.Keeper, nftKeeper types.NftKeeper, gs types.GenesisState) { k.SetParamSet(ctx, gs.Params) + + for _, classAttributes := range gs.ClassAttributesList { + if err := InitClassRelatingData(ctx, k, nftKeeper, *classAttributes); err != nil { + panic(err) + } + } } // ExportGenesis export genesis state for nftmarket module func ExportGenesis(ctx sdk.Context, k keeper.Keeper) types.GenesisState { + classAttributesList := k.GetClassAttributesList(ctx) + return types.GenesisState{ - Params: k.GetParamSet(ctx), + Params: k.GetParamSet(ctx), + ClassAttributesList: classAttributesList, + } +} + +func InitClassRelatingData(ctx sdk.Context, k keeper.Keeper, nftKeeper types.NftKeeper, classAttributes types.ClassAttributes) error { + class, exists := nftKeeper.GetClass(ctx, classAttributes.ClassId) + if !exists { + return sdkerrors.Wrap(nfttypes.ErrClassNotExists, classAttributes.ClassId) } + + params := k.GetParamSet(ctx) + if err := types.ValidateCreateClass( + params, + class.Name, class.Symbol, classAttributes.BaseTokenUri, class.Description, + classAttributes.MintingPermission, + classAttributes.TokenSupplyCap, + ); err != nil { + return err + } + + if err := k.SetClassAttributes(ctx, types.NewClassAttributes( + class.Id, + classAttributes.Owner.AccAddress(), + classAttributes.BaseTokenUri, + classAttributes.MintingPermission, + classAttributes.TokenSupplyCap, + )); err != nil { + return err + } + + owningClassIdList := k.AddClassIDToOwningClassIdList(ctx, classAttributes.Owner.AccAddress(), class.Id) + if err := k.SetOwningClassIdList(ctx, owningClassIdList); err != nil { + return err + } + + classNameIdList := k.AddClassNameIdList(ctx, class.Name, class.Id) + if err := k.SetClassNameIdList(ctx, classNameIdList); err != nil { + return err + } + + return nil } diff --git a/x/nftmint/keeper/class.go b/x/nftmint/keeper/class.go index 1fc0fc8bd..64a1d92fb 100644 --- a/x/nftmint/keeper/class.go +++ b/x/nftmint/keeper/class.go @@ -204,7 +204,7 @@ func (k Keeper) GetClassAttributes(ctx sdk.Context, classID string) (types.Class prefixStore := prefix.NewStore(store, types.KeyPrefixClassAttributes) bz := prefixStore.Get([]byte(classID)) - if len(bz) == 0 { + if bz == nil { return types.ClassAttributes{}, false } var classAttributes types.ClassAttributes @@ -218,7 +218,7 @@ func (k Keeper) GetOwningClassIdList(ctx sdk.Context, owner sdk.AccAddress) (typ var owningClassIdList types.OwningClassIdList bz := prefixStore.Get(owner.Bytes()) - if len(bz) == 0 { + if bz == nil { return types.OwningClassIdList{}, false } k.cdc.MustUnmarshal(bz, &owningClassIdList) @@ -231,13 +231,52 @@ func (k Keeper) GetClassNameIdList(ctx sdk.Context, className string) (types.Cla var classNameIdList types.ClassNameIdList bz := prefixStore.Get([]byte(className)) - if len(bz) == 0 { + if bz == nil { return types.ClassNameIdList{}, false } k.cdc.MustUnmarshal(bz, &classNameIdList) return classNameIdList, true } +func (k Keeper) GetClassAttributesList(ctx sdk.Context) (classAttributesList []*types.ClassAttributes) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, types.KeyPrefixClassAttributes) + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + var classAttributes types.ClassAttributes + k.cdc.MustUnmarshal(iterator.Value(), &classAttributes) + classAttributesList = append(classAttributesList, &classAttributes) + } + + return +} + +func (k Keeper) GetOwningClassIdLists(ctx sdk.Context) (owningClassIdLists []*types.OwningClassIdList) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, types.KeyPrefixOwningClassIdList) + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + var owningClassIdList types.OwningClassIdList + k.cdc.MustUnmarshal(iterator.Value(), &owningClassIdList) + owningClassIdLists = append(owningClassIdLists, &owningClassIdList) + } + + return +} + +func (k Keeper) GetClassNameIdLists(ctx sdk.Context) (classNameIdLists []*types.ClassNameIdList) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, types.KeyPrefixClassNameIdList) + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + var classNameIdList types.ClassNameIdList + k.cdc.MustUnmarshal(iterator.Value(), &classNameIdList) + classNameIdLists = append(classNameIdLists, &classNameIdList) + } + + return +} + func (k Keeper) AddClassIDToOwningClassIdList(ctx sdk.Context, owner sdk.AccAddress, classID string) types.OwningClassIdList { owningClassIdList, exists := k.GetOwningClassIdList(ctx, owner) if !exists { diff --git a/x/nftmint/keeper/class_test.go b/x/nftmint/keeper/class_test.go index e2e98c3b9..070d25b81 100644 --- a/x/nftmint/keeper/class_test.go +++ b/x/nftmint/keeper/class_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/ed25519" + ununifitypes "github.com/UnUniFi/chain/types" "github.com/UnUniFi/chain/x/nftmint/keeper" "github.com/UnUniFi/chain/x/nftmint/types" ) @@ -388,3 +389,127 @@ func (suite *KeeperTestSuite) CreateClass(ctx sdk.Context, classID string, sende err := suite.app.NftmintKeeper.CreateClass(ctx, classID, &testMsgCreateClass) return err } + +// test for the GetClassAttributes relating functions +func (suite *KeeperTestSuite) TestGetClassAttributes() { + owner := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + owner_seq, _ := suite.app.AccountKeeper.GetSequence(suite.ctx, owner) + classId := keeper.CreateClassId(owner_seq, owner) + _ = suite.CreateClass(suite.ctx, classId, owner) + + tests := []struct { + testCase string + classId string + validClass bool + }{ + { + testCase: "invalid class name", + classId: "invalid_class_id", + validClass: false, + }, + { + testCase: "successful case", + classId: classId, + validClass: true, + }, + } + for _, tc := range tests { + res, valid := suite.app.NftmintKeeper.GetClassAttributes(suite.ctx, tc.classId) + + // invalid cases + if !tc.validClass { + suite.Require().False(valid) + suite.Require().Equal(res.ClassId, "") + } + + // valid case + if tc.validClass { + suite.Require().True(valid) + suite.Require().Equal(res.ClassId, classId) + suite.Require().Equal(res.Owner.AccAddress(), owner) + } + } +} + +// test for the GetOwningClassIdList relating functions +func (suite *KeeperTestSuite) TestGetOwningClassIdList() { + owner := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + owner_seq, _ := suite.app.AccountKeeper.GetSequence(suite.ctx, owner) + classId := keeper.CreateClassId(owner_seq, owner) + _ = suite.CreateClass(suite.ctx, classId, owner) + + invalidOwner := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + + tests := []struct { + testCase string + ownerAddress sdk.AccAddress + validOwner bool + }{ + { + testCase: "invalid sender", + ownerAddress: invalidOwner, + validOwner: false, + }, + { + testCase: "successful case", + ownerAddress: owner, + validOwner: true, + }, + } + for _, tc := range tests { + res, valid := suite.app.NftmintKeeper.GetOwningClassIdList(suite.ctx, tc.ownerAddress) + + // invalid cases + if !tc.validOwner { + suite.Require().False(valid) + suite.Require().Equal(len(res.ClassId), 0) + } + + // valid case + if tc.validOwner { + suite.Require().True(valid) + suite.Require().Equal(res.Owner, ununifitypes.StringAccAddress(tc.ownerAddress)) + suite.Require().Equal(res.ClassId[0], classId) + } + } +} + +// test for the GetClassNameIdList relating functions +func (suite *KeeperTestSuite) TestGetClassNameIdList() { + owner := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + owner_seq, _ := suite.app.AccountKeeper.GetSequence(suite.ctx, owner) + classId := keeper.CreateClassId(owner_seq, owner) + _ = suite.CreateClass(suite.ctx, classId, owner) + + tests := []struct { + testCase string + className string + validClass bool + }{ + { + testCase: "invalid class name", + className: "invalid_class", + validClass: false, + }, + { + testCase: "successful case", + className: testName, + validClass: true, + }, + } + for _, tc := range tests { + res, valid := suite.app.NftmintKeeper.GetClassNameIdList(suite.ctx, tc.className) + + // invalid cases + if !tc.validClass { + suite.Require().False(valid) + suite.Require().Equal(len(res.ClassId), 0) + } + + // valid case + if tc.validClass { + suite.Require().True(valid) + suite.Require().Equal(res.ClassId[0], classId) + } + } +} diff --git a/x/nftmint/keeper/grpc_query_test.go b/x/nftmint/keeper/grpc_query_test.go index 942926490..29eb9dd6d 100644 --- a/x/nftmint/keeper/grpc_query_test.go +++ b/x/nftmint/keeper/grpc_query_test.go @@ -1 +1,88 @@ package keeper_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tendermint/tendermint/crypto/ed25519" + + "github.com/UnUniFi/chain/x/nftmint/keeper" + "github.com/UnUniFi/chain/x/nftmint/types" +) + +func (suite *KeeperTestSuite) TestQueryClassAttributes() { + sender := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + sender_seq, _ := suite.app.AccountKeeper.GetSequence(suite.ctx, sender) + classId := keeper.CreateClassId(sender_seq, sender) + _ = suite.CreateClass(suite.ctx, classId, sender) + + req := types.QueryClassAttributesRequest{ + ClassId: classId, + } + res, err := suite.app.NftmintKeeper.ClassAttributes(suite.ctx, &req) + suite.Require().NoError(err) + suite.Require().Equal(classId, res.ClassAttributes.ClassId) + suite.Require().Equal(testBaseTokenUri, res.ClassAttributes.BaseTokenUri) + + invalidReq := types.QueryClassAttributesRequest{ + ClassId: "invalidClassId", + } + _, err = suite.app.NftmintKeeper.ClassAttributes(suite.ctx, &invalidReq) + suite.Require().Error(err) +} + +func (suite *KeeperTestSuite) TestQueryNftMinter() { + sender := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + sender_seq, _ := suite.app.AccountKeeper.GetSequence(suite.ctx, sender) + classId := keeper.CreateClassId(sender_seq, sender) + _ = suite.CreateClass(suite.ctx, classId, sender) + _ = suite.MintNFT(suite.ctx, classId, testNFTId, sender) + + req := types.QueryNFTMinterRequest{ + ClassId: classId, + NftId: testNFTId, + } + res, err := suite.app.NftmintKeeper.NFTMinter(suite.ctx, &req) + suite.Require().NoError(err) + suite.Require().Equal(sender.String(), res.Minter) +} + +func (suite *KeeperTestSuite) TestQueryClassIdsByOwner() { + sender := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + sender_seq, _ := suite.app.AccountKeeper.GetSequence(suite.ctx, sender) + classId := keeper.CreateClassId(sender_seq, sender) + _ = suite.CreateClass(suite.ctx, classId, sender) + _ = suite.MintNFT(suite.ctx, classId, testNFTId, sender) + + req := types.QueryClassIdsByOwnerRequest{ + Owner: sender.String(), + } + res, err := suite.app.NftmintKeeper.ClassIdsByOwner(suite.ctx, &req) + suite.Require().NoError(err) + var classIds []string + classIds = append(classIds, classId) + expectedRes := types.OwningClassIdList{ + Owner: sender.Bytes(), + ClassId: classIds[:], + } + suite.Require().Equal(&expectedRes, res.OwningClassIdList) +} + +func (suite *KeeperTestSuite) TestQueryIdsByName() { + sender := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + sender_seq, _ := suite.app.AccountKeeper.GetSequence(suite.ctx, sender) + classId := keeper.CreateClassId(sender_seq, sender) + _ = suite.CreateClass(suite.ctx, classId, sender) + _ = suite.MintNFT(suite.ctx, classId, testNFTId, sender) + + req := types.QueryClassIdsByNameRequest{ + ClassName: testName, + } + res, err := suite.app.NftmintKeeper.ClassIdsByName(suite.ctx, &req) + suite.Require().NoError(err) + var classIds []string + classIds = append(classIds, classId) + expectedRes := types.ClassNameIdList{ + ClassName: testName, + ClassId: classIds, + } + suite.Require().Equal(&expectedRes, res.ClassNameIdList) +} diff --git a/x/nftmint/keeper/nft.go b/x/nftmint/keeper/nft.go index 74e86fe1d..a2c2a2632 100644 --- a/x/nftmint/keeper/nft.go +++ b/x/nftmint/keeper/nft.go @@ -1,11 +1,12 @@ package keeper import ( - "github.com/UnUniFi/chain/x/nftmint/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" nfttypes "github.com/cosmos/cosmos-sdk/x/nft" + + "github.com/UnUniFi/chain/x/nftmint/types" ) // MintNFT does validate the contents of MsgMintNFT and operate whole flow for MintNFT message @@ -100,7 +101,7 @@ func (k Keeper) GetNFTMinter(ctx sdk.Context, classID, nftID string) (sdk.AccAdd prefixStore := prefix.NewStore(store, []byte(types.KeyPrefixNFTMinter)) bz := prefixStore.Get(types.NFTMinterKey(classID, nftID)) - if len(bz) == 0 { + if bz == nil { return nil, false } diff --git a/x/nftmint/module.go b/x/nftmint/module.go index 1d2378a11..5548f64f5 100644 --- a/x/nftmint/module.go +++ b/x/nftmint/module.go @@ -9,15 +9,16 @@ import ( "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" - "github.com/UnUniFi/chain/x/nftmint/client/cli" - "github.com/UnUniFi/chain/x/nftmint/keeper" - "github.com/UnUniFi/chain/x/nftmint/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" abci "github.com/tendermint/tendermint/abci/types" + + "github.com/UnUniFi/chain/x/nftmint/client/cli" + "github.com/UnUniFi/chain/x/nftmint/keeper" + "github.com/UnUniFi/chain/x/nftmint/types" ) var ( @@ -99,15 +100,15 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { type AppModule struct { AppModuleBasic - keeper keeper.Keeper - accountKeeper types.AccountKeeper + keeper keeper.Keeper + nftKeeper types.NftKeeper } -func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, accountKeeper types.AccountKeeper) AppModule { +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, nftKeeper types.NftKeeper) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, keeper: keeper, - accountKeeper: accountKeeper, + nftKeeper: nftKeeper, } } @@ -146,7 +147,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.Ra // Initialize global index to index in genesis state cdc.MustUnmarshalJSON(gs, &genState) - InitGenesis(ctx, am.keeper, am.accountKeeper, genState) + InitGenesis(ctx, am.keeper, am.nftKeeper, genState) return []abci.ValidatorUpdate{} } diff --git a/x/nftmint/types/genesis.go b/x/nftmint/types/genesis.go index b58381ad9..2ff6fd3ce 100644 --- a/x/nftmint/types/genesis.go +++ b/x/nftmint/types/genesis.go @@ -19,6 +19,12 @@ func (gs GenesisState) Validate() error { return err } + for _, classAttributes := range gs.ClassAttributesList { + if err := ValidateClassAttributes(*classAttributes, gs.Params); err != nil { + return err + } + } + return nil } diff --git a/x/nftmint/types/genesis.pb.go b/x/nftmint/types/genesis.pb.go index cb53a0188..c946c57d5 100644 --- a/x/nftmint/types/genesis.pb.go +++ b/x/nftmint/types/genesis.pb.go @@ -25,7 +25,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the nftmint module's genesis state. type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params" yaml:"params"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params" yaml:"params"` + ClassAttributesList []*ClassAttributes `protobuf:"bytes,2,rep,name=class_attributes_list,json=classAttributesList,proto3" json:"class_attributes_list,omitempty" yaml:"class_attributes_list"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -68,6 +69,13 @@ func (m *GenesisState) GetParams() Params { return Params{} } +func (m *GenesisState) GetClassAttributesList() []*ClassAttributes { + if m != nil { + return m.ClassAttributesList + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "ununifi.nftmint.GenesisState") } @@ -75,20 +83,24 @@ func init() { func init() { proto.RegisterFile("nftmint/genesis.proto", fileDescriptor_86187404abd2f43c) } var fileDescriptor_86187404abd2f43c = []byte{ - // 207 bytes of a gzipped FileDescriptorProto + // 270 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcd, 0x4b, 0x2b, 0xc9, 0xcd, 0xcc, 0x2b, 0xd1, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x2f, 0xcd, 0x2b, 0xcd, 0xcb, 0x4c, 0xcb, 0xd4, 0x83, 0x4a, 0x4b, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xe5, 0xf4, 0x41, 0x2c, 0x88, 0x32, 0x29, 0xb8, 0x6e, 0x28, 0x0d, 0x11, - 0x56, 0x0a, 0xe3, 0xe2, 0x71, 0x87, 0x18, 0x17, 0x5c, 0x92, 0x58, 0x92, 0x2a, 0xe4, 0xc6, 0xc5, - 0x56, 0x90, 0x58, 0x94, 0x98, 0x5b, 0x2c, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xae, 0x87, - 0x66, 0xbc, 0x5e, 0x00, 0x58, 0xda, 0x49, 0xf4, 0xc4, 0x3d, 0x79, 0x86, 0x4f, 0xf7, 0xe4, 0x79, - 0x2b, 0x13, 0x73, 0x73, 0xac, 0x94, 0x20, 0x9a, 0x94, 0x82, 0xa0, 0xba, 0x9d, 0x9c, 0x4e, 0x3c, - 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, - 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x23, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, - 0x2f, 0x39, 0x3f, 0x57, 0x3f, 0x34, 0x2f, 0x34, 0x2f, 0xd3, 0x2d, 0x53, 0x3f, 0x39, 0x23, 0x31, - 0x33, 0x4f, 0xbf, 0x02, 0xe6, 0x36, 0xfd, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x13, - 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xf9, 0xc7, 0x42, 0xb8, 0xf9, 0x00, 0x00, 0x00, + 0x56, 0x3a, 0xc7, 0xc8, 0xc5, 0xe3, 0x0e, 0x31, 0x2f, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0xc8, 0x8d, + 0x8b, 0xad, 0x20, 0xb1, 0x28, 0x31, 0xb7, 0x58, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x5c, + 0x0f, 0xcd, 0x7c, 0xbd, 0x00, 0xb0, 0xb4, 0x93, 0xe8, 0x89, 0x7b, 0xf2, 0x0c, 0x9f, 0xee, 0xc9, + 0xf3, 0x56, 0x26, 0xe6, 0xe6, 0x58, 0x29, 0x41, 0x34, 0x29, 0x05, 0x41, 0x75, 0x0b, 0x95, 0x71, + 0x89, 0x26, 0xe7, 0x24, 0x16, 0x17, 0xc7, 0x27, 0x96, 0x94, 0x14, 0x65, 0x26, 0x95, 0x96, 0xa4, + 0x16, 0xc7, 0xe7, 0x64, 0x16, 0x97, 0x48, 0x30, 0x29, 0x30, 0x6b, 0x70, 0x1b, 0x29, 0x60, 0x18, + 0xeb, 0x0c, 0x52, 0xed, 0x08, 0x57, 0xec, 0xa4, 0xf0, 0xe9, 0x9e, 0xbc, 0x0c, 0xc4, 0x6c, 0xac, + 0x06, 0x29, 0x05, 0x09, 0x27, 0xa3, 0x6a, 0xf1, 0xc9, 0x2c, 0x2e, 0x71, 0x72, 0x3a, 0xf1, 0x48, + 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, + 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0x8d, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, + 0xe4, 0xfc, 0x5c, 0xfd, 0xd0, 0xbc, 0xd0, 0xbc, 0x4c, 0xb7, 0x4c, 0xfd, 0xe4, 0x8c, 0xc4, 0xcc, + 0x3c, 0xfd, 0x0a, 0x58, 0xa0, 0xe8, 0x97, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0xc3, 0xc6, + 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xf2, 0xed, 0x71, 0x71, 0x72, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -111,6 +123,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.ClassAttributesList) > 0 { + for iNdEx := len(m.ClassAttributesList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ClassAttributesList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } { size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -143,6 +169,12 @@ func (m *GenesisState) Size() (n int) { _ = l l = m.Params.Size() n += 1 + l + sovGenesis(uint64(l)) + if len(m.ClassAttributesList) > 0 { + for _, e := range m.ClassAttributesList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -214,6 +246,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClassAttributesList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClassAttributesList = append(m.ClassAttributesList, &ClassAttributes{}) + if err := m.ClassAttributesList[len(m.ClassAttributesList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/nftmint/types/validation.go b/x/nftmint/types/validation.go index b53c28f25..49a0c2ed0 100644 --- a/x/nftmint/types/validation.go +++ b/x/nftmint/types/validation.go @@ -57,6 +57,18 @@ func ValidateMintNFT( return nil } +func ValidateClassAttributes(classAttributes ClassAttributes, params Params) error { + if err := ValidateUri(params.MinUriLen, params.MaxUriLen, classAttributes.BaseTokenUri); err != nil { + return err + } + + if err := ValidateTokenSupplyCap(params.MaxNFTSupplyCap, classAttributes.TokenSupplyCap); err != nil { + return err + } + + return nil +} + func ValidateMintingPermission(mintingPermission MintingPermission, owner, minter sdk.AccAddress) error { switch mintingPermission { case 0: @@ -72,7 +84,6 @@ func ValidateMintingPermission(mintingPermission MintingPermission, owner, minte } // Measure length of the string as byte length - func ValidateClassName(minLen, maxLen uint64, className string) error { len := len(className) if len < int(minLen) || len > int(maxLen) {