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

Guards on chained methods on types #1901

Open
kiltsonfire opened this issue Jun 19, 2024 · 1 comment
Open

Guards on chained methods on types #1901

kiltsonfire opened this issue Jun 19, 2024 · 1 comment
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@kiltsonfire
Copy link
Contributor

Rationale

Chained methods on our types can cause crashes if a method or a field in a struct is nil

Implementation

Should we put guards on these? Do we know these fields/method returns will always be non-nil?

Example:
// Type returns the transaction type.
func (tx *Transaction) Type() uint8 {
return tx.inner.txType()
}

// ChainId returns the chain ID of the transaction. The return value will always be
// non-nil.
func (tx *Transaction) ChainId() *big.Int {
return tx.inner.chainID()
}

@kiltsonfire kiltsonfire added bug Something isn't working enhancement New feature or request labels Jun 19, 2024
@jdowning100
Copy link
Contributor

As far as I know those fields should never be nil in a transaction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants