diff --git a/contracts/core/src/contract.rs b/contracts/core/src/contract.rs index c8abb94e..dbaf42d6 100644 --- a/contracts/core/src/contract.rs +++ b/contracts/core/src/contract.rs @@ -6,17 +6,13 @@ use cosmwasm_std::{ }; use cw_storage_plus::Bound; use drop_helpers::answer::response; -use drop_helpers::pause::{is_paused, pause_guard, set_pause, unpause, PauseInfoResponse}; -use drop_puppeteer_base::msg::TransferReadyBatchesMsg; -use drop_puppeteer_base::peripheral_hook::IBCTransferReason; -use drop_staking_base::msg::core::{BondCallback, BondHook}; -use drop_staking_base::state::core::{BOND_HOOKS, BOND_PROVIDERS, BOND_PROVIDER_REPLY_ID}; +use drop_puppeteer_base::{msg::TransferReadyBatchesMsg, peripheral_hook::IBCTransferReason}; use drop_staking_base::{ error::core::{ContractError, ContractResult}, msg::{ core::{ - ExecuteMsg, FailedBatchResponse, InstantiateMsg, LastPuppeteerResponse, MigrateMsg, - QueryMsg, + BondCallback, BondHook, ExecuteMsg, FailedBatchResponse, InstantiateMsg, + LastPuppeteerResponse, MigrateMsg, QueryMsg, }, token::{ ConfigResponse as TokenConfigResponse, ExecuteMsg as TokenExecuteMsg, @@ -28,8 +24,9 @@ use drop_staking_base::{ core::{ unbond_batches_map, Config, ConfigOptional, ContractState, Pause, UnbondBatch, UnbondBatchStatus, UnbondBatchStatusTimestamps, UnbondBatchesResponse, BONDED_AMOUNT, - CONFIG, EXCHANGE_RATE, FAILED_BATCH_ID, FSM, LAST_ICA_CHANGE_HEIGHT, LAST_IDLE_CALL, - LAST_PUPPETEER_RESPONSE, LD_DENOM, UNBOND_BATCH_ID, + BOND_HOOKS, BOND_PROVIDERS, BOND_PROVIDER_REPLY_ID, CONFIG, EXCHANGE_RATE, + FAILED_BATCH_ID, FSM, LAST_ICA_CHANGE_HEIGHT, LAST_IDLE_CALL, LAST_PUPPETEER_RESPONSE, + LD_DENOM, PAUSE, UNBOND_BATCH_ID, }, validatorset::ValidatorInfo, withdrawal_voucher::{Metadata, Trait}, @@ -124,14 +121,6 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> ContractResu }) } -fn query_pause_info(deps: Deps) -> ContractResult { - if is_paused(deps.storage)? { - to_json_binary(&PauseInfoResponse::Paused {}).map_err(From::from) - } else { - to_json_binary(&PauseInfoResponse::Unpaused {}).map_err(From::from) - } -} - fn query_total_async_tokens(deps: Deps) -> ContractResult { let mut total_async_shares = Uint128::zero(); let bond_providers = BOND_PROVIDERS.get_all_providers(deps.storage)?; @@ -295,7 +284,6 @@ pub fn execute( batch_id, withdrawn_amount, } => execute_update_withdrawn_amount(deps, env, info, batch_id, withdrawn_amount), - ExecuteMsg::Tick {} => execute_tick(deps, env, info), ExecuteMsg::PeripheralHook(msg) => execute_puppeteer_hook(deps, env, info, *msg), ExecuteMsg::SetPause(pause) => execute_set_pause(deps, info, pause), ExecuteMsg::SetBondHooks { hooks } => execute_set_bond_hooks(deps, info, hooks), diff --git a/contracts/core/src/tests.rs b/contracts/core/src/tests.rs index 6d3d7086..f822b9d3 100644 --- a/contracts/core/src/tests.rs +++ b/contracts/core/src/tests.rs @@ -8,16 +8,10 @@ use cosmwasm_std::{ to_json_binary, Addr, Coin, CosmosMsg, Decimal, Decimal256, Event, OwnedDeps, Response, SubMsg, Timestamp, Uint128, WasmMsg, }; -use drop_helpers::testing::{mock_dependencies, WasmMockQuerier}; use drop_helpers::{ pause::PauseError, testing::{mock_dependencies, WasmMockQuerier}, }; -use drop_puppeteer_base::{ - msg::TransferReadyBatchesMsg, - state::{Delegations, DropDelegation, RedeemShareItem}, -}; - use drop_puppeteer_base::msg::TransferReadyBatchesMsg; use drop_staking_base::{ error::core::ContractError, @@ -28,10 +22,10 @@ use drop_staking_base::{ }, state::{ core::{ - unbond_batches_map, Config, ConfigOptional, ContractState, UnbondBatch, + unbond_batches_map, Config, ConfigOptional, ContractState, Pause, UnbondBatch, UnbondBatchStatus, UnbondBatchStatusTimestamps, BONDED_AMOUNT, BOND_HOOKS, BOND_PROVIDERS, BOND_PROVIDER_REPLY_ID, CONFIG, FAILED_BATCH_ID, FSM, - LAST_ICA_CHANGE_HEIGHT, LAST_IDLE_CALL, LAST_PUPPETEER_RESPONSE, LD_DENOM, + LAST_ICA_CHANGE_HEIGHT, LAST_IDLE_CALL, LAST_PUPPETEER_RESPONSE, LD_DENOM, PAUSE, TOTAL_LSM_SHARES, UNBOND_BATCH_ID, }, puppeteer::{Delegations, DropDelegation}, diff --git a/contracts/factory/src/tests.rs b/contracts/factory/src/tests.rs index 40a39b87..009ec56c 100644 --- a/contracts/factory/src/tests.rs +++ b/contracts/factory/src/tests.rs @@ -1,8 +1,8 @@ use crate::{ contract::{execute, instantiate, query}, msg::{ - CoreMsg, CoreParams, ExecuteMsg, FeeParams, InstantiateMsg, LsmShareBondParams, - NativeBondParams, ProxyMsg, QueryMsg, UpdateConfigMsg, ValidatorSetMsg, + CoreParams, ExecuteMsg, FeeParams, InstantiateMsg, LsmShareBondParams, NativeBondParams, + QueryMsg, UpdateConfigMsg, ValidatorSetMsg, }, state::{CodeIds, RemoteOpts, State, Timeout, STATE}, }; diff --git a/packages/base/src/msg/core.rs b/packages/base/src/msg/core.rs index b70b82bd..0b86446e 100644 --- a/packages/base/src/msg/core.rs +++ b/packages/base/src/msg/core.rs @@ -1,6 +1,5 @@ use crate::{ error::core::ContractResult, - msg::staker::ResponseHookMsg as StakerResponseHookMsg, state::core::{Config, ConfigOptional, Pause}, }; use cosmwasm_schema::{cw_serde, QueryResponses}; @@ -8,7 +7,7 @@ use cosmwasm_schema::{cw_serde, QueryResponses}; #[allow(unused_imports)] use cosmwasm_std::{Addr, Deps, Uint128, Uint64}; use cw_ownable::cw_ownable_execute; -use drop_puppeteer_base::msg::ResponseHookMsg as PuppeteerResponseHookMsg; +use drop_puppeteer_base::peripheral_hook::ResponseHookMsg as PuppeteerResponseHookMsg; #[cw_serde] pub struct InstantiateMsg { diff --git a/ts-client/lib/contractLib/dropCore.d.ts b/ts-client/lib/contractLib/dropCore.d.ts index f5110292..f294156c 100644 --- a/ts-client/lib/contractLib/dropCore.d.ts +++ b/ts-client/lib/contractLib/dropCore.d.ts @@ -1,10 +1,5 @@ -import { - CosmWasmClient, - SigningCosmWasmClient, - ExecuteResult, - InstantiateResult, -} from '@cosmjs/cosmwasm-stargate'; -import { StdFee } from '@cosmjs/amino'; +import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult, InstantiateResult } from "@cosmjs/cosmwasm-stargate"; +import { StdFee } from "@cosmjs/amino"; export type ArrayOfString = string[]; /** * A human readable address. @@ -31,7 +26,7 @@ export type ArrayOfAddr = Addr[]; * let c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ``` */ export type Uint128 = string; -export type ContractState = 'idle' | 'peripheral' | 'claiming' | 'unbonding'; +export type ContractState = "idle" | "peripheral" | "claiming" | "unbonding"; /** * A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq. * @@ -52,133 +47,101 @@ export type Uint1281 = string; * The greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18) */ export type Decimal = string; -export type ResponseHookMsg = - | { - success: ResponseHookSuccessMsg; - } - | { - error: ResponseHookErrorMsg; - }; -export type ResponseAnswer = - | { - grant_delegate_response: MsgGrantResponse; - } - | { - delegate_response: MsgDelegateResponse; - } - | { - undelegate_response: MsgUndelegateResponse; - } - | { - begin_redelegate_response: MsgBeginRedelegateResponse; - } - | { - tokenize_shares_response: MsgTokenizeSharesResponse; - } - | { - redeem_tokensfor_shares_response: MsgRedeemTokensforSharesResponse; - } - | { - authz_exec_response: MsgExecResponse; - } - | { - i_b_c_transfer: MsgIBCTransfer; - } - | { - transfer_response: MsgSendResponse; - } - | { - unknown_response: {}; - }; +export type ResponseHookMsg = { + success: ResponseHookSuccessMsg; +} | { + error: ResponseHookErrorMsg; +}; +export type ResponseAnswer = { + grant_delegate_response: MsgGrantResponse; +} | { + delegate_response: MsgDelegateResponse; +} | { + undelegate_response: MsgUndelegateResponse; +} | { + begin_redelegate_response: MsgBeginRedelegateResponse; +} | { + tokenize_shares_response: MsgTokenizeSharesResponse; +} | { + redeem_tokensfor_shares_response: MsgRedeemTokensforSharesResponse; +} | { + authz_exec_response: MsgExecResponse; +} | { + i_b_c_transfer: MsgIBCTransfer; +} | { + transfer_response: MsgSendResponse; +} | { + unknown_response: {}; +}; /** * Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline. * * This is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also . */ export type Binary = string; -export type Transaction = - | { - undelegate: { +export type Transaction = { + undelegate: { batch_id: number; denom: string; interchain_account_id: string; items: [string, Uint128][]; - }; - } - | { - redelegate: { + }; +} | { + redelegate: { amount: number; denom: string; interchain_account_id: string; validator_from: string; validator_to: string; - }; - } - | { - withdraw_reward: { + }; +} | { + withdraw_reward: { interchain_account_id: string; validator: string; - }; - } - | { - tokenize_share: { + }; +} | { + tokenize_share: { amount: number; denom: string; interchain_account_id: string; validator: string; - }; - } - | { - redeem_shares: { + }; +} | { + redeem_shares: { items: RedeemShareItem[]; - }; - } - | { - claim_rewards_and_optionaly_transfer: { + }; +} | { + claim_rewards_and_optionaly_transfer: { denom: string; interchain_account_id: string; transfer?: TransferReadyBatchesMsg | null; validators: string[]; - }; - } - | { - i_b_c_transfer: { + }; +} | { + i_b_c_transfer: { amount: number; denom: string; real_amount: number; reason: IBCTransferReason; recipient: string; - }; - } - | { - stake: { + }; +} | { + stake: { amount: Uint128; - }; - } - | { - transfer: { + }; +} | { + transfer: { interchain_account_id: string; items: [string, Coin][]; - }; - } - | { - setup_protocol: { + }; +} | { + setup_protocol: { interchain_account_id: string; rewards_withdraw_address: string; - }; }; -export type IBCTransferReason = 'l_s_m_share' | 'delegate'; +}; +export type IBCTransferReason = "l_s_m_share" | "delegate"; export type String = string; -/** - * Information about if the contract is currently paused. - */ -export type PauseInfoResponse = - | { - paused: {}; - } - | { - unpaused: {}; - }; /** * A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq. * @@ -227,15 +190,7 @@ export type Uint1284 = string; * The greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18) */ export type Decimal1 = string; -export type UnbondBatchStatus = - | 'new' - | 'unbond_requested' - | 'unbond_failed' - | 'unbonding' - | 'withdrawing' - | 'withdrawn' - | 'withdrawing_emergency' - | 'withdrawn_emergency'; +export type UnbondBatchStatus = "new" | "unbond_requested" | "unbond_failed" | "unbonding" | "withdrawing" | "withdrawn" | "withdrawing_emergency" | "withdrawn_emergency"; /** * A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq. * @@ -248,38 +203,30 @@ export type UnbondBatchStatus = * let b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ``` */ export type Uint64 = string; -export type PeripheralHookArgs = - | { - success: ResponseHookSuccessMsg; - } - | { - error: ResponseHookErrorMsg; - }; +export type PeripheralHookArgs = { + success: ResponseHookSuccessMsg; +} | { + error: ResponseHookErrorMsg; +}; /** * Actions that can be taken to alter the contract's ownership */ -export type UpdateOwnershipArgs = - | { - transfer_ownership: { +export type UpdateOwnershipArgs = { + transfer_ownership: { expiry?: Expiration | null; new_owner: string; - }; - } - | 'accept_ownership' - | 'renounce_ownership'; + }; +} | "accept_ownership" | "renounce_ownership"; /** * Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future) */ -export type Expiration = - | { - at_height: number; - } - | { - at_time: Timestamp2; - } - | { - never: {}; - }; +export type Expiration = { + at_height: number; +} | { + at_time: Timestamp2; +} | { + never: {}; +}; /** * A point in time in nanosecond precision. * @@ -293,375 +240,263 @@ export type Expiration = */ export type Timestamp2 = Uint64; export interface DropCoreSchema { - responses: - | ArrayOfString - | ArrayOfAddr - | Config - | ContractState - | Uint1281 - | Decimal - | FailedBatchResponse - | LastPuppeteerResponse - | String - | PauseInfoResponse - | Uint1282 - | Uint1283 - | Uint1284 - | UnbondBatch - | UnbondBatchesResponse; - query: UnbondBatchArgs | UnbondBatchesArgs; - execute: - | BondArgs - | AddBondProviderArgs - | RemoveBondProviderArgs - | UpdateConfigArgs - | UpdateWithdrawnAmountArgs - | PeripheralHookArgs - | ProcessEmergencyBatchArgs - | SetBondHooksArgs - | UpdateOwnershipArgs; - instantiate?: InstantiateMsg; - [k: string]: unknown; + responses: ArrayOfString | ArrayOfAddr | Config | ContractState | Uint1281 | Decimal | FailedBatchResponse | LastPuppeteerResponse | String | Pause | Uint1282 | Uint1283 | Uint1284 | UnbondBatch | UnbondBatchesResponse; + query: UnbondBatchArgs | UnbondBatchesArgs; + execute: BondArgs | AddBondProviderArgs | RemoveBondProviderArgs | UpdateConfigArgs | UpdateWithdrawnAmountArgs | PeripheralHookArgs | ProcessEmergencyBatchArgs | SetPauseArgs | SetBondHooksArgs | UpdateOwnershipArgs; + instantiate?: InstantiateMsg; + [k: string]: unknown; } export interface Config { - base_denom: string; - bond_limit?: Uint128 | null; - emergency_address?: string | null; - icq_update_delay: number; - idle_min_interval: number; - pump_ica_address?: string | null; - puppeteer_contract: Addr; - remote_denom: string; - strategy_contract: Addr; - token_contract: Addr; - transfer_channel_id: string; - unbond_batch_switch_time: number; - unbonding_period: number; - unbonding_safe_period: number; - validators_set_contract: Addr; - withdrawal_manager_contract: Addr; - withdrawal_voucher_contract: Addr; + base_denom: string; + bond_limit?: Uint128 | null; + emergency_address?: string | null; + icq_update_delay: number; + idle_min_interval: number; + pump_ica_address?: string | null; + puppeteer_contract: Addr; + remote_denom: string; + strategy_contract: Addr; + token_contract: Addr; + transfer_channel_id: string; + unbond_batch_switch_time: number; + unbonding_period: number; + unbonding_safe_period: number; + validators_set_contract: Addr; + withdrawal_manager_contract: Addr; + withdrawal_voucher_contract: Addr; } export interface FailedBatchResponse { - response?: number | null; + response?: number | null; } export interface LastPuppeteerResponse { - response?: ResponseHookMsg | null; + response?: ResponseHookMsg | null; } export interface ResponseHookSuccessMsg { - answers: ResponseAnswer[]; - local_height: number; - remote_height: number; - request: RequestPacket; - request_id: number; - transaction: Transaction; -} -export interface MsgGrantResponse {} -export interface MsgDelegateResponse {} + answers: ResponseAnswer[]; + local_height: number; + remote_height: number; + request: RequestPacket; + request_id: number; + transaction: Transaction; +} +export interface MsgGrantResponse { +} +export interface MsgDelegateResponse { +} export interface MsgUndelegateResponse { - completion_time?: Timestamp | null; + completion_time?: Timestamp | null; } export interface Timestamp { - nanos: number; - seconds: number; + nanos: number; + seconds: number; } export interface MsgBeginRedelegateResponse { - completion_time?: Timestamp | null; + completion_time?: Timestamp | null; } export interface MsgTokenizeSharesResponse { - amount?: Coin | null; + amount?: Coin | null; } export interface Coin { - amount: Uint128; - denom: string; - [k: string]: unknown; + amount: Uint128; + denom: string; + [k: string]: unknown; } export interface MsgRedeemTokensforSharesResponse { - amount?: Coin | null; + amount?: Coin | null; } export interface MsgExecResponse { - results: number[][]; + results: number[][]; +} +export interface MsgIBCTransfer { +} +export interface MsgSendResponse { } -export interface MsgIBCTransfer {} -export interface MsgSendResponse {} export interface RequestPacket { - data?: Binary | null; - destination_channel?: string | null; - destination_port?: string | null; - sequence?: number | null; - source_channel?: string | null; - source_port?: string | null; - timeout_height?: RequestPacketTimeoutHeight | null; - timeout_timestamp?: number | null; - [k: string]: unknown; + data?: Binary | null; + destination_channel?: string | null; + destination_port?: string | null; + sequence?: number | null; + source_channel?: string | null; + source_port?: string | null; + timeout_height?: RequestPacketTimeoutHeight | null; + timeout_timestamp?: number | null; + [k: string]: unknown; } export interface RequestPacketTimeoutHeight { - revision_height?: number | null; - revision_number?: number | null; - [k: string]: unknown; + revision_height?: number | null; + revision_number?: number | null; + [k: string]: unknown; } export interface RedeemShareItem { - amount: Uint128; - local_denom: string; - remote_denom: string; + amount: Uint128; + local_denom: string; + remote_denom: string; } export interface TransferReadyBatchesMsg { - amount: Uint128; - batch_ids: number[]; - emergency: boolean; - recipient: string; + amount: Uint128; + batch_ids: number[]; + emergency: boolean; + recipient: string; } export interface ResponseHookErrorMsg { - details: string; - request: RequestPacket; - request_id: number; - transaction: Transaction; + details: string; + request: RequestPacket; + request_id: number; + transaction: Transaction; +} +export interface Pause { + bond: boolean; + tick: boolean; + unbond: boolean; } export interface UnbondBatch { - expected_native_asset_amount: Uint128; - expected_release_time: number; - slashing_effect?: Decimal1 | null; - status: UnbondBatchStatus; - status_timestamps: UnbondBatchStatusTimestamps; - total_dasset_amount_to_withdraw: Uint128; - total_unbond_items: number; - unbonded_amount?: Uint128 | null; - withdrawn_amount?: Uint128 | null; + expected_native_asset_amount: Uint128; + expected_release_time: number; + slashing_effect?: Decimal1 | null; + status: UnbondBatchStatus; + status_timestamps: UnbondBatchStatusTimestamps; + total_dasset_amount_to_withdraw: Uint128; + total_unbond_items: number; + unbonded_amount?: Uint128 | null; + withdrawn_amount?: Uint128 | null; } export interface UnbondBatchStatusTimestamps { - new: number; - unbond_failed?: number | null; - unbond_requested?: number | null; - unbonding?: number | null; - withdrawing?: number | null; - withdrawing_emergency?: number | null; - withdrawn?: number | null; - withdrawn_emergency?: number | null; + new: number; + unbond_failed?: number | null; + unbond_requested?: number | null; + unbonding?: number | null; + withdrawing?: number | null; + withdrawing_emergency?: number | null; + withdrawn?: number | null; + withdrawn_emergency?: number | null; } export interface UnbondBatchesResponse { - next_page_key?: Uint128 | null; - unbond_batches: UnbondBatch1[]; + next_page_key?: Uint128 | null; + unbond_batches: UnbondBatch1[]; } export interface UnbondBatch1 { - expected_native_asset_amount: Uint128; - expected_release_time: number; - slashing_effect?: Decimal1 | null; - status: UnbondBatchStatus; - status_timestamps: UnbondBatchStatusTimestamps; - total_dasset_amount_to_withdraw: Uint128; - total_unbond_items: number; - unbonded_amount?: Uint128 | null; - withdrawn_amount?: Uint128 | null; + expected_native_asset_amount: Uint128; + expected_release_time: number; + slashing_effect?: Decimal1 | null; + status: UnbondBatchStatus; + status_timestamps: UnbondBatchStatusTimestamps; + total_dasset_amount_to_withdraw: Uint128; + total_unbond_items: number; + unbonded_amount?: Uint128 | null; + withdrawn_amount?: Uint128 | null; } export interface UnbondBatchArgs { - batch_id: Uint128; + batch_id: Uint128; } export interface UnbondBatchesArgs { - limit?: Uint64 | null; - page_key?: Uint128 | null; + limit?: Uint64 | null; + page_key?: Uint128 | null; } export interface BondArgs { - receiver?: string | null; - ref?: string | null; + receiver?: string | null; + ref?: string | null; } export interface AddBondProviderArgs { - bond_provider_address: string; + bond_provider_address: string; } export interface RemoveBondProviderArgs { - bond_provider_address: string; + bond_provider_address: string; } export interface UpdateConfigArgs { - new_config: ConfigOptional; + new_config: ConfigOptional; } export interface ConfigOptional { - base_denom?: string | null; - bond_limit?: Uint128 | null; - emergency_address?: string | null; - idle_min_interval?: number | null; - pump_ica_address?: string | null; - puppeteer_contract?: string | null; - remote_denom?: string | null; - rewards_receiver?: string | null; - staker_contract?: string | null; - strategy_contract?: string | null; - token_contract?: string | null; - transfer_channel_id?: string | null; - unbond_batch_switch_time?: number | null; - unbonding_period?: number | null; - unbonding_safe_period?: number | null; - validators_set_contract?: string | null; - withdrawal_manager_contract?: string | null; - withdrawal_voucher_contract?: string | null; + base_denom?: string | null; + bond_limit?: Uint128 | null; + emergency_address?: string | null; + idle_min_interval?: number | null; + pump_ica_address?: string | null; + puppeteer_contract?: string | null; + remote_denom?: string | null; + rewards_receiver?: string | null; + staker_contract?: string | null; + strategy_contract?: string | null; + token_contract?: string | null; + transfer_channel_id?: string | null; + unbond_batch_switch_time?: number | null; + unbonding_period?: number | null; + unbonding_safe_period?: number | null; + validators_set_contract?: string | null; + withdrawal_manager_contract?: string | null; + withdrawal_voucher_contract?: string | null; } export interface UpdateWithdrawnAmountArgs { - batch_id: number; - withdrawn_amount: Uint128; + batch_id: number; + withdrawn_amount: Uint128; } export interface ProcessEmergencyBatchArgs { - batch_id: number; - unbonded_amount: Uint128; + batch_id: number; + unbonded_amount: Uint128; } export interface SetPauseArgs { - type?: 'object'; - required?: ['bond', 'tick', 'unbond']; - properties?: { - [k: string]: unknown; - }; - additionalProperties?: never; + type?: "object"; + required?: ["bond", "tick", "unbond"]; + properties?: { + [k: string]: unknown; + }; + additionalProperties?: never; } export interface SetBondHooksArgs { - hooks: string[]; + hooks: string[]; } export interface InstantiateMsg { - base_denom: string; - bond_limit?: Uint128 | null; - emergency_address?: string | null; - icq_update_delay: number; - idle_min_interval: number; - owner: string; - pump_ica_address?: string | null; - puppeteer_contract: string; - remote_denom: string; - strategy_contract: string; - token_contract: string; - transfer_channel_id: string; - unbond_batch_switch_time: number; - unbonding_period: number; - unbonding_safe_period: number; - validators_set_contract: string; - withdrawal_manager_contract: string; - withdrawal_voucher_contract: string; + base_denom: string; + bond_limit?: Uint128 | null; + emergency_address?: string | null; + icq_update_delay: number; + idle_min_interval: number; + owner: string; + pump_ica_address?: string | null; + puppeteer_contract: string; + remote_denom: string; + strategy_contract: string; + token_contract: string; + transfer_channel_id: string; + unbond_batch_switch_time: number; + unbonding_period: number; + unbonding_safe_period: number; + validators_set_contract: string; + withdrawal_manager_contract: string; + withdrawal_voucher_contract: string; } export declare class Client { - private readonly client; - contractAddress: string; - constructor( - client: CosmWasmClient | SigningCosmWasmClient, - contractAddress: string, - ); - mustBeSigningClient(): Error; - static instantiate( - client: SigningCosmWasmClient, - sender: string, - codeId: number, - initMsg: InstantiateMsg, - label: string, - fees: StdFee | 'auto' | number, - initCoins?: readonly Coin[], - ): Promise; - static instantiate2( - client: SigningCosmWasmClient, - sender: string, - codeId: number, - salt: number, - initMsg: InstantiateMsg, - label: string, - fees: StdFee | 'auto' | number, - initCoins?: readonly Coin[], - ): Promise; - queryConfig: () => Promise; - queryOwner: () => Promise; - queryExchangeRate: () => Promise; - queryCurrentUnbondBatch: () => Promise; - queryUnbondBatch: (args: UnbondBatchArgs) => Promise; - queryUnbondBatches: ( - args: UnbondBatchesArgs, - ) => Promise; - queryContractState: () => Promise; - queryLastPuppeteerResponse: () => Promise; - queryTotalBonded: () => Promise; - queryBondProviders: () => Promise; - queryTotalLSMShares: () => Promise; - queryTotalAsyncTokens: () => Promise; - queryFailedBatch: () => Promise; - queryPause: () => Promise; - queryBondHooks: () => Promise; - bond: ( - sender: string, - args: BondArgs, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ) => Promise; - unbond: ( - sender: string, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ) => Promise; - addBondProvider: ( - sender: string, - args: AddBondProviderArgs, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ) => Promise; - removeBondProvider: ( - sender: string, - args: RemoveBondProviderArgs, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ) => Promise; - updateConfig: ( - sender: string, - args: UpdateConfigArgs, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ) => Promise; - updateWithdrawnAmount: ( - sender: string, - args: UpdateWithdrawnAmountArgs, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ) => Promise; - tick: ( - sender: string, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ) => Promise; - peripheralHook: ( - sender: string, - args: PeripheralHookArgs, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ) => Promise; - resetBondedAmount: ( - sender: string, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ) => Promise; - processEmergencyBatch: ( - sender: string, - args: ProcessEmergencyBatchArgs, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ) => Promise; - setPause: ( - sender: string, - args: SetPauseArgs, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ) => Promise; - setBondHooks: ( - sender: string, - args: SetBondHooksArgs, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ) => Promise; - updateOwnership: ( - sender: string, - args: UpdateOwnershipArgs, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ) => Promise; + private readonly client; + contractAddress: string; + constructor(client: CosmWasmClient | SigningCosmWasmClient, contractAddress: string); + mustBeSigningClient(): Error; + static instantiate(client: SigningCosmWasmClient, sender: string, codeId: number, initMsg: InstantiateMsg, label: string, fees: StdFee | 'auto' | number, initCoins?: readonly Coin[]): Promise; + static instantiate2(client: SigningCosmWasmClient, sender: string, codeId: number, salt: number, initMsg: InstantiateMsg, label: string, fees: StdFee | 'auto' | number, initCoins?: readonly Coin[]): Promise; + queryConfig: () => Promise; + queryOwner: () => Promise; + queryExchangeRate: () => Promise; + queryCurrentUnbondBatch: () => Promise; + queryUnbondBatch: (args: UnbondBatchArgs) => Promise; + queryUnbondBatches: (args: UnbondBatchesArgs) => Promise; + queryContractState: () => Promise; + queryLastPuppeteerResponse: () => Promise; + queryTotalBonded: () => Promise; + queryBondProviders: () => Promise; + queryTotalLSMShares: () => Promise; + queryTotalAsyncTokens: () => Promise; + queryFailedBatch: () => Promise; + queryPause: () => Promise; + queryBondHooks: () => Promise; + bond: (sender: string, args: BondArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; + unbond: (sender: string, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; + tick: (sender: string, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; + addBondProvider: (sender: string, args: AddBondProviderArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; + removeBondProvider: (sender: string, args: RemoveBondProviderArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; + updateConfig: (sender: string, args: UpdateConfigArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; + updateWithdrawnAmount: (sender: string, args: UpdateWithdrawnAmountArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; + peripheralHook: (sender: string, args: PeripheralHookArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; + resetBondedAmount: (sender: string, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; + processEmergencyBatch: (sender: string, args: ProcessEmergencyBatchArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; + setPause: (sender: string, args: SetPauseArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; + setBondHooks: (sender: string, args: SetBondHooksArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; + updateOwnership: (sender: string, args: UpdateOwnershipArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise; } diff --git a/ts-client/lib/contractLib/dropCore.js b/ts-client/lib/contractLib/dropCore.js index c882b443..b8378d43 100644 --- a/ts-client/lib/contractLib/dropCore.js +++ b/ts-client/lib/contractLib/dropCore.js @@ -1,267 +1,153 @@ -'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); exports.Client = void 0; function isSigningCosmWasmClient(client) { - return 'execute' in client; + return 'execute' in client; } class Client { - client; - contractAddress; - constructor(client, contractAddress) { - this.client = client; - this.contractAddress = contractAddress; - } - mustBeSigningClient() { - return new Error('This client is not a SigningCosmWasmClient'); - } - static async instantiate( - client, - sender, - codeId, - initMsg, - label, - fees, - initCoins, - ) { - const res = await client.instantiate(sender, codeId, initMsg, label, fees, { - ...(initCoins && initCoins.length && { funds: initCoins }), - }); - return res; - } - static async instantiate2( - client, - sender, - codeId, - salt, - initMsg, - label, - fees, - initCoins, - ) { - const res = await client.instantiate2( - sender, - codeId, - new Uint8Array([salt]), - initMsg, - label, - fees, - { - ...(initCoins && initCoins.length && { funds: initCoins }), - }, - ); - return res; - } - queryConfig = async () => { - return this.client.queryContractSmart(this.contractAddress, { config: {} }); - }; - queryOwner = async () => { - return this.client.queryContractSmart(this.contractAddress, { owner: {} }); - }; - queryExchangeRate = async () => { - return this.client.queryContractSmart(this.contractAddress, { - exchange_rate: {}, - }); - }; - queryCurrentUnbondBatch = async () => { - return this.client.queryContractSmart(this.contractAddress, { - current_unbond_batch: {}, - }); - }; - queryUnbondBatch = async (args) => { - return this.client.queryContractSmart(this.contractAddress, { - unbond_batch: args, - }); - }; - queryUnbondBatches = async (args) => { - return this.client.queryContractSmart(this.contractAddress, { - unbond_batches: args, - }); - }; - queryContractState = async () => { - return this.client.queryContractSmart(this.contractAddress, { - contract_state: {}, - }); - }; - queryLastPuppeteerResponse = async () => { - return this.client.queryContractSmart(this.contractAddress, { - last_puppeteer_response: {}, - }); - }; - queryTotalBonded = async () => { - return this.client.queryContractSmart(this.contractAddress, { - total_bonded: {}, - }); - }; - queryBondProviders = async () => { - return this.client.queryContractSmart(this.contractAddress, { - bond_providers: {}, - }); - }; - queryTotalLSMShares = async () => { - return this.client.queryContractSmart(this.contractAddress, { - total_l_s_m_shares: {}, - }); - }; - queryTotalAsyncTokens = async () => { - return this.client.queryContractSmart(this.contractAddress, { - total_async_tokens: {}, - }); - }; - queryFailedBatch = async () => { - return this.client.queryContractSmart(this.contractAddress, { - failed_batch: {}, - }); - }; - queryPause = async () => { - return this.client.queryContractSmart(this.contractAddress, { pause: {} }); - }; - queryBondHooks = async () => { - return this.client.queryContractSmart(this.contractAddress, { - bond_hooks: {}, - }); - }; - bond = async (sender, args, fee, memo, funds) => { - if (!isSigningCosmWasmClient(this.client)) { - throw this.mustBeSigningClient(); + client; + contractAddress; + constructor(client, contractAddress) { + this.client = client; + this.contractAddress = contractAddress; } - return this.client.execute( - sender, - this.contractAddress, - { bond: args }, - fee || 'auto', - memo, - funds, - ); - }; - unbond = async (sender, fee, memo, funds) => { - if (!isSigningCosmWasmClient(this.client)) { - throw this.mustBeSigningClient(); + mustBeSigningClient() { + return new Error("This client is not a SigningCosmWasmClient"); } - return this.client.execute( - sender, - this.contractAddress, - { unbond: {} }, - fee || 'auto', - memo, - funds, - ); - }; - tick = async (sender, fee, memo, funds) => { - if (!isSigningCosmWasmClient(this.client)) { - throw this.mustBeSigningClient(); + static async instantiate(client, sender, codeId, initMsg, label, fees, initCoins) { + const res = await client.instantiate(sender, codeId, initMsg, label, fees, { + ...(initCoins && initCoins.length && { funds: initCoins }), + }); + return res; } - return this.client.execute( - sender, - this.contractAddress, - { tick: {} }, - fee || 'auto', - memo, - funds, - ); - }; - updateConfig = async (sender, args, fee, memo, funds) => { - if (!isSigningCosmWasmClient(this.client)) { - throw this.mustBeSigningClient(); + static async instantiate2(client, sender, codeId, salt, initMsg, label, fees, initCoins) { + const res = await client.instantiate2(sender, codeId, new Uint8Array([salt]), initMsg, label, fees, { + ...(initCoins && initCoins.length && { funds: initCoins }), + }); + return res; } - return this.client.execute( - sender, - this.contractAddress, - { update_config: args }, - fee || 'auto', - memo, - funds, - ); - }; - updateWithdrawnAmount = async (sender, args, fee, memo, funds) => { - if (!isSigningCosmWasmClient(this.client)) { - throw this.mustBeSigningClient(); - } - return this.client.execute( - sender, - this.contractAddress, - { update_withdrawn_amount: args }, - fee || 'auto', - memo, - funds, - ); - }; - puppeteerHook = async (sender, args, fee, memo, funds) => { - if (!isSigningCosmWasmClient(this.client)) { - throw this.mustBeSigningClient(); - } - return this.client.execute( - sender, - this.contractAddress, - { peripheral_hook: args }, - fee || 'auto', - memo, - funds, - ); - }; - resetBondedAmount = async (sender, fee, memo, funds) => { - if (!isSigningCosmWasmClient(this.client)) { - throw this.mustBeSigningClient(); - } - return this.client.execute( - sender, - this.contractAddress, - { reset_bonded_amount: {} }, - fee || 'auto', - memo, - funds, - ); - }; - processEmergencyBatch = async (sender, args, fee, memo, funds) => { - if (!isSigningCosmWasmClient(this.client)) { - throw this.mustBeSigningClient(); - } - return this.client.execute( - sender, - this.contractAddress, - { process_emergency_batch: args }, - fee || 'auto', - memo, - funds, - ); - }; - setPause = async (sender, args, fee, memo, funds) => { - if (!isSigningCosmWasmClient(this.client)) { - throw this.mustBeSigningClient(); - } - return this.client.execute( - sender, - this.contractAddress, - { set_pause: args }, - fee || 'auto', - memo, - funds, - ); - }; - setBondHooks = async (sender, args, fee, memo, funds) => { - if (!isSigningCosmWasmClient(this.client)) { - throw this.mustBeSigningClient(); - } - return this.client.execute( - sender, - this.contractAddress, - { set_bond_hooks: args }, - fee || 'auto', - memo, - funds, - ); - }; - updateOwnership = async (sender, args, fee, memo, funds) => { - if (!isSigningCosmWasmClient(this.client)) { - throw this.mustBeSigningClient(); - } - return this.client.execute( - sender, - this.contractAddress, - { update_ownership: args }, - fee || 'auto', - memo, - funds, - ); - }; + queryConfig = async () => { + return this.client.queryContractSmart(this.contractAddress, { config: {} }); + }; + queryOwner = async () => { + return this.client.queryContractSmart(this.contractAddress, { owner: {} }); + }; + queryExchangeRate = async () => { + return this.client.queryContractSmart(this.contractAddress, { exchange_rate: {} }); + }; + queryCurrentUnbondBatch = async () => { + return this.client.queryContractSmart(this.contractAddress, { current_unbond_batch: {} }); + }; + queryUnbondBatch = async (args) => { + return this.client.queryContractSmart(this.contractAddress, { unbond_batch: args }); + }; + queryUnbondBatches = async (args) => { + return this.client.queryContractSmart(this.contractAddress, { unbond_batches: args }); + }; + queryContractState = async () => { + return this.client.queryContractSmart(this.contractAddress, { contract_state: {} }); + }; + queryLastPuppeteerResponse = async () => { + return this.client.queryContractSmart(this.contractAddress, { last_puppeteer_response: {} }); + }; + queryTotalBonded = async () => { + return this.client.queryContractSmart(this.contractAddress, { total_bonded: {} }); + }; + queryBondProviders = async () => { + return this.client.queryContractSmart(this.contractAddress, { bond_providers: {} }); + }; + queryTotalLSMShares = async () => { + return this.client.queryContractSmart(this.contractAddress, { total_l_s_m_shares: {} }); + }; + queryTotalAsyncTokens = async () => { + return this.client.queryContractSmart(this.contractAddress, { total_async_tokens: {} }); + }; + queryFailedBatch = async () => { + return this.client.queryContractSmart(this.contractAddress, { failed_batch: {} }); + }; + queryPause = async () => { + return this.client.queryContractSmart(this.contractAddress, { pause: {} }); + }; + queryBondHooks = async () => { + return this.client.queryContractSmart(this.contractAddress, { bond_hooks: {} }); + }; + bond = async (sender, args, fee, memo, funds) => { + if (!isSigningCosmWasmClient(this.client)) { + throw this.mustBeSigningClient(); + } + return this.client.execute(sender, this.contractAddress, { bond: args }, fee || "auto", memo, funds); + }; + unbond = async (sender, fee, memo, funds) => { + if (!isSigningCosmWasmClient(this.client)) { + throw this.mustBeSigningClient(); + } + return this.client.execute(sender, this.contractAddress, { unbond: {} }, fee || "auto", memo, funds); + }; + tick = async (sender, fee, memo, funds) => { + if (!isSigningCosmWasmClient(this.client)) { + throw this.mustBeSigningClient(); + } + return this.client.execute(sender, this.contractAddress, { tick: {} }, fee || "auto", memo, funds); + }; + addBondProvider = async (sender, args, fee, memo, funds) => { + if (!isSigningCosmWasmClient(this.client)) { + throw this.mustBeSigningClient(); + } + return this.client.execute(sender, this.contractAddress, { add_bond_provider: args }, fee || "auto", memo, funds); + }; + removeBondProvider = async (sender, args, fee, memo, funds) => { + if (!isSigningCosmWasmClient(this.client)) { + throw this.mustBeSigningClient(); + } + return this.client.execute(sender, this.contractAddress, { remove_bond_provider: args }, fee || "auto", memo, funds); + }; + updateConfig = async (sender, args, fee, memo, funds) => { + if (!isSigningCosmWasmClient(this.client)) { + throw this.mustBeSigningClient(); + } + return this.client.execute(sender, this.contractAddress, { update_config: args }, fee || "auto", memo, funds); + }; + updateWithdrawnAmount = async (sender, args, fee, memo, funds) => { + if (!isSigningCosmWasmClient(this.client)) { + throw this.mustBeSigningClient(); + } + return this.client.execute(sender, this.contractAddress, { update_withdrawn_amount: args }, fee || "auto", memo, funds); + }; + peripheralHook = async (sender, args, fee, memo, funds) => { + if (!isSigningCosmWasmClient(this.client)) { + throw this.mustBeSigningClient(); + } + return this.client.execute(sender, this.contractAddress, { peripheral_hook: args }, fee || "auto", memo, funds); + }; + resetBondedAmount = async (sender, fee, memo, funds) => { + if (!isSigningCosmWasmClient(this.client)) { + throw this.mustBeSigningClient(); + } + return this.client.execute(sender, this.contractAddress, { reset_bonded_amount: {} }, fee || "auto", memo, funds); + }; + processEmergencyBatch = async (sender, args, fee, memo, funds) => { + if (!isSigningCosmWasmClient(this.client)) { + throw this.mustBeSigningClient(); + } + return this.client.execute(sender, this.contractAddress, { process_emergency_batch: args }, fee || "auto", memo, funds); + }; + setPause = async (sender, args, fee, memo, funds) => { + if (!isSigningCosmWasmClient(this.client)) { + throw this.mustBeSigningClient(); + } + return this.client.execute(sender, this.contractAddress, { set_pause: args }, fee || "auto", memo, funds); + }; + setBondHooks = async (sender, args, fee, memo, funds) => { + if (!isSigningCosmWasmClient(this.client)) { + throw this.mustBeSigningClient(); + } + return this.client.execute(sender, this.contractAddress, { set_bond_hooks: args }, fee || "auto", memo, funds); + }; + updateOwnership = async (sender, args, fee, memo, funds) => { + if (!isSigningCosmWasmClient(this.client)) { + throw this.mustBeSigningClient(); + } + return this.client.execute(sender, this.contractAddress, { update_ownership: args }, fee || "auto", memo, funds); + }; } exports.Client = Client; diff --git a/ts-client/src/contractLib/dropCore.ts b/ts-client/src/contractLib/dropCore.ts index 6a0b0f5b..47d7a38c 100644 --- a/ts-client/src/contractLib/dropCore.ts +++ b/ts-client/src/contractLib/dropCore.ts @@ -1,10 +1,5 @@ -import { - CosmWasmClient, - SigningCosmWasmClient, - ExecuteResult, - InstantiateResult, -} from '@cosmjs/cosmwasm-stargate'; -import { StdFee } from '@cosmjs/amino'; +import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult, InstantiateResult } from "@cosmjs/cosmwasm-stargate"; +import { StdFee } from "@cosmjs/amino"; export type ArrayOfString = string[]; /** * A human readable address. @@ -31,7 +26,7 @@ export type ArrayOfAddr = Addr[]; * let c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ``` */ export type Uint128 = string; -export type ContractState = 'idle' | 'peripheral' | 'claiming' | 'unbonding'; +export type ContractState = "idle" | "peripheral" | "claiming" | "unbonding"; /** * A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq. * @@ -167,12 +162,8 @@ export type Transaction = rewards_withdraw_address: string; }; }; -export type IBCTransferReason = 'l_s_m_share' | 'delegate'; +export type IBCTransferReason = "l_s_m_share" | "delegate"; export type String = string; -export type ArrayOfTupleOfStringAndTupleOfStringAndUint1281 = [ - string, - [string, Uint128], -][]; /** * A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq. * @@ -222,14 +213,14 @@ export type Uint1284 = string; */ export type Decimal1 = string; export type UnbondBatchStatus = - | 'new' - | 'unbond_requested' - | 'unbond_failed' - | 'unbonding' - | 'withdrawing' - | 'withdrawn' - | 'withdrawing_emergency' - | 'withdrawn_emergency'; + | "new" + | "unbond_requested" + | "unbond_failed" + | "unbonding" + | "withdrawing" + | "withdrawn" + | "withdrawing_emergency" + | "withdrawn_emergency"; /** * A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq. * @@ -259,8 +250,8 @@ export type UpdateOwnershipArgs = new_owner: string; }; } - | 'accept_ownership' - | 'renounce_ownership'; + | "accept_ownership" + | "renounce_ownership"; /** * Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future) */ @@ -299,7 +290,6 @@ export interface DropCoreSchema { | LastPuppeteerResponse | String | Pause - | ArrayOfTupleOfStringAndTupleOfStringAndUint1281 | Uint1282 | Uint1283 | Uint1284 @@ -414,9 +404,6 @@ export interface ResponseHookErrorMsg { request_id: number; transaction: Transaction; } -export interface LastStakerResponse { - response?: ResponseHookMsg | null; -} export interface Pause { bond: boolean; tick: boolean; @@ -507,8 +494,8 @@ export interface ProcessEmergencyBatchArgs { unbonded_amount: Uint128; } export interface SetPauseArgs { - type?: 'object'; - required?: ['bond', 'tick', 'unbond']; + type?: "object"; + required?: ["bond", "tick", "unbond"]; properties?: { [k: string]: unknown; }; @@ -538,8 +525,9 @@ export interface InstantiateMsg { withdrawal_voucher_contract: string; } + function isSigningCosmWasmClient( - client: CosmWasmClient | SigningCosmWasmClient, + client: CosmWasmClient | SigningCosmWasmClient ): client is SigningCosmWasmClient { return 'execute' in client; } @@ -547,15 +535,12 @@ function isSigningCosmWasmClient( export class Client { private readonly client: CosmWasmClient | SigningCosmWasmClient; contractAddress: string; - constructor( - client: CosmWasmClient | SigningCosmWasmClient, - contractAddress: string, - ) { + constructor(client: CosmWasmClient | SigningCosmWasmClient, contractAddress: string) { this.client = client; this.contractAddress = contractAddress; } mustBeSigningClient() { - return new Error('This client is not a SigningCosmWasmClient'); + return new Error("This client is not a SigningCosmWasmClient"); } static async instantiate( client: SigningCosmWasmClient, @@ -581,294 +566,106 @@ export class Client { fees: StdFee | 'auto' | number, initCoins?: readonly Coin[], ): Promise { - const res = await client.instantiate2( - sender, - codeId, - new Uint8Array([salt]), - initMsg, - label, - fees, - { - ...(initCoins && initCoins.length && { funds: initCoins }), - }, - ); + const res = await client.instantiate2(sender, codeId, new Uint8Array([salt]), initMsg, label, fees, { + ...(initCoins && initCoins.length && { funds: initCoins }), + }); return res; } - queryConfig = async (): Promise => { + queryConfig = async(): Promise => { return this.client.queryContractSmart(this.contractAddress, { config: {} }); - }; - queryOwner = async (): Promise => { + } + queryOwner = async(): Promise => { return this.client.queryContractSmart(this.contractAddress, { owner: {} }); - }; - queryExchangeRate = async (): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - exchange_rate: {}, - }); - }; - queryCurrentUnbondBatch = async (): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - current_unbond_batch: {}, - }); - }; - queryUnbondBatch = async (args: UnbondBatchArgs): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - unbond_batch: args, - }); - }; - queryUnbondBatches = async ( - args: UnbondBatchesArgs, - ): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - unbond_batches: args, - }); - }; - queryContractState = async (): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - contract_state: {}, - }); - }; - queryLastPuppeteerResponse = async (): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - last_puppeteer_response: {}, - }); - }; - queryTotalBonded = async (): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - total_bonded: {}, - }); - }; - queryBondProviders = async (): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - bond_providers: {}, - }); - }; - queryTotalLSMShares = async (): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - total_l_s_m_shares: {}, - }); - }; - queryTotalAsyncTokens = async (): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - total_async_tokens: {}, - }); - }; - queryFailedBatch = async (): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - failed_batch: {}, - }); - }; - queryPause = async (): Promise => { + } + queryExchangeRate = async(): Promise => { + return this.client.queryContractSmart(this.contractAddress, { exchange_rate: {} }); + } + queryCurrentUnbondBatch = async(): Promise => { + return this.client.queryContractSmart(this.contractAddress, { current_unbond_batch: {} }); + } + queryUnbondBatch = async(args: UnbondBatchArgs): Promise => { + return this.client.queryContractSmart(this.contractAddress, { unbond_batch: args }); + } + queryUnbondBatches = async(args: UnbondBatchesArgs): Promise => { + return this.client.queryContractSmart(this.contractAddress, { unbond_batches: args }); + } + queryContractState = async(): Promise => { + return this.client.queryContractSmart(this.contractAddress, { contract_state: {} }); + } + queryLastPuppeteerResponse = async(): Promise => { + return this.client.queryContractSmart(this.contractAddress, { last_puppeteer_response: {} }); + } + queryTotalBonded = async(): Promise => { + return this.client.queryContractSmart(this.contractAddress, { total_bonded: {} }); + } + queryBondProviders = async(): Promise => { + return this.client.queryContractSmart(this.contractAddress, { bond_providers: {} }); + } + queryTotalLSMShares = async(): Promise => { + return this.client.queryContractSmart(this.contractAddress, { total_l_s_m_shares: {} }); + } + queryTotalAsyncTokens = async(): Promise => { + return this.client.queryContractSmart(this.contractAddress, { total_async_tokens: {} }); + } + queryFailedBatch = async(): Promise => { + return this.client.queryContractSmart(this.contractAddress, { failed_batch: {} }); + } + queryPause = async(): Promise => { return this.client.queryContractSmart(this.contractAddress, { pause: {} }); - }; - queryBondHooks = async (): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - bond_hooks: {}, - }); - }; - bond = async ( - sender: string, - args: BondArgs, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ): Promise => { - if (!isSigningCosmWasmClient(this.client)) { - throw this.mustBeSigningClient(); - } - return this.client.execute( - sender, - this.contractAddress, - { bond: args }, - fee || 'auto', - memo, - funds, - ); - }; - unbond = async ( - sender: string, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ): Promise => { - if (!isSigningCosmWasmClient(this.client)) { - throw this.mustBeSigningClient(); - } - return this.client.execute( - sender, - this.contractAddress, - { unbond: {} }, - fee || 'auto', - memo, - funds, - ); - }; - tick = async ( - sender: string, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ): Promise => { - if (!isSigningCosmWasmClient(this.client)) { - throw this.mustBeSigningClient(); - } - return this.client.execute( - sender, - this.contractAddress, - { tick: {} }, - fee || 'auto', - memo, - funds, - ); - }; - updateConfig = async ( - sender: string, - args: UpdateConfigArgs, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ): Promise => { - if (!isSigningCosmWasmClient(this.client)) { - throw this.mustBeSigningClient(); - } - return this.client.execute( - sender, - this.contractAddress, - { update_config: args }, - fee || 'auto', - memo, - funds, - ); - }; - updateWithdrawnAmount = async ( - sender: string, - args: UpdateWithdrawnAmountArgs, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ): Promise => { - if (!isSigningCosmWasmClient(this.client)) { - throw this.mustBeSigningClient(); - } - return this.client.execute( - sender, - this.contractAddress, - { update_withdrawn_amount: args }, - fee || 'auto', - memo, - funds, - ); - }; - puppeteerHook = async ( - sender: string, - args: PuppeteerHookArgs, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ): Promise => { - if (!isSigningCosmWasmClient(this.client)) { - throw this.mustBeSigningClient(); - } - return this.client.execute( - sender, - this.contractAddress, - { peripheral_hook: args }, - fee || 'auto', - memo, - funds, - ); - }; - resetBondedAmount = async ( - sender: string, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ): Promise => { - if (!isSigningCosmWasmClient(this.client)) { - throw this.mustBeSigningClient(); - } - return this.client.execute( - sender, - this.contractAddress, - { reset_bonded_amount: {} }, - fee || 'auto', - memo, - funds, - ); - }; - processEmergencyBatch = async ( - sender: string, - args: ProcessEmergencyBatchArgs, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ): Promise => { - if (!isSigningCosmWasmClient(this.client)) { - throw this.mustBeSigningClient(); - } - return this.client.execute( - sender, - this.contractAddress, - { process_emergency_batch: args }, - fee || 'auto', - memo, - funds, - ); - }; - setPause = async ( - sender: string, - args: SetPauseArgs, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ): Promise => { - if (!isSigningCosmWasmClient(this.client)) { - throw this.mustBeSigningClient(); - } - return this.client.execute( - sender, - this.contractAddress, - { set_pause: args }, - fee || 'auto', - memo, - funds, - ); - }; - setBondHooks = async ( - sender: string, - args: SetBondHooksArgs, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ): Promise => { - if (!isSigningCosmWasmClient(this.client)) { - throw this.mustBeSigningClient(); - } - return this.client.execute( - sender, - this.contractAddress, - { set_bond_hooks: args }, - fee || 'auto', - memo, - funds, - ); - }; - updateOwnership = async ( - sender: string, - args: UpdateOwnershipArgs, - fee?: number | StdFee | 'auto', - memo?: string, - funds?: Coin[], - ): Promise => { - if (!isSigningCosmWasmClient(this.client)) { - throw this.mustBeSigningClient(); - } - return this.client.execute( - sender, - this.contractAddress, - { update_ownership: args }, - fee || 'auto', - memo, - funds, - ); - }; + } + queryBondHooks = async(): Promise => { + return this.client.queryContractSmart(this.contractAddress, { bond_hooks: {} }); + } + bond = async(sender:string, args: BondArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]): Promise => { + if (!isSigningCosmWasmClient(this.client)) { throw this.mustBeSigningClient(); } + return this.client.execute(sender, this.contractAddress, { bond: args }, fee || "auto", memo, funds); + } + unbond = async(sender: string, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]): Promise => { + if (!isSigningCosmWasmClient(this.client)) { throw this.mustBeSigningClient(); } + return this.client.execute(sender, this.contractAddress, { unbond: {} }, fee || "auto", memo, funds); + } + tick = async(sender: string, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]): Promise => { + if (!isSigningCosmWasmClient(this.client)) { throw this.mustBeSigningClient(); } + return this.client.execute(sender, this.contractAddress, { tick: {} }, fee || "auto", memo, funds); + } + addBondProvider = async(sender:string, args: AddBondProviderArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]): Promise => { + if (!isSigningCosmWasmClient(this.client)) { throw this.mustBeSigningClient(); } + return this.client.execute(sender, this.contractAddress, { add_bond_provider: args }, fee || "auto", memo, funds); + } + removeBondProvider = async(sender:string, args: RemoveBondProviderArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]): Promise => { + if (!isSigningCosmWasmClient(this.client)) { throw this.mustBeSigningClient(); } + return this.client.execute(sender, this.contractAddress, { remove_bond_provider: args }, fee || "auto", memo, funds); + } + updateConfig = async(sender:string, args: UpdateConfigArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]): Promise => { + if (!isSigningCosmWasmClient(this.client)) { throw this.mustBeSigningClient(); } + return this.client.execute(sender, this.contractAddress, { update_config: args }, fee || "auto", memo, funds); + } + updateWithdrawnAmount = async(sender:string, args: UpdateWithdrawnAmountArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]): Promise => { + if (!isSigningCosmWasmClient(this.client)) { throw this.mustBeSigningClient(); } + return this.client.execute(sender, this.contractAddress, { update_withdrawn_amount: args }, fee || "auto", memo, funds); + } + peripheralHook = async(sender:string, args: PeripheralHookArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]): Promise => { + if (!isSigningCosmWasmClient(this.client)) { throw this.mustBeSigningClient(); } + return this.client.execute(sender, this.contractAddress, { peripheral_hook: args }, fee || "auto", memo, funds); + } + resetBondedAmount = async(sender: string, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]): Promise => { + if (!isSigningCosmWasmClient(this.client)) { throw this.mustBeSigningClient(); } + return this.client.execute(sender, this.contractAddress, { reset_bonded_amount: {} }, fee || "auto", memo, funds); + } + processEmergencyBatch = async(sender:string, args: ProcessEmergencyBatchArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]): Promise => { + if (!isSigningCosmWasmClient(this.client)) { throw this.mustBeSigningClient(); } + return this.client.execute(sender, this.contractAddress, { process_emergency_batch: args }, fee || "auto", memo, funds); + } + setPause = async(sender:string, args: SetPauseArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]): Promise => { + if (!isSigningCosmWasmClient(this.client)) { throw this.mustBeSigningClient(); } + return this.client.execute(sender, this.contractAddress, { set_pause: args }, fee || "auto", memo, funds); + } + setBondHooks = async(sender:string, args: SetBondHooksArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]): Promise => { + if (!isSigningCosmWasmClient(this.client)) { throw this.mustBeSigningClient(); } + return this.client.execute(sender, this.contractAddress, { set_bond_hooks: args }, fee || "auto", memo, funds); + } + updateOwnership = async(sender:string, args: UpdateOwnershipArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]): Promise => { + if (!isSigningCosmWasmClient(this.client)) { throw this.mustBeSigningClient(); } + return this.client.execute(sender, this.contractAddress, { update_ownership: args }, fee || "auto", memo, funds); + } }