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

feat: add metamask-snap support #208

Merged
merged 22 commits into from
Apr 24, 2024

Conversation

naorye
Copy link
Contributor

@naorye naorye commented Dec 13, 2023

  • Check metamask and snap support upon bootstrap
  • In case of support, load metamask-starknet and initialize wallet object

Pending for metamask-starknet packge implementation

@naorye naorye changed the title Add metamask-snap support feat: add metamask-snap support Dec 13, 2023
@naorye naorye changed the title feat: add metamask-snap support feat: add metamask-snap support [WIP] Dec 13, 2023
@dan-ziv dan-ziv self-requested a review December 13, 2023 14:49
@naorye naorye marked this pull request as draft December 13, 2023 15:35
@stanleyyconsensys
Copy link

@naorye2 please use the new release "1.0.0-dev-fc04076-202312205118" for your development

- Show metamask if there is metamask extension with snap support
- Load consensys metamask package if the user selects metamask from the list
Copy link

@stanleyyconsensys stanleyyconsensys left a comment

Choose a reason for hiding this comment

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

thank you for your work, i leave some comment

@naorye2 naorye2 changed the title feat: add metamask-snap support [WIP] feat: add metamask-snap support Mar 17, 2024
@naorye2 naorye2 marked this pull request as ready for review April 9, 2024 11:26
@naorye2 naorye2 requested review from stanleyyconsensys, naorye2 and avimak and removed request for stanleyyconsensys and naorye2 April 9, 2024 11:26
Copy link

@stanleyyconsensys stanleyyconsensys left a comment

Choose a reason for hiding this comment

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

LGTM, A small change request on createMetaMaskProviderWrapper

packages/core/src/wallet/metamaskBridge.ts Outdated Show resolved Hide resolved
packages/core/src/wallet/metamaskBridge.ts Outdated Show resolved Hide resolved
name: "MetaMaskStarknetSnapWallet",
alias: "MetaMaskStarknetSnapWallet",
entry:
"https://s3.eu-central-1.amazonaws.com/dev.snaps.consensys.io/get-starknet/remoteEntry.js",

Choose a reason for hiding this comment

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

shall we move this URL in discovery.ts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@stanleyyconsensys
I am not sure this url need to be part of the discovery as this is relevant only for metamask.
In version 4 there is a definition of Virtual Wallet the includes this url.

@@ -75,6 +76,8 @@ export function getStarknet(
}
const lastConnectedStore = storageFactoryImplementation("gsw-last")

injectMetamaskBridge()
Copy link
Collaborator

Choose a reason for hiding this comment

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

pass ssrSafeWindow to avoid assuming window availability later inside injectMetamaskBridge

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fixed.


async function hasSnapSupport(provider: MetaMaskProvider) {
try {
await provider.request({ method: "wallet_getSnaps" })
Copy link
Collaborator

Choose a reason for hiding this comment

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

use non-api call to check for starknet support (not just and snaps?)

Choose a reason for hiding this comment

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

hi @avimak the life cycle of a snap is working like that way

  1. you detect where you have a install metamask
  2. you detect where you have an correct version of metamask -> which using similar method as above
  3. then you ask metamask to install the starknet snap -> that should be trigger by enable() / or any similar method

so you can only cehck if the metamask support starknet by first checking if it has supported snap

In addtional, metamask does not inject any extra method to the provider (window.ethereum) to verify if it is support snap, it means, you must using request method to determined

does it help to clarify your questions?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@avimak
After consulting with @stanleyyconsensys we decided to remove that check.

@naorye2 naorye2 requested a review from avimak April 16, 2024 18:13
@dan-ziv dan-ziv merged commit 4d359d8 into starknet-io:master Apr 24, 2024
1 check passed
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.

5 participants