Skip to content

Commit

Permalink
First bond
Browse files Browse the repository at this point in the history
  • Loading branch information
faust403 committed Dec 11, 2024
1 parent 28260c3 commit 1ec26de
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions contracts/lazy-staking/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
)?),
QueryMsg::ExchangeRate {} => Ok(to_json_binary(&query_exchange_rate(deps, env)?)?),
QueryMsg::Rewards {} => Ok(to_json_binary(&query_rewards(deps, env)?)?),
QueryMsg::Denom {} => Ok(to_json_binary(&DENOM.load(deps.storage)?)?),
}
}

Expand Down
2 changes: 2 additions & 0 deletions contracts/lazy-staking/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pub enum QueryMsg {
ExchangeRate {},
#[returns(cosmwasm_std::Decimal)]
Rewards {},
#[returns(String)]
Denom {},
}

#[cw_ownable::cw_ownable_execute]
Expand Down
17 changes: 16 additions & 1 deletion integration_tests/src/testcases/lazy-staking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('Lazy Staking', () => {
factoryContractClient?: InstanceType<typeof DropTemplateFactoryClient>;

dntrnDenom?: string;
ldntrnDenom?: string;
} = {};

beforeAll(async (t) => {
Expand Down Expand Up @@ -171,7 +172,7 @@ describe('Lazy Staking', () => {
);
context.dntrnDenom = await context.tokenContractClient.queryDenom();
await context.tokenContractClient.mint(account.address, {
amount: '1000000',
amount: '1000000000',
});
}
{
Expand Down Expand Up @@ -213,6 +214,20 @@ describe('Lazy Staking', () => {
client,
contractAddress,
);
context.ldntrnDenom = await context.lazyStakingClient.queryDenom();
}
});

it('Send 10 dNTRN and get 10 ldNTRN back', async () => {
const { lazyStakingClient, client, account, dntrnDenom, ldntrnDenom } =
context;
await lazyStakingClient.bond(account.address, undefined, undefined, [
{
denom: dntrnDenom,
amount: '10000000',
},
]);
const { amount } = await client.getBalance(account.address, ldntrnDenom);
expect(amount).toEqual('10000000');
});
});
4 changes: 3 additions & 1 deletion ts-client/lib/contractLib/dropLazyStaking.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult, InstantiateResult } from "@cosmjs/cosmwasm-stargate";
import { StdFee } from "@cosmjs/amino";
import { Coin } from "@cosmjs/amino";
export type String = string;
/**
* A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0
*
Expand Down Expand Up @@ -57,7 +58,7 @@ export type UpdateOwnershipArgs = {
};
} | "accept_ownership" | "renounce_ownership";
export interface DropLazyStakingSchema {
responses: Decimal | OwnershipForString | Decimal1;
responses: String | Decimal | OwnershipForString | Decimal1;
execute: UpdateOwnershipArgs;
instantiate?: InstantiateMsg;
[k: string]: unknown;
Expand Down Expand Up @@ -122,6 +123,7 @@ export declare class Client {
static instantiate2(client: SigningCosmWasmClient, sender: string, codeId: number, salt: number, initMsg: InstantiateMsg, label: string, fees: StdFee | 'auto' | number, initCoins?: readonly Coin[]): Promise<InstantiateResult>;
queryExchangeRate: () => Promise<Decimal>;
queryRewards: () => Promise<Decimal>;
queryDenom: () => Promise<String>;
queryOwnership: () => Promise<OwnershipForString>;
bond: (sender: string, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise<ExecuteResult>;
unbond: (sender: string, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise<ExecuteResult>;
Expand Down
3 changes: 3 additions & 0 deletions ts-client/lib/contractLib/dropLazyStaking.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class Client {
queryRewards = async () => {
return this.client.queryContractSmart(this.contractAddress, { rewards: {} });
};
queryDenom = async () => {
return this.client.queryContractSmart(this.contractAddress, { denom: {} });
};
queryOwnership = async () => {
return this.client.queryContractSmart(this.contractAddress, { ownership: {} });
};
Expand Down
6 changes: 5 additions & 1 deletion ts-client/src/contractLib/dropLazyStaking.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult, InstantiateResult } from "@cosmjs/cosmwasm-stargate";
import { StdFee } from "@cosmjs/amino";
import { Coin } from "@cosmjs/amino";
export type String = string;
/**
* A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0
*
Expand Down Expand Up @@ -64,7 +65,7 @@ export type UpdateOwnershipArgs =
| "renounce_ownership";

export interface DropLazyStakingSchema {
responses: Decimal | OwnershipForString | Decimal1;
responses: String | Decimal | OwnershipForString | Decimal1;
execute: UpdateOwnershipArgs;
instantiate?: InstantiateMsg;
[k: string]: unknown;
Expand Down Expand Up @@ -173,6 +174,9 @@ export class Client {
queryRewards = async(): Promise<Decimal> => {
return this.client.queryContractSmart(this.contractAddress, { rewards: {} });
}
queryDenom = async(): Promise<String> => {
return this.client.queryContractSmart(this.contractAddress, { denom: {} });
}
queryOwnership = async(): Promise<OwnershipForString> => {
return this.client.queryContractSmart(this.contractAddress, { ownership: {} });
}
Expand Down

0 comments on commit 1ec26de

Please sign in to comment.