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 WebChannel RPC transport layer. #181

Merged
merged 10 commits into from
Jun 11, 2024
Merged

Conversation

Chralu
Copy link
Collaborator

@Chralu Chralu commented Mar 25, 2024

No description provided.

@Chralu Chralu force-pushed the webchannel_rpc branch 2 times, most recently from 2c2db3e to d4caac7 Compare April 9, 2024 09:15
@Chralu Chralu changed the base branch from master to develop May 28, 2024 09:12
@Chralu Chralu marked this pull request as ready for review May 28, 2024 15:22
this._state = AWCStreamChannelState.CONNECTING

console.log(`[AWC] Wait for popup extension ...`)
await chrome.runtime.sendMessage(this.extensionId, 'ensureExtensionPopupOpened')
Copy link
Member

Choose a reason for hiding this comment

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

I saw on MDN doc it's prefered to support cross platform api like suggest by:

Firefox also supports the chrome.* namespace for APIs that are compatible with Chrome, primarily to assist with porting. However, using the browser.* namespace is preferred. In addition to being the proposed standard, browser.* uses promises—a modern and convenient mechanism for handling asynchronous events.

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Build_a_cross_browser_extension

Maybe using a polyfill or using the browser.* can leverage firefox & chrome at the same time

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

browser.* is not supported by chrome yet.
Using a polyfill like this one seems like a requirement to get a wide compatibility.

I'll look at that in a second step 👍

src/endpoint.ts Outdated

if (url.protocol === "ws:") {
return new WalletRPCEndpoint(endpoint);
static build(endpoint: string | undefined): Endpoint {
Copy link
Member

@samuelmanzanera samuelmanzanera May 29, 2024

Choose a reason for hiding this comment

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

What do you think to support String | Endpoint | undefined ? This way custom AWCEndpoint such as AWCWebBrowserExtension or any AWCEndpoint might be passed as argument

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In my understanding, that method is a factory. Its role is to choose which kind of Endpoint to instanciate for a given endpoint uri.

I guess you suggest that change because once AWCWebBrowserExtension will be extracted from libjs, build method won't be able to build the AWCEndpoint anymore.

Maybe the solution would be to follow your next proposal 👇

/**
* @param endpoint if undefined, endpoint will be resolved using ArchethicWalletClient.
*/
constructor(endpoint: string | undefined) {
Copy link
Member

Choose a reason for hiding this comment

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

Probably the same remark/question as above

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I Agree with you.

We could directly pass an Endpoint instance here. This will be mandatory to extract AWCWebBrowserExtention from here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After more thought, this would be a breaking change.

Looking at the number of PRs waiting for validation, I think that change should wait a bit.

@Chralu Chralu requested a review from samuelmanzanera June 3, 2024 12:17
@samuelmanzanera samuelmanzanera added the feature New feature request label Jun 3, 2024
@samuelmanzanera samuelmanzanera merged commit 24cbf2e into develop Jun 11, 2024
3 checks passed
@samuelmanzanera samuelmanzanera deleted the webchannel_rpc branch June 11, 2024 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants