osmosis-labs / osmojs

OsmosJS makes it easy to compose and broadcast Osmosis and Cosmos messages
https://cosmology.zone/products/osmojs
Apache License 2.0
63 stars 32 forks source link

'Long' only refers to a type, but is being used as a namespace here. #13

Closed rixhy-cyd closed 1 year ago

rixhy-cyd commented 1 year ago

Long is not imported into the file that throughs error

Screenshot 2022-10-11 at 12 02 24 PM

<img width="716" alt="Screenshot 2022-10-11 at 12 02 34 PM" src="https://user-images.githubusercontent.com/107479292/195014104-b7de1338-03ad

Screenshot 2022-10-11 at 12 17 32 PM
pyramation commented 1 year ago

I haven't seen this, but I have seen ts complaining about import Long from 'long'.

Do you have a suggestion for the fix?

pyramation commented 1 year ago

or you mean to say that Long is never imported?

rixhy-cyd commented 1 year ago

or you mean to say that Long is never imported?

If I look into the code of that file where i get the error, Long was not imported

rixhy-cyd commented 1 year ago

I haven't seen this, but I have seen ts complaining about import Long from 'long'.

Do you have a suggestion for the fix?

Even am looking for the fix

pyramation commented 1 year ago

I think I am able to fix if it's just missing an import.

rixhy-cyd commented 1 year ago
Screenshot 2022-10-11 at 12 17 32 PM

Also am getting this import error

pyramation commented 1 year ago
import { AminoMsg } from "@cosmjs/amino";
import { Long } from "../../../../helpers";
import { MsgCreateStableswapPool, MsgStableSwapAdjustScalingFactors } from "./tx";
export interface AminoMsgCreateStableswapPool extends AminoMsg {
    type: "osmosis/gamm/create-stableswap-pool";
    value: {
        sender: string;
        pool_params: {
            swap_fee: string;
            exit_fee: string;
        };
        initial_pool_liquidity: {
            denom: string;
            amount: string;
        }[];
        scaling_factors: Long[];
        future_pool_governor: string;
    };
}
export interface AminoMsgStableSwapAdjustScalingFactors extends AminoMsg {
    type: "osmosis/gamm/stable-swap-adjust-scaling-factors";
    value: {
        sender: string;
        pool_id: string;
        scaling_factors: Long[];
    };
}
export declare const AminoConverter: {
    "/osmosis.gamm.poolmodels.stableswap.v1beta1.MsgCreateStableswapPool": {
        aminoType: string;
        toAmino: ({ sender, poolParams, initialPoolLiquidity, scalingFactors, futurePoolGovernor }: MsgCreateStableswapPool) => AminoMsgCreateStableswapPool["value"];
        fromAmino: ({ sender, pool_params, initial_pool_liquidity, scaling_factors, future_pool_governor }: AminoMsgCreateStableswapPool["value"]) => MsgCreateStableswapPool;
    };
    "/osmosis.gamm.poolmodels.stableswap.v1beta1.MsgStableSwapAdjustScalingFactors": {
        aminoType: string;
        toAmino: ({ sender, poolId, scalingFactors }: MsgStableSwapAdjustScalingFactors) => AminoMsgStableSwapAdjustScalingFactors["value"];
        fromAmino: ({ sender, pool_id, scaling_factors }: AminoMsgStableSwapAdjustScalingFactors["value"]) => MsgStableSwapAdjustScalingFactors;
    };
};

what version are you running? This all seems to work.

rixhy-cyd commented 1 year ago

If I use npm i osmojs it installs v0.28.0

pyramation commented 1 year ago

and you don't see import { Long } from "../../../../helpers"; at the top of the files where Long is used? I can't seem to find this missing as indicated.

rixhy-cyd commented 1 year ago

node_modules/osmojs/types/codegen/osmosis/bundle.d.ts:1211:50 - error TS2304: Cannot find name 'Long'.

1211 scaling_factors: Long[];



node_modules/osmojs/types/codegen/osmosis/client.d.ts:589:30 - error TS2304: Cannot find name 'Long'.

589             scaling_factors: Long[];
rixhy-cyd commented 1 year ago
Screenshot 2022-10-11 at 12 33 45 PM

You can see here that there it says to import it found this in node_modules/osmojs/types/codegen/osmosis/client.d.ts:

rixhy-cyd commented 1 year ago
import { AminoMsg } from "@cosmjs/amino";
import { Long } from "../../../../helpers";
import { MsgCreateStableswapPool, MsgStableSwapAdjustScalingFactors } from "./tx";
export interface AminoMsgCreateStableswapPool extends AminoMsg {
    type: "osmosis/gamm/create-stableswap-pool";
    value: {
        sender: string;
        pool_params: {
            swap_fee: string;
            exit_fee: string;
        };
        initial_pool_liquidity: {
            denom: string;
            amount: string;
        }[];
        scaling_factors: Long[];
        future_pool_governor: string;
    };
}
export interface AminoMsgStableSwapAdjustScalingFactors extends AminoMsg {
    type: "osmosis/gamm/stable-swap-adjust-scaling-factors";
    value: {
        sender: string;
        pool_id: string;
        scaling_factors: Long[];
    };
}
export declare const AminoConverter: {
    "/osmosis.gamm.poolmodels.stableswap.v1beta1.MsgCreateStableswapPool": {
        aminoType: string;
        toAmino: ({ sender, poolParams, initialPoolLiquidity, scalingFactors, futurePoolGovernor }: MsgCreateStableswapPool) => AminoMsgCreateStableswapPool["value"];
        fromAmino: ({ sender, pool_params, initial_pool_liquidity, scaling_factors, future_pool_governor }: AminoMsgCreateStableswapPool["value"]) => MsgCreateStableswapPool;
    };
    "/osmosis.gamm.poolmodels.stableswap.v1beta1.MsgStableSwapAdjustScalingFactors": {
        aminoType: string;
        toAmino: ({ sender, poolId, scalingFactors }: MsgStableSwapAdjustScalingFactors) => AminoMsgStableSwapAdjustScalingFactors["value"];
        fromAmino: ({ sender, pool_id, scaling_factors }: AminoMsgStableSwapAdjustScalingFactors["value"]) => MsgStableSwapAdjustScalingFactors;
    };
};

what version are you running? This all seems to work.

What version should I use

pyramation commented 1 year ago

I don't see the issue with long in 0.28. It is exported from the helpers file:

import Long from 'long';

if (_m0.util.Long !== Long) {
    _m0.util.Long = (Long as any);

    _m0.configure();
}

export { Long };
pyramation commented 1 year ago

I can only see screenshots, but do you see an import at the top of the file? I am starting to think it's an issue with something else besides the code or long type itself. Maybe the TS server.

pyramation commented 1 year ago

for long maybe we can try

import * as Long from 'long'; 

instead of

import Long from 'long'

and then export it. This may fix that part.

rixhy-cyd commented 1 year ago

I can only see screenshots, but do you see an import at the top of the file? I am starting to think it's an issue with something else besides the code or long type itself. Maybe the TS server.

Nope I don't see any import statements for Long in this file node_modules/osmojs/types/codegen/osmosis/client.d.ts

pyramation commented 1 year ago

I can only see screenshots, but do you see an import at the top of the file? I am starting to think it's an issue with something else besides the code or long type itself. Maybe the TS server.

Nope I don't see any import statements for Long in this file node_modules/osmojs/types/codegen/osmosis/client.d.ts

ok, that's what I needed, thanks for the path. Will get this taken care of.

rixhy-cyd commented 1 year ago

I can only see screenshots, but do you see an import at the top of the file? I am starting to think it's an issue with something else besides the code or long type itself. Maybe the TS server.

Nope I don't see any import statements for Long in this file node_modules/osmojs/types/codegen/osmosis/client.d.ts

ok, that's what I needed, thanks for the path. Will get this taken care of.

Thanks for looking into it, let me know if the issue is fixed

pyramation commented 1 year ago
Successfully published:
 - osmojs@0.29.0
pyramation commented 1 year ago

should be fixed now @rishikhesh-cyD

pyramation commented 1 year ago
rixhy-cyd commented 1 year ago

@pyramation still facing some issues with the long import

Screenshot 2022-10-11 at 1 29 20 PM
rixhy-cyd commented 1 year ago

'Long' only refers to a type, but is being used as a namespace here. Also facing this error with ts in all the places where long is used inside the files of this path node_modules/cosmjs-types/tendermint/ @pyramation