diff --git a/package.json b/package.json index b1d32728..cfcd20fa 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "test": "yarn test:parallel && yarn test:run_in_band", "test:parallel": "vitest --run src/testcases/parallel --bail 1 --reporter=basic", - "test:run_in_band": "yarn test:feemarket && yarn test:globalfee && yarn test:interchaintx && yarn test:interchain_kv_query && yarn test:interchain_tx_query_plain && yarn test:tokenomics && yarn test:reserve && yarn test:ibc_hooks && yarn test:float && yarn test:parameters && yarn test:slinky && yarn test:chain_manager && yarn test:tokenfactory && yarn test:cron && yarn test:dex_grpc && yarn test:dex_bindings", + "test:run_in_band": "yarn test:feemarket && yarn test:globalfee && yarn test:interchaintx && yarn test:interchain_kv_query && yarn test:interchain_tx_query_plain && yarn test:tokenomics && yarn test:reserve && yarn test:ibc_hooks && yarn test:float && yarn test:parameters && yarn test:slinky && yarn test:chain_manager && yarn test:tokenfactory && yarn test:cron && yarn test:dex_grpc", "test:ibc_transfer": "vitest --run src/testcases/parallel/ibc_transfer --bail 1", "test:slinky": "vitest --run src/testcases/run_in_band/slinky --bail 1", "test:cron": "vitest --run src/testcases/run_in_band/cron --bail 1", @@ -28,7 +28,6 @@ "test:voting_registry": "vitest --run src/testcases/parallel/voting_registry --bail 1", "test:float": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 vitest --run src/testcases/run_in_band/float --bail 1", "test:dex_grpc": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 vitest --run src/testcases/run_in_band/dex_grpc --bail 1", - "test:dex_bindings": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 vitest --run src/testcases/run_in_band/dex_bindings --bail 1", "test:chain_manager": "vitest --run src/testcases/run_in_band/chain_manager --bail 1", "test:feemarket": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 vitest --run src/testcases/run_in_band/feemarket --bail 1", "test:ibc_rate_limit": "vitest --run src/testcases/run_in_band/ibc_rate_limit --bail 1", diff --git a/src/helpers/constants.ts b/src/helpers/constants.ts index 1648bcd4..d9eba9a9 100644 --- a/src/helpers/constants.ts +++ b/src/helpers/constants.ts @@ -58,7 +58,6 @@ export const CONTRACTS = { // https://github.com/CosmWasm/cosmwasm/tree/main/contracts/floaty FLOATY: '../contracts_thirdparty/floaty_2.0.wasm', DEX_GRPC: 'dex_grpc.wasm', - DEX_DEV: 'dex.wasm', CRON: 'cron.wasm', // TGE liquidity migration related contracts with fixed versions diff --git a/src/helpers/interchainqueries.ts b/src/helpers/interchainqueries.ts index 1d0c5f2b..51bc596f 100644 --- a/src/helpers/interchainqueries.ts +++ b/src/helpers/interchainqueries.ts @@ -511,26 +511,24 @@ export const getRegisteredQuery = async ( contractAddress: string, queryId: number, ): Promise<{ - registered_query: { - id: number; - owner: string; - keys: { - path: string; - key: string; - }[]; - query_type: string; - transactions_filter: string; - connection_id: string; - update_period: number; - last_submitted_result_local_height: number; - last_submitted_result_remote_height: { - revision_number: number; - revision_height: number; - }; - deposit: { denom: string; amount: string }[]; - submit_timeout: number; - registered_at_height: number; + id: number; + owner: string; + keys: { + path: string; + key: string; + }[]; + query_type: string; + transactions_filter: string; + connection_id: string; + update_period: number; + last_submitted_result_local_height: number; + last_submitted_result_remote_height: { + revision_number: number; + revision_height: number; }; + deposit: { denom: string; amount: string }[]; + submit_timeout: number; + registered_at_height: number; }> => client.queryContractSmart(contractAddress, { get_registered_query: { @@ -549,8 +547,8 @@ export const waitForICQResultWithRemoteHeight = ( client, () => getRegisteredQuery(client, contractAddress, queryId), async (query) => - query.registered_query.last_submitted_result_remote_height - .revision_height >= targetHeight, + +query.last_submitted_result_remote_height.revision_height >= + targetHeight, numAttempts, ); @@ -581,7 +579,7 @@ export const waitForTransfersAmount = ( client, async () => (await queryTransfersNumber(client, contractAddress)).transfers_number, - async (amount) => amount == expectedTransfersAmount, + async (amount) => amount.toString() == expectedTransfersAmount.toString(), numAttempts, ); diff --git a/src/testcases/parallel/interchain_tx_query_resubmit.test.ts b/src/testcases/parallel/interchain_tx_query_resubmit.test.ts index 528f1b7b..b1ae758d 100644 --- a/src/testcases/parallel/interchain_tx_query_resubmit.test.ts +++ b/src/testcases/parallel/interchain_tx_query_resubmit.test.ts @@ -93,17 +93,17 @@ describe('Neutron / Interchain TX Query Resubmit', () => { test('check registered transfers query', async () => { const query = await getRegisteredQuery(neutronClient, contractAddress, 1); - expect(query.registered_query.id).toEqual(1); - expect(query.registered_query.owner).toEqual(contractAddress); - expect(query.registered_query.keys.length).toEqual(0); - expect(query.registered_query.query_type).toEqual('tx'); - expect(query.registered_query.transactions_filter).toEqual( + expect(query.id).toEqual('1'); + expect(query.owner).toEqual(contractAddress); + expect(query.keys.length).toEqual(0); + expect(query.query_type).toEqual('tx'); + expect(query.transactions_filter).toEqual( '[{"field":"transfer.recipient","op":"Eq","value":"' + watchedAddr1 + '"}]', ); - expect(query.registered_query.connection_id).toEqual(connectionId); - expect(query.registered_query.update_period).toEqual(query1UpdatePeriod); + expect(query.connection_id).toEqual(connectionId); + expect(query.update_period).toEqual(query1UpdatePeriod.toString()); }); test('check failed txs', async () => { diff --git a/src/testcases/run_in_band/dex_bindings.test.ts b/src/testcases/run_in_band/dex_bindings.test.ts deleted file mode 100644 index 55eb055c..00000000 --- a/src/testcases/run_in_band/dex_bindings.test.ts +++ /dev/null @@ -1,658 +0,0 @@ -import { inject } from 'vitest'; -import { NEUTRON_DENOM } from '@neutron-org/neutronjsplus/dist/constants'; -import { LocalState } from '../../helpers/local_state'; -import { - MsgCreateDenom, - MsgMint, -} from '@neutron-org/neutronjs/osmosis/tokenfactory/v1beta1/tx'; -import { SigningNeutronClient } from '../../helpers/signing_neutron_client'; -import { Wallet } from '../../helpers/wallet'; -import { CONTRACTS } from '../../helpers/constants'; -import { - getEventAttribute, - getEventAttributesFromTx, -} from '@neutron-org/neutronjsplus/dist/cosmos'; -import config from '../../config.json'; - -describe('Neutron / dex module bindings', () => { - let testState: LocalState; - let neutronClient: SigningNeutronClient; - let neutronWallet: Wallet; - let contractAddress: string; - let activeTrancheKey: string; - let inactiveTrancheKey: string; - const multiHopSwapDenoms: any[] = []; - - beforeAll(async () => { - testState = await LocalState.create(config, inject('mnemonics')); - neutronWallet = testState.wallets.neutron.demo1; - neutronClient = await SigningNeutronClient.connectWithSigner( - testState.rpcNeutron, - neutronWallet.directwallet, - neutronWallet.address, - ); - }); - - describe('Instantiate dex binding contract', () => { - test('instantiate contract', async () => { - contractAddress = await neutronClient.create(CONTRACTS.DEX_DEV, {}); - }); - test('send funds', async () => { - await neutronClient.sendTokens( - contractAddress, - [{ denom: NEUTRON_DENOM, amount: '100000000' }], - { - gas: '200000', - amount: [{ denom: NEUTRON_DENOM, amount: '1000' }], - }, - ); - - await neutronClient.sendTokens( - contractAddress, - [{ denom: 'uibcusdc', amount: '100000000' }], - { - gas: '200000', - amount: [{ denom: NEUTRON_DENOM, amount: '1000' }], - }, - ); - }); - }); - - describe('DEX messages', () => { - describe('Deposit', () => { - test('Invalid pair', async () => { - await expect( - neutronClient.execute(contractAddress, { - deposit: { - receiver: contractAddress, - token_a: 'untrn', - token_b: 'untrn', - amounts_a: ['100'], // uint128 - amounts_b: ['100'], // uint128 - tick_indexes_a_to_b: [1], // i64 - fees: [0], // u64 - options: [ - { - disable_autoswap: true, - fail_tx_on_bel: false, - }, - ], - }, - }), - ).rejects.toThrowError( - /failed to execute \*types.MsgDeposit: failed to validate MsgDeposit: tokenA cannot equal tokenB: Invalid token denom/, - ); - }); - test('Valid pair', async () => { - // pool denom - 'neutron/pool/0' - const res = await neutronClient.execute(contractAddress, { - deposit: { - receiver: contractAddress, - token_a: 'untrn', - token_b: 'uibcusdc', - amounts_a: ['1000'], // uint128 - amounts_b: ['1000'], // uint128 - tick_indexes_a_to_b: [1], // i64 - fees: [0], // u64 - options: [ - { - disable_autoswap: true, - fail_tx_on_bel: false, - }, - ], - }, - }); - expect(res.code).toEqual(0); - }); - }); - describe('Withdrawal', () => { - test('valid', async () => { - // pool denom - 'neutron/pool/0' - const res = await neutronClient.execute(contractAddress, { - withdrawal: { - receiver: contractAddress, - token_a: 'untrn', - token_b: 'uibcusdc', - shares_to_remove: ['10'], // uint128 - tick_indexes_a_to_b: [1], // i64 - fees: [0], // u64 - }, - }); - expect(res.code).toEqual(0); - }); - }); - describe('LimitOrder', () => { - test('GOOD_TIL_CANCELLED', async () => { - // Place order deep in orderbook. Doesn't change existing liquidity - const res = await neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - tick_index_in_to_out: 0, - limit_sell_price: '1.221390545', - amount_in: '1000000', - order_type: 'GOOD_TIL_CANCELLED', - }, - }); - expect(res.code).toEqual(0); - }); - test('FILL_OR_KILL', async () => { - // Trades through some of LP position at tick 1 - const res = await neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - limit_sell_price: '0.74', - tick_index_in_to_out: 0, - amount_in: '100', - order_type: 'FILL_OR_KILL', - max_amount_out: '100', - }, - }); - expect(res.code).toEqual(0); - }); - test('IMMEDIATE_OR_CANCEL', async () => { - // Trades through remainder of LP position at tick 1 - const res = await neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - tick_index_in_to_out: 0, - limit_sell_price: '0.98', - amount_in: '1000000', - order_type: 'IMMEDIATE_OR_CANCEL', - }, - }); - expect(res.code).toEqual(0); - }); - test('JUST_IN_TIME', async () => { - // Place JIT deep in orderbook - const res = await neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - tick_index_in_to_out: 0, - limit_sell_price: '7.38', - amount_in: '1000000', - order_type: 'JUST_IN_TIME', - }, - }); - expect(res.code).toEqual(0); - }); - test('GOOD_TIL_TIME', async () => { - const res = await neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - tick_index_in_to_out: 0, - limit_sell_price: '1.002', - amount_in: '10000000', - expiration_time: Math.ceil(Date.now() / 1000) + 1000, - order_type: 'GOOD_TIL_TIME', - }, - }); - expect(res.code).toEqual(0); - }); - test('GOOD_TIL_TIME expired', async () => { - await expect( - neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - tick_index_in_to_out: 0, - limit_sell_price: '0.998', - amount_in: '10000000', - expiration_time: 1, - order_type: 'GOOD_TIL_TIME', - }, - }), - ).rejects.toThrowError( - /Limit order expiration time must be greater than current block time/, - ); - }); - test('unknown order type', async () => { - await expect( - neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - tick_index_in_to_out: 0, - limit_sell_price: '1.0001', - amount_in: '10', - expiration_time: 1, - order_type: 'unknown', - }, - }), - ).rejects.toThrowError( - /unknown variant `unknown`, expected one of `GOOD_TIL_CANCELLED`, `FILL_OR_KILL`, `IMMEDIATE_OR_CANCEL`, `JUST_IN_TIME`, `GOOD_TIL_TIME`/, - ); - }); - test('limit_sell_price scientific notation', async () => { - const res = await neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - tick_index_in_to_out: 0, - limit_sell_price: '1.4564654E-4', - amount_in: '100000', - order_type: 'GOOD_TIL_CANCELLED', - }, - }); - expect(res.code).toEqual(0); - }); - }); - describe('Withdraw filled LO', () => { - test('Withdraw', async () => { - // place GTC LO at top of orderbook - const res1 = await neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - tick_index_in_to_out: 0, - limit_sell_price: '0.8188125757', - amount_in: '1000000', - order_type: 'GOOD_TIL_CANCELLED', - }, - }); - expect(res1.code).toEqual(0); - activeTrancheKey = getEventAttributesFromTx( - { tx_response: res1 }, - 'TickUpdate', - ['TrancheKey'], - )[0]['TrancheKey']; - // Trade through some of the GTC order - const res2 = await neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'uibcusdc', - token_out: 'untrn', - tick_index_in_to_out: 0, - limit_sell_price: '1.1', - amount_in: '1000', - order_type: 'IMMEDIATE_OR_CANCEL', - }, - }); - expect(res2.code).toEqual(0); - - const res3 = await neutronClient.execute(contractAddress, { - withdraw_filled_limit_order: { - tranche_key: activeTrancheKey, - }, - }); - expect(res3.code).toEqual(0); - }); - }); - describe('cancel LO', () => { - test('success', async () => { - // Cancel the limit order created above - const res = await neutronClient.execute(contractAddress, { - cancel_limit_order: { - tranche_key: activeTrancheKey, - }, - }); - expect(res.code).toEqual(0); - }); - - test('cancel failed', async () => { - // Attempt to cancel again fails - await expect( - neutronClient.execute(contractAddress, { - cancel_limit_order: { - tranche_key: activeTrancheKey, - }, - }), - ).rejects.toThrowError(/Limit order tranche not found:/); - }); - }); - - describe('MultiHopSwap', () => { - test('successful multihops', async () => { - const numberDenoms = 10; - const fee = { - gas: '500000', - amount: [{ denom: NEUTRON_DENOM, amount: '1250' }], - }; - for (let i = 0; i < numberDenoms; i++) { - const data = await neutronClient.signAndBroadcast( - [ - { - typeUrl: MsgCreateDenom.typeUrl, - value: MsgCreateDenom.fromPartial({ - sender: neutronWallet.address, - subdenom: String(i), - }), - }, - ], - fee, - ); - - const newTokenDenom = getEventAttribute( - data.events, - 'create_denom', - 'new_token_denom', - ); - - await neutronClient.signAndBroadcast( - [ - { - typeUrl: MsgMint.typeUrl, - value: MsgMint.fromPartial({ - sender: neutronWallet.address, - amount: { - denom: newTokenDenom, - amount: '1000000', - }, - mintToAddress: neutronWallet.address, - }), - }, - ], - fee, - ); - - await neutronClient.sendTokens( - contractAddress, - [{ denom: newTokenDenom, amount: '1000000' }], - { - gas: '200000', - amount: [{ denom: NEUTRON_DENOM, amount: '1000' }], - }, - ); - multiHopSwapDenoms.push({ - denom: newTokenDenom, - balance: 1000000, - }); - } - for (let i = 0; i < numberDenoms - 1; i++) { - const res = await neutronClient.execute(contractAddress, { - deposit: { - receiver: contractAddress, - token_a: multiHopSwapDenoms[i].denom, - token_b: multiHopSwapDenoms[i + 1].denom, - amounts_a: ['1000'], // uint128 - amounts_b: ['1000'], // uint128 - tick_indexes_a_to_b: [5], // i64 - fees: [0], // u64 - options: [ - { - disable_autoswap: true, - fail_tx_on_bel: false, - }, - ], - }, - }); - expect(res.code).toEqual(0); - } - const res = await neutronClient.execute(contractAddress, { - multi_hop_swap: { - receiver: contractAddress, - routes: [ - { - hops: [ - multiHopSwapDenoms[0].denom, - multiHopSwapDenoms[1].denom, - multiHopSwapDenoms[2].denom, - multiHopSwapDenoms[3].denom, - multiHopSwapDenoms[4].denom, - multiHopSwapDenoms[5].denom, - multiHopSwapDenoms[6].denom, - multiHopSwapDenoms[7].denom, - multiHopSwapDenoms[8].denom, - multiHopSwapDenoms[9].denom, - ], - }, - ], - amount_in: '100', - exit_limit_price: '0.1', - pick_best_route: true, - }, - }); - expect(res.code).toEqual(0); - }); - - test('no route found', async () => { - await expect( - neutronClient.execute(contractAddress, { - multi_hop_swap: { - receiver: contractAddress, - routes: [ - { - hops: [ - multiHopSwapDenoms[0].denom, - multiHopSwapDenoms[9].denom, - ], - }, - ], - amount_in: '100', - exit_limit_price: '0.1', - pick_best_route: true, - }, - }), - ).rejects.toThrowError( - /All multihop routes failed limitPrice check or had insufficient liquidity/, - ); - }); - }); - }); - describe('DEX queries', () => { - beforeAll(async () => { - // create a new active tranche - const res1 = await neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - tick_index_in_to_out: 0, - limit_sell_price: '0.8188125757', - amount_in: '1000000', - order_type: 'GOOD_TIL_CANCELLED', - }, - }); - activeTrancheKey = getEventAttributesFromTx( - { tx_response: res1 }, - 'TickUpdate', - ['TrancheKey'], - )[0]['TrancheKey']; - - // create an expired tranche - const res2 = await neutronClient.execute(contractAddress, { - place_limit_order: { - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - tick_index_in_to_out: 0, - limit_sell_price: '7.3816756536', - amount_in: '1000000', - order_type: 'JUST_IN_TIME', - }, - }); - inactiveTrancheKey = getEventAttributesFromTx( - { tx_response: res2 }, - 'TickUpdate', - ['TrancheKey'], - )[0]['TrancheKey']; - // wait a few blocks to make sure JIT order expires - await neutronClient.waitBlocks(2); - }); - test('ParamsQuery', async () => { - await neutronClient.queryContractSmart(contractAddress, { - params: {}, - }); - }); - test('LimitOrderTrancheUserQuery', async () => { - const res = await neutronClient.queryContractSmart(contractAddress, { - limit_order_tranche_user: { - address: contractAddress, - tranche_key: activeTrancheKey, - }, - }); - expect(res.limit_order_tranche_user).toBeDefined(); - }); - test('LimitOrderTrancheUserAllQuery', async () => { - const res = await neutronClient.queryContractSmart(contractAddress, { - limit_order_tranche_user_all: {}, - }); - expect(res.limit_order_tranche_user.length).toBeGreaterThan(0); - }); - test('LimitOrderTrancheUserAllByAddressQuery', async () => { - const res = await neutronClient.queryContractSmart(contractAddress, { - limit_order_tranche_user_all_by_address: { - address: contractAddress, - }, - }); - expect(res.limit_orders.length).toBeGreaterThan(0); - }); - test('LimitOrderTrancheQuery', async () => { - const res = await neutronClient.queryContractSmart(contractAddress, { - limit_order_tranche: { - pair_id: 'uibcusdc<>untrn', - tick_index: -1999, - token_in: 'untrn', - tranche_key: activeTrancheKey, - }, - }); - expect(res.limit_order_tranche).toBeDefined(); - }); - test('invalid LimitOrderTrancheQuery', async () => { - await expect( - neutronClient.queryContractSmart(contractAddress, { - limit_order_tranche: { - pair_id: 'untrn<>notadenom', - tick_index: -1999, - token_in: 'untrn', - tranche_key: activeTrancheKey, - }, - }), - ).rejects.toThrowError(); - }); - test('AllLimitOrderTranche', async () => { - // const res = - await neutronClient.queryContractSmart(contractAddress, { - limit_order_tranche_all: { - pair_id: 'uibcusdc<>untrn', - token_in: 'untrn', - }, - }); - // TODO: add tranche for tests - // expect(res.limit_order_tranche.length).toBeGreaterThan(0); - }); - test('AllUserDeposits', async () => { - const resp = await neutronClient.queryContractSmart(contractAddress, { - user_deposit_all: { - address: contractAddress, - include_pool_data: true, - }, - }); - expect(Number(resp.deposits[0].total_shares)).toBeGreaterThan(0); - expect(Number(resp.deposits[0].pool.id)).toEqual(0); - - const respNoPoolData = await neutronClient.queryContractSmart( - contractAddress, - { - user_deposit_all: { - address: contractAddress, - include_pool_data: false, - }, - }, - ); - expect(respNoPoolData.deposits[0].total_shares).toBeNull(); - expect(respNoPoolData.deposits[0].pool).toBeNull(); - }); - test('AllTickLiquidity', async () => { - const res = await neutronClient.queryContractSmart(contractAddress, { - tick_liquidity_all: { - pair_id: 'uibcusdc<>untrn', - token_in: 'untrn', - }, - }); - expect(res.tick_liquidity.length).toBeGreaterThan(0); - }); - test('InactiveLimitOrderTranche', async () => { - await neutronClient.queryContractSmart(contractAddress, { - inactive_limit_order_tranche: { - pair_id: 'uibcusdc<>untrn', - tick_index: 19991, - token_in: 'untrn', - tranche_key: inactiveTrancheKey, - }, - }); - }); - test('AllInactiveLimitOrderTranche', async () => { - const res = await neutronClient.queryContractSmart(contractAddress, { - inactive_limit_order_tranche_all: {}, - }); - expect(res.inactive_limit_order_tranche.length).toBeGreaterThan(0); - }); - test('AllPoolReserves', async () => { - const res = await neutronClient.queryContractSmart(contractAddress, { - pool_reserves_all: { - pair_id: 'uibcusdc<>untrn', - token_in: 'untrn', - }, - }); - expect(res.pool_reserves.length).toBeGreaterThan(0); - }); - test('PoolReserves', async () => { - await neutronClient.queryContractSmart(contractAddress, { - pool_reserves: { - pair_id: 'uibcusdc<>untrn', - tick_index: -1, - token_in: 'untrn', - fee: 0, - }, - }); - }); - test.skip('EstimateMultiHopSwap', async () => { - // TODO - // await neutronWallet.queryContract( - // contractAddress, - // { - // params: {}, - // }, - // ); - }); - test('EstimatePlaceLimitOrder', async () => { - await neutronClient.queryContractSmart(contractAddress, { - estimate_place_limit_order: { - creator: contractAddress, - receiver: contractAddress, - token_in: 'untrn', - token_out: 'uibcusdc', - tick_index_in_to_out: 1, - amount_in: '100000', - expiration_time: Math.ceil(Date.now() / 1000) + 1000, - order_type: 'GOOD_TIL_TIME', - }, - }); - }); - test('Pool', async () => { - await neutronClient.queryContractSmart(contractAddress, { - pool: { pair_id: 'uibcusdc<>untrn', tick_index: -1, fee: 0 }, - }); - }); - test('PoolByID', async () => { - await neutronClient.queryContractSmart(contractAddress, { - pool_by_id: { pool_id: 0 }, - }); - }); - test('PoolMetadata', async () => { - await neutronClient.queryContractSmart(contractAddress, { - pool_metadata: { id: 0 }, - }); - }); - test('AllPoolMetadata', async () => { - const res = await neutronClient.queryContractSmart(contractAddress, { - pool_metadata_all: {}, - }); - expect(res.pool_metadata.length).toBeGreaterThan(0); - }); - }); -}); diff --git a/src/testcases/run_in_band/dex_grpc.test.ts b/src/testcases/run_in_band/dex_grpc.test.ts index f14b0b5e..15458d35 100644 --- a/src/testcases/run_in_band/dex_grpc.test.ts +++ b/src/testcases/run_in_band/dex_grpc.test.ts @@ -740,6 +740,7 @@ describe('Neutron / dex module (grpc contract)', () => { amount_in: '10000', order_type: LimitOrderType.FillOrKill.toString(), max_amount_out: '', + min_average_sell_price: '', }, }, }); diff --git a/src/testcases/run_in_band/interchain_kv_query.test.ts b/src/testcases/run_in_band/interchain_kv_query.test.ts index dee876a9..1e589183 100644 --- a/src/testcases/run_in_band/interchain_kv_query.test.ts +++ b/src/testcases/run_in_band/interchain_kv_query.test.ts @@ -373,18 +373,16 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.registered_query.id).toEqual(queryId); - expect(queryResult.registered_query.owner).toEqual(contractAddress); - expect(queryResult.registered_query.keys.length).toEqual(1); - expect(queryResult.registered_query.keys[0].path).toEqual('bank'); - expect(queryResult.registered_query.keys[0].key.length).toBeGreaterThan( - 0, - ); - expect(queryResult.registered_query.query_type).toEqual('kv'); - expect(queryResult.registered_query.transactions_filter).toEqual(''); - expect(queryResult.registered_query.connection_id).toEqual(connectionId); - expect(queryResult.registered_query.update_period).toEqual( - updatePeriods[queryId], + expect(queryResult.id).toEqual(queryId.toString()); + expect(queryResult.owner).toEqual(contractAddress); + expect(queryResult.keys.length).toEqual(1); + expect(queryResult.keys[0].path).toEqual('bank'); + expect(queryResult.keys[0].key.length).toBeGreaterThan(0); + expect(queryResult.query_type).toEqual('kv'); + expect(queryResult.transactions_filter).toEqual(''); + expect(queryResult.connection_id).toEqual(connectionId); + expect(queryResult.update_period).toEqual( + updatePeriods[queryId].toString(), ); }); @@ -396,10 +394,10 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.registered_query.id).toEqual(queryId); - expect(queryResult.registered_query.keys.length).toEqual(1); - expect(queryResult.registered_query.update_period).toEqual( - updatePeriods[queryId], + expect(queryResult.id).toEqual(queryId.toString()); + expect(queryResult.keys.length).toEqual(1); + expect(queryResult.update_period).toEqual( + updatePeriods[queryId].toString(), ); }); @@ -410,15 +408,15 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.registered_query.id).toEqual(queryId); - expect(queryResult.registered_query.owner).toEqual(contractAddress); + expect(queryResult.id).toEqual(queryId.toString()); + expect(queryResult.owner).toEqual(contractAddress); // we expect three keys, 1 always + 2 per validator - expect(queryResult.registered_query.keys.length).toEqual(3); - expect(queryResult.registered_query.query_type).toEqual('kv'); - expect(queryResult.registered_query.transactions_filter).toEqual(''); - expect(queryResult.registered_query.connection_id).toEqual(connectionId); - expect(queryResult.registered_query.update_period).toEqual( - updatePeriods[queryId], + expect(queryResult.keys.length).toEqual(3); + expect(queryResult.query_type).toEqual('kv'); + expect(queryResult.transactions_filter).toEqual(''); + expect(queryResult.connection_id).toEqual(connectionId); + expect(queryResult.update_period).toEqual( + updatePeriods[queryId].toString(), ); }); @@ -429,22 +427,18 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.registered_query.id).toEqual(queryId); - expect(queryResult.registered_query.owner).toEqual(contractAddress); - expect(queryResult.registered_query.keys.length).toEqual(2); - expect(queryResult.registered_query.keys[0].path).toEqual('bank'); - expect(queryResult.registered_query.keys[0].key.length).toBeGreaterThan( - 0, - ); - expect(queryResult.registered_query.keys[1].path).toEqual('bank'); - expect(queryResult.registered_query.keys[1].key.length).toBeGreaterThan( - 0, - ); - expect(queryResult.registered_query.query_type).toEqual('kv'); - expect(queryResult.registered_query.transactions_filter).toEqual(''); - expect(queryResult.registered_query.connection_id).toEqual(connectionId); - expect(queryResult.registered_query.update_period).toEqual( - updatePeriods[queryId], + expect(queryResult.id).toEqual(queryId.toString()); + expect(queryResult.owner).toEqual(contractAddress); + expect(queryResult.keys.length).toEqual(2); + expect(queryResult.keys[0].path).toEqual('bank'); + expect(queryResult.keys[0].key.length).toBeGreaterThan(0); + expect(queryResult.keys[1].path).toEqual('bank'); + expect(queryResult.keys[1].key.length).toBeGreaterThan(0); + expect(queryResult.query_type).toEqual('kv'); + expect(queryResult.transactions_filter).toEqual(''); + expect(queryResult.connection_id).toEqual(connectionId); + expect(queryResult.update_period).toEqual( + updatePeriods[queryId].toString(), ); }); @@ -455,21 +449,19 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.registered_query.id).toEqual(queryId); - expect(queryResult.registered_query.owner).toEqual(contractAddress); - expect(queryResult.registered_query.keys.length).toEqual(100); - for (let i = 0; i < queryResult.registered_query.keys.length; i++) { - expect(queryResult.registered_query.keys[i].path).toEqual('bank'); - expect(queryResult.registered_query.keys[i].key.length).toBeGreaterThan( - 0, - ); + expect(queryResult.id).toEqual(queryId.toString()); + expect(queryResult.owner).toEqual(contractAddress); + expect(queryResult.keys.length).toEqual(100); + for (let i = 0; i < queryResult.keys.length; i++) { + expect(queryResult.keys[i].path).toEqual('bank'); + expect(queryResult.keys[i].key.length).toBeGreaterThan(0); } - expect(queryResult.registered_query.query_type).toEqual('kv'); - expect(queryResult.registered_query.transactions_filter).toEqual(''); - expect(queryResult.registered_query.connection_id).toEqual(connectionId); - expect(queryResult.registered_query.update_period).toEqual( - updatePeriods[queryId], + expect(queryResult.query_type).toEqual('kv'); + expect(queryResult.transactions_filter).toEqual(''); + expect(queryResult.connection_id).toEqual(connectionId); + expect(queryResult.update_period).toEqual( + updatePeriods[queryId].toString(), ); }); @@ -481,12 +473,10 @@ describe('Neutron / Interchain KV Query', () => { queryId, ); - expect( - queryResult.registered_query.last_submitted_result_local_height, - ).greaterThan(0); - expect( - queryResult.registered_query.last_submitted_result_local_height, - ).lessThan(queryResult.registered_query.update_period); + expect(+queryResult.last_submitted_result_local_height).greaterThan(0); + expect(+queryResult.last_submitted_result_local_height).lessThan( + +queryResult.update_period, + ); }); test("registered icq #8 doesn't exist", async () => { @@ -741,10 +731,8 @@ describe('Neutron / Interchain KV Query', () => { queryId, ); - expect(queryResult.registered_query.deposit).toEqual( - params.params.queryDeposit, - ); - expect(queryResult.registered_query.submit_timeout.toString()).toEqual( + expect(queryResult.deposit).toEqual(params.params.queryDeposit); + expect(queryResult.submit_timeout.toString()).toEqual( params.params.querySubmitTimeout.toString(), ); }); @@ -804,10 +792,8 @@ describe('Neutron / Interchain KV Query', () => { queryId, ); - expect(queryResult.registered_query.deposit).toEqual(queryDepositParam); - expect(queryResult.registered_query.submit_timeout.toString()).toEqual( - '1', - ); + expect(queryResult.deposit).toEqual(queryDepositParam); + expect(queryResult.submit_timeout.toString()).toEqual('1'); const interchainQueriesParams = await interchainqQuerier.params(); @@ -825,12 +811,12 @@ describe('Neutron / Interchain KV Query', () => { 2, ); - expect( - registeredQueryBeforeParamChange.registered_query.deposit, - ).toEqual(registeredQueryAfterParamChange.registered_query.deposit); - expect( - registeredQueryBeforeParamChange.registered_query.deposit, - ).toEqual(registeredQueryAfterParamChange.registered_query.deposit); + expect(registeredQueryBeforeParamChange.deposit).toEqual( + registeredQueryAfterParamChange.deposit, + ); + expect(registeredQueryBeforeParamChange.deposit).toEqual( + registeredQueryAfterParamChange.deposit, + ); }); // FIXME: enable after fix change params via proposal @@ -856,8 +842,8 @@ describe('Neutron / Interchain KV Query', () => { await neutronClient.getWithAttempts( () => getRegisteredQuery(neutronClient, contractAddress, queryId), async (response) => - response.registered_query.last_submitted_result_local_height > 0 && - response.registered_query.last_submitted_result_local_height + 5 < + +response.last_submitted_result_local_height > 0 && + +response.last_submitted_result_local_height + 5 < (await neutronClient.getHeight()), 20, ); @@ -975,18 +961,16 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.registered_query.id).toEqual(queryId); - expect(queryResult.registered_query.owner).toEqual(contractAddress); + expect(queryResult.id).toEqual(queryId.toString()); + expect(queryResult.owner).toEqual(contractAddress); // XXX: I could actually check that "key" is correctly derived from contractAddress, // but this requires bech32 decoding/encoding shenanigans - expect(queryResult.registered_query.keys.length).toEqual(2); - expect(queryResult.registered_query.keys[0].path).toEqual('gov'); - expect(queryResult.registered_query.keys[0].key.length).toBeGreaterThan( - 0, - ); - expect(queryResult.registered_query.query_type).toEqual('kv'); - expect(queryResult.registered_query.transactions_filter).toEqual(''); - expect(queryResult.registered_query.connection_id).toEqual(connectionId); + expect(queryResult.keys.length).toEqual(2); + expect(queryResult.keys[0].path).toEqual('gov'); + expect(queryResult.keys[0].key.length).toBeGreaterThan(0); + expect(queryResult.query_type).toEqual('kv'); + expect(queryResult.transactions_filter).toEqual(''); + expect(queryResult.connection_id).toEqual(connectionId); }); test('proposal votes data', async () => { @@ -1058,18 +1042,16 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.registered_query.id).toEqual(queryId); - expect(queryResult.registered_query.owner).toEqual(contractAddress); + expect(queryResult.id).toEqual(queryId.toString()); + expect(queryResult.owner).toEqual(contractAddress); // XXX: I could actually check that "key" is correctly derived from contractAddress, // but this requires bech32 decoding/encoding shenanigans - expect(queryResult.registered_query.keys.length).toEqual(3); - expect(queryResult.registered_query.keys[0].path).toEqual('gov'); - expect(queryResult.registered_query.keys[0].key.length).toBeGreaterThan( - 0, - ); - expect(queryResult.registered_query.query_type).toEqual('kv'); - expect(queryResult.registered_query.transactions_filter).toEqual(''); - expect(queryResult.registered_query.connection_id).toEqual(connectionId); + expect(queryResult.keys.length).toEqual(3); + expect(queryResult.keys[0].path).toEqual('gov'); + expect(queryResult.keys[0].key.length).toBeGreaterThan(0); + expect(queryResult.query_type).toEqual('kv'); + expect(queryResult.transactions_filter).toEqual(''); + expect(queryResult.connection_id).toEqual(connectionId); }); test('proposals data', async () => { @@ -1166,16 +1148,14 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.registered_query.id).toEqual(queryId); - expect(queryResult.registered_query.owner).toEqual(contractAddress); - expect(queryResult.registered_query.keys.length).toEqual(1); - expect(queryResult.registered_query.keys[0].path).toEqual('slashing'); - expect(queryResult.registered_query.keys[0].key.length).toBeGreaterThan( - 0, - ); - expect(queryResult.registered_query.query_type).toEqual('kv'); - expect(queryResult.registered_query.transactions_filter).toEqual(''); - expect(queryResult.registered_query.connection_id).toEqual(connectionId); + expect(queryResult.id).toEqual(queryId.toString()); + expect(queryResult.owner).toEqual(contractAddress); + expect(queryResult.keys.length).toEqual(1); + expect(queryResult.keys[0].path).toEqual('slashing'); + expect(queryResult.keys[0].key.length).toBeGreaterThan(0); + expect(queryResult.query_type).toEqual('kv'); + expect(queryResult.transactions_filter).toEqual(''); + expect(queryResult.connection_id).toEqual(connectionId); }); test('signing info data', async () => { @@ -1252,16 +1232,14 @@ describe('Neutron / Interchain KV Query', () => { contractAddress, queryId, ); - expect(queryResult.registered_query.id).toEqual(queryId); - expect(queryResult.registered_query.owner).toEqual(contractAddress); - expect(queryResult.registered_query.keys.length).toEqual(1); - expect(queryResult.registered_query.keys[0].path).toEqual('staking'); - expect(queryResult.registered_query.keys[0].key.length).toBeGreaterThan( - 0, - ); - expect(queryResult.registered_query.query_type).toEqual('kv'); - expect(queryResult.registered_query.transactions_filter).toEqual(''); - expect(queryResult.registered_query.connection_id).toEqual(connectionId); + expect(queryResult.id).toEqual(queryId.toString()); + expect(queryResult.owner).toEqual(contractAddress); + expect(queryResult.keys.length).toEqual(1); + expect(queryResult.keys[0].path).toEqual('staking'); + expect(queryResult.keys[0].key.length).toBeGreaterThan(0); + expect(queryResult.query_type).toEqual('kv'); + expect(queryResult.transactions_filter).toEqual(''); + expect(queryResult.connection_id).toEqual(connectionId); }); test('query result', async () => { diff --git a/src/testcases/run_in_band/interchain_tx_query_plain.test.ts b/src/testcases/run_in_band/interchain_tx_query_plain.test.ts index 00979913..923ee031 100644 --- a/src/testcases/run_in_band/interchain_tx_query_plain.test.ts +++ b/src/testcases/run_in_band/interchain_tx_query_plain.test.ts @@ -136,17 +136,17 @@ describe('Neutron / Interchain TX Query', () => { test('check registered transfers query', async () => { const query = await getRegisteredQuery(neutronClient, contractAddress, 1); - expect(query.registered_query.id).toEqual(1); - expect(query.registered_query.owner).toEqual(contractAddress); - expect(query.registered_query.keys.length).toEqual(0); - expect(query.registered_query.query_type).toEqual('tx'); - expect(query.registered_query.transactions_filter).toEqual( + expect(query.id).toEqual('1'); + expect(query.owner).toEqual(contractAddress); + expect(query.keys.length).toEqual(0); + expect(query.query_type).toEqual('tx'); + expect(query.transactions_filter).toEqual( '[{"field":"transfer.recipient","op":"Eq","value":"' + watchedAddr1 + '"}]', ); - expect(query.registered_query.connection_id).toEqual(connectionId); - expect(query.registered_query.update_period).toEqual(query1UpdatePeriod); + expect(query.connection_id).toEqual(connectionId); + expect(query.update_period).toEqual(query1UpdatePeriod.toString()); }); test('handle callback on a sending', async () => { @@ -299,17 +299,17 @@ describe('Neutron / Interchain TX Query', () => { test('check registered transfers query', async () => { const query = await getRegisteredQuery(neutronClient, contractAddress, 2); - expect(query.registered_query.id).toEqual(2); - expect(query.registered_query.owner).toEqual(contractAddress); - expect(query.registered_query.keys.length).toEqual(0); - expect(query.registered_query.query_type).toEqual('tx'); - expect(query.registered_query.transactions_filter).toEqual( + expect(query.id).toEqual('2'); + expect(query.owner).toEqual(contractAddress); + expect(query.keys.length).toEqual(0); + expect(query.query_type).toEqual('tx'); + expect(query.transactions_filter).toEqual( '[{"field":"transfer.recipient","op":"Eq","value":"' + watchedAddr2 + '"}]', ); - expect(query.registered_query.connection_id).toEqual(connectionId); - expect(query.registered_query.update_period).toEqual(query2UpdatePeriod); + expect(query.connection_id).toEqual(connectionId); + expect(query.update_period).toEqual(query2UpdatePeriod.toString()); }); test('handle callback on a past sending', async () => { @@ -368,17 +368,17 @@ describe('Neutron / Interchain TX Query', () => { test('check registered transfers query', async () => { const query = await getRegisteredQuery(neutronClient, contractAddress, 3); - expect(query.registered_query.id).toEqual(3); - expect(query.registered_query.owner).toEqual(contractAddress); - expect(query.registered_query.keys.length).toEqual(0); - expect(query.registered_query.query_type).toEqual('tx'); - expect(query.registered_query.transactions_filter).toEqual( + expect(query.id).toEqual('3'); + expect(query.owner).toEqual(contractAddress); + expect(query.keys.length).toEqual(0); + expect(query.query_type).toEqual('tx'); + expect(query.transactions_filter).toEqual( '[{"field":"transfer.recipient","op":"Eq","value":"' + watchedAddr3 + '"}]', ); - expect(query.registered_query.connection_id).toEqual(connectionId); - expect(query.registered_query.update_period).toEqual(query3UpdatePeriod); + expect(query.connection_id).toEqual(connectionId); + expect(query.update_period).toEqual(query3UpdatePeriod.toString()); }); test('check first sending handling', async () => { @@ -460,9 +460,6 @@ describe('Neutron / Interchain TX Query', () => { }); let deposits = await depositsPromise; // update time hasn't come yet despite the fact that sent funds are already on the account - console.log( - 'deposits.transfers: \n' + JSON.stringify(deposits.transfers), - ); expect(deposits.transfers).toEqual([ { recipient: watchedAddr3, @@ -701,30 +698,30 @@ describe('Neutron / Interchain TX Query', () => { test('check registered transfers query', async () => { let query = await getRegisteredQuery(neutronClient, contractAddress, 4); - expect(query.registered_query.id).toEqual(4); - expect(query.registered_query.owner).toEqual(contractAddress); - expect(query.registered_query.keys.length).toEqual(0); - expect(query.registered_query.query_type).toEqual('tx'); - expect(query.registered_query.transactions_filter).toEqual( + expect(query.id).toEqual('4'); + expect(query.owner).toEqual(contractAddress); + expect(query.keys.length).toEqual(0); + expect(query.query_type).toEqual('tx'); + expect(query.transactions_filter).toEqual( '[{"field":"transfer.recipient","op":"Eq","value":"' + watchedAddr4 + '"}]', ); - expect(query.registered_query.connection_id).toEqual(connectionId); - expect(query.registered_query.update_period).toEqual(query4UpdatePeriod); + expect(query.connection_id).toEqual(connectionId); + expect(query.update_period).toEqual(query4UpdatePeriod.toString()); query = await getRegisteredQuery(neutronClient, contractAddress, 5); - expect(query.registered_query.id).toEqual(5); - expect(query.registered_query.owner).toEqual(contractAddress); - expect(query.registered_query.keys.length).toEqual(0); - expect(query.registered_query.query_type).toEqual('tx'); - expect(query.registered_query.transactions_filter).toEqual( + expect(query.id).toEqual('5'); + expect(query.owner).toEqual(contractAddress); + expect(query.keys.length).toEqual(0); + expect(query.query_type).toEqual('tx'); + expect(query.transactions_filter).toEqual( '[{"field":"transfer.recipient","op":"Eq","value":"' + watchedAddr5 + '"}]', ); - expect(query.registered_query.connection_id).toEqual(connectionId); - expect(query.registered_query.update_period).toEqual(query5UpdatePeriod); + expect(query.connection_id).toEqual(connectionId); + expect(query.update_period).toEqual(query5UpdatePeriod.toString()); }); test('make younger sending and check', async () => { @@ -848,17 +845,17 @@ describe('Neutron / Interchain TX Query', () => { test('check registered transfers query', async () => { const query = await getRegisteredQuery(neutronClient, contractAddress, 6); - expect(query.registered_query.id).toEqual(6); - expect(query.registered_query.owner).toEqual(contractAddress); - expect(query.registered_query.keys.length).toEqual(0); - expect(query.registered_query.query_type).toEqual('tx'); - expect(JSON.parse(query.registered_query.transactions_filter)).toEqual( + expect(query.id).toEqual('6'); + expect(query.owner).toEqual(contractAddress); + expect(query.keys.length).toEqual(0); + expect(query.query_type).toEqual('tx'); + expect(JSON.parse(query.transactions_filter)).toEqual( Array(50) .fill(watchedAddr2) .map((v) => ({ field: 'transfer.recipient', op: 'Eq', value: v })), ); - expect(query.registered_query.connection_id).toEqual(connectionId); - expect(query.registered_query.update_period).toEqual(query2UpdatePeriod); + expect(query.connection_id).toEqual(connectionId); + expect(query.update_period).toEqual(query2UpdatePeriod.toString()); }); }); @@ -927,28 +924,30 @@ describe('Neutron / Interchain TX Query', () => { describe('update recipient and check', () => { const newWatchedAddr5 = 'cosmos1jy7lsk5pk38zjfnn6nt6qlaphy9uejn4hu65xa'; it('should update recipient', async () => { + const query = await getRegisteredQuery(neutronClient, contractAddress, 3); const res = await neutronClient.execute(contractAddress, { update_interchain_query: { query_id: 3, new_update_period: query3UpdatePeriod, new_recipient: newWatchedAddr5, + new_keys: query.keys, }, }); expect(res.code).toEqual(0); }); it('seems registered transfers query is updated', async () => { const query = await getRegisteredQuery(neutronClient, contractAddress, 3); - expect(query.registered_query.id).toEqual(3); - expect(query.registered_query.owner).toEqual(contractAddress); - expect(query.registered_query.keys.length).toEqual(0); - expect(query.registered_query.query_type).toEqual('tx'); - expect(query.registered_query.update_period).toEqual(query3UpdatePeriod); - expect(query.registered_query.transactions_filter).toEqual( + expect(query.id).toEqual('3'); + expect(query.owner).toEqual(contractAddress); + expect(query.keys.length).toEqual(0); + expect(query.query_type).toEqual('tx'); + expect(query.update_period).toEqual(query3UpdatePeriod.toString()); + expect(query.transactions_filter).toEqual( '[{"field":"transfer.recipient","op":"Eq","value":"' + newWatchedAddr5 + '"}]', ); - expect(query.registered_query.connection_id).toEqual(connectionId); + expect(query.connection_id).toEqual(connectionId); }); it('should handle callback on a sending to the new address', async () => { diff --git a/src/testcases/run_in_band/interchaintx.test.ts b/src/testcases/run_in_band/interchaintx.test.ts index 59543e3b..120025cd 100644 --- a/src/testcases/run_in_band/interchaintx.test.ts +++ b/src/testcases/run_in_band/interchaintx.test.ts @@ -132,7 +132,7 @@ describe('Neutron / Interchain TXs', () => { register: { connection_id: connectionId, interchain_account_id: unorderedIcaId, - ordering: 'ORDER_UNORDERED', + ordering: 'Unordered', }, }); expect(res.code).toEqual(0); diff --git a/src/testcases/run_in_band/slinky.test.ts b/src/testcases/run_in_band/slinky.test.ts index 3a499541..8ca10f77 100644 --- a/src/testcases/run_in_band/slinky.test.ts +++ b/src/testcases/run_in_band/slinky.test.ts @@ -78,14 +78,14 @@ describe('Neutron / Slinky', () => { }); describe('before create market map', () => { - test('query last should return null', async () => { + test('query last should return 0', async () => { const res: LastUpdatedResponse = await neutronClient.queryContractSmart( marketmapContract, { last_updated: {}, }, ); - expect(res.last_updated).toBe(null); + expect(res.last_updated).toBe('0'); }); }); @@ -162,7 +162,7 @@ describe('Neutron / Slinky', () => { }); }); - describe('wasmbindings oracle', () => { + describe('grpc oracle', () => { test('query prices', async () => { const res: GetPricesResponse = await neutronClient.queryContractSmart( oracleContract, @@ -180,7 +180,7 @@ describe('Neutron / Slinky', () => { const res: GetPriceResponse = await neutronClient.queryContractSmart( oracleContract, { - get_price: { currency_pair: { Base: 'AAVE', Quote: 'USD' } }, + get_price: { base: 'AAVE', quote: 'USD' }, }, ); expect(+res.price.price).toBeGreaterThan(0); @@ -191,11 +191,11 @@ describe('Neutron / Slinky', () => { await neutronClient.queryContractSmart(oracleContract, { get_all_currency_pairs: {}, }); - expect(res.currency_pairs[0].Base).toBe('AAVE'); - expect(res.currency_pairs[0].Quote).toBe('USD'); + expect(res.currency_pairs[0].base).toBe('AAVE'); + expect(res.currency_pairs[0].quote).toBe('USD'); }); }); - describe('wasmbindings marketmap', () => { + describe('grpc marketmap', () => { test('query last', async () => { const res: LastUpdatedResponse = await neutronClient.queryContractSmart( marketmapContract, @@ -203,14 +203,14 @@ describe('Neutron / Slinky', () => { last_updated: {}, }, ); - expect(res.last_updated).toBeGreaterThan(0); + expect(+res.last_updated).toBeGreaterThan(0); }); test('query market', async () => { const res: MarketResponse = await neutronClient.queryContractSmart( marketmapContract, { - market: { currency_pair: { Base: 'AAVE', Quote: 'USD' } }, + market: { currency_pair: { base: 'AAVE', quote: 'USD' } }, }, ); expect(res.market).toBeDefined(); @@ -220,7 +220,7 @@ describe('Neutron / Slinky', () => { const res: MarketResponse = await neutronClient.queryContractSmart( marketmapContract, { - market: { currency_pair: { Base: 'USDT', Quote: 'USD' } }, + market: { currency_pair: { base: 'USDT', quote: 'USD' } }, }, ); expect(res.market).toBeDefined(); @@ -265,62 +265,22 @@ export type GetPricesResponse = { }; export type CurrencyPair = { - Quote: string; - Base: string; + quote: string; + base: string; }; export type GetAllCurrencyPairsResponse = { currency_pairs: CurrencyPair[]; }; -export type ParamsResponse = { - params: Params; -}; - -export type CurrencyPair2 = { - base: string; - quote: string; -}; - export type LastUpdatedResponse = { last_updated: number; }; -export type MarketMapResponse = { - // MarketMap defines the global set of market configurations for all providers - // and markets. - market_map: MarketMap; - // LastUpdated is the last block height that the market map was updated. - // This field can be used as an optimization for clients checking if there - // is a new update to the map. - last_updated: number; - // ChainId is the chain identifier for the market map. - chain_id: string; -}; - export type MarketResponse = { market: Market; }; -export type QuotePrice = { - price: string; - // // BlockTimestamp tracks the block height associated with this price update. - // // We include block timestamp alongside the price to ensure that smart - // // contracts and applications are not utilizing stale oracle prices - // block_timestamp: time.Time, - // BlockHeight is height of block mentioned above - block_height: number; -}; - -export type Params = { - admin: string; - market_authorities: string[]; -}; - -export type MarketMap = { - markets: Map; -}; - export type Market = { // Tickers is the full list of tickers and their associated configurations // to be stored on-chain. @@ -342,7 +302,7 @@ export type ProviderConfig = { // For example, if the desired Ticker is BTC/USD, this market could be reached // using: OffChainTicker = BTC/USDT NormalizeByPair = USDT/USD This field is // optional and nullable. - normalize_by_pair: CurrencyPair2; + normalize_by_pair: CurrencyPair; // Invert is a boolean indicating if the BASE and QUOTE of the market should // be inverted. i.e. BASE -> QUOTE, QUOTE -> BASE invert: boolean; @@ -353,7 +313,7 @@ export type ProviderConfig = { export type Ticker = { // CurrencyPair is the currency pair for this ticker. - currency_pair: CurrencyPair2; + currency_pair: CurrencyPair; // Decimals is the number of decimal places for the ticker. The number of // decimal places is used to convert the price to a human-readable format. decimals: number; diff --git a/src/testcases/run_in_band/tokenfactory.test.ts b/src/testcases/run_in_band/tokenfactory.test.ts index b160fbe3..02b72178 100644 --- a/src/testcases/run_in_band/tokenfactory.test.ts +++ b/src/testcases/run_in_band/tokenfactory.test.ts @@ -648,7 +648,7 @@ describe('Neutron / Tokenfactory', () => { }); }); - describe('wasmbindings', () => { + describe('grpc', () => { let contractAddress: string; const subdenom = 'mycoin'; let denom: string; @@ -692,7 +692,7 @@ describe('Neutron / Tokenfactory', () => { denom_units: [ { denom, - exponent: 0, + exponent: '0', aliases: [], }, ], @@ -794,15 +794,16 @@ describe('Neutron / Tokenfactory', () => { test('full denom query', async () => { const res = await neutronClient.queryContractSmart(contractAddress, { - full_denom: { creator_addr: contractAddress, subdenom }, + full_denom: { creator: contractAddress, subdenom }, }); - expect(res.denom).toEqual(denom); + expect(res.full_denom).toEqual(denom); }); test('denom admin query', async () => { const res = await neutronClient.queryContractSmart(contractAddress, { denom_admin: { - subdenom: denom, + creator: contractAddress, + subdenom, }, }); expect(res.admin).toEqual(contractAddress); @@ -824,7 +825,8 @@ describe('Neutron / Tokenfactory', () => { }); const res = await neutronClient.queryContractSmart(contractAddress, { before_send_hook: { - denom, + creator: contractAddress, + subdenom, }, }); expect(res.contract_addr).toEqual(contractAddress); @@ -901,7 +903,8 @@ describe('Neutron / Tokenfactory', () => { expect(balance).toEqual(amount); const res = await neutronClient.queryContractSmart(contractAddress, { denom_admin: { - subdenom: denom, + creator: contractAddress, + subdenom, }, }); expect(res.admin).toEqual(neutronWallet.address);