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 a method to get the Certificate type to the interface #636

Open
wolf31o2 opened this issue May 16, 2024 · 1 comment
Open

Add a method to get the Certificate type to the interface #636

wolf31o2 opened this issue May 16, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@wolf31o2
Copy link
Member

A common use case for Certificate data will be to only operate on specific certificate types. It would greatly simplify downstream if we had a way to access the type from the Certificate interface.

@wolf31o2 wolf31o2 added the enhancement New feature or request label May 16, 2024
@agaffney
Copy link
Contributor

The idea is to use Go's type switch/assertion for determining the cert type, since multiple types are returned using the ledger.Certificate interface. However, we have the information readily available to also return the integer value for the cert type, so adding a .Type() function wouldn't be difficult.

Type switch example:

switch v := myCert.(type) {
case ledger.StakeDelegationCertificate:
    // you can access v.StakeCredential and v.PoolKeyHash directly here
case ledger.PoolRegistrationCertificate:
    // you can access v.Operator, v.Pledge, v.Margin, etc. directly here
}

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

No branches or pull requests

2 participants