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

fulfill adr 006 #1567

Closed

Conversation

turbocrime
Copy link
Contributor

@turbocrime turbocrime commented Jul 26, 2024

deletes react package fixes #1522 #1523

fixes #1521

prax-wallet/prax#120 will need work in prax but this interface is compatible

matching PR prax-wallet/prax#134

cc @VanishMax review

interfaces very close to meeting ADR as written.

  1. request and connect are no longer distinct methods
  2. isConnected returns a boolean only
  3. PenumbraClient wraps the page API
  4. PenumbraClient is created with createPenumbraClient
  5. PenumbraClient is connected with an instance method which returns manifest URL
  6. createServiceClient is available

Minifront is updated to use createPenumbraClient to init a transport. Larger refactor to support createServiceClient is out of scope.

Copy link

changeset-bot bot commented Jul 26, 2024

🦋 Changeset detected

Latest commit: 3690624

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@penumbra-zone/client Major
minifront Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

packages/client/src/index.ts Outdated Show resolved Hide resolved
packages/client/src/index.ts Outdated Show resolved Hide resolved
@turbocrime turbocrime force-pushed the turbocrime/fulfill-adr-006 branch 2 times, most recently from 9e5a6e1 to 2651888 Compare July 29, 2024 23:34
@turbocrime turbocrime changed the base branch from main to feat/adr-006-client-apis July 29, 2024 23:34
@turbocrime turbocrime force-pushed the feat/adr-006-client-apis branch from 7f4d398 to a19b911 Compare July 29, 2024 23:37
@turbocrime turbocrime force-pushed the turbocrime/fulfill-adr-006 branch from 2651888 to 378152d Compare July 29, 2024 23:38
@turbocrime turbocrime force-pushed the turbocrime/fulfill-adr-006 branch from 378152d to d8bbc2b Compare July 30, 2024 00:43
@turbocrime turbocrime force-pushed the turbocrime/fulfill-adr-006 branch from 027ab50 to e336ca8 Compare July 30, 2024 06:19
@turbocrime turbocrime force-pushed the turbocrime/fulfill-adr-006 branch from e336ca8 to 87e821c Compare July 30, 2024 06:23
Copy link
Contributor

@VanishMax VanishMax left a comment

Choose a reason for hiding this comment

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

One small suggestion and questions. The rest is all good 👍


await request;

return this.provider.manifest;
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion:

Suggested change
return this.provider.manifest;
return providerOrigin;

Manifest URL usually appends /manifest to the origin but we want to keep returning the origin URL

Copy link
Contributor

Choose a reason for hiding this comment

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

question: what's the point of removing react package?

@@ -34,11 +35,12 @@ const handleErr = (e: unknown) => {

const useExtConnector = () => {
const [result, setResult] = useState<boolean>();
const navigate = useNavigate();

const request = async () => {
try {
await requestPraxAccess();
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: after the update, reloading Minifront results in displaying the connection screen.

suggestion: add isConnected() check and, if connected, navigate('/')

Copy link
Contributor

@grod220 grod220 left a comment

Choose a reason for hiding this comment

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

What's the plan with the react-package? Will there be a follow up to update this?

Comment on lines +17 to +18
/** Reexports the `isConnected` function from injected provider */
readonly isConnected: () => boolean | undefined;
Copy link
Contributor

@grod220 grod220 Jul 30, 2024

Choose a reason for hiding this comment

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

issue: please update this to

readonly isConnected: () => boolean

import './global.js';

/** Return the specified provider, without verifying anything. */
export const getPenumbraUnsafe = (penumbraOrigin: string) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: not sure this naming makes sense if it can safely return undefined


/** Return the specified provider after confirming presence of its manifest. */
export const getPenumbra = (penumbraOrigin: string): Promise<PenumbraProvider> =>
assertProviderManifest(penumbraOrigin).then(() => getPenumbraUnsafe(penumbraOrigin)!);
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: instead of getPenumbraUnsafe(penumbraOrigin)!, think it best to throw an error if not present. Will help with debugging later when it does throw with a proper message.

export interface IPenumbraClient {
/**
* Asks users to approve the connection to a specific browser manifest URL.
* If `manifest` argument is not provided, tries to connect to the first injected provider.
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (idea):

Suggested change
* If `manifest` argument is not provided, tries to connect to the first injected provider.
* If `manifest` argument is not provided, tries to connect to the previously-connected or the first injected provider.

from the implementation point, it's going to look over the isConnected() of all injected providers and connect to the first one with true

@turbocrime
Copy link
Contributor Author

closing in favor of #1647 which will see more pushes with implementation of updated interface

@turbocrime turbocrime closed this Aug 5, 2024
@turbocrime turbocrime deleted the turbocrime/fulfill-adr-006 branch August 6, 2024 04:02
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.

3 participants