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

'make' namespace for kinds #10666

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

'make' namespace for kinds #10666

wants to merge 5 commits into from

Conversation

turadg
Copy link
Member

@turadg turadg commented Dec 10, 2024

variant of #10663

Description

Defines a convention (with a helper) for a make object that has kind constructors.

  • easier to verify that all kinds are defined in the synchronous prelude
  • distinguishes methods that make things from kind constructors

Security Considerations

Scaling Considerations

Documentation Considerations

Testing Considerations

Upgrade Considerations


const { make } = organizeMakers({
...orchestrateAll(flows, {}),
makeSettler: prepareSettler(zone, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about a record like this, but sometimes you have to pass makeA into prepareB.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh good point. That thought crossed my mind while I was refactoring but it consolidating like this was too delicious

Copy link

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: c1e4cea
Status: ✅  Deploy successful!
Preview URL: https://63de8717.agoric-sdk.pages.dev
Branch Preview URL: https://ta-make-namespace.agoric-sdk.pages.dev

View logs

if (!key.startsWith('make')) {
throw new Error(`Unexpected key ${key}`);
}
const newKey = key.slice(4); // Remove 'make'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const newKey = key.slice(4); // Remove 'make'
const newKey = key.slice('make'.length);

make[newKey] = fn;
}
// @ts-expect-error cast
return harden({ make });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why a record? why not return make;? in case there are other facets later or something? that doesn't seem like your style.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To enforce that the name used is make. Though that could be done by a lint rule, like React's useState does to enforce that the tuple it returns of [state object, state setter] has the the consistent naming [myState, setMyState].

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.

2 participants