diff --git a/ignite.ci.yml b/ignite.ci.yml deleted file mode 100644 index a1c274f4..00000000 --- a/ignite.ci.yml +++ /dev/null @@ -1,32 +0,0 @@ -accounts: - - name: alice - coins: [ "200000000uflix" ] - - name: bob - coins: [ "100000000uflix" ] -validator: - name: alice - staked: "100000000uflix" -client: - openapi: - path: "docs/static/openapi.yml" -faucet: - name: bob - coins: [ "100000uflix" ] -genesis: - chain_id: "flixnet-3" - app_state: - staking: - params: - bond_denom: "uflix" - gov: - deposit_params: - min_deposit: - - amount: "10000000" - denom: "uflix" - mint: - params: - mint_denom: "uflix" - crisis: - constant_fee: - amount: "1000" - denom: "uflix" diff --git a/readme.md b/readme.md index 7d4bfed7..79a8e288 100644 --- a/readme.md +++ b/readme.md @@ -21,16 +21,6 @@ wget -q -O - https://git.io/vQhTU | bash -s -- --version 1.21.3 **Linux** -### Before v2 upgrade -``` -git clone https://github.com/Omniflix/omniflixhub.git -cd omniflixhub -git checkout v0.12.1 -go mod tidy -make install -``` - -### After v2 upgrade ``` git clone https://github.com/Omniflix/omniflixhub.git cd omniflixhub @@ -83,6 +73,7 @@ curl https://raw.githubusercontent.com/OmniFlix/mainnet/main/omniflixhub-1/genes - [v0.11.0](https://github.com/OmniFlix/docs/blob/main/guides/mainnet/omniflixhub-1/upgrades/v0.11.0-upgrade.md) at block 7339200 - [v0.12.x](https://github.com/OmniFlix/docs/blob/main/guides/mainnet/omniflixhub-1/upgrades/v0.12.x-upgrade.md) at block 8054200 - [v2](https://github.com/OmniFlix/docs/blob/main/guides/mainnet/omniflixhub-1/upgrades/v2-upgrade.md) at block 10428200 + - [v2.1]((https://github.com/OmniFlix/docs/blob/main/guides/mainnet/omniflixhub-1/upgrades/v2.1-upgrade.md)) at block 10678600 ### Testnets diff --git a/x/itc/keeper/itc.go b/x/itc/keeper/itc.go index eabfec0e..84611f52 100644 --- a/x/itc/keeper/itc.go +++ b/x/itc/keeper/itc.go @@ -178,9 +178,9 @@ func (k Keeper) FinalizeAndEndCampaigns(ctx sdk.Context) error { func (k Keeper) endCampaign(ctx sdk.Context, campaign types.Campaign) { // Transfer Remaining funds to creator availableTokens := campaign.AvailableTokens + moduleAccAddr := k.accountKeeper.GetModuleAddress(types.ModuleName) if availableTokens.IsValid() && availableTokens.Amount != sdk.ZeroInt() { - if err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, - types.ModuleName, campaign.GetCreator(), + if err := k.bankKeeper.SendCoins(ctx, moduleAccAddr, campaign.GetCreator(), sdk.NewCoins(sdk.NewCoin(availableTokens.Denom, availableTokens.Amount))); err != nil { panic(err) } @@ -191,7 +191,7 @@ func (k Keeper) endCampaign(ctx sdk.Context, campaign types.Campaign) { err := k.nftKeeper.TransferOwnership(ctx, campaign.NftDenomId, nft, - k.GetModuleAccountAddress(ctx), + moduleAccAddr, campaign.GetCreator(), ) if err != nil { diff --git a/x/marketplace/keeper/auction.go b/x/marketplace/keeper/auction.go index c54c5871..6ca2328c 100644 --- a/x/marketplace/keeper/auction.go +++ b/x/marketplace/keeper/auction.go @@ -276,8 +276,8 @@ func (k Keeper) processBid(ctx sdk.Context, auction types.AuctionListing, bid ty } BidAmountCoin := bid.Amount auctionSaleAmountCoin := BidAmountCoin - err = k.nftKeeper.TransferOwnership(ctx, auction.GetDenomId(), auction.GetNftId(), - k.accountKeeper.GetModuleAddress(types.ModuleName), bid.GetBidder()) + moduleAccAddr := k.accountKeeper.GetModuleAddress(types.ModuleName) + err = k.nftKeeper.TransferOwnership(ctx, auction.GetDenomId(), auction.GetNftId(), moduleAccAddr, bid.GetBidder()) if err != nil { return err } @@ -308,7 +308,7 @@ func (k Keeper) processBid(ctx sdk.Context, auction types.AuctionListing, bid ty sharePortionCoin := k.GetProportions(auctionSaleAmountCoin, share.Weight) sharePortionCoins := sdk.NewCoins(sharePortionCoin) if share.Address == "" { - err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, owner, sharePortionCoins) + err = k.bankKeeper.SendCoins(ctx, moduleAccAddr, owner, sharePortionCoins) if err != nil { return err } @@ -317,21 +317,20 @@ func (k Keeper) processBid(ctx sdk.Context, auction types.AuctionListing, bid ty if err != nil { return err } - err = k.bankKeeper.SendCoinsFromModuleToAccount( - ctx, types.ModuleName, saleSplitAddr, sharePortionCoins) + err = k.bankKeeper.SendCoins(ctx, moduleAccAddr, saleSplitAddr, sharePortionCoins) if err != nil { return err } - k.createSplitShareTransferEvent(ctx, k.accountKeeper.GetModuleAddress(types.ModuleName), saleSplitAddr, sharePortionCoin) + k.createSplitShareTransferEvent(ctx, moduleAccAddr, saleSplitAddr, sharePortionCoin) } remaining = remaining.Sub(sharePortionCoin) } - err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, owner, sdk.NewCoins(remaining)) + err = k.bankKeeper.SendCoins(ctx, moduleAccAddr, owner, sdk.NewCoins(remaining)) if err != nil { return err } } else { - err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, owner, sdk.NewCoins(remaining)) + err = k.bankKeeper.SendCoins(ctx, moduleAccAddr, owner, sdk.NewCoins(remaining)) if err != nil { return err } diff --git a/x/marketplace/keeper/keeper.go b/x/marketplace/keeper/keeper.go index fe49ec98..699cf095 100644 --- a/x/marketplace/keeper/keeper.go +++ b/x/marketplace/keeper/keeper.go @@ -118,13 +118,13 @@ func (k Keeper) Buy(ctx sdk.Context, listing types.Listing, buyer sdk.AccAddress if err != nil { return err } + moduleAccAddr := k.accountKeeper.GetModuleAddress(types.ModuleName) - err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, buyer, types.ModuleName, sdk.NewCoins(listingPriceCoin)) + err = k.bankKeeper.SendCoins(ctx, buyer, moduleAccAddr, sdk.NewCoins(listingPriceCoin)) if err != nil { return err } - err = k.nftKeeper.TransferOwnership(ctx, listing.GetDenomId(), listing.GetNftId(), - k.accountKeeper.GetModuleAddress(types.ModuleName), buyer) + err = k.nftKeeper.TransferOwnership(ctx, listing.GetDenomId(), listing.GetNftId(), moduleAccAddr, buyer) if err != nil { return err } @@ -156,7 +156,7 @@ func (k Keeper) Buy(ctx sdk.Context, listing types.Listing, buyer sdk.AccAddress sharePortionCoin := k.GetProportions(listingSaleAmountCoin, share.Weight) sharePortionCoins := sdk.NewCoins(sharePortionCoin) if share.Address == "" { - err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, owner, sharePortionCoins) + err = k.bankKeeper.SendCoins(ctx, moduleAccAddr, owner, sharePortionCoins) if err != nil { return err } @@ -165,21 +165,20 @@ func (k Keeper) Buy(ctx sdk.Context, listing types.Listing, buyer sdk.AccAddress if err != nil { return err } - err = k.bankKeeper.SendCoinsFromModuleToAccount( - ctx, types.ModuleName, saleSplitAddr, sharePortionCoins) + err = k.bankKeeper.SendCoins(ctx, moduleAccAddr, saleSplitAddr, sharePortionCoins) if err != nil { return err } - k.createSplitShareTransferEvent(ctx, k.accountKeeper.GetModuleAddress(types.ModuleName), saleSplitAddr, sharePortionCoin) + k.createSplitShareTransferEvent(ctx, moduleAccAddr, saleSplitAddr, sharePortionCoin) } remaining = remaining.Sub(sharePortionCoin) } - err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, owner, sdk.NewCoins(remaining)) + err = k.bankKeeper.SendCoins(ctx, moduleAccAddr, owner, sdk.NewCoins(remaining)) if err != nil { return err } } else { - err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, owner, sdk.NewCoins(remaining)) + err = k.bankKeeper.SendCoins(ctx, moduleAccAddr, owner, sdk.NewCoins(remaining)) if err != nil { return err } @@ -196,14 +195,16 @@ func (k Keeper) GetProportions(totalCoin sdk.Coin, ratio sdk.Dec) sdk.Coin { func (k Keeper) DistributeCommission(ctx sdk.Context, marketplaceCoin sdk.Coin) error { distrParams := k.GetMarketplaceDistributionParams(ctx) stakingCommissionCoin := k.GetProportions(marketplaceCoin, distrParams.Staking) + moduleAccAddr := k.accountKeeper.GetModuleAddress(types.ModuleName) + feeCollectorAddr := k.accountKeeper.GetModuleAddress(authtypes.FeeCollectorName) if distrParams.Staking.GT(sdk.ZeroDec()) && stakingCommissionCoin.Amount.GT(sdk.ZeroInt()) { - err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, authtypes.FeeCollectorName, sdk.NewCoins(stakingCommissionCoin)) + err := k.bankKeeper.SendCoins(ctx, moduleAccAddr, feeCollectorAddr, sdk.NewCoins(stakingCommissionCoin)) if err != nil { return err } k.createSaleCommissionTransferEvent(ctx, - k.accountKeeper.GetModuleAddress(types.ModuleName), - k.accountKeeper.GetModuleAddress(authtypes.FeeCollectorName), + moduleAccAddr, + feeCollectorAddr, stakingCommissionCoin, ) marketplaceCoin = marketplaceCoin.Sub(stakingCommissionCoin) @@ -213,13 +214,13 @@ func (k Keeper) DistributeCommission(ctx sdk.Context, marketplaceCoin sdk.Coin) err := k.distributionKeeper.FundCommunityPool( ctx, sdk.NewCoins(communityPoolCommissionCoin), - k.accountKeeper.GetModuleAddress(types.ModuleName), + moduleAccAddr, ) if err != nil { return err } k.createSaleCommissionTransferEvent(ctx, - k.accountKeeper.GetModuleAddress(types.ModuleName), + moduleAccAddr, k.accountKeeper.GetModuleAddress("distribution"), communityPoolCommissionCoin, ) @@ -289,15 +290,19 @@ func (k Keeper) PlaceBid(ctx sdk.Context, auction types.AuctionListing, newBid t return errorsmod.Wrapf(types.ErrBidAmountNotEnough, "cannot place bid for given auction %d, required amount to bid is %s", auction.Id, newBidPrice.String()) } + moduleAccAddr := k.accountKeeper.GetModuleAddress(types.ModuleName) // Transfer amount from bidder to module account - err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, newBid.GetBidder(), types.ModuleName, sdk.NewCoins(newBid.Amount)) + err := k.bankKeeper.SendCoins(ctx, newBid.GetBidder(), moduleAccAddr, sdk.NewCoins(newBid.Amount)) if err != nil { return err } // Release previous Bid if bidExists { - _ = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, prevBid.GetBidder(), sdk.NewCoins(prevBid.Amount)) + err = k.bankKeeper.SendCoins(ctx, moduleAccAddr, prevBid.GetBidder(), sdk.NewCoins(prevBid.Amount)) + if err != nil { + return err + } k.RemoveBid(ctx, prevBid.AuctionId) } // Set new bid @@ -318,6 +323,7 @@ func (k Keeper) TransferRoyalty( ) error { // if royalty splits configured, distributing royalty // else sending royalty to collection creator + moduleAcc := k.accountKeeper.GetModuleAddress(types.ModuleName) if len(royaltyReceivers) > 0 { remaining := nftRoyaltyShareCoin for _, share := range royaltyReceivers { @@ -326,34 +332,34 @@ func (k Keeper) TransferRoyalty( royaltySplitAddr, err := sdk.AccAddressFromBech32(share.Address) if err != nil { // ignoring error and sending royalty to creator - if err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, creator, sharePortionCoins); err != nil { + if err := k.bankKeeper.SendCoins(ctx, moduleAcc, creator, sharePortionCoins); err != nil { return err } - k.createRoyaltyShareTransferEvent(ctx, k.accountKeeper.GetModuleAddress(types.ModuleName), creator, sharePortionCoin) + k.createRoyaltyShareTransferEvent(ctx, moduleAcc, creator, sharePortionCoin) } else { - err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, royaltySplitAddr, sharePortionCoins) + err = k.bankKeeper.SendCoins(ctx, moduleAcc, royaltySplitAddr, sharePortionCoins) if err != nil { return err } - k.createRoyaltyShareTransferEvent(ctx, k.accountKeeper.GetModuleAddress(types.ModuleName), royaltySplitAddr, sharePortionCoin) + k.createRoyaltyShareTransferEvent(ctx, moduleAcc, royaltySplitAddr, sharePortionCoin) } remaining = remaining.Sub(sharePortionCoin) } // sending remaining to creator if remaining.Amount.GT(sdk.ZeroInt()) { - err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, creator, sdk.NewCoins(remaining)) + err := k.bankKeeper.SendCoins(ctx, moduleAcc, creator, sdk.NewCoins(remaining)) if err != nil { return err } - k.createRoyaltyShareTransferEvent(ctx, k.accountKeeper.GetModuleAddress(types.ModuleName), creator, nftRoyaltyShareCoin) + k.createRoyaltyShareTransferEvent(ctx, moduleAcc, creator, nftRoyaltyShareCoin) } } else { - err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, creator, sdk.NewCoins(nftRoyaltyShareCoin)) + err := k.bankKeeper.SendCoins(ctx, moduleAcc, creator, sdk.NewCoins(nftRoyaltyShareCoin)) if err != nil { return err } - k.createRoyaltyShareTransferEvent(ctx, k.accountKeeper.GetModuleAddress(types.ModuleName), creator, nftRoyaltyShareCoin) + k.createRoyaltyShareTransferEvent(ctx, moduleAcc, creator, nftRoyaltyShareCoin) } return nil } diff --git a/x/onft/types/keys.go b/x/onft/types/keys.go index 46d90006..a7a8656a 100644 --- a/x/onft/types/keys.go +++ b/x/onft/types/keys.go @@ -1,12 +1,8 @@ package types import ( - "bytes" - "errors" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" gogotypes "github.com/cosmos/gogoproto/types" ) @@ -17,128 +13,26 @@ const ( ) var ( - PrefixONFT = []byte{0x01} - PrefixOwners = []byte{0x02} - PrefixCollection = []byte{0x03} - PrefixDenom = []byte{0x04} - PrefixDenomSymbol = []byte{0x05} - PrefixCreator = []byte{0x06} + PrefixONFT = []byte{0x01} + PrefixOwners = []byte{0x02} + PrefixCollection = []byte{0x03} + PrefixDenom = []byte{0x04} ParamsKey = []byte{0x07} - - delimiter = []byte("/") ) -func SplitKeyOwner(key []byte) (address sdk.AccAddress, denom, id string, err error) { - key = key[len(PrefixOwners)+len(delimiter):] - keys := bytes.Split(key, delimiter) - if len(keys) != 3 { - return address, denom, id, errors.New("wrong KeyOwner") - } - - address, _ = sdk.AccAddressFromBech32(string(keys[0])) - denom = string(keys[1]) - id = string(keys[2]) - return -} - -func SplitKeyDenom(key []byte) (denomID, nftID string, err error) { - keys := bytes.Split(key, delimiter) - if len(keys) != 2 { - return denomID, nftID, errors.New("wrong KeyOwner") - } - - denomID = string(keys[0]) - nftID = string(keys[1]) - return -} - -func KeyOwner(address sdk.AccAddress, denomID, onftID string) []byte { - key := append(PrefixOwners, delimiter...) - if address != nil { - key = append(key, []byte(address.String())...) - key = append(key, delimiter...) - } - - if address != nil && len(denomID) > 0 { - key = append(key, []byte(denomID)...) - key = append(key, delimiter...) - } - - if address != nil && len(denomID) > 0 && len(onftID) > 0 { - key = append(key, []byte(onftID)...) - } - return key -} - -func KeyONFT(denomID, onftID string) []byte { - key := append(PrefixONFT, delimiter...) - if len(denomID) > 0 { - key = append(key, []byte(denomID)...) - key = append(key, delimiter...) - } - - if len(denomID) > 0 && len(onftID) > 0 { - key = append(key, []byte(onftID)...) - } - return key -} - -func KeyCollection(denomID string) []byte { - key := append(PrefixCollection, delimiter...) - return append(key, []byte(denomID)...) -} - -func KeyDenomID(id string) []byte { - key := append(PrefixDenom, delimiter...) - return append(key, []byte(id)...) -} - -func KeyDenomCreator(address sdk.AccAddress, denomId string) []byte { - key := append(PrefixCreator, delimiter...) - if address != nil { - key = append(key, []byte(address)...) - key = append(key, delimiter...) - } - if address != nil && len(denomId) > 0 { - key = append(key, []byte(denomId)...) - key = append(key, delimiter...) - } - return key -} - -func KeyDenomSymbol(symbol string) []byte { - key := append(PrefixDenomSymbol, delimiter...) - return append(key, []byte(symbol)...) -} - -func MustMarshalSupply(cdc codec.BinaryCodec, supply uint64) []byte { - supplyWrap := gogotypes.UInt64Value{Value: supply} - return cdc.MustMarshal(&supplyWrap) -} - func MustUnMarshalSupply(cdc codec.BinaryCodec, value []byte) uint64 { var supplyWrap gogotypes.UInt64Value cdc.MustUnmarshal(value, &supplyWrap) return supplyWrap.Value } -func MustMarshalONFTID(cdc codec.BinaryCodec, onftID string) []byte { - onftIDWrap := gogotypes.StringValue{Value: onftID} - return cdc.MustMarshal(&onftIDWrap) -} - func MustUnMarshalONFTID(cdc codec.BinaryCodec, value []byte) string { var onftIDWrap gogotypes.StringValue cdc.MustUnmarshal(value, &onftIDWrap) return onftIDWrap.Value } -func MustMarshalDenomID(cdc codec.BinaryCodec, denomID string) []byte { - denomIDWrap := gogotypes.StringValue{Value: denomID} - return cdc.MustMarshal(&denomIDWrap) -} - func MustUnMarshalDenomID(cdc codec.BinaryCodec, value []byte) string { var denomIDWrap gogotypes.StringValue cdc.MustUnmarshal(value, &denomIDWrap) diff --git a/x/tokenfactory/README.md b/x/tokenfactory/README.md index 7d6644e4..bbdc48a9 100644 --- a/x/tokenfactory/README.md +++ b/x/tokenfactory/README.md @@ -104,7 +104,7 @@ Setting of metadata for a specific denom is only allowed for the admin of the de It allows the overwriting of the denom metadata in the bank module. ```go -message MsgChangeAdmin { +message MsgSetDenomMetadata { string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; cosmos.bank.v1beta1.Metadata metadata = 2 [ (gogoproto.moretags) = "yaml:\"metadata\"", (gogoproto.nullable) = false ]; }