From a8bd98900cac28f37844b2bbdaf9139c3ba9b6ac Mon Sep 17 00:00:00 2001 From: Samy RABAH-MONTAROU Date: Thu, 1 Feb 2024 09:57:03 +0100 Subject: [PATCH 1/3] load ledger connect kit via package instead of loader --- packages/demo/package.json | 2 +- packages/ledger/package.json | 4 +-- packages/ledger/src/v1.ts | 13 +++------ packages/ledger/src/v2.ts | 13 +++------ yarn.lock | 55 ++++++++++++++++++++++++++++++++++++ 5 files changed, 66 insertions(+), 21 deletions(-) diff --git a/packages/demo/package.json b/packages/demo/package.json index e70082347..d06f3759b 100644 --- a/packages/demo/package.json +++ b/packages/demo/package.json @@ -45,7 +45,7 @@ "@web3-onboard/injected-wallets": "^2.10.11", "@web3-onboard/keepkey": "^2.3.7", "@web3-onboard/keystone": "^2.3.7", - "@web3-onboard/ledger": "^2.5.2", + "@web3-onboard/ledger": "^2.5.3-alpha.1", "@web3-onboard/magic": "^2.1.6", "@web3-onboard/metamask": "^2.0.2", "@web3-onboard/mew-wallet": "^2.0.3", diff --git a/packages/ledger/package.json b/packages/ledger/package.json index 31eec94aa..a2b08269c 100644 --- a/packages/ledger/package.json +++ b/packages/ledger/package.json @@ -1,6 +1,6 @@ { "name": "@web3-onboard/ledger", - "version": "2.5.2", + "version": "2.5.3-alpha.1", "description": "Ledger hardware wallet module for connecting to Web3-Onboard. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardized 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 @@ }, "dependencies": { "@ethersproject/providers": "5.5.0", - "@ledgerhq/connect-kit-loader": "^1.1.0", + "@ledgerhq/connect-kit": "1.1.12", "@walletconnect/client": "^1.8.0", "@walletconnect/ethereum-provider": "2.9.1", "@walletconnect/modal": "2.6.1", diff --git a/packages/ledger/src/v1.ts b/packages/ledger/src/v1.ts index c8589c011..f3fb2d9d5 100644 --- a/packages/ledger/src/v1.ts +++ b/packages/ledger/src/v1.ts @@ -7,7 +7,7 @@ import { ChainId, AccountAddress } from '@web3-onboard/common' -import type { EthereumProvider } from '@ledgerhq/connect-kit-loader' +import type { EthereumProvider } from '@ledgerhq/connect-kit/dist/umd/index.d.ts' import type { StaticJsonRpcProvider as StaticJsonRpcProviderType } from '@ethersproject/providers' import WalletConnect from '@walletconnect/client' import { isHexString, LedgerOptionsWCv1 } from './index.js' @@ -20,18 +20,13 @@ function ledger( label: 'Ledger', getIcon: async () => (await import('./icon.js')).default, getInterface: async ({ chains, EventEmitter }: GetInterfaceHelpers) => { - const { - loadConnectKit, - SupportedProviders, - SupportedProviderImplementations - } = await import('@ledgerhq/connect-kit-loader') + const connectKit = await import('@ledgerhq/connect-kit/dist/umd') - const connectKit = await loadConnectKit() if (options.enableDebugLogs) { connectKit.enableDebugLogs() } const checkSupportResult = connectKit.checkSupport({ - providerType: SupportedProviders.Ethereum, + providerType: connectKit.SupportedProviders.Ethereum, chainId: options?.chainId, infuraId: options?.infuraId, rpc: options?.rpc @@ -44,7 +39,7 @@ function ledger( // return the Ledger Extension provider if ( checkSupportResult.providerImplementation === - SupportedProviderImplementations.LedgerConnect + connectKit.SupportedProviderImplementations.LedgerConnect ) { return { provider: instance diff --git a/packages/ledger/src/v2.ts b/packages/ledger/src/v2.ts index eefaf4554..1491c3d7c 100644 --- a/packages/ledger/src/v2.ts +++ b/packages/ledger/src/v2.ts @@ -4,7 +4,7 @@ import { EIP1193Provider, ProviderAccounts } from '@web3-onboard/common' -import type { EthereumProvider as LedgerEthereumProvider } from '@ledgerhq/connect-kit-loader' +import type { EthereumProvider as LedgerEthereumProvider } from '@ledgerhq/connect-kit/dist/umd/index.d.ts' import { isHexString, LedgerOptionsWCv2 } from './index.js' import type { JQueryStyleEventEmitter } from 'rxjs/internal/observable/fromEvent' @@ -30,13 +30,8 @@ function ledger(options?: LedgerOptionsWCv2): WalletInit { label: 'Ledger', getIcon: async () => (await import('./icon.js')).default, getInterface: async ({ chains, EventEmitter }) => { - const { - loadConnectKit, - SupportedProviders, - SupportedProviderImplementations - } = await import('@ledgerhq/connect-kit-loader') + const connectKit = await import('@ledgerhq/connect-kit/dist/umd') - const connectKit = await loadConnectKit() if (options?.enableDebugLogs) { connectKit.enableDebugLogs() } @@ -54,7 +49,7 @@ function ledger(options?: LedgerOptionsWCv2): WalletInit { : defaultOptionalMethods const checkSupportResult = connectKit.checkSupport({ - providerType: SupportedProviders.Ethereum, + providerType: connectKit.SupportedProviders.Ethereum, walletConnectVersion: 2, projectId: options?.projectId, chains: requiredChains, @@ -79,7 +74,7 @@ function ledger(options?: LedgerOptionsWCv2): WalletInit { // return the Ledger Extension provider if ( checkSupportResult.providerImplementation === - SupportedProviderImplementations.LedgerConnect + connectKit.SupportedProviderImplementations.LedgerConnect ) { return { provider: instance diff --git a/yarn.lock b/yarn.lock index b741602b0..b7cde201a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2742,6 +2742,14 @@ resolved "https://registry.yarnpkg.com/@ledgerhq/connect-kit-loader/-/connect-kit-loader-1.1.0.tgz#10343b78ef13436818bf3453568a559c0eeb9d48" integrity sha512-HUy12FEczoWY2FPubnsm1uOA8tkVWc0j90i47suThV3C9NL2xx69ZAIEU3Ytzs2bwLek9S1Q2S1VQJvA+3Ygkg== +"@ledgerhq/connect-kit@1.1.12": + version "1.1.12" + resolved "https://registry.yarnpkg.com/@ledgerhq/connect-kit/-/connect-kit-1.1.12.tgz#e6782c207a2c8d1f4db603d090c0bbecef02e5fd" + integrity sha512-dmnG2BGBckzaUaqXmkoDxy1+Yvk/simH8NNaZOQaOFk2EfFNsaw5Q3EKrw9tzqjSXmg6t6eGUNPxE0ji9uZprw== + dependencies: + rollup-plugin-dotenv "0.5.0" + uuid "9.0.1" + "@lit-labs/ssr-dom-shim@^1.0.0", "@lit-labs/ssr-dom-shim@^1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.1.0.tgz#3361d6b8c4cb2ac426d5794ac7cd9776cd2f0814" @@ -3487,6 +3495,14 @@ "@rollup/pluginutils" "^3.1.0" magic-string "^0.25.7" +"@rollup/plugin-replace@^5.0.1": + version "5.0.5" + resolved "https://registry.yarnpkg.com/@rollup/plugin-replace/-/plugin-replace-5.0.5.tgz#33d5653dce6d03cb24ef98bef7f6d25b57faefdf" + integrity sha512-rYO4fOi8lMaTg/z5Jb+hKnrHHVn8j2lwkqwyS4kTRhKyWOLf2wST2sWXr4WzWiTcoHTp2sTjqUbqIj2E39slKQ== + dependencies: + "@rollup/pluginutils" "^5.0.1" + magic-string "^0.30.3" + "@rollup/plugin-typescript@^8.0.0": version "8.3.0" resolved "https://registry.yarnpkg.com/@rollup/plugin-typescript/-/plugin-typescript-8.3.0.tgz#bc1077fa5897b980fc27e376c4e377882c63e68b" @@ -3504,6 +3520,15 @@ estree-walker "^1.0.1" picomatch "^2.2.2" +"@rollup/pluginutils@^5.0.1": + version "5.1.0" + resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-5.1.0.tgz#7e53eddc8c7f483a4ad0b94afb1f7f5fd3c771e0" + integrity sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g== + dependencies: + "@types/estree" "^1.0.0" + estree-walker "^2.0.2" + picomatch "^2.3.1" + "@safe-global/safe-apps-provider@^0.17.1": version "0.17.1" resolved "https://registry.yarnpkg.com/@safe-global/safe-apps-provider/-/safe-apps-provider-0.17.1.tgz#72df2a66be5343940ed505efe594ed3b0f2f7015" @@ -4617,6 +4642,11 @@ resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f" integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw== +"@types/estree@^1.0.0": + version "1.0.5" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4" + integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw== + "@types/ethereumjs-util@^5.2.0": version "5.2.0" resolved "https://registry.yarnpkg.com/@types/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz#f49fe8114789ec0871721392c09318c3eb56671b" @@ -8664,6 +8694,11 @@ domexception@^1.0.1: dependencies: webidl-conversions "^4.0.2" +dotenv@^16.0.3: + version "16.4.1" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.1.tgz#1d9931f1d3e5d2959350d1250efab299561f7f11" + integrity sha512-CjA3y+Dr3FyFDOAMnxZEGtnW9KBR2M0JvvUtXNW+dYJL5ROWxP9DUHCwgFqpMk0OXCc0ljhaNTr2w/kutYIcHQ== + drbg.js@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/drbg.js/-/drbg.js-1.0.1.tgz#3e36b6c42b37043823cdbc332d58f31e2445480b" @@ -12027,6 +12062,13 @@ magic-string@^0.25.7: dependencies: sourcemap-codec "^1.4.4" +magic-string@^0.30.3: + version "0.30.6" + resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.30.6.tgz#996e21b42f944e45591a68f0905d6a740a12506c" + integrity sha512-n62qCLbPjNjyo+owKtveQxZFZTBm+Ms6YoGD23Wew6Vw337PElFNifQpknPruVRQV57kVShPnLGo9vWxVhpPvA== + dependencies: + "@jridgewell/sourcemap-codec" "^1.4.15" + make-error@^1.1.1: version "1.3.6" resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" @@ -14200,6 +14242,14 @@ rlp@^2.0.0, rlp@^2.2.3, rlp@^2.2.4: dependencies: bn.js "^5.2.0" +rollup-plugin-dotenv@0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/rollup-plugin-dotenv/-/rollup-plugin-dotenv-0.5.0.tgz#c2df297be52f3dcc0ae7fb048e08f906cee112e7" + integrity sha512-M2gZqEZebtcKaA7OBdO4UF3WmkI02wVD6UVwoxFlRKoq4/n1Q9Cw6UV8dPvVZYpGQ+ug2JPoogrCLaydIKU96A== + dependencies: + "@rollup/plugin-replace" "^5.0.1" + dotenv "^16.0.3" + rollup-plugin-svelte@^7.0.0: version "7.1.0" resolved "https://registry.yarnpkg.com/rollup-plugin-svelte/-/rollup-plugin-svelte-7.1.0.tgz#d45f2b92b1014be4eb46b55aa033fb9a9c65f04d" @@ -16011,6 +16061,11 @@ uuid@9.0.0, uuid@^9.0.0: resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.0.tgz#592f550650024a38ceb0c562f2f6aa435761efb5" integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg== +uuid@9.0.1: + version "9.0.1" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30" + integrity sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA== + uuid@^3.3.2, uuid@^3.4.0: version "3.4.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" From 53855df44210538a341473734298501d33e59eed Mon Sep 17 00:00:00 2001 From: Samy RABAH-MONTAROU Date: Thu, 1 Feb 2024 10:16:30 +0100 Subject: [PATCH 2/3] change import ethereumprovider type file extension --- packages/ledger/src/v1.ts | 2 +- packages/ledger/src/v2.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/ledger/src/v1.ts b/packages/ledger/src/v1.ts index f3fb2d9d5..fa36154f8 100644 --- a/packages/ledger/src/v1.ts +++ b/packages/ledger/src/v1.ts @@ -7,7 +7,7 @@ import { ChainId, AccountAddress } from '@web3-onboard/common' -import type { EthereumProvider } from '@ledgerhq/connect-kit/dist/umd/index.d.ts' +import type { EthereumProvider } from '@ledgerhq/connect-kit/dist/umd/index.js' import type { StaticJsonRpcProvider as StaticJsonRpcProviderType } from '@ethersproject/providers' import WalletConnect from '@walletconnect/client' import { isHexString, LedgerOptionsWCv1 } from './index.js' diff --git a/packages/ledger/src/v2.ts b/packages/ledger/src/v2.ts index 1491c3d7c..40b2ffe49 100644 --- a/packages/ledger/src/v2.ts +++ b/packages/ledger/src/v2.ts @@ -4,7 +4,7 @@ import { EIP1193Provider, ProviderAccounts } from '@web3-onboard/common' -import type { EthereumProvider as LedgerEthereumProvider } from '@ledgerhq/connect-kit/dist/umd/index.d.ts' +import type { EthereumProvider as LedgerEthereumProvider } from '@ledgerhq/connect-kit/dist/umd/index.js' import { isHexString, LedgerOptionsWCv2 } from './index.js' import type { JQueryStyleEventEmitter } from 'rxjs/internal/observable/fromEvent' From 19a8ddaeecf1e07517819fa863ee00288d216725 Mon Sep 17 00:00:00 2001 From: Adam Carpenter Date: Fri, 2 Feb 2024 11:59:17 -0700 Subject: [PATCH 3/3] Update default optional methods, bump to minor version as deps changed and test --- packages/demo/package.json | 2 +- packages/ledger/package.json | 2 +- packages/ledger/src/v2.ts | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/demo/package.json b/packages/demo/package.json index d06f3759b..ab5a567d4 100644 --- a/packages/demo/package.json +++ b/packages/demo/package.json @@ -45,7 +45,7 @@ "@web3-onboard/injected-wallets": "^2.10.11", "@web3-onboard/keepkey": "^2.3.7", "@web3-onboard/keystone": "^2.3.7", - "@web3-onboard/ledger": "^2.5.3-alpha.1", + "@web3-onboard/ledger": "^2.6.0-alpha.1", "@web3-onboard/magic": "^2.1.6", "@web3-onboard/metamask": "^2.0.2", "@web3-onboard/mew-wallet": "^2.0.3", diff --git a/packages/ledger/package.json b/packages/ledger/package.json index a2b08269c..80d80b97b 100644 --- a/packages/ledger/package.json +++ b/packages/ledger/package.json @@ -1,6 +1,6 @@ { "name": "@web3-onboard/ledger", - "version": "2.5.3-alpha.1", + "version": "2.6.0-alpha.1", "description": "Ledger hardware wallet module for connecting to Web3-Onboard. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardized 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", diff --git a/packages/ledger/src/v2.ts b/packages/ledger/src/v2.ts index 40b2ffe49..230060378 100644 --- a/packages/ledger/src/v2.ts +++ b/packages/ledger/src/v2.ts @@ -15,7 +15,9 @@ const defaultOptionalMethods = [ 'personal_sign', 'eth_sign', 'eth_signTypedData', - 'eth_signTypedData_v4' + 'eth_signTypedData_v4', + 'wallet_addEthereumChain', + 'wallet_switchEthereumChain' ] function ledger(options?: LedgerOptionsWCv2): WalletInit {