-
Notifications
You must be signed in to change notification settings - Fork 542
Feat: Metamask SDK integration #1908
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
Merged
Adamj1232
merged 24 commits into
thirdweb-dev:develop
from
abretonc7s:feat/metamask-sdk
Oct 23, 2023
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
48d4e82
Merge pull request #1960 from blocknative/release/2.24.14
Adamj1232 c23acc3
feat: initial commit - sdk integration
abretonc7s be4e0f7
feat: metamask sdk working integration
abretonc7s fe59103
feat: update metamask sdk 0.6.2
abretonc7s 6b118cd
feat: update example
abretonc7s 7cdb93c
feat: cleanup imports
abretonc7s 3bca6a8
feat: remove unused code
abretonc7s 50bf46b
feat: cleanup for PR
abretonc7s dd4d74f
Update packages/core/src/disconnect.ts
Adamj1232 58c05a8
Update packages/core/src/disconnect.ts
Adamj1232 0473911
Update packages/metamask/package.json
Adamj1232 fb2ddd3
Add MetaMask sdk to demo package for testing
Adamj1232 2431852
Remove yarn.lock from MM package
Adamj1232 5dd5311
Update MetaMask provider to import modules dynamically on select of M…
Adamj1232 72e2c40
Return docs yarn lock
Adamj1232 f4d4781
Reorder MM wallet to be first along with injected wallets so the SDK …
Adamj1232 94b4b1d
Get upstream docs yarn.lock
Adamj1232 263e4cb
feat: upgrade sdk to 0.10.
abretonc7s 809ef4b
Merge remote-tracking branch 'upstream/develop' into feat/metamask-sdk
Adamj1232 d893a1c
Add MetaMask to wallet docs
Adamj1232 6db7d39
Update docs pages
Adamj1232 4faf65e
Refine docs and README
Adamj1232 46ca8e2
Add metamask package to docs
Adamj1232 8494451
Revert changes to docs yarn.lock
Adamj1232 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| nodejs 18.16.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
docs/src/routes/docs/[...4]wallets/[...18]metamask/+page.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| --- | ||
| title: MetaMask | ||
| --- | ||
|
|
||
| # {$frontmatter.title} | ||
|
|
||
| ## Wallet module for connecting MetaMask Wallet SDK to web3-onboard | ||
|
|
||
| The MetaMask Web3-Onboard module provides a reliable, secure, and seamless connection from your dapp to the MetaMask browser extension and MetaMask Mobile. | ||
| See [MetaMask SDK Developer Docs](https://github.com/MetaMask/metamask-sdk) | ||
|
|
||
| ::: | ||
|
|
||
| ## Install | ||
|
|
||
| <Tabs values={['yarn', 'npm']}> | ||
| <TabPanel value="yarn"> | ||
|
|
||
| ```sh copy | ||
| yarn add @web3-onboard/metamask | ||
| ``` | ||
|
|
||
| </TabPanel> | ||
| <TabPanel value="npm"> | ||
|
|
||
| ```sh copy | ||
| npm install @web3-onboard/metamask | ||
| ``` | ||
|
|
||
| </TabPanel> | ||
| </Tabs> | ||
|
|
||
| ## Options | ||
|
|
||
| ```typescript | ||
| // For a complete list of options check https://github.com/MetaMask/metamask-sdk | ||
| interface MetaMaskSDKOptions { | ||
| dappMetadata: { | ||
| url?: string; | ||
| name?: string; | ||
| base64Icon?: string; | ||
| }, | ||
| /** | ||
| * If MetaMask browser extension is detected, directly use it without prompting the user. | ||
| */ | ||
| extensionOnly?: boolean; | ||
| } | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ```typescript | ||
| import Onboard from '@web3-onboard/core' | ||
| import metamaskSDK from '@web3-onboard/metamask' | ||
|
|
||
| // initialize the module with options | ||
| const metamaskSDKWallet = metamaskSDK({options: { | ||
| extensionOnly: false, | ||
| dappMetadata: { | ||
| name: 'Demo Web3Onboard' | ||
| } | ||
| }}) | ||
|
|
||
| const onboard = Onboard({ | ||
| // ... other Onboard options | ||
| wallets: [ | ||
| metamaskSDKWallet | ||
| //... other wallets | ||
| ] | ||
| }) | ||
|
|
||
| const connectedWallets = await onboard.connectWallet() | ||
| console.log(connectedWallets) | ||
| ``` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
| import xdefiWalletModule from '@web3-onboard/xdefi' | ||
| import zealModule from '@web3-onboard/zeal' | ||
| import transactionPreviewModule from '@web3-onboard/transaction-preview' | ||
| import metamaskSDK from '@web3-onboard/metamask' | ||
| import enkryptModule from '@web3-onboard/enkrypt' | ||
| import mewWalletModule from '@web3-onboard/mew-wallet' | ||
| import uauthModule from '@web3-onboard/uauth' | ||
|
|
@@ -79,7 +80,11 @@ | |
| // displayUnavailable: true, | ||
| // || | ||
| // display specific unavailable wallets | ||
| displayUnavailable: [ProviderLabel.MetaMask, ProviderLabel.Trust, ProviderLabel.Phantom] | ||
| displayUnavailable: [ | ||
| ProviderLabel.MetaMask, | ||
| ProviderLabel.Trust, | ||
| ProviderLabel.Phantom | ||
| ] | ||
| // but only show Binance and Bitski wallet if they are available | ||
| // filter: { | ||
| // [ProviderLabel.Binance]: 'unavailable', | ||
|
|
@@ -116,6 +121,18 @@ | |
|
|
||
| const coinbaseWallet = coinbaseModule() | ||
|
|
||
| const metamaskSDKWallet = metamaskSDK({ | ||
| options: { | ||
| extensionOnly: false, | ||
| i18nOptions: { | ||
| enabled: true | ||
| }, | ||
| dappMetadata: { | ||
| name: 'Demo Web3Onboard' | ||
| } | ||
| } | ||
| }) | ||
|
|
||
| const walletConnect = walletConnectModule({ | ||
| handleUri: uri => console.log(uri), | ||
| projectId: 'f6bd6e2911b56f5ac3bc8b2d0e2d7ad5', | ||
|
|
@@ -144,14 +161,14 @@ | |
| const keepkey = keepkeyModule() | ||
| const keystone = keystoneModule() | ||
| const safe = safeModule() | ||
| const tallyho = tallyHoModule() | ||
| const xdefi = xdefiWalletModule() | ||
| const zeal = zealModule() | ||
| const phantom = phantomModule() | ||
| const trust = trustModule() | ||
| const frontier = frontierModule() | ||
| const cedeStore = cedeStoreModule() | ||
| const blocto = bloctoModule() | ||
| const tallyho = tallyHoModule() | ||
|
|
||
| const trezorOptions = { | ||
| email: '[email protected]', | ||
|
|
@@ -193,6 +210,7 @@ | |
|
|
||
| const onboard = Onboard({ | ||
| wallets: [ | ||
| metamaskSDKWallet, | ||
| injected, | ||
| ledger, | ||
| trezor, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5580,6 +5580,13 @@ cross-fetch@^4.0.0: | |
| dependencies: | ||
| node-fetch "^2.6.12" | ||
|
|
||
| cross-fetch@^3.1.6: | ||
| version "3.1.8" | ||
| resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.8.tgz#0327eba65fd68a7d119f8fb2bf9334a1a7956f82" | ||
| integrity sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg== | ||
| dependencies: | ||
| node-fetch "^2.6.12" | ||
|
|
||
| cross-spawn@^7.0.1, cross-spawn@^7.0.3: | ||
| version "7.0.3" | ||
| resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" | ||
|
|
@@ -10671,6 +10678,11 @@ tslib@^2.0.0, tslib@^2.1.0, tslib@^2.3.0, tslib@^2.3.1, tslib@^2.4.0: | |
| resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" | ||
| integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== | ||
|
|
||
| tslib@^2.3.1: | ||
| version "2.5.0" | ||
| resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf" | ||
| integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg== | ||
|
|
||
| tunnel-agent@^0.6.0: | ||
| version "0.6.0" | ||
| resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" | ||
|
|
@@ -10807,6 +10819,15 @@ usb@^2.9.0: | |
| node-addon-api "^7.0.0" | ||
| node-gyp-build "^4.5.0" | ||
|
|
||
| usb@^2.9.0: | ||
| version "2.10.0" | ||
| resolved "https://registry.yarnpkg.com/usb/-/usb-2.10.0.tgz#c582b62d709c85d63c76a9864fc670d6ad65928b" | ||
| integrity sha512-FbzLhziRs4rHnTDZX+eKl9yBVjiuMNX+opl0r8TFPj265PuNtqak3qw5c8DLpBwq3z1JZgAOgm5Nn7cV30nCxg== | ||
| dependencies: | ||
| "@types/w3c-web-usb" "^1.0.6" | ||
| node-addon-api "^7.0.0" | ||
| node-gyp-build "^4.5.0" | ||
|
|
||
| [email protected]: | ||
| version "1.2.0" | ||
| resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz#7dbefd6ef3fe4e767a0cf5d7287aacfb5846928a" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # @web3-onboard/metamask | ||
|
|
||
| ## Wallet module for connecting MetaMask Wallet SDK to web3-onboard | ||
| The MetaMask Web3-Onboard module provides a reliable, secure, and seamless connection from your dapp to the MetaMask browser extension and MetaMask Mobile. | ||
| See [MetaMask SDK Developer Docs](https://github.com/MetaMask/metamask-sdk) | ||
|
|
||
| ### Install | ||
|
|
||
| `npm i @web3-onboard/metamask` | ||
|
|
||
| ## Options | ||
|
|
||
| ```typescript | ||
| // For a complete list of options check https://github.com/MetaMask/metamask-sdk | ||
| interface MetaMaskSDKOptions { | ||
| dappMetadata: { | ||
| url?: string; | ||
| name?: string; | ||
| base64Icon?: string; | ||
| }, | ||
| /** | ||
| * If MetaMask browser extension is detected, directly use it without prompting the user. | ||
| */ | ||
| extensionOnly?: boolean; | ||
| } | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ```typescript | ||
| import Onboard from '@web3-onboard/core' | ||
| import metamaskSDK from '@web3-onboard/metamask' | ||
|
|
||
| // initialize the module with options | ||
| const metamaskSDKWallet = metamaskSDK({options: { | ||
| extensionOnly: false, | ||
| dappMetadata: { | ||
| name: 'Demo Web3Onboard' | ||
| } | ||
| }}) | ||
|
|
||
| const onboard = Onboard({ | ||
| // ... other Onboard options | ||
| wallets: [ | ||
| metamaskSDKWallet | ||
| //... other wallets | ||
| ] | ||
| }) | ||
|
|
||
| const connectedWallets = await onboard.connectWallet() | ||
| console.log(connectedWallets) | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| { | ||
| "name": "@web3-onboard/metamask", | ||
| "version": "2.0.0-alpha.1", | ||
| "description": "MetaMask SDK wallet module for connecting to Web3-Onboard. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.", | ||
| "keywords": [ | ||
| "Ethereum", | ||
| "Web3", | ||
| "EVM", | ||
| "dapp", | ||
| "Multichain", | ||
| "Wallet", | ||
| "Transaction", | ||
| "Provider", | ||
| "Hardware Wallet", | ||
| "Notifications", | ||
| "React", | ||
| "Svelte", | ||
| "Vue", | ||
| "Next", | ||
| "Nuxt", | ||
| "MetaMask", | ||
| "Coinbase", | ||
| "WalletConnect", | ||
| "Ledger", | ||
| "Trezor", | ||
| "Connect Wallet", | ||
| "Ethereum Hooks", | ||
| "Blocknative", | ||
| "Mempool", | ||
| "pending", | ||
| "confirmed", | ||
| "Injected Wallet", | ||
| "Crypto", | ||
| "Crypto Wallet" | ||
| ], | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/blocknative/web3-onboard.git", | ||
| "directory": "packages/metamask" | ||
| }, | ||
| "homepage": "https://onboard.blocknative.com", | ||
| "bugs": "https://github.com/blocknative/web3-onboard/issues", | ||
| "module": "dist/index.js", | ||
| "browser": "dist/index.js", | ||
| "main": "dist/index.js", | ||
| "type": "module", | ||
| "typings": "dist/index.d.ts", | ||
| "files": [ | ||
| "dist" | ||
| ], | ||
| "license": "MIT", | ||
| "scripts": { | ||
| "build": "tsc", | ||
| "dev": "tsc -w", | ||
| "type-check": "tsc --noEmit" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/node": "^20.5.7", | ||
| "ts-node": "^10.9.1", | ||
| "typescript": "^5.2.2" | ||
| }, | ||
| "dependencies": { | ||
| "@metamask/sdk": "^0.10.0", | ||
| "@web3-onboard/common": "^2.3.3" | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to explain a little more here about what can be done with the SDK, connect mobile MM to desktop dapps, etc
I will get any additional verbiage added to our docs pages as well!