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

Why is hash optional in TransactionResponse? (typings) #537

Closed
mrwillis opened this issue Jun 5, 2019 · 5 comments
Closed

Why is hash optional in TransactionResponse? (typings) #537

mrwillis opened this issue Jun 5, 2019 · 5 comments
Labels
discussion Questions, feedback and general information.

Comments

@mrwillis
Copy link

mrwillis commented Jun 5, 2019

I suspect this has to do with submitting a manual transaction vs submitting a transaction to the network as TransactionResponse inherits from Transaction. Is there ever a case where TransactionResponse wouldn't have a hash?

export interface TransactionResponse extends Transaction {
    blockNumber?: number;
    blockHash?: string;
    timestamp?: number;
    confirmations: number;
    from: string;
    raw?: string;
    wait: (confirmations?: number) => Promise<TransactionReceipt>;
}
export interface Transaction {
    hash?: string;
    to?: string;
    from?: string;
    nonce: number;
    gasLimit: BigNumber;
    gasPrice: BigNumber;
    data: string;
    value: BigNumber;
    chainId: number;
    r?: string;
    s?: string;
    v?: number;
}
@ricmoo
Copy link
Member

ricmoo commented Jun 6, 2019

I've spent the day trying to recall, and cannot. There was a weird case a long time ago, and I suspect it had to do with Ganache, but am not certain.

I will try making it non-optional in v5 and see if any issues crop up. I not, in v5 it won't be optional. :)

@ricmoo ricmoo added discussion Questions, feedback and general information. next version labels Jun 6, 2019
@naddison36
Copy link

That will save me using the bang(!) operator to appease the TS compiler. eg

const tx = await signer.sendTransaction(transaction)
const receipt = await provider.waitForTransaction(tx.hash!)

@ricmoo
Copy link
Member

ricmoo commented Jun 6, 2019

@naddison36 I have no idea what that post-fix operator does... TypeScript has some crazy things... Is that in the docs anywhere? Is it because you use the strict null checking?

@naddison36
Copy link

@ricmoo
Copy link
Member

ricmoo commented Jul 15, 2019

Closing this now, as v5 has been updated to reflect this change.

Thanks! :)

@ricmoo ricmoo closed this as completed Jul 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Questions, feedback and general information.
Projects
None yet
Development

No branches or pull requests

3 participants