Skip to content

Please document the fields in your Ethereum types #2037

Open
@PaulRBerg

Description

@PaulRBerg

Which packages are impacted by your issue?

@graphprotocol/graph-ts

export class Block {
constructor(
public hash: Bytes,
public parentHash: Bytes,
public unclesHash: Bytes,
public author: Address,
public stateRoot: Bytes,
public transactionsRoot: Bytes,
public receiptsRoot: Bytes,
public number: BigInt,
public gasUsed: BigInt,
public gasLimit: BigInt,
public timestamp: BigInt,
public difficulty: BigInt,
public totalDifficulty: BigInt,
public size: BigInt | null,
public baseFeePerGas: BigInt | null,
) {}
}
/**
* An Ethereum transaction.
*/
export class Transaction {
constructor(
public hash: Bytes,
public index: BigInt,
public from: Address,
public to: Address | null,
public value: BigInt,
public gasLimit: BigInt,
public gasPrice: BigInt,
public input: Bytes,
public nonce: BigInt,
) {}
}
/**
* An Ethereum transaction receipt.
*/
export class TransactionReceipt {
constructor(
public transactionHash: Bytes,
public transactionIndex: BigInt,
public blockHash: Bytes,
public blockNumber: BigInt,
public cumulativeGasUsed: BigInt,
public gasUsed: BigInt,
public contractAddress: Address,
public logs: Array<Log>,
public status: BigInt,
public root: Bytes,
public logsBloom: Bytes,
) {}
}
/**
* An Ethereum event log.
*/
export class Log {
constructor(
public address: Address,
public topics: Array<Bytes>,
public data: Bytes,
public blockHash: Bytes,
public blockNumber: Bytes,
public transactionHash: Bytes,
public transactionIndex: BigInt,
public logIndex: BigInt,
public transactionLogIndex: BigInt,
public logType: string,
public removed: Wrapped<bool> | null,
) {}
}
/**
* Common representation for Ethereum smart contract calls.
*/
export class Call {
constructor(
public to: Address,
public from: Address,
public block: Block,
public transaction: Transaction,
public inputValues: Array<EventParam>,
public outputValues: Array<EventParam>,
) {}
}

Describe the issue

It would be super duper helpful if the ethereum types, e.g. Transaction, Event`, etc., contained explanatory comments.

Lacking this information leads to uncertainty, e.g.:

In particular, I see that you provide some types that are not part of the standard Ethereum JavaScript API, e.g. transactionLogIndex. This index value can be easily misunderstood for the transactionIndex, which is the index of the tx within the block.

Explanatory comments would provide clarity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions