Web3.js: [typescript] Account interface does not seems to be right

Created on 12 Feb 2019  路  3Comments  路  Source: ChainSafe/web3.js

All issues which aren't created with this template will get immediately closed.
Hello,

I'm not sure the typing Account.signTransaction interface is correct here, should be that isn't it?

Expected behavior

    signTransaction(tx: Transaction, privateKey: string, callback?: () => void): Promise<SignedTransaction>;

source

or similar

Actual behavior

    signTransaction?: (tx: Transaction) => {};

source

Steps to reproduce the behavior

  1. Use typescript
  2. Install the version >1.0.0-beta.36
  3. Use the Account typing definition

Error Logs

Expected 1 arguments, but got 2.ts(2554)

Versions

Typescript latest
npm latest

types

Most helpful comment

Hey @oktapodia Thanks for raising this looking at it you are correct. In actual fact the documents are incorrect as well https://web3js.readthedocs.io/en/1.0/web3-eth-accounts.html#signtransaction

I think it needs to be

signTransaction(tx: Transaction, callback?: (signTransaction: SignedTransaction) => void): Promise<SignedTransaction>;

as it gets your private key from your account so the typing's should be above.

https://github.com/ethereum/web3.js/blob/v1.0.0-beta.46/packages/web3-eth-accounts/src/Accounts.js#L92

I will do a PR later on and update the docs to be inline with the code. good spot!

All 3 comments

Hey @oktapodia Thanks for raising this looking at it you are correct. In actual fact the documents are incorrect as well https://web3js.readthedocs.io/en/1.0/web3-eth-accounts.html#signtransaction

I think it needs to be

signTransaction(tx: Transaction, callback?: (signTransaction: SignedTransaction) => void): Promise<SignedTransaction>;

as it gets your private key from your account so the typing's should be above.

https://github.com/ethereum/web3.js/blob/v1.0.0-beta.46/packages/web3-eth-accounts/src/Accounts.js#L92

I will do a PR later on and update the docs to be inline with the code. good spot!

Awesome! Let me know if you need any help on that

Hey sorry about the delay i have been away from my computer.

https://github.com/ethereum/web3.js/pull/2417

It is fixed in this PR and will be released within the next release - thanks again for the issue raised.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

praveengupta0895 picture praveengupta0895  路  3Comments

nivida picture nivida  路  3Comments

baxy picture baxy  路  3Comments

princesinha19 picture princesinha19  路  3Comments

mishell-trickster picture mishell-trickster  路  3Comments