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

Replaces custom VM with custom "Urbit" element #26

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

elliotBraem
Copy link

@elliotBraem elliotBraem commented May 28, 2024

This is a continuation of #25.

Screenshot 2024-05-28 at 7 32 57 AM

To improve the developer experience and align the other "custom VM" implementations (Livepeer, Vara Network), this pull request replaces the near-social-vm with the most recent version and exposes a <Urbit /> custom element (see Configuring custom VM elements).

This custom element is a higher order component that has a "provides" prop, in order to pass helpful Urbit methods from the gateway to any widgets visible through the gateway. For example, for Poke:

<Urbit
  provides={({ poke }) => (
    <button
      onClick={() =>
        poke("hood", "helm-hi", "hello urbit!").then((res) => {
          console.log(`${pokeVal} been printed in dojo`);
        })
      }
    >
      poke
    </button>
  )}
/>

Although it may be clearer when used like a "Provider" to a Widget, like this:

<Urbit
    provides={({ poke }) => (
      <Widget
        src={"${config_account}/widget/components.pokeUrbit"}
        props={{ poke }}
      />
    )}
  />

Then poke is accessible via props.

This pattern removes the need for a custom VM (and no longer needs to update and adjust for security vulnerabilities), and is more convenient for initializing the api as this can be done by the gateway, rather than inside the widget. It removes the "setApi" method.

It also provides developers with an easier to manage + customize Urbit API within the gateway code itself, rather than needing to modify the VM

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.

1 participant