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

Typescript return type of web3.eth.accounts.signTransaction() is incorrect. #2228

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

Comments

@lucashenning
Copy link

lucashenning commented Jan 27, 2019

Expected behavior

The return type of web3.eth.accounts.signTransaction(tx,privateKey)
should be Promise<{ messageHash, v, r, s, rawTransaction }>,
not Promise<string> | Signature

Actual behavior

web3.eth.accounts.signTransaction(tx,privateKey) returns string | Signature

Steps to reproduce the behavior

The following code works perfectly but signedTx.rawTransaction throws a type error during typescript compilation.

let deployTx : TransactionObject<Contract> = contract.deploy({
        data: contractJson.bytecode,
        arguments: []
    });
let tx : Tx = {
        from: accountAddress,
        data: txObject.encodeABI(),
        gas : await deployTx.estimateGas(),
        value : 0
    };
let signedTx = await web3.eth.accounts.signTransaction(tx,privateKey);
web3.eth.sendSignedTransaction(signedTx.rawTransaction)

Error Logs

{"message": "Property 'rawTransaction' does not exist on type 'string | Signature'.\n Property 'rawTransaction' does not exist on type 'string'.", }

Versions

Node v11.7.0
npm v6.7.0
web3 v1.0.0-beta.34

@lucashenning
Copy link
Author

Fixed in #2217 and merged in ec585b1

Thanks @joshstevens19

@nivida nivida 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

2 participants