Skip to content

Commit

Permalink
fixes after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
albertandrejev committed Feb 9, 2024
1 parent 1efd62f commit 95a9d4c
Show file tree
Hide file tree
Showing 6 changed files with 316 additions and 51 deletions.
2 changes: 1 addition & 1 deletion contracts/factory/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ fn execute_init(
}),
CosmosMsg::Wasm(WasmMsg::Instantiate2 {
admin: Some(env.contract.address.to_string()),
code_id: config.rewards_manager_code_id,
code_id: config.code_ids.rewards_manager_code_id,
label: get_contract_label("rewards manager"),
msg: to_json_binary(&RewardsMangerInstantiateMsg {
core_address: core_contract.to_string(),
Expand Down
62 changes: 34 additions & 28 deletions integration_tests/src/generated/contractLib/index.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,47 @@
import * as _0 from './lidoCore';
export const LidoCore = _0;
import * as _0 from './lidoAstroportExchangeHandler';
export const LidoAstroportExchangeHandler = _0;

import * as _1 from './lidoDistribution';
export const LidoDistribution = _1;
import * as _1 from './lidoCore';
export const LidoCore = _1;

import * as _2 from './lidoFactory';
export const LidoFactory = _2;
import * as _2 from './lidoDistribution';
export const LidoDistribution = _2;

import * as _3 from './lidoHookTester';
export const LidoHookTester = _3;
import * as _3 from './lidoFactory';
export const LidoFactory = _3;

import * as _4 from './lidoPump';
export const LidoPump = _4;
import * as _4 from './lidoHookTester';
export const LidoHookTester = _4;

import * as _5 from './lidoPuppeteerAuthz';
export const LidoPuppeteerAuthz = _5;
import * as _5 from './lidoPump';
export const LidoPump = _5;

import * as _6 from './lidoPuppeteer';
export const LidoPuppeteer = _6;
import * as _6 from './lidoPuppeteerAuthz';
export const LidoPuppeteerAuthz = _6;

import * as _7 from './lidoStargatePoc';
export const LidoStargatePoc = _7;
import * as _7 from './lidoPuppeteer';
export const LidoPuppeteer = _7;

import * as _8 from './lidoStrategy';
export const LidoStrategy = _8;
import * as _8 from './lidoRewardsManager';
export const LidoRewardsManager = _8;

import * as _9 from './lidoToken';
export const LidoToken = _9;
import * as _9 from './lidoStargatePoc';
export const LidoStargatePoc = _9;

import * as _10 from './lidoValidatorsSet';
export const LidoValidatorsSet = _10;
import * as _10 from './lidoStrategy';
export const LidoStrategy = _10;

import * as _11 from './lidoValidatorsStats';
export const LidoValidatorsStats = _11;
import * as _11 from './lidoToken';
export const LidoToken = _11;

import * as _12 from './lidoWithdrawalManager';
export const LidoWithdrawalManager = _12;
import * as _12 from './lidoValidatorsSet';
export const LidoValidatorsSet = _12;

import * as _13 from './lidoWithdrawalVoucher';
export const LidoWithdrawalVoucher = _13;
import * as _13 from './lidoValidatorsStats';
export const LidoValidatorsStats = _13;

import * as _14 from './lidoWithdrawalManager';
export const LidoWithdrawalManager = _14;

import * as _15 from './lidoWithdrawalVoucher';
export const LidoWithdrawalVoucher = _15;
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult, InstantiateResult } from "@cosmjs/cosmwasm-stargate";
import { StdFee } from "@cosmjs/amino";
import { Coin } from "@cosmjs/amino";
/**
* 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.
*
* # Examples
*
* Use `from` to create instances of this and `u128` to get the value out:
*
* ``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);
*
* let b = Uint128::from(42u64); assert_eq!(b.u128(), 42);
*
* let c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```
*/
export type Uint128 = string;

export interface InstantiateMsg {
core_contract: string;
cron_address: string;
from_denom: string;
min_rewards: Uint128;
owner: string;
pair_contract: string;
router_contract: string;
}
/**
* 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.
*
* # Examples
*
* Use `from` to create instances of this and `u128` to get the value out:
*
* ``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);
*
* let b = Uint128::from(42u64); assert_eq!(b.u128(), 42);
*
* let c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```
*/
export type Uint128 = string;
/**
* This enum describes a swap operation.
*/
export type SwapOperation =
| {
native_swap: {
/**
* The name (denomination) of the native asset to swap to
*/
ask_denom: string;
/**
* The name (denomination) of the native asset to swap from
*/
offer_denom: string;
};
}
| {
astro_swap: {
/**
* Information about the asset we swap to
*/
ask_asset_info: AssetInfo;
/**
* Information about the asset being swapped
*/
offer_asset_info: AssetInfo;
};
};
/**
* This enum describes available Token types. ## Examples ``` # use cosmwasm_std::Addr; # use astroport::asset::AssetInfo::{NativeToken, Token}; Token { contract_addr: Addr::unchecked("stake...") }; NativeToken { denom: String::from("uluna") }; ```
*/
export type AssetInfo =
| {
token: {
contract_addr: Addr;
};
}
| {
native_token: {
denom: string;
};
};
/**
* A human readable address.
*
* In Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.
*
* This type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.
*
* This type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.
*/
export type Addr = string;

export interface LidoAstroportExchangeHandlerSchema {
responses: ConfigResponse;
execute: UpdateConfigArgs | UpdateSwapOperationsArgs;
[k: string]: unknown;
}
export interface ConfigResponse {
core_contract: string;
cron_address: string;
from_denom: string;
min_rewards: Uint128;
owner: string;
pair_contract: string;
router_contract: string;
swap_operations?: SwapOperation[] | null;
}
export interface UpdateConfigArgs {
core_contract?: string | null;
cron_address?: string | null;
from_denom?: string | null;
min_rewards?: Uint128 | null;
owner?: string | null;
pair_contract?: string | null;
router_contract?: string | null;
}
export interface UpdateSwapOperationsArgs {
operations?: SwapOperation[] | null;
}


function isSigningCosmWasmClient(
client: CosmWasmClient | SigningCosmWasmClient
): client is SigningCosmWasmClient {
return 'execute' in client;
}

export class Client {
private readonly 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");
}
static async instantiate(
client: SigningCosmWasmClient,
sender: string,
codeId: number,
initMsg: InstantiateMsg,
label: string,
initCoins?: readonly Coin[],
fees?: StdFee | 'auto' | number,
): Promise<InstantiateResult> {
const res = await client.instantiate(sender, codeId, initMsg, label, fees, {
...(initCoins && initCoins.length && { funds: initCoins }),
});
return res;
}
queryConfig = async(): Promise<ConfigResponse> => {
return this.client.queryContractSmart(this.contractAddress, { config: {} });
}
updateConfig = async(sender:string, args: UpdateConfigArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]): Promise<ExecuteResult> => {
if (!isSigningCosmWasmClient(this.client)) { throw this.mustBeSigningClient(); }
return this.client.execute(sender, this.contractAddress, { update_config: args }, fee || "auto", memo, funds);
}
updateSwapOperations = async(sender:string, args: UpdateSwapOperationsArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]): Promise<ExecuteResult> => {
if (!isSigningCosmWasmClient(this.client)) { throw this.mustBeSigningClient(); }
return this.client.execute(sender, this.contractAddress, { update_swap_operations: args }, fee || "auto", memo, funds);
}
exchange = async(sender: string, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]): Promise<ExecuteResult> => {
if (!isSigningCosmWasmClient(this.client)) { throw this.mustBeSigningClient(); }
return this.client.execute(sender, this.contractAddress, { exchange: {} }, fee || "auto", memo, funds);
}
}
2 changes: 2 additions & 0 deletions integration_tests/src/generated/contractLib/lidoFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface CodeIds {
core_code_id: number;
distribution_code_id: number;
puppeteer_code_id: number;
rewards_manager_code_id: number;
strategy_code_id: number;
token_code_id: number;
validators_set_code_id: number;
Expand Down Expand Up @@ -85,6 +86,7 @@ export interface State {
core_contract: string;
distribution_contract: string;
puppeteer_contract: string;
rewards_manager_contract: string;
strategy_contract: string;
token_contract: string;
validators_set_contract: string;
Expand Down
96 changes: 96 additions & 0 deletions integration_tests/src/generated/contractLib/lidoRewardsManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult, InstantiateResult } from "@cosmjs/cosmwasm-stargate";
import { StdFee } from "@cosmjs/amino";
import { Coin } from "@cosmjs/amino";
export interface InstantiateMsg {
core_address: string;
}
/**
* 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.
*
* # Examples
*
* Use `from` to create instances of this and `u128` to get the value out:
*
* ``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);
*
* let b = Uint128::from(42u64); assert_eq!(b.u128(), 42);
*
* let c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```
*/
export type Uint128 = string;

export interface LidoRewardsManagerSchema {
responses: ConfigResponse;
execute: UpdateConfigArgs | AddHandlerArgs | RemoveHandlerArgs;
[k: string]: unknown;
}
export interface ConfigResponse {
core_address: string;
handlers: HandlerConfig[];
}
export interface HandlerConfig {
address: string;
denom: string;
min_rewards: Uint128;
}
export interface UpdateConfigArgs {
core_address?: string | null;
}
export interface AddHandlerArgs {
config: HandlerConfig;
}
export interface RemoveHandlerArgs {
denom: string;
}


function isSigningCosmWasmClient(
client: CosmWasmClient | SigningCosmWasmClient
): client is SigningCosmWasmClient {
return 'execute' in client;
}

export class Client {
private readonly 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");
}
static async instantiate(
client: SigningCosmWasmClient,
sender: string,
codeId: number,
initMsg: InstantiateMsg,
label: string,
initCoins?: readonly Coin[],
fees?: StdFee | 'auto' | number,
): Promise<InstantiateResult> {
const res = await client.instantiate(sender, codeId, initMsg, label, fees, {
...(initCoins && initCoins.length && { funds: initCoins }),
});
return res;
}
queryConfig = async(): Promise<ConfigResponse> => {
return this.client.queryContractSmart(this.contractAddress, { config: {} });
}
updateConfig = async(sender:string, args: UpdateConfigArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]): Promise<ExecuteResult> => {
if (!isSigningCosmWasmClient(this.client)) { throw this.mustBeSigningClient(); }
return this.client.execute(sender, this.contractAddress, { update_config: args }, fee || "auto", memo, funds);
}
addHandler = async(sender:string, args: AddHandlerArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]): Promise<ExecuteResult> => {
if (!isSigningCosmWasmClient(this.client)) { throw this.mustBeSigningClient(); }
return this.client.execute(sender, this.contractAddress, { add_handler: args }, fee || "auto", memo, funds);
}
removeHandler = async(sender:string, args: RemoveHandlerArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]): Promise<ExecuteResult> => {
if (!isSigningCosmWasmClient(this.client)) { throw this.mustBeSigningClient(); }
return this.client.execute(sender, this.contractAddress, { remove_handler: args }, fee || "auto", memo, funds);
}
exchangeRewards = async(sender: string, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]): Promise<ExecuteResult> => {
if (!isSigningCosmWasmClient(this.client)) { throw this.mustBeSigningClient(); }
return this.client.execute(sender, this.contractAddress, { exchange_rewards: {} }, fee || "auto", memo, funds);
}
}
Loading

0 comments on commit 95a9d4c

Please sign in to comment.