-
Notifications
You must be signed in to change notification settings - Fork 115
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: implement metamask starknet snap #206
feat: implement metamask starknet snap #206
Conversation
fix: fix type errors
- add network manage method - refactor snap instance
@stanleyyconsensys |
hi @naorye2 thanks for the review as snap is a JS script that run on metamask, it act like a serverless API, hence, the script itself cant inject anything |
@stanleyyconsensys got it. I suggest the following:
WDYT? |
thank you for the advice the major different is, when we using async load script, there may be some issue from user ENV, may blocking the access of the script with npm package, get-starknet would just need to maintain the version of our package, but it may also create a dependency on us how does it sound like to you? |
@stanleyyconsensys |
thank you for the feedback |
@stanleyyconsensys
|
@naorye2 , the detectEthereumProvider can be useful if the client browser only install metamask, but in some edge case, if the user has installed some wallets which overrided the Ethereum object, it will lead to using the wrong provider i would suggest you can combine both way to inject the provider, may i ask where will you inject the bootstrapMetamaskBridge? |
i think you can try that way first, and i will test it by enabling Phantom and coinbase wallet later |
@naorye2 here is the consensys package for supporting get-starknet, for your information, the version of that module doesn't needed to corresponding with the snap version Hence, when a snap version update, it is not always needed to update the version of the module therefore, we have add a snapVersion parameter when constructing the MetaMaskSnapWallet for flexible changes the current beta version for the snap will be '2.3.0-staging' it is a dev version |
@stanleyyconsensys Please review my pr #208. |
Sure, let me export all the type and component for you |
Handled here #208 |
Description:
the PR is to add metamask starknet snap as a wallet options on the get-starknet UI and return a compilable wallet object to get-starknet as well as the other wallets
the concept is same with the other PR: #195
Concept:
Due to MetaMask limitation, the SNAP itself can not directly inject a object into window instance, and snap itself is communicated via JSONRPC, SNAP can only return JSON-serializable response
https://docs.metamask.io/snaps/reference/rpc-api/
Hence we create a wallet object in get-starknet codebase, the object itself will setup as a bridge to communicate with SNAP via JSONRPC
We then runtime inject this object into get-starknet
Detail implementation
MetaMaskSnap
to communicate with the snap via the window ethereum providerMetaMaskAccount
to extend theAccount
class from starknet package, and overriding execute, signMessage, declare withMetaMaskSnap
MetaMaskSigner
to implement theSignerInterface
interface from starknet package, and implement all member methods withMetaMaskSnap
MetaMaskSnapWallet
to implement the same API asIStarknetWindowObject
enable
method trigger, it will request user to install starknet snap into metamask if not installedMetaMaskSnapWallet
whengetAvailableWallets, getPreAuthorizedWallets, getDiscoveryWallets, getLastConnectedWallet
method are consuming