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

Web3 1.0.0-beta.38 TypeError: DeployTransactionResponse estimateGas() arguments and return type incorrect #2230

Closed
lucashenning opened this issue Jan 27, 2019 · 1 comment
Labels
Types Incorrect or missing types

Comments

@lucashenning
Copy link

Expected behavior

According to the documentation web3.Contract methods.myMethod.estimateGas(),
the estimateGas() function, defined in the DeployTransactionResponse interface expects 0 - 3 arguments and returns Promise<number>

Actual behavior

estimateGas() expects 1 - 2 arguments and returns void.

Steps to reproduce the behavior

let deployTx : DeployTransactionResponse = databaseSyncContract.deploy({
        data: contractJson.bytecode,
        arguments: []
    });
    let tx : Transaction = {
        from: nodemanager.getAccountAddress(),
        data: deployTx.encodeABI(),
        gas : await deployTx.estimateGas(),
        value : 0
    };

await deployTx.estimateGas() requires as an argument: An object with the property gas.

This works but doesn't make any sense:
await deployTx.estimateGas( { gas : 1000 } )

Incorrect Types Definition

This is the incorrect types definition of DeployTransactionResponse node_modules/web3-eth-contract/types/index.d.ts.

options should be optional. The return type should be number instead of void.

export interface DeployTransactionResponse {
    array: any[];

    send(options: SendOptions): () => Promise<Contract>;

    estimateGas(options: EstimateGasOptions, callback?: (err: Error, gas: number) => void): void;

    estimateGas(callback: (err: Error, gas: number) => void): void;

    estimateGas(options: EstimateGasOptions, callback: (err: Error, gas: number) => void): void;

    estimateGas(options: EstimateGasOptions): void;

    encodeABI(): string;
}

Versions

web3 v1.0.0-beta.38

@joshstevens19
Copy link
Contributor

Thanks for this - PR is in #2231

@joshstevens19 joshstevens19 added the Types Incorrect or missing types label Jan 27, 2019
@nivida nivida closed this as completed Jan 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Types Incorrect or missing types
Projects
None yet
Development

No branches or pull requests

3 participants