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

loaders: getContract returns non-nullable ContractResult #81

Merged
merged 2 commits into from
Jan 22, 2024
Merged

Conversation

shazow
Copy link
Owner

@shazow shazow commented Jan 22, 2024

Made ContractResult non-nullable (and renamed to be similar to AutoloadResult).

This way we can do more ergonomic

const { abi, name, ok } = await loader.getContract(address);
if (!ok) throw "failed"; // If we care, or skip this altogether if we don't
...

Rather than

const result = await loader.getContract(address);
if (result === null) throw "failed"; // Need this check either way, because it's nullable
const { abi, name } = result;
...

@SonOfMosiah what do you think?

@SonOfMosiah
Copy link
Contributor

Looks great! I was thinking of a status or success variable and I ok does the trick.

@shazow
Copy link
Owner Author

shazow commented Jan 22, 2024

I figure ok is a little closer to the Result-type that some other languages have. 🤷

@shazow shazow merged commit 8166252 into main Jan 22, 2024
2 checks passed
@shazow shazow deleted the loaders-patch branch January 22, 2024 16:37
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

Successfully merging this pull request may close these issues.

None yet

2 participants