Skip to content

Commit

Permalink
add checks
Browse files Browse the repository at this point in the history
  • Loading branch information
NeverHappened committed Oct 6, 2023
1 parent 59f073c commit 00aaaa7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 15 deletions.
9 changes: 5 additions & 4 deletions src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use cosmos_sdk_proto::cosmos::distribution::v1beta1::MsgFundCommunityPool;
use cosmwasm_std::entry_point;
use cosmwasm_std::{
to_binary, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult,
SubMsg, WasmMsg,
WasmMsg,
};
use cw2::set_contract_version;
use prost::Message;
Expand Down Expand Up @@ -32,7 +32,7 @@ const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");
const DEFAULT_TIMEOUT_HEIGHT: u64 = 10000000;
const NEUTRON_DENOM: &str = "untrn";

const SEND_TOKENS_TO_COMMUNITY_POOL_ID: u64 = 1;
// const SEND_TOKENS_TO_COMMUNITY_POOL_ID: u64 = 1;

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
Expand Down Expand Up @@ -196,10 +196,11 @@ fn execute_fund_community_pool(
fee, // TODO: check
);

let submsg = SubMsg::reply_on_success(cosmos_msg, SEND_TOKENS_TO_COMMUNITY_POOL_ID);
// let submsg = SubMsg::reply_on_success(cosmos_msg, SEND_TOKENS_TO_COMMUNITY_POOL_ID);
// todo: reply handler? don't know if needed

Ok(Response::default().add_submessage(submsg))
// Ok(Response::default().add_submessage(submsg))
Ok(Response::default().add_message(cosmos_msg))
}

fn execute_done() -> NeutronResult<Response<NeutronMsg>> {
Expand Down
44 changes: 33 additions & 11 deletions test/src/airdrop_test_sequence.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate';
import { AccountData, DirectSecp256k1HdWallet } from '@cosmjs/proto-signing';
import { SigningStargateClient } from '@cosmjs/stargate';
import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing';
import { Decimal } from "@cosmjs/math";
import fs from 'fs';
import {coin} from "@cosmjs/amino/build/coins";

const delay = ms => new Promise(res => setTimeout(res, ms));

export async function AirdropTest(walletMnemonic: string): Promise<void> {
// prepare...
const wallet: DirectSecp256k1HdWallet = await DirectSecp256k1HdWallet.fromMnemonic(walletMnemonic, {
Expand Down Expand Up @@ -108,40 +109,61 @@ export async function AirdropTest(walletMnemonic: string): Promise<void> {






console.log('Sending money to the credits (mint)')
console.log('Prestep - Sending money to the credits (mint)')
const sendmoneyres = await cosmwasm.execute(instantiator, creditsAddress, {
mint: {}
}, 'auto', 'mint in credits', [coin(9000, "untrn")])
console.log('sendmoneyres ' + JSON.stringify(sendmoneyres));




console.log('Step 1 - claiming money from airdrop -> credits -> airdrop -> reserve_address (claimerAddress)')
const claimmoneyres = await cosmwasm.execute(instantiator, claimerAddress, {
"claim_unclaimed": {},
}, 'auto', 'mint in credits', [])
console.log('claimmoneyres ' + JSON.stringify(claimmoneyres));

await delay(1000);

console.log('Step 1 check')
const balance = await cosmwasm.getBalance(claimerAddress, 'untrn')
console.log('Balance of claimer account (should be 9000): ' + JSON.stringify(balance))

console.log('Step 2 - create hub ica')
const createhubicares = await cosmwasm.execute(instantiator, claimerAddress, {
"create_hub_ica": {},
create_hub_ica: {},
}, 'auto', 'create hub ica', [])
console.log('createhubicares ' + JSON.stringify(createhubicares));
console.log('createhubicares ' + JSON.stringify(createhubicares))

await delay(30000);

console.log('Step 2 check')
// todo: wait for response? relayer one
const icaResponse = await cosmwasm.queryContractSmart(claimerAddress, { interchain_account: {} })
console.log('ICA address: ' + icaResponse)

console.log('Step 3 - send claimed tokens to ica')
const sendtokenstoicares = await cosmwasm.execute(instantiator, claimerAddress, {
"send_claimed_tokens_to_ica": {},
send_claimed_tokens_to_ica: {},
}, 'auto', 'send tokens to ica', [])
console.log('sendtokenstoicares ' + JSON.stringify(sendtokenstoicares));

await delay(30000);

console.log('Step 3 check')
const balanceAfter = await cosmwasm.getBalance(claimerAddress, 'untrn')
console.log('Balance of claimer account (should be 0): ' + JSON.stringify(balanceAfter))
console.log('Stage: ' + await cosmwasm.queryContractSmart(claimerAddress, { stage: {} }))


console.log('Step 4 - fund community pool')
const fundcommunitypoolres = await cosmwasm.execute(instantiator, claimerAddress, {
"fund_community_pool": {},
fund_community_pool: {},
}, 'auto', 'fund community pool', [])
console.log('fundcommunitypoolres ' + JSON.stringify(fundcommunitypoolres));
console.log('fundcommunitypoolres ' + JSON.stringify(fundcommunitypoolres))

console.log('Step 4 check')
console.log('ICA address: ' + await cosmwasm.queryContractSmart(claimerAddress, { transfer_amount: {} }))
console.log('Stage: ' + await cosmwasm.queryContractSmart(claimerAddress, { stage: {} }))
}

0 comments on commit 00aaaa7

Please sign in to comment.