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

Fix/not changing the switched chain id in in app browser #288

Merged

Conversation

q20274982
Copy link
Member

@q20274982 q20274982 commented Oct 18, 2023

Summary

by adding eventListeners to the bloctoSDK and also adding it in the in-app browser's existedSDK,
it allows invoking event functions in the in-app-browser as well.

Related Links

Asana: https://app.asana.com/0/1201812548509877/1205706441564006/f

Checklist

  • Pasted Asana link.
  • Tagged labels.

Prerequisite/Related Pull Requests

@q20274982 q20274982 added the bug Something isn't working label Oct 18, 2023
@q20274982 q20274982 requested a review from akira02 October 18, 2023 09:31
@changeset-bot
Copy link

changeset-bot bot commented Oct 18, 2023

⚠️ No Changeset found

Latest commit: 51a3a80

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@@ -872,7 +876,7 @@ export default class EthereumProvider
async handleDisconnect(): Promise<void> {
const existedSDK = (window as any).ethereum;
if (existedSDK && existedSDK.isBlocto) {
return existedSDK.disconnect();
return existedSDK.request({ method: 'wallet_disconnect' });
Copy link
Member Author

Choose a reason for hiding this comment

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

It seems that the disconnect function is not declared in the in-app-browser existedSDK, so I replaced it using request({ method: 'wallet_disconnect' })

@@ -907,4 +911,20 @@ export default class EthereumProvider
throw ethErrors.rpc.invalidParams('Empty networkList');
}
}

override on(event: string, listener: (arg: any) => void): void {
if (this.existedSDK?.isBlocto)
Copy link
Member Author

Choose a reason for hiding this comment

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

I think the condition if (this.existedSDK?.isBlocto) is more concise and achieves the same effect as const existedSDK = (window as any).ethereum; if (existedSDK && existedSDK.isBlocto). If there are no issues, I'll replace const existedSDK = (window as any).ethereum; if (existedSDK && existedSDK.isBlocto) with it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I replaced all the const existedSDK = (window as any).ethereum; if (existedSDK && existedSDK.isBlocto) with if (this.existedSDK?.isBlocto) in this commit refactor: enhance existedSDK check condition

@q20274982 q20274982 requested review from mordochi and sanyu1225 and removed request for akira02 and mordochi October 23, 2023 04:37
@q20274982 q20274982 force-pushed the fix/not-changing-the-switched-chain-id-in-in-app-browser branch 2 times, most recently from 0651bcd to 484d367 Compare October 26, 2023 03:53
sanyu1225
sanyu1225 previously approved these changes Oct 27, 2023
@q20274982 q20274982 force-pushed the fix/not-changing-the-switched-chain-id-in-in-app-browser branch from e8155e5 to 44c70c7 Compare October 31, 2023 05:05
@q20274982 q20274982 requested a review from sanyu1225 October 31, 2023 05:07
sanyu1225
sanyu1225 previously approved these changes Oct 31, 2023
Copy link
Member

@mordochi mordochi left a comment

Choose a reason for hiding this comment

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

這個 proxy event 的操作可以也幫我加到 aptos provider 嗎?

@q20274982
Copy link
Member Author

這個 proxy event 的操作可以也幫我加到 aptos provider 嗎?

solved here feat: enable aptos's existedSDK event

Copy link
Member

@mordochi mordochi left a comment

Choose a reason for hiding this comment

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

如果 local 測完都沒問題(adapters 也試試看) 就可以幫我 merge 然後發一版 beta 版給 @scottphc 用用看ㄛ

@q20274982 q20274982 merged commit b6d9b62 into develop Nov 2, 2023
3 checks passed
@q20274982 q20274982 deleted the fix/not-changing-the-switched-chain-id-in-in-app-browser branch November 2, 2023 01:42
@q20274982 q20274982 mentioned this pull request Nov 2, 2023
2 tasks
q20274982 added a commit that referenced this pull request Nov 2, 2023
…in-id-in-in-app-browser

chore: add changeset for #288
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working BugFix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants