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

Add optional privateFor to Typescript Declaration File in web3-core to support Quorum private transactions #3318

Closed
MarcoMazzoni opened this issue Jan 20, 2020 · 1 comment

Comments

@MarcoMazzoni
Copy link

According to Quorum documentation https://docs.goquorum.com/en/latest/Getting%20Started/api/, in order to support private transactions the web3.eth.sendTransaction(object) API method has been modified by adding the two following parameters to the transaction object:

  • privateFrom: String - (optional) When sending a private transaction, the sending party’s base64-encoded public key to use. If not present and passing privateFor, use the default key as configured in the TransactionManager.
  • privateFor: List - (optional) When sending a private transaction, an array of the recipients’ base64-encoded public keys.

Actual behavior

I am doing a Quorum project using React and Typescript, and wen I use the web3.eth.sendTransaction method with those two new parameters I get the following error:

Argument of type '{ from: string; to: string; gasPrice: number; data: string; privateFrom: string; privateFor: string[]; }' is not assignable to parameter of type 'TransactionConfig'. Object literal may only specify known properties, and 'privateFrom' does not exist in type 'TransactionConfig'.

Solution proposal

In order to tackle this problem, I changed in (my node_modules folder) the TransactionConfig interface which you can find in file index.d.ts in web3-core/types folder, into this one (just added the two optional parameters privateFrom and privateFor):

export interface TransactionConfig {
    from?: string | number;
    to?: string;
    value?: number | string | BN;
    gas?: number | string;
    gasPrice?: number | string | BN;
    data?: string;
    nonce?: number;
    chainId?: number;
    common?: Common;
    chain?: string;
    hardfork?: string;
    privateFrom?: string;
    privateFor?: string[];
}

I tested it into my project, and now the private transaction is working.

Could you please add those two optional params to the TransactionConfig interface?
Thank you very much for your help.

Versions

[NPM 6.12.0, Node 12.13.0, Web3.js 1.2.4, OS: Linux 18.04]

@nivida
Copy link
Contributor

nivida commented Jan 20, 2020

@MarcoMazzoni Thanks for opening this issue! Because the mentioned properties do not exist in the web3.js library do we recommend to use the extend method with a custom input and output formatter and your own type definitions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants