Feature/migration additions (#560)
* Changed default contract execution gas limit to 250_000 (from 9_000_000_000) * Introduced ability to perform contract migration * Removed unused import
This commit is contained in:
committed by
GitHub
parent
7659424f28
commit
f536449f0c
@@ -5,7 +5,7 @@ import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
|
||||
import MixnodesCache from "./caches/mixnodes";
|
||||
import { coin, Coin, coins } from "@cosmjs/launchpad";
|
||||
import { BroadcastTxResponse } from "@cosmjs/stargate"
|
||||
import { ExecuteResult, InstantiateOptions, InstantiateResult, UploadMeta, UploadResult } from "@cosmjs/cosmwasm";
|
||||
import { ExecuteResult, InstantiateOptions, InstantiateResult, MigrateResult, UploadMeta, UploadResult } from "@cosmjs/cosmwasm";
|
||||
import { CoinMap, displayAmountToNative, MappedCoin, nativeCoinToDisplay, printableBalance, printableCoin } from "./currency";
|
||||
import GatewaysCache from "./caches/gateways";
|
||||
import QueryClient, { IQueryClient } from "./query-client";
|
||||
@@ -255,6 +255,14 @@ export default class ValidatorClient {
|
||||
throw new Error("Tried to instantiate with a query client");
|
||||
}
|
||||
}
|
||||
|
||||
public migrate(senderAddress: string, contractAddress: string, codeId: number, migrateMsg: Record<string, unknown>, memo?: string): Promise<MigrateResult> {
|
||||
if (this.client instanceof NetClient) {
|
||||
return this.client.migrate(senderAddress, contractAddress, codeId, migrateMsg, memo)
|
||||
} else {
|
||||
throw new Error("Tried to migrate with a query client");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
|
||||
import { Coin, GasPrice } from "@cosmjs/launchpad";
|
||||
import { BroadcastTxResponse } from "@cosmjs/stargate"
|
||||
import { nymGasLimits } from "./stargate-helper"
|
||||
import { ExecuteResult, InstantiateOptions, InstantiateResult, UploadMeta, UploadResult } from "@cosmjs/cosmwasm";
|
||||
import { ExecuteResult, InstantiateOptions, InstantiateResult, MigrateResult, UploadMeta, UploadResult } from "@cosmjs/cosmwasm";
|
||||
|
||||
export interface INetClient {
|
||||
clientAddress: string;
|
||||
@@ -92,4 +92,8 @@ export default class NetClient implements INetClient {
|
||||
public instantiate(senderAddress: string, codeId: number, initMsg: Record<string, unknown>, label: string, options?: InstantiateOptions): Promise<InstantiateResult> {
|
||||
return this.cosmClient.instantiate(senderAddress, codeId, initMsg, label, options);
|
||||
}
|
||||
|
||||
public migrate(senderAddress: string, contractAddress: string, codeId: number, migrateMsg: Record<string, unknown>, memo?: string): Promise<MigrateResult> {
|
||||
return this.cosmClient.migrate(senderAddress, contractAddress, codeId, migrateMsg, memo)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::msg::{HandleMsg, InitMsg, QueryMsg};
|
||||
use crate::msg::{HandleMsg, InitMsg, MigrateMsg, QueryMsg};
|
||||
use crate::queries::{
|
||||
query_gateways_paged, query_mixnodes_paged, query_owns_gateway, query_owns_mixnode,
|
||||
};
|
||||
@@ -6,7 +6,7 @@ use crate::state::{config, gateways, gateways_read, State};
|
||||
use crate::{error::ContractError, state::mixnodes, state::mixnodes_read};
|
||||
use cosmwasm_std::{
|
||||
attr, coins, to_binary, BankMsg, Binary, Coin, Deps, DepsMut, Env, HandleResponse,
|
||||
InitResponse, MessageInfo, StdResult, Uint128,
|
||||
InitResponse, MessageInfo, MigrateResponse, StdResult, Uint128,
|
||||
};
|
||||
use mixnet_contract::{Gateway, GatewayBond, MixNode, MixNodeBond};
|
||||
|
||||
@@ -207,6 +207,15 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn migrate(
|
||||
_deps: DepsMut,
|
||||
_env: Env,
|
||||
_info: MessageInfo,
|
||||
_msg: MigrateMsg,
|
||||
) -> Result<MigrateResponse, ContractError> {
|
||||
Ok(Default::default())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -6,4 +6,4 @@ pub mod state;
|
||||
pub mod support;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
cosmwasm_std::create_entry_points!(contract);
|
||||
cosmwasm_std::create_entry_points_with_migration!(contract);
|
||||
|
||||
@@ -33,3 +33,7 @@ pub enum QueryMsg {
|
||||
address: HumanAddr,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct MigrateMsg {}
|
||||
|
||||
Reference in New Issue
Block a user