Skip to content

Commit

Permalink
Merge branch 'master' into yaroslav/fix-ledger-new-app
Browse files Browse the repository at this point in the history
  • Loading branch information
ysv authored Nov 7, 2023
2 parents d8690f7 + e73cf05 commit 164ef18
Show file tree
Hide file tree
Showing 32 changed files with 308 additions and 246 deletions.
8 changes: 4 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ var (
distr.AppModuleBasic{},
gov.NewAppModuleBasic(
[]govclient.ProposalHandler{
// TODO: Remove once IBC migrates to the new mechanism
// TODO(v4): Remove once IBC upgrades to the new param management mechanism. Check ibc-go/modules/core/02-client/types/params.go
paramsclient.ProposalHandler,
ibcclientclient.UpdateClientProposalHandler,
ibcclientclient.UpgradeProposalHandler,
Expand Down Expand Up @@ -531,7 +531,7 @@ func New(
// See: https://docs.cosmos.network/main/modules/gov#proposal-messages
govRouter := govv1beta1.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler).
// TODO: Remove once IBC upgrades to the new mechanism
// TODO(v4): Remove once IBC upgrades to the new param management mechanism. Check ibc-go/modules/core/02-client/types/params.go
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper))

Expand Down Expand Up @@ -627,7 +627,7 @@ func New(
app.BankKeeper,
app.StakingKeeper,
distrkeeper.NewQuerier(app.DistrKeeper),
app.IBCKeeper.ChannelKeeper, // FIXME(v47-ibc) add the fee wrapper
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
app.ScopedWASMKeeper,
Expand All @@ -645,7 +645,7 @@ func New(
// FIXME(v47-legacy): remove once we finish with full migration
govRouter.AddRoute(wasmtypes.RouterKey, wasmkeeper.NewWasmProposalHandler(app.WasmKeeper, wasmtypes.EnableAllProposals)) //nolint:staticcheck // we need to keep backward compatibility

// FIXME(v47-legacy): remove once we finish with full migration
// FIXME(v4): drop once we drop gov v1beta1 compatibility.
// Set legacy router for backwards compatibility with gov v1beta1
app.GovKeeper.SetLegacyRouter(govRouter)

Expand Down
10 changes: 2 additions & 8 deletions app/upgrade/v3/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ func New(

// wasm:
wasmtypes.ModuleName: wasmtypes.ParamKeyTable(), //nolint:staticcheck

// coreum:
// TODO(migration-away-from-x/params): Add migration of params for Coreum modules. Skipping them for now.
}

// https://github.com/cosmos/cosmos-sdk/pull/12363/files
Expand All @@ -113,7 +110,6 @@ func New(
subspace := subspace

if lo.Contains([]string{
// TODO(migration-away-from-x/params): Add migration of params for Coreum modules. Skipping them for now.
feemodeltypes.ModuleName,
assetfttypes.ModuleName,
assetnfttypes.ModuleName,
Expand Down Expand Up @@ -170,8 +166,7 @@ func New(
params.AllowedClients = append(params.AllowedClients, ibccoreexported.Localhost)
ibcClientKeeper.SetParams(ctx, params)

// TODO(new-gov-params): Discuss new values for the following params with the team and set here & inside genesis.v3.json.
// min_initial_deposit_ratio, burn_vote_quorum, burn_proposal_deposit_prevote, burn_vote_veto
// Set values for new params: min_initial_deposit_ratio, burn_vote_quorum, burn_proposal_deposit_prevote, burn_vote_veto
govParams := govKeeper.GetParams(ctx)
govParams.MinInitialDepositRatio = sdk.NewDec(50).Quo(sdk.NewDec(100)).String()
govParams.BurnVoteQuorum = false
Expand All @@ -181,8 +176,7 @@ func New(
return nil, err
}

// TODO(new-staking-params): Discuss new values for the following params with the team and set here & inside genesis.v3.json.
// min_commission_rate
// Set value for new param min_commission_rate
stakingParams := stakingKeeper.GetParams(ctx)
stakingParams.MinCommissionRate = sdk.ZeroDec()
err = stakingKeeper.SetParams(ctx, stakingParams)
Expand Down
6 changes: 2 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ replace (
// cosmos keyring
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
// dgrijalva/jwt-go is deprecated and doesn't receive security updates.
// TODO: remove it: https://github.com/cosmos/cosmos-sdk/issues/13134
// TODO(v4): remove it: https://github.com/cosmos/cosmos-sdk/issues/13134
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2
// Fix upstream GHSA-h395-qcrw-5vmq vulnerability.
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
// TODO(v4) Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.0
// https://github.com/cosmos/cosmos-sdk/issues/14949
// pin the version of goleveldb to v1.0.1-0.20210819022825-2ae1ddf74ef7 required by SDK v47 upgrade guide.
Expand All @@ -31,7 +31,6 @@ require (
github.com/golang/protobuf v1.5.3
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.2
github.com/samber/lo v1.38.1
github.com/spf13/cast v1.5.1
github.com/spf13/cobra v1.7.0
Expand Down Expand Up @@ -99,7 +98,6 @@ require (
github.com/dvsekhvalnov/jose2go v1.5.0 // indirect
github.com/felixge/httpsnoop v1.0.2 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
Expand Down
3 changes: 0 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,6 @@ github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW
github.com/getkin/kin-openapi v0.61.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
github.com/getsentry/sentry-go v0.23.0 h1:dn+QRCeJv4pPt9OjVXiMcGIBIefaTJPw/h0bZWO05nE=
github.com/getsentry/sentry-go v0.23.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
Expand Down Expand Up @@ -723,8 +722,6 @@ github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgf
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.2 h1:dygLcbEBA+t/P7ck6a8AkXv6juQ4cK0RHBoh32jxhHM=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.2/go.mod h1:Ap9RLCIJVtgQg1/BBgVEfypOAySvvlcpcVQkSzJCH4Y=
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU=
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0=
github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s=
Expand Down
22 changes: 11 additions & 11 deletions integration-tests/contracts/modules/ft/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions integration-tests/contracts/modules/ft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ backtraces = ["cosmwasm-std/backtraces"]
library = []

[dependencies]
cosmwasm-std = "1.4.1"
cosmwasm-storage = "1.4.1"
cosmwasm-std = "1.5.0"
cosmwasm-storage = "1.5.0"
cw-storage-plus = "1.1.0"
cw2 = "1.1.1"
thiserror = "1.0.50"
coreum-wasm-sdk = "0.2.1"
coreum-wasm-sdk = "0.2.3"
cosmwasm-schema = "1.4.1"
cw-ownable = "0.5.1"
8 changes: 2 additions & 6 deletions integration-tests/contracts/modules/ft/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ For more detailed information of the AssetFT module and functionality go to [Ass

# Messages

### Mint (amount) [Mint](https://github.com/CoreumFoundation/coreum/tree/master/x/asset/ft/spec#mint)
### Mint (amount, recipient) [Mint](https://github.com/CoreumFoundation/coreum/tree/master/x/asset/ft/spec#mint)

The contract (issuer) will mint the amount of tokens provided.
The contract (issuer) will mint the amount of tokens provided to the corresponding recipient.

### Burn (amount) [Burn](https://github.com/CoreumFoundation/coreum/tree/master/x/asset/ft/spec#burn)

Expand All @@ -55,10 +55,6 @@ Globally unfreezes the token.

Sets a whitelisted limit for an account.

### MintAndSend (account, amount)

Combines the Mint feature described above with a bank transfer for convenience.

# Queries

### Params
Expand Down
76 changes: 35 additions & 41 deletions integration-tests/contracts/modules/ft/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use coreum_wasm_sdk::assetft::{
};
use coreum_wasm_sdk::core::{CoreumMsg, CoreumQueries, CoreumResult};
use coreum_wasm_sdk::pagination::PageRequest;
use cosmwasm_std::{coin, entry_point, to_binary, Binary, Deps, QueryRequest, StdResult};
use cosmwasm_std::{Coin, DepsMut, Env, MessageInfo, Response, SubMsg};
use cosmwasm_std::{coin, entry_point, to_json_binary, Binary, Deps, QueryRequest, StdResult};
use cosmwasm_std::{DepsMut, Env, MessageInfo, Response};
use cw2::set_contract_version;
use cw_ownable::{assert_owner, initialize_owner};

Expand Down Expand Up @@ -62,27 +62,28 @@ pub fn execute(
msg: ExecuteMsg,
) -> CoreumResult<ContractError> {
match msg {
ExecuteMsg::Mint { amount } => mint(deps, info, amount),
ExecuteMsg::Mint { amount, recipient } => mint(deps, info, amount, recipient),
ExecuteMsg::Burn { amount } => burn(deps, info, amount),
ExecuteMsg::Freeze { account, amount } => freeze(deps, info, account, amount),
ExecuteMsg::Unfreeze { account, amount } => unfreeze(deps, info, account, amount),
ExecuteMsg::SetFrozen { account, amount } => set_frozen(deps, info, account, amount),
ExecuteMsg::GloballyFreeze {} => globally_freeze(deps, info),
ExecuteMsg::GloballyUnfreeze {} => globally_unfreeze(deps, info),
ExecuteMsg::SetWhitelistedLimit { account, amount } => {
set_whitelisted_limit(deps, info, account, amount)
}
ExecuteMsg::MintAndSend { account, amount } => mint_and_send(deps, info, account, amount),
ExecuteMsg::UpgradeTokenV1 { ibc_enabled } => upgrate_token_v1(deps, info, ibc_enabled),
}
}

// ********** Transactions **********

fn mint(deps: DepsMut, info: MessageInfo, amount: u128) -> CoreumResult<ContractError> {
fn mint(deps: DepsMut, info: MessageInfo, amount: u128, recipient: Option<String>) -> CoreumResult<ContractError> {
assert_owner(deps.storage, &info.sender)?;
let denom = DENOM.load(deps.storage)?;
let msg = CoreumMsg::AssetFT(assetft::Msg::Mint {
coin: coin(amount, denom.clone()),
recipient,
});

Ok(Response::new()
Expand Down Expand Up @@ -149,6 +150,27 @@ fn unfreeze(
.add_message(msg))
}

fn set_frozen(
deps: DepsMut,
info: MessageInfo,
account: String,
amount: u128,
) -> CoreumResult<ContractError> {
assert_owner(deps.storage, &info.sender)?;
let denom = DENOM.load(deps.storage)?;

let msg = CoreumMsg::AssetFT(assetft::Msg::SetFrozen {
account,
coin: coin(amount, denom.clone()),
});

Ok(Response::new()
.add_attribute("method", "set_frozen")
.add_attribute("denom", denom)
.add_attribute("amount", amount.to_string())
.add_message(msg))
}

fn globally_freeze(deps: DepsMut, info: MessageInfo) -> CoreumResult<ContractError> {
assert_owner(deps.storage, &info.sender)?;
let denom = DENOM.load(deps.storage)?;
Expand Down Expand Up @@ -198,34 +220,6 @@ fn set_whitelisted_limit(
.add_message(msg))
}

fn mint_and_send(
deps: DepsMut,
info: MessageInfo,
account: String,
amount: u128,
) -> CoreumResult<ContractError> {
assert_owner(deps.storage, &info.sender)?;
let denom = DENOM.load(deps.storage)?;

let mint_msg = SubMsg::new(CoreumMsg::AssetFT(assetft::Msg::Mint {
coin: coin(amount, denom.clone()),
}));

let send_msg = SubMsg::new(cosmwasm_std::BankMsg::Send {
to_address: account,
amount: vec![Coin {
amount: amount.into(),
denom: denom.clone(),
}],
});

Ok(Response::new()
.add_attribute("method", "mint_and_send")
.add_attribute("denom", denom)
.add_attribute("amount", amount.to_string())
.add_submessages([mint_msg, send_msg]))
}

fn upgrate_token_v1(
deps: DepsMut,
info: MessageInfo,
Expand All @@ -250,17 +244,17 @@ fn upgrate_token_v1(
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps<CoreumQueries>, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::Params {} => to_binary(&query_params(deps)?),
QueryMsg::Token {} => to_binary(&query_token(deps)?),
QueryMsg::Tokens { issuer } => to_binary(&query_tokens(deps, issuer)?),
QueryMsg::FrozenBalance { account } => to_binary(&query_frozen_balance(deps, account)?),
QueryMsg::Params {} => to_json_binary(&query_params(deps)?),
QueryMsg::Token {} => to_json_binary(&query_token(deps)?),
QueryMsg::Tokens { issuer } => to_json_binary(&query_tokens(deps, issuer)?),
QueryMsg::FrozenBalance { account } => to_json_binary(&query_frozen_balance(deps, account)?),
QueryMsg::WhitelistedBalance { account } => {
to_binary(&query_whitelisted_balance(deps, account)?)
to_json_binary(&query_whitelisted_balance(deps, account)?)
}
QueryMsg::Balance { account } => to_binary(&query_balance(deps, account)?),
QueryMsg::FrozenBalances { account } => to_binary(&query_frozen_balances(deps, account)?),
QueryMsg::Balance { account } => to_json_binary(&query_balance(deps, account)?),
QueryMsg::FrozenBalances { account } => to_json_binary(&query_frozen_balances(deps, account)?),
QueryMsg::WhitelistedBalances { account } => {
to_binary(&query_whitelisted_balances(deps, account)?)
to_json_binary(&query_whitelisted_balances(deps, account)?)
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions integration-tests/contracts/modules/ft/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ pub struct InstantiateMsg {

#[cw_serde]
pub enum ExecuteMsg {
Mint { amount: u128 },
Mint { amount: u128, recipient: Option<String> },
Burn { amount: u128 },
Freeze { account: String, amount: u128 },
Unfreeze { account: String, amount: u128 },
SetFrozen { account: String, amount: u128 },
GloballyFreeze {},
GloballyUnfreeze {},
SetWhitelistedLimit { account: String, amount: u128 },
// custom message we use to show the submission of multiple messages
MintAndSend { account: String, amount: u128 },
UpgradeTokenV1 { ibc_enabled: bool },
}

Expand Down
9 changes: 5 additions & 4 deletions integration-tests/contracts/modules/nft.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ type IssueNFTRequest struct {
//
//nolint:tagliatelle
type NftMintRequest struct {
ID string `json:"id"`
URI string `json:"uri"`
URIHash string `json:"uri_hash"`
Data string `json:"data"`
ID string `json:"id"`
URI string `json:"uri"`
URIHash string `json:"uri_hash"`
Data string `json:"data"`
Recipient string `json:"recipient"`
}

// NftIDRequest is used to query NFT with ID.
Expand Down
Loading

0 comments on commit 164ef18

Please sign in to comment.