From 546d699b5317c505ceeed283bae7af3f0d7cb0d4 Mon Sep 17 00:00:00 2001 From: Adam Carpenter Date: Wed, 1 Nov 2023 10:01:23 -0600 Subject: [PATCH 1/4] Update docs causing build errors --- docs/package.json | 2 +- .../[...1]overview/[...1]introduction/+page.md | 2 +- .../docs/[...3]modules/[...4]solid/+page.md | 4 ++-- .../docs/[...4]wallets/[...18]metamask/+page.md | 16 +++++++++++----- docs/yarn.lock | 8 ++++---- packages/metamask/README.md | 8 +++++++- packages/metamask/src/index.ts | 1 + 7 files changed, 27 insertions(+), 14 deletions(-) diff --git a/docs/package.json b/docs/package.json index d77f94771..f6d5d0cc8 100644 --- a/docs/package.json +++ b/docs/package.json @@ -70,7 +70,7 @@ "@web3-onboard/keystone": "^2.3.7", "@web3-onboard/ledger": "^2.5.1", "@web3-onboard/magic": "^2.1.7", - "@web3-onboard/metamask": "^2.0.0-alpha.1", + "@web3-onboard/metamask": "^2.0.1-alpha.1", "@web3-onboard/mew-wallet": "^2.0.4", "@web3-onboard/phantom": "^2.0.3", "@web3-onboard/portis": "^2.1.7", diff --git a/docs/src/routes/docs/[...1]overview/[...1]introduction/+page.md b/docs/src/routes/docs/[...1]overview/[...1]introduction/+page.md index 7959c3ce9..91b7302c5 100644 --- a/docs/src/routes/docs/[...1]overview/[...1]introduction/+page.md +++ b/docs/src/routes/docs/[...1]overview/[...1]introduction/+page.md @@ -170,7 +170,7 @@ We recommend you add the [Core Repo](../../modules/core.md#install) and consider **SDK Wallets** - [Arcana Auth](../../wallets/arcana.md#install) -- [Blocto](../../docs/wallets/blocto.md#install) +- [Blocto](../../wallets/blocto.md#install) - [Coinbase](../../wallets/coinbase.md#install) - [Fortmatic](../../wallets/fortmatic.md#install) - [Frame](../../wallets/frame.md#install) diff --git a/docs/src/routes/docs/[...3]modules/[...4]solid/+page.md b/docs/src/routes/docs/[...3]modules/[...4]solid/+page.md index 6af18cd77..60dd592ee 100644 --- a/docs/src/routes/docs/[...3]modules/[...4]solid/+page.md +++ b/docs/src/routes/docs/[...3]modules/[...4]solid/+page.md @@ -78,7 +78,7 @@ if (connectedWallet) { ### `init` -The `init` function initializes `web3-onboard` and makes it available to the `useOnboard()` composable. For references check out the [initialization docs for `@web3-onboard/core`](../core/README.md#initialization) +The `init` function initializes `web3-onboard` and makes it available to the `useOnboard()` composable. For references check out the [initialization docs for `@web3-onboard/core`](/docs/modules/core#initialization) #### Example usage @@ -126,7 +126,7 @@ const { ### `connectWallet` -Function to open the onboard modal and connect to a wallet provider. For reference check out the [connecting a wallet for `@web3-onboard/core`](../core/README.md#connecting-a-wallet) +Function to open the onboard modal and connect to a wallet provider. For reference check out the [connecting a wallet for `@web3-onboard/core`](/docs/modules/core#connecting-a-wallet) #### Example usage diff --git a/docs/src/routes/docs/[...4]wallets/[...18]metamask/+page.md b/docs/src/routes/docs/[...4]wallets/[...18]metamask/+page.md index c88a05891..17b4d6064 100644 --- a/docs/src/routes/docs/[...4]wallets/[...18]metamask/+page.md +++ b/docs/src/routes/docs/[...4]wallets/[...18]metamask/+page.md @@ -9,6 +9,10 @@ title: MetaMask 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) +:::admonition type=tip +When utilizing this package alongside the `@web3-onboard/injected-wallets` module, ensure to list this package prior to the initialized injected-wallets module within the wallets list of the Web3-Onboard init. + +This order prioritizes the SDK when a MetaMask browser wallet is detected, allowing the SDK to take precedence. ::: ## Install @@ -36,14 +40,14 @@ npm install @web3-onboard/metamask // For a complete list of options check https://github.com/MetaMask/metamask-sdk interface MetaMaskSDKOptions { dappMetadata: { - url?: string; - name?: string; - base64Icon?: string; - }, + url?: string + name?: string + base64Icon?: string + } /** * If MetaMask browser extension is detected, directly use it without prompting the user. */ - extensionOnly?: boolean; + extensionOnly?: boolean } ``` @@ -66,6 +70,8 @@ const onboard = Onboard({ wallets: [ metamaskSDKWallet //... other wallets + // Make sure to pass in before or above the injected-wallets module + injectedWalletModule ] }) diff --git a/docs/yarn.lock b/docs/yarn.lock index 80130798d..913d7197e 100644 --- a/docs/yarn.lock +++ b/docs/yarn.lock @@ -4314,10 +4314,10 @@ magic-sdk "^8.1.0" rxjs "^7.5.2" -"@web3-onboard/metamask@^2.0.0-alpha.1": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@web3-onboard/metamask/-/metamask-2.0.0.tgz#c2dae6413611e530bfe904335750e25728db0779" - integrity sha512-tZSGa1p9yRScGK0qSAjtvZK8pAZOL6B5j+OutAYLs5WpEFZiXxiJUkJwiEhlL0YI78RMA5K3/4GhY6GTC6ruiA== +"@web3-onboard/metamask@^2.0.1-alpha.1": + version "2.0.1-alpha.2" + resolved "https://registry.yarnpkg.com/@web3-onboard/metamask/-/metamask-2.0.1-alpha.2.tgz#b5371a55f43ba7ef70a73e8febf7d252bd47322e" + integrity sha512-KUcblErwCRpL4LvM8PJvKHND1ePmiDbphiizdmwiOpNxEQ6VGR3S0eIZq1iKv2hxkImdMtprHni426W4w7Q8RA== dependencies: "@metamask/sdk" "^0.10.0" "@web3-onboard/common" "^2.3.3" diff --git a/packages/metamask/README.md b/packages/metamask/README.md index 34ade5df5..5958ccee8 100644 --- a/packages/metamask/README.md +++ b/packages/metamask/README.md @@ -8,6 +8,10 @@ See [MetaMask SDK Developer Docs](https://github.com/MetaMask/metamask-sdk) `npm i @web3-onboard/metamask` +### If using this package with the `@web3-onboard/injected-wallets` module +_When utilizing this package alongside the `@web3-onboard/injected-wallets` module, ensure to list this package prior to the initialized injected-wallets module within the wallets list of the Web3-Onboard init._ +_This order prioritizes the SDK when a MetaMask browser wallet is detected, allowing the SDK to take precedence._ + ## Options ```typescript @@ -42,8 +46,10 @@ const metamaskSDKWallet = metamaskSDK({options: { const onboard = Onboard({ // ... other Onboard options wallets: [ - metamaskSDKWallet + metamaskSDKWallet, //... other wallets + // Make sure to pass in before or above the injected-wallets module + injectedWalletModule ] }) diff --git a/packages/metamask/src/index.ts b/packages/metamask/src/index.ts index 5bc7e0779..5d9993f35 100644 --- a/packages/metamask/src/index.ts +++ b/packages/metamask/src/index.ts @@ -1,5 +1,6 @@ import type { MetaMaskSDKOptions } from '@metamask/sdk' import type { WalletInit } from '@web3-onboard/common' +export type { MetaMaskSDKOptions } from '@metamask/sdk' function metamask({ options From 1a30597be4d7bdd74090ac8e3b1d4b88e634dcfc Mon Sep 17 00:00:00 2001 From: Adam Carpenter Date: Wed, 1 Nov 2023 10:13:05 -0600 Subject: [PATCH 2/4] yarn docs --- docs/yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/yarn.lock b/docs/yarn.lock index 913d7197e..17ebbb403 100644 --- a/docs/yarn.lock +++ b/docs/yarn.lock @@ -2504,9 +2504,9 @@ integrity sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw== "@react-native-async-storage/async-storage@^1.17.11": - version "1.19.3" - resolved "https://registry.yarnpkg.com/@react-native-async-storage/async-storage/-/async-storage-1.19.3.tgz#ad5fe3ed0a82d4624aa4500321c1e09c02daeb46" - integrity sha512-CwGfoHCWdPOTPS+2fW6YRE1fFBpT9++ahLEroX5hkgwyoQ+TkmjOaUxixdEIoVua9Pz5EF2pGOIJzqOTMWfBlA== + version "1.19.4" + resolved "https://registry.yarnpkg.com/@react-native-async-storage/async-storage/-/async-storage-1.19.4.tgz#f3c8648fa6d06f085e30f68f0810ea8e53165ace" + integrity sha512-Stj6Q1v5knTMaYOinEEJl030SzJWEhqW+IYI5uA9Nl9Olo+vDUecmQXqpIxELucwOGDJ8KwvI0UL22UHudwZeQ== dependencies: merge-options "^3.0.4" From e7a7a3557ad1bef59bad50e8f5bac812ea07982a Mon Sep 17 00:00:00 2001 From: Adam Carpenter Date: Wed, 1 Nov 2023 10:33:55 -0600 Subject: [PATCH 3/4] Fix metamask sdk with patch on local store item causing issues --- packages/demo/package.json | 2 +- packages/metamask/package.json | 4 ++-- packages/metamask/src/index.ts | 4 +++- yarn.lock | 18 +++++++++--------- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/demo/package.json b/packages/demo/package.json index da324c486..9f7f9bcd9 100644 --- a/packages/demo/package.json +++ b/packages/demo/package.json @@ -46,7 +46,7 @@ "@web3-onboard/keystone": "^2.3.7", "@web3-onboard/ledger": "^2.5.2", "@web3-onboard/magic": "^2.1.6", - "@web3-onboard/metamask": "^2.0.1-alpha.1", + "@web3-onboard/metamask": "^2.0.1-alpha.3", "@web3-onboard/mew-wallet": "^2.0.3", "@web3-onboard/phantom": "^2.0.3", "@web3-onboard/portis": "^2.1.6", diff --git a/packages/metamask/package.json b/packages/metamask/package.json index f2127ab26..7e5b7495c 100644 --- a/packages/metamask/package.json +++ b/packages/metamask/package.json @@ -1,6 +1,6 @@ { "name": "@web3-onboard/metamask", - "version": "2.0.1-alpha.2", + "version": "2.0.1-alpha.3", "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", @@ -60,7 +60,7 @@ "typescript": "^5.2.2" }, "dependencies": { - "@metamask/sdk": "^0.10.0", + "@metamask/sdk": "^0.10.1", "@web3-onboard/common": "^2.3.3" } } diff --git a/packages/metamask/src/index.ts b/packages/metamask/src/index.ts index 5d9993f35..917368756 100644 --- a/packages/metamask/src/index.ts +++ b/packages/metamask/src/index.ts @@ -18,8 +18,10 @@ function metamask({ const { createEIP1193Provider } = await import('@web3-onboard/common') const { default: metaMask, MetaMaskSDK } = await import('@metamask/sdk') - let MetaMaskSDKConstructor + // Patch issue with MetaMask SDK, remove after SDK is fixed + localStorage.removeItem('providerType') + let MetaMaskSDKConstructor if (!MetaMaskSDK) { // @ts-ignore MetaMaskSDKConstructor = metaMask.MetaMaskSDK diff --git a/yarn.lock b/yarn.lock index 1dc7b3cae..4aa7c810e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2197,10 +2197,10 @@ resolved "https://registry.yarnpkg.com/@metamask/safe-event-emitter/-/safe-event-emitter-3.0.0.tgz#8c2b9073fe0722d48693143b0dc8448840daa3bd" integrity sha512-j6Z47VOmVyGMlnKXZmL0fyvWfEYtKWCA9yGZkU3FCsGZUT5lHGmvaV9JA5F2Y+010y7+ROtR3WMXIkvl/nVzqQ== -"@metamask/sdk-communication-layer@0.10.0": - version "0.10.0" - resolved "https://registry.yarnpkg.com/@metamask/sdk-communication-layer/-/sdk-communication-layer-0.10.0.tgz#897ed0e1b881517e09d40a3e9c9a323c1a9b11b5" - integrity sha512-Hi8sySaP+dyjd9+SQUtTnmYFRjKWgNo371yWcfOx1vogpP5YwD4VaHDbPQr5rWKDGXb/x1wai6UzPkMqHbllwQ== +"@metamask/sdk-communication-layer@0.10.1": + version "0.10.1" + resolved "https://registry.yarnpkg.com/@metamask/sdk-communication-layer/-/sdk-communication-layer-0.10.1.tgz#95c6a1786dcd7a64c54a8e5cbd11489aa708b074" + integrity sha512-lWeh1PUq114h1/44llZgBcG51uOEi5dHjnNHlcYK9Sjq/iJ4s3mp0y39DGXHEs2r6rJQRyQpryoYyPsQTF2Imw== dependencies: cross-fetch "^3.1.5" date-fns "^2.29.3" @@ -2222,15 +2222,15 @@ react-dom "^18.2.0" react-i18next "^13.2.2" -"@metamask/sdk@^0.10.0": - version "0.10.0" - resolved "https://registry.yarnpkg.com/@metamask/sdk/-/sdk-0.10.0.tgz#3eb169ee07e95e232ebf3f3ef27906e28423fdaa" - integrity sha512-a6H51cKjiWd2gb4ugjl4zP+6ZRtcSc8cwtXUSiKKlXwa//54nnx7OzCNOjbPJFnnqT51rs3v9kSoRhOgS04ezQ== +"@metamask/sdk@^0.10.1": + version "0.10.1" + resolved "https://registry.yarnpkg.com/@metamask/sdk/-/sdk-0.10.1.tgz#3a9d029d5b16684de59d6ee34401d1165dc1a740" + integrity sha512-cxTWnniZG0cmvaFxf/WAf4SqPw4lHrt16cMMiefAJAsNyL3aPUh8M26fh29EdftIhUXytT9ErNGW+Nf5V4EsCQ== dependencies: "@metamask/onboarding" "^1.0.1" "@metamask/post-message-stream" "^6.1.0" "@metamask/providers" "^10.2.1" - "@metamask/sdk-communication-layer" "0.10.0" + "@metamask/sdk-communication-layer" "0.10.1" "@metamask/sdk-install-modal-web" "0.10.0" "@react-native-async-storage/async-storage" "^1.17.11" "@types/dom-screen-wake-lock" "^1.0.0" From dce2bc5282c20440b4c4e23ff86a5a16458574cb Mon Sep 17 00:00:00 2001 From: Adam Carpenter Date: Wed, 1 Nov 2023 10:52:01 -0600 Subject: [PATCH 4/4] Add null check for MMSDK --- packages/metamask/src/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/metamask/src/index.ts b/packages/metamask/src/index.ts index 917368756..6dc9d49db 100644 --- a/packages/metamask/src/index.ts +++ b/packages/metamask/src/index.ts @@ -29,6 +29,10 @@ function metamask({ MetaMaskSDKConstructor = MetaMaskSDK } + if (!MetaMaskSDKConstructor) { + throw new Error('Error importing and initializing MetaMask SDK') + } + const sdk = new MetaMaskSDKConstructor({ ...options, dappMetadata: {