Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove esbuild + remove some any #61

Merged
merged 16 commits into from
Jan 19, 2023
6 changes: 6 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
presets: [
['@babel/preset-env', { targets: { esmodules: true } }],
'@babel/preset-typescript',
],
};
12 changes: 1 addition & 11 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,7 @@ const config = {
},
setupFilesAfterEnv: ['jest-extended/all'],
transform: {
'^.+\\.tsx?$': [
'esbuild-jest',
{
target: 'node14',
format: 'cjs',
sourcemap: true,
loaders: {
'.test.ts': 'tsx',
},
},
],
'^.+\\.[t|j]sx?$': 'babel-jest',
},
};

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@
"@types/lodash": "^4.14.182",
"@types/long": "^4.0.2",
"axios": "^0.27.2",
"babel-jest": "^29.3.1",
"date-fns": "^2.16.1",
"esbuild": "^0.14.49",
"esbuild-jest": "^0.5.0",
"express": "^4.17.1",
"jest": "^27.5.1",
"lodash": "^4.17.21",
"long": "^5.2.0"
},
"devDependencies": {
"@babel/preset-env": "^7.20.2",
"@babel/preset-typescript": "^7.18.6",
"@types/express": "^4.17.9",
"@types/jest": "^28.1",
"@typescript-eslint/eslint-plugin": "^5.19.0",
Expand Down
22 changes: 12 additions & 10 deletions src/helpers/cosmos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,15 @@ type SingleChoiceProposal = {
/// The threshold at which this proposal will pass.
/// proposal's creation.
readonly total_power: string;
readonly status:
| 'open'
| 'rejected'
| 'passed'
| 'executed'
| 'closed'
| 'execution_failed';
readonly proposal: {
status:
| 'open'
| 'rejected'
| 'passed'
| 'executed'
| 'closed'
| 'execution_failed';
};
};

type TotalPowerAtHeightResponse = {
Expand Down Expand Up @@ -541,7 +543,7 @@ export class CosmosWrapper {
);
}

async queryProposal(proposalId: number): Promise<any> {
async queryProposal(proposalId: number): Promise<SingleChoiceProposal> {
return await this.queryContract<SingleChoiceProposal>(
PROPOSE_CONTRACT_ADDRESS,
{
Expand All @@ -552,7 +554,7 @@ export class CosmosWrapper {
);
}

async queryTotalVotingPower(): Promise<any> {
async queryTotalVotingPower(): Promise<TotalPowerAtHeightResponse> {
return await this.queryContract<TotalPowerAtHeightResponse>(
CORE_CONTRACT_ADDRESS,
{
Expand All @@ -561,7 +563,7 @@ export class CosmosWrapper {
);
}

async queryVotingPower(addr: string): Promise<any> {
async queryVotingPower(addr: string): Promise<VotingPowerAtHeightResponse> {
return await this.queryContract<VotingPowerAtHeightResponse>(
CORE_CONTRACT_ADDRESS,
{
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ export const waitForChannel = async (
if (
r.data.channels.length > 0 &&
r.data.channels.every(
(channel: any) => channel.counterparty.channel_id !== '',
(channel: { counterparty: { channel_id: string } }) =>
zavgorodnii marked this conversation as resolved.
Show resolved Hide resolved
channel.counterparty.channel_id !== '',
)
) {
await wait(20);
Expand Down
5 changes: 3 additions & 2 deletions src/helpers/wait.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { rest } from '@cosmos-client/core';
import { CosmosSDK } from '@cosmos-client/core/cjs/sdk';

export const wait = async (seconds: number) =>
new Promise((r) => {
Expand All @@ -16,7 +17,7 @@ export const getRemoteHeight = async (sdk: any) => {
return +block.data.block.header.height;
};

export const waitBlocks = async (sdk: any, n: number) => {
export const waitBlocks = async (sdk: CosmosSDK, n: number) => {
foxpy marked this conversation as resolved.
Show resolved Hide resolved
const targetHeight = (await getRemoteHeight(sdk)) + n;
for (;;) {
await wait(1);
Expand All @@ -32,7 +33,7 @@ export const waitBlocks = async (sdk: any, n: number) => {
* and only then returns result of getFunc()
*/
export const getWithAttempts = async <T>(
sdk: any,
sdk: CosmosSDK,
getFunc: () => Promise<T>,
readyFunc: (t: T) => Promise<boolean>,
numAttempts = 20,
Expand Down
6 changes: 1 addition & 5 deletions src/testcases/interchain_kv_query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -637,12 +637,8 @@ describe('Neutron / Interchain KV Query', () => {

test('should fail to remove icq #2 from non owner address before timeout expiration', async () => {
const queryId = 2;

const result = await removeQueryViaTx(cm[1], queryId);

expect((result as any).raw_log).toMatch(
/authorization failed: unauthorized/i,
);
expect(result.raw_log).toMatch(/authorization failed: unauthorized/i);
});

describe('Remove interchain query', () => {
Expand Down
Loading