diff --git a/README.md b/README.md index cf688c198..aaeff76a0 100644 --- a/README.md +++ b/README.md @@ -2,28 +2,28 @@ NEAR Wallet Selector makes it easy for users to interact with your dApp by providing an abstraction over various wallets within the NEAR ecosystem: -- [My NEAR Wallet](https://www.npmjs.com/package/@near-wallet-selector/my-near-wallet) - Browser wallet. -- [Mintbase Wallet](https://www.npmjs.com/package/@near-wallet-selector/mintbase-wallet) - Browser wallet. +- [Bitget Wallet](https://www.npmjs.com/package/@near-wallet-selector/bitget-wallet) - Injected wallet. - [Bitte Wallet](https://www.npmjs.com/package/@near-wallet-selector/bitte-wallet) - Browser wallet. +- [Coin98 Wallet](https://www.npmjs.com/package/@near-wallet-selector/coin98-wallet) - Injected wallet. +- [Ethereum wallets](https://www.npmjs.com/package/@near-wallet-selector/ethereum-wallets) - Injected wallet. +- [Here Wallet](https://www.npmjs.com/package/@near-wallet-selector/here-wallet) - Mobile wallet. - [Ledger](https://www.npmjs.com/package/@near-wallet-selector/ledger) - Hardware wallet. -- [Sender](https://www.npmjs.com/package/@near-wallet-selector/sender) - Injected wallet. - [Math Wallet](https://www.npmjs.com/package/@near-wallet-selector/math-wallet) - Injected wallet. -- [Nightly](https://www.npmjs.com/package/@near-wallet-selector/nightly) - Injected wallet. -- [Meteor Wallet](https://www.npmjs.com/package/@near-wallet-selector/meteor-wallet) - Injected wallet. - [Metamask Snap](https://www.npmjs.com/package/@near-wallet-selector/near-snap) - Injected wallet. -- [OKX Wallet](https://www.npmjs.com/package/@near-wallet-selector/okx-wallet) - Injected wallet. +- [Meteor Wallet](https://www.npmjs.com/package/@near-wallet-selector/meteor-wallet) - Injected wallet. +- [Mintbase Wallet](https://www.npmjs.com/package/@near-wallet-selector/mintbase-wallet) - Browser wallet. +- [My NEAR Wallet](https://www.npmjs.com/package/@near-wallet-selector/my-near-wallet) - Browser wallet. - [Narwallets](https://www.npmjs.com/package/@near-wallet-selector/narwallets) - Injected wallet. -- [WELLDONE Wallet](https://www.npmjs.com/package/@near-wallet-selector/welldone-wallet) - Injected wallet. -- [Coin98 Wallet](https://www.npmjs.com/package/@near-wallet-selector/coin98-wallet) - Injected wallet. +- [Near Mobile Wallet](https://www.npmjs.com/package/@near-wallet-selector/near-mobile-wallet) - Mobile Wallet. +- [NearFi Wallet](https://www.npmjs.com/package/@near-wallet-selector/nearfi) - Mobile wallet. - [Neth](https://www.npmjs.com/package/@near-wallet-selector/neth) - Injected wallet. -- [XDEFI Wallet](https://www.npmjs.com/package/@near-wallet-selector/xdefi) - Injected wallet. +- [Nightly](https://www.npmjs.com/package/@near-wallet-selector/nightly) - Injected wallet. +- [OKX Wallet](https://www.npmjs.com/package/@near-wallet-selector/okx-wallet) - Injected wallet. - [Ramper Wallet](https://www.npmjs.com/package/@near-wallet-selector/ramper-wallet) - Injected wallet. -- [Bitget Wallet](https://www.npmjs.com/package/@near-wallet-selector/bitget-wallet) - Injected wallet. -- [Here Wallet](https://www.npmjs.com/package/@near-wallet-selector/here-wallet) - Mobile wallet. -- [NearFi Wallet](https://www.npmjs.com/package/@near-wallet-selector/nearfi) - Mobile wallet. -- [Near Mobile Wallet](https://www.npmjs.com/package/@near-wallet-selector/near-mobile-wallet) - Mobile Wallet. +- [Sender](https://www.npmjs.com/package/@near-wallet-selector/sender) - Injected wallet. - [WalletConnect](https://www.npmjs.com/package/@near-wallet-selector/wallet-connect) - Bridge wallet. -- [Ethereum wallets](https://www.npmjs.com/package/@near-wallet-selector/ethereum-wallets) - Injected wallet. +- [WELLDONE Wallet](https://www.npmjs.com/package/@near-wallet-selector/welldone-wallet) - Injected wallet. +- [XDEFI Wallet](https://www.npmjs.com/package/@near-wallet-selector/xdefi) - Injected wallet. ## Preview diff --git a/examples/angular/src/app/pages/wallet-selector/wallet-selector.component.ts b/examples/angular/src/app/pages/wallet-selector/wallet-selector.component.ts index 74be6a265..090ef6410 100644 --- a/examples/angular/src/app/pages/wallet-selector/wallet-selector.component.ts +++ b/examples/angular/src/app/pages/wallet-selector/wallet-selector.component.ts @@ -42,8 +42,6 @@ declare global { // Get a project ID at https://cloud.walletconnect.com const projectId = "30147604c5f01d0bc4482ab0665b5697"; -// NOTE: This is the NEAR wallet playground used in dev mode. -// TODO: Replace with the NEAR chain after the protocol upgrade. const near: Chain = { id: 398, name: "NEAR Protocol Testnet", @@ -53,13 +51,13 @@ const near: Chain = { symbol: "NEAR", }, rpcUrls: { - default: { http: ["https://near-wallet-relayer.testnet.aurora.dev"] }, - public: { http: ["https://near-wallet-relayer.testnet.aurora.dev"] }, + default: { http: ["https://eth-rpc.testnet.near.org"] }, + public: { http: ["https://eth-rpc.testnet.near.org"] }, }, blockExplorers: { default: { name: "NEAR Explorer", - url: "https://testnet.nearblocks.io", + url: "https://eth-explorer-testnet.near.org", }, }, testnet: true, diff --git a/examples/react/contexts/WalletSelectorContext.tsx b/examples/react/contexts/WalletSelectorContext.tsx index 5fadd74e9..55d0fdcac 100644 --- a/examples/react/contexts/WalletSelectorContext.tsx +++ b/examples/react/contexts/WalletSelectorContext.tsx @@ -73,8 +73,6 @@ const WalletSelectorContext = // Get a project ID at https://cloud.walletconnect.com const projectId = "30147604c5f01d0bc4482ab0665b5697"; -// NOTE: This is the NEAR wallet playground used in dev mode. -// TODO: Replace with the NEAR chain after the protocol upgrade. const near: Chain = { id: 398, name: "NEAR Protocol Testnet", @@ -84,13 +82,13 @@ const near: Chain = { symbol: "NEAR", }, rpcUrls: { - default: { http: ["https://near-wallet-relayer.testnet.aurora.dev"] }, - public: { http: ["https://near-wallet-relayer.testnet.aurora.dev"] }, + default: { http: ["https://eth-rpc.testnet.near.org"] }, + public: { http: ["https://eth-rpc.testnet.near.org"] }, }, blockExplorers: { default: { name: "NEAR Explorer", - url: "https://testnet.nearblocks.io", + url: "https://eth-explorer-testnet.near.org", }, }, testnet: true, @@ -137,6 +135,7 @@ export const WalletSelectorContextProvider: React.FC<{ if (!selector) { return; } + // Watch the connected Ethereum account and connect to the `ethereum-wallets` module automatically. watchAccount(wagmiConfig, { onChange: (data: GetAccountReturnType) => { if (!data.address || selector.store.getState().selectedWalletId) { diff --git a/package.json b/package.json index 20f8975a7..61d8ce234 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "near-wallet-selector", - "version": "8.9.13", + "version": "8.9.14", "description": "NEAR Wallet Selector makes it easy for users to interact with your dApp by providing an abstraction over various wallets within the NEAR ecosystem", "keywords": [ "near", @@ -94,7 +94,7 @@ "@here-wallet/core": "3.3.1", "@jscutlery/semver": "5.3.1", "@ledgerhq/hw-transport": "6.30.3", - "@ledgerhq/hw-transport-webhid": "6.29.2", + "@ledgerhq/hw-transport-webhid": "6.29.4", "@metamask/detect-provider": "2.0.0", "@meteorwallet/sdk": "1.0.9", "@mintbase-js/wallet": "0.6.1", @@ -107,8 +107,8 @@ "@walletconnect/modal": "2.6.2", "@walletconnect/sign-client": "2.13.0", "@web3modal/wagmi": "5.0.6", - "better-sqlite3": "11.2.1", - "big.js": "6.2.1", + "better-sqlite3": "11.3.0", + "big.js": "6.2.2", "borsh": "0.7.0", "browserify-fs": "1.0.0", "bs58": "5.0.0", @@ -223,4 +223,4 @@ "webpack": "5.75.0", "webpack-merge": "5.8.0" } -} +} \ No newline at end of file diff --git a/packages/account-export/package.json b/packages/account-export/package.json index f32408578..5b67ace17 100644 --- a/packages/account-export/package.json +++ b/packages/account-export/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/account-export", - "version": "8.9.13", + "version": "8.9.14", "description": "This is the Export Selector UI package for NEAR Wallet Selector.", "keywords": [ "near", @@ -23,4 +23,4 @@ "peerDependencies": { "near-api-js": "4.0.3" } -} +} \ No newline at end of file diff --git a/packages/arepa-wallet/package.json b/packages/arepa-wallet/package.json index d88a31de2..49ebec0fe 100644 --- a/packages/arepa-wallet/package.json +++ b/packages/arepa-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/arepa-wallet", - "version": "8.9.13", + "version": "8.9.14", "description": "Arepa Wallet package for NEAR Wallet Selector.", "keywords": [ "near", @@ -20,8 +20,5 @@ "bugs": { "url": "https://github.com/near/wallet-selector/issues" }, - "homepage": "https://github.com/near/wallet-selector/tree/main/packages/arepa-wallet", - "peerDependencies": { - "near-api-js": "4.0.3" - } -} + "homepage": "https://github.com/near/wallet-selector/tree/main/packages/arepa-wallet" +} \ No newline at end of file diff --git a/packages/bitget-wallet/package.json b/packages/bitget-wallet/package.json index b0909194a..fa7537816 100644 --- a/packages/bitget-wallet/package.json +++ b/packages/bitget-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/bitget-wallet", - "version": "8.9.13", + "version": "8.9.14", "description": "Bitget wallet package for NEAR Wallet Selector.", "keywords": [ "near", @@ -21,4 +21,4 @@ "url": "https://github.com/near/wallet-selector/issues" }, "homepage": "https://github.com/near/wallet-selector/tree/main/packages/bitget-wallet" -} +} \ No newline at end of file diff --git a/packages/bitte-wallet/package.json b/packages/bitte-wallet/package.json index 0a983cc2c..e4a25fa4c 100644 --- a/packages/bitte-wallet/package.json +++ b/packages/bitte-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/bitte-wallet", - "version": "8.9.13", + "version": "8.9.14", "description": "Bitte wallet package for NEAR Wallet Selector.", "keywords": [ "near", @@ -21,4 +21,4 @@ "url": "https://github.com/near/wallet-selector/issues" }, "homepage": "https://github.com/near/wallet-selector/tree/main/packages/bitte-wallet" -} +} \ No newline at end of file diff --git a/packages/coin98-wallet/package.json b/packages/coin98-wallet/package.json index 9ffde9e8c..629a87afe 100644 --- a/packages/coin98-wallet/package.json +++ b/packages/coin98-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/coin98-wallet", - "version": "8.9.13", + "version": "8.9.14", "description": "Coin 98 wallet package for NEAR Wallet Selector.", "keywords": [ "near", @@ -21,4 +21,4 @@ "url": "https://github.com/near/wallet-selector/issues" }, "homepage": "https://github.com/near/wallet-selector/tree/main/packages/coin98-wallet" -} +} \ No newline at end of file diff --git a/packages/core/package.json b/packages/core/package.json index 62ddc3417..d0c679045 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/core", - "version": "8.9.13", + "version": "8.9.14", "description": "This is the core package for NEAR Wallet Selector.", "keywords": [ "near", @@ -23,4 +23,4 @@ "near-api-js": "4.0.3", "@near-js/providers": "latest" } -} +} \ No newline at end of file diff --git a/packages/ethereum-wallets/README.md b/packages/ethereum-wallets/README.md index 93e3b33ba..c0623e612 100644 --- a/packages/ethereum-wallets/README.md +++ b/packages/ethereum-wallets/README.md @@ -5,19 +5,19 @@ The package adds support for Ethereum wallets by creating Ethereum-compatible tr Ethereum wallet support NEP: https://github.com/near/NEPs/issues/518 -Any Ethereum wallet can be connected via Web3Modal: the dApp can chose which wallets to support and a multichain dApp can switch networks using the same wallet connection. +Any Ethereum wallet can be connected via Web3Modal: the App can chose which wallets to support and a multichain App can switch networks using the same wallet connection. SignIn requires switching to NEAR network to ensure that the wallet is compatible, if the user switches to other networks he will be prompted to switch back to NEAR before making a transaction. Sign out prompts to remove the FunctionCall access key if there is one, this action is non blocking and the user can sign out without executing the transaction. -A NEAR dApp can connect to multiple Ethereum wallet addresses. If the user switches to a new address from the Ethereum wallet, the NEAR wallet will be disconnected so that it can reconnect with the signIn flow. If the dApp doesn't require a FunctionCall access key or the Ethereum wallet address already signed in, then the address connects automatically when changed. +A NEAR App can connect to multiple Ethereum wallet addresses. If the user switches to a new address from the Ethereum wallet, the NEAR wallet will be disconnected so that it can reconnect with the signIn flow. If the App doesn't require a FunctionCall access key or the Ethereum wallet address already signed in, then the address connects automatically when changed. NEP-518 doesn't support multiple actions within the same transaction, so when multiple actions are requested, they are split into separate transactions and executed 1 by 1. NEP-518 rpc relayer uses a FunctionCall access key to execute transactions on behalf of the user by calling `rlp_execute`. If this key is not yet added, the wallet will be onboarded before the first transaction is made. -`signMessage` and `verifyOwner` are not implemented because Ethereum wallets are not compatible with these standards, instead a dApp can use `personal_sign` or `eth_signTypedData_v4` to authenticate the wallet by interacting with it directly. +`signMessage` and `verifyOwner` are not implemented because Ethereum wallets are not compatible with these standards, instead Apps can use `personal_sign` or `eth_signTypedData_v4` to authenticate the wallet by interacting with it directly. ## Installation and Usage @@ -29,42 +29,113 @@ yarn add near-api-js @web3modal/wagmi wagmi viem @tanstack/react-query @near-wal npm install near-api-js @web3modal/wagmi wagmi viem @tanstack/react-query @near-wallet-selector/ethereum-wallets ``` -Then use it in your dApp: +Then use it in your App: Visit https://docs.walletconnect.com for the latest configuration of Web3Modal. +Tested versions from `/examples`: +```json +"dependencies": { + "@web3modal/wagmi": "5.0.6", + "@tanstack/react-query": "5.24.8", + "viem": "2.16.2", + "wagmi": "2.10.9", +} +``` + ```ts import type { Config } from "@wagmi/core"; +import type { Chain } from "@wagmi/core/chains"; import { reconnect, http, createConfig } from "@wagmi/core"; import { walletConnect, injected } from "@wagmi/connectors"; import { setupWalletSelector } from "@near-wallet-selector/core"; +import { setupModal } from "@near-wallet-selector/modal-ui"; import { setupEthereumWallets } from "@near-wallet-selector/ethereum-wallets"; +// Mainnet +const near: Chain = { + id: 397, + name: "NEAR Protocol", + nativeCurrency: { + decimals: 18, + name: "NEAR", + symbol: "NEAR", + }, + rpcUrls: { + default: { http: ["https://eth-rpc.mainnet.near.org"] }, + public: { http: ["https://eth-rpc.mainnet.near.org"] }, + }, + blockExplorers: { + default: { + name: "NEAR Explorer", + url: "https://eth-explorer.near.org", + }, + }, +} + +// Testnet +/* +const near: Chain = { + id: 398, + name: "NEAR Protocol Testnet", + nativeCurrency: { + decimals: 18, + name: "NEAR", + symbol: "NEAR", + }, + rpcUrls: { + default: { http: ["https://eth-rpc.testnet.near.org"] }, + public: { http: ["https://eth-rpc.testnet.near.org"] }, + }, + blockExplorers: { + default: { + name: "NEAR Explorer", + url: "https://eth-explorer-testnet.near.org", + }, + }, + testnet: true, +}; +*/ + +// Get a project ID at https://cloud.walletconnect.com +const projectId = "" + const wagmiConfig: Config = createConfig({ chains: [near], transports: { [near.id]: http(), }, connectors: [ - walletConnect({ projectId, metadata, showQrModal: false }), + walletConnect({ + projectId, + metadata: { + name: "NEAR Guest Book", + description: "A guest book with comments stored on the NEAR blockchain", + url: "https://near.github.io/wallet-selector", + icons: ["https://near.github.io/wallet-selector/favicon.ico"], + }, + showQrModal: false + }), injected({ shimDisconnect: true }), ], }); -reconnect(wagmiConfig); const web3Modal = createWeb3Modal({ - wagmiConfig: config, - // Get a project ID at https://cloud.walletconnect.com + wagmiConfig, projectId, }); -const _selector = await setupWalletSelector({ - network: "mainnet", - debug: true, - modules: [ - setupEthereumWallets({ wagmiConfig, web3Modal }), - ], -}); +export const WalletSelectorContextProvider = () => { + const init = useCallback(async () => { + const _selector = await setupWalletSelector({ + network: "mainnet", + modules: [ + setupEthereumWallets({ wagmiConfig, web3Modal }), + ], + }); + const _modal = setupModal(_selector, { contractId: "" }) + }, []); +} ``` ## Wallet Connect Configuration @@ -77,8 +148,9 @@ Project ID is required, please obtain it from [walletconnect.com](https://wallet - `web3Modal` (`Web3Modal?`): Web3Modal object for connecting an Ethereum wallet. If not provided this module will connect to the default injected wallet (MetaMask browser extension, embedded browser wallets...). - `chainId` (`number?`): Chain ID of the NEAR web3 rpc to connect to. Defaults to `397` (`mainnet`) or `398` (`testnet`) depending on the `setupWalletSelector` network configuration. - `iconUrl` (`string?`): Image URL for the icon shown in the modal. This can also be a relative path or base64 encoded image. Defaults to `./assets/ethereum-wallets-icon.png`. -- `wagmiCore` (`typeof import("@wagmi/core")?`): Optional, @wagmi/core functions can be overidden by the dapp to interract with the wallet. -- `alwaysOnboardDuringSignIn` (`boolean?`): A dapp without SignIn access key will not onboard the relayer by default, this option does the relayer onboarding during login. +- `wagmiCore` (`typeof import("@wagmi/core")?`): Optional, @wagmi/core functions can be overidden by the App to interract with the wallet. +- `alwaysOnboardDuringSignIn` (`boolean?`): Apps without SignIn access key will not onboard the relayer by default, this option does the relayer onboarding during login. +- `skipSignInAccessKey` (`boolean?`): Allows connecting Ethereum wallets without adding a Limited Access Key which would require owning NEAR to execute the transaction (for rainbowbridge.app and welcome.near.org). - `nearNodeUrl` (`string?`): NEAR node url to query the NEAR transaction status and onboarding access key. Developent options (before the NEAR protocol upgrade to support 0x accounts natively): @@ -88,33 +160,22 @@ Developent options (before the NEAR protocol upgrade to support 0x accounts nati ## Log in with Ethereum flow -Dapps can connect to Ethereum wallets directly (using `w3m-button` for example) by watching the connected Ethereum account and connecting to the `ethereum-wallets` module automatically without opening the NEAR modal. +Apps can connect to Ethereum wallets directly without opening the NEAR modal (using a dedicated button). ```js -import { watchAccount } from "@wagmi/core"; -useEffect(() => { - if (!selector) { - return - } - watchAccount(wagmiConfig, { - onChange: (data) => { - if (!data.address || selector.store.getState().selectedWalletId) { - return - } - selector.wallet("ethereum-wallets").then((wallet) => - wallet.signIn({ - contractId: CONTRACT_ID, - }) - ) - }, - }) -}, [selector]) +const loginWithEthereum = () => { + selector.wallet("ethereum-wallets").then((wallet) => + wallet.signIn({ + contractId: CONTRACT_ID, + }) + ) +} ``` ## Use without Web3Modal -Web3Modal and Log in with Ethereum flows are the preferred UX for connecting to any Ethereum wallet. -But this module is also available to use without Web3Modal: it will connect to the default injected wallet (Metamask browser extension, embedded browser wallets...). +Web3Modal is the preferred UX for connecting to any Ethereum wallet. +But `ethereum-wallets` is also available to use without Web3Modal: it will connect to the default injected wallet (Metamask browser extension, embedded browser wallets...). ## License diff --git a/packages/ethereum-wallets/package.json b/packages/ethereum-wallets/package.json index f11e43cf3..0bb1a3e99 100644 --- a/packages/ethereum-wallets/package.json +++ b/packages/ethereum-wallets/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/ethereum-wallets", - "version": "8.9.13", + "version": "8.9.14", "description": "Ethereum wallets package for NEAR Wallet Selector.", "keywords": [ "near", @@ -22,8 +22,5 @@ "bugs": { "url": "https://github.com/near/wallet-selector/issues" }, - "homepage": "https://github.com/near/wallet-selector/tree/main/packages/ethereum-wallets", - "peerDependencies": { - "near-api-js": "^1.0.0 || ^2.0.0" - } -} + "homepage": "https://github.com/near/wallet-selector/tree/main/packages/ethereum-wallets" +} \ No newline at end of file diff --git a/packages/ethereum-wallets/src/lib/index.ts b/packages/ethereum-wallets/src/lib/index.ts index 92efa1fec..0d9acfe75 100644 --- a/packages/ethereum-wallets/src/lib/index.ts +++ b/packages/ethereum-wallets/src/lib/index.ts @@ -65,6 +65,7 @@ export interface EthereumWalletsParams { devModeAccount?: string; deprecated?: boolean; nearNodeUrl?: string; + skipSignInAccessKey?: boolean; } interface EthereumWalletsState { @@ -105,6 +106,7 @@ const EthereumWallets: WalletBehaviourFactory< devMode, devModeAccount = "eth-wallet.testnet", nearNodeUrl, + skipSignInAccessKey, }, }) => { if (!wagmiCore) { @@ -848,7 +850,7 @@ const EthereumWallets: WalletBehaviourFactory< // Login with FunctionCall access key, reuse keypair or create a new one. const accountId = devMode ? address + "." + devModeAccount : address; let publicKey; - if (contractId) { + if (contractId && !skipSignInAccessKey) { const keyPair = await _state.keystore.getKey( options.network.networkId, accountId @@ -995,7 +997,7 @@ export function setupEthereumWallets( iconUrl: params.iconUrl ?? icon, deprecated: params.deprecated ?? false, available: true, - downloadUrl: "", + downloadUrl: "https://explorer.walletconnect.com", }, init: (config) => { return EthereumWallets({ diff --git a/packages/here-wallet/package.json b/packages/here-wallet/package.json index c2fbc5295..2dfa305b4 100644 --- a/packages/here-wallet/package.json +++ b/packages/here-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/here-wallet", - "version": "8.9.13", + "version": "8.9.14", "description": "Here wallet package for NEAR Wallet Selector.", "keywords": [ "near", @@ -21,4 +21,4 @@ "url": "https://github.com/near/wallet-selector/issues" }, "homepage": "https://github.com/near/wallet-selector/tree/main/packages/here-wallet" -} +} \ No newline at end of file diff --git a/packages/ledger/package.json b/packages/ledger/package.json index 7594aa8ff..350c21f77 100644 --- a/packages/ledger/package.json +++ b/packages/ledger/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/ledger", - "version": "8.9.13", + "version": "8.9.14", "description": "Ledger package for NEAR Wallet Selector.", "keywords": [ "near", @@ -21,4 +21,4 @@ "url": "https://github.com/near/wallet-selector/issues" }, "homepage": "https://github.com/near/wallet-selector/tree/main/packages/ledger" -} +} \ No newline at end of file diff --git a/packages/math-wallet/package.json b/packages/math-wallet/package.json index 6e0726b16..7c3defbcf 100644 --- a/packages/math-wallet/package.json +++ b/packages/math-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/math-wallet", - "version": "8.9.13", + "version": "8.9.14", "description": "Math wallet package for NEAR Wallet Selector.", "keywords": [ "near", @@ -21,4 +21,4 @@ "url": "https://github.com/near/wallet-selector/issues" }, "homepage": "https://github.com/near/wallet-selector/tree/main/packages/math-wallet" -} +} \ No newline at end of file diff --git a/packages/meteor-wallet/package.json b/packages/meteor-wallet/package.json index 68c487d62..9e9dcf18a 100644 --- a/packages/meteor-wallet/package.json +++ b/packages/meteor-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/meteor-wallet", - "version": "8.9.13", + "version": "8.9.14", "description": "Meteor wallet package for NEAR Wallet Selector.", "keywords": [ "near", @@ -21,4 +21,4 @@ "url": "https://github.com/near/wallet-selector/issues" }, "homepage": "https://github.com/near/wallet-selector/tree/main/packages/meteor-wallet" -} +} \ No newline at end of file diff --git a/packages/mintbase-wallet/package.json b/packages/mintbase-wallet/package.json index c1793b815..3a0a54d3e 100644 --- a/packages/mintbase-wallet/package.json +++ b/packages/mintbase-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/mintbase-wallet", - "version": "8.9.13", + "version": "8.9.14", "description": "Mintbase wallet package for NEAR Wallet Selector.", "keywords": [ "near", @@ -21,4 +21,4 @@ "url": "https://github.com/near/wallet-selector/issues" }, "homepage": "https://github.com/near/wallet-selector/tree/main/packages/mintbase-wallet" -} +} \ No newline at end of file diff --git a/packages/modal-ui-js/package.json b/packages/modal-ui-js/package.json index 97819b23c..02665dae8 100644 --- a/packages/modal-ui-js/package.json +++ b/packages/modal-ui-js/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/modal-ui-js", - "version": "8.9.13", + "version": "8.9.14", "description": "Modal UI package for NEAR wallet Selector", "keywords": [ "near", @@ -19,4 +19,4 @@ "url": "https://github.com/near/wallet-selector/issues" }, "homepage": "https://github.com/near/wallet-selector/tree/main/packages/modal-ui-js" -} +} \ No newline at end of file diff --git a/packages/modal-ui/package.json b/packages/modal-ui/package.json index 0da355ac7..031f6a75b 100644 --- a/packages/modal-ui/package.json +++ b/packages/modal-ui/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/modal-ui", - "version": "8.9.13", + "version": "8.9.14", "description": "Modal UI package for NEAR wallet Selector", "keywords": [ "near", @@ -19,4 +19,4 @@ "url": "https://github.com/near/wallet-selector/issues" }, "homepage": "https://github.com/near/wallet-selector/tree/main/packages/modal-ui" -} +} \ No newline at end of file diff --git a/packages/my-near-wallet/package.json b/packages/my-near-wallet/package.json index 12f11f6d9..036161c6a 100644 --- a/packages/my-near-wallet/package.json +++ b/packages/my-near-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/my-near-wallet", - "version": "8.9.13", + "version": "8.9.14", "description": "My Near Wallet package for NEAR Wallet Selector.", "keywords": [ "near", @@ -21,4 +21,4 @@ "url": "https://github.com/near/wallet-selector/issues" }, "homepage": "https://github.com/near/wallet-selector/tree/main/packages/my-near-wallet" -} +} \ No newline at end of file diff --git a/packages/narwallets/package.json b/packages/narwallets/package.json index 3263a0848..fbf65469d 100644 --- a/packages/narwallets/package.json +++ b/packages/narwallets/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/narwallets", - "version": "8.9.13", + "version": "8.9.14", "description": "This is the Narwallets package for NEAR Wallet Selector.", "keywords": [ "near", @@ -20,4 +20,4 @@ "url": "https://github.com/near/wallet-selector/issues" }, "homepage": "https://github.com/near/wallet-selector/tree/main/packages/narwallets" -} +} \ No newline at end of file diff --git a/packages/near-mobile-wallet/package.json b/packages/near-mobile-wallet/package.json index 6c36d958b..90d56edf1 100644 --- a/packages/near-mobile-wallet/package.json +++ b/packages/near-mobile-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/near-mobile-wallet", - "version": "8.9.13", + "version": "8.9.14", "description": "NEAR Mobile wallet package for NEAR Wallet Selector.", "keywords": [ "near", @@ -21,4 +21,4 @@ "url": "https://github.com/near/wallet-selector/issues" }, "homepage": "https://github.com/near/wallet-selector/tree/main/packages/near-mobile-wallet" -} +} \ No newline at end of file diff --git a/packages/near-snap/package.json b/packages/near-snap/package.json index 687d64634..91091b5df 100644 --- a/packages/near-snap/package.json +++ b/packages/near-snap/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/near-snap", - "version": "8.9.13", + "version": "8.9.14", "description": "Metamask snap to interact with Near dapps.", "keywords": [ "near", @@ -21,4 +21,4 @@ "url": "https://github.com/near/wallet-selector/issues" }, "homepage": "https://github.com/near/wallet-selector/tree/main/packages/near-snap" -} +} \ No newline at end of file diff --git a/packages/nearfi/package.json b/packages/nearfi/package.json index 0704ffb2e..5f76b00bc 100644 --- a/packages/nearfi/package.json +++ b/packages/nearfi/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/nearfi", - "version": "8.9.13", + "version": "8.9.14", "description": "Nearfi package for NEAR Wallet Selector.", "keywords": [ "near", @@ -21,4 +21,4 @@ "url": "https://github.com/near/wallet-selector/issues" }, "homepage": "https://github.com/near/wallet-selector/tree/main/packages/nearfi" -} +} \ No newline at end of file diff --git a/packages/neth/package.json b/packages/neth/package.json index 8f0da4770..9c3cc5354 100644 --- a/packages/neth/package.json +++ b/packages/neth/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/neth", - "version": "8.9.13", + "version": "8.9.14", "description": "Control NEAR accounts with ETH accounts", "author": "mattlockyer", "keywords": [ @@ -21,4 +21,4 @@ "url": "https://github.com/near/wallet-selector/issues" }, "homepage": "https://github.com/near/wallet-selector/tree/main/packages/neth" -} +} \ No newline at end of file diff --git a/packages/nightly/package.json b/packages/nightly/package.json index 5f3aa2230..3d15d2b1d 100644 --- a/packages/nightly/package.json +++ b/packages/nightly/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/nightly", - "version": "8.9.13", + "version": "8.9.14", "description": "Nightly wallet package for NEAR Wallet Selector.", "keywords": [ "near", @@ -21,4 +21,4 @@ "url": "https://github.com/near/wallet-selector/issues" }, "homepage": "https://github.com/near/wallet-selector/tree/main/packages/nightly" -} +} \ No newline at end of file diff --git a/packages/okx-wallet/package.json b/packages/okx-wallet/package.json index 78f7f5ca7..204ac2d1c 100644 --- a/packages/okx-wallet/package.json +++ b/packages/okx-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/okx-wallet", - "version": "8.9.13", + "version": "8.9.14", "description": "OKX Wallet package for NEAR Wallet Selector.", "keywords": [ "near", @@ -21,4 +21,4 @@ "url": "https://github.com/near/wallet-selector/issues" }, "homepage": "https://github.com/near/wallet-selector/tree/main/packages/okx-wallet" -} +} \ No newline at end of file diff --git a/packages/ramper-wallet/package.json b/packages/ramper-wallet/package.json index 61f51927b..09981549e 100644 --- a/packages/ramper-wallet/package.json +++ b/packages/ramper-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/ramper-wallet", - "version": "8.9.13", + "version": "8.9.14", "description": "Ramper wallet package for NEAR Wallet Selector.", "keywords": [ "near", @@ -21,4 +21,4 @@ "url": "https://github.com/near/wallet-selector/issues" }, "homepage": "https://github.com/near/wallet-selector/tree/main/packages/ramper-wallet" -} +} \ No newline at end of file diff --git a/packages/sender/package.json b/packages/sender/package.json index 995ec220b..7e515b8d9 100644 --- a/packages/sender/package.json +++ b/packages/sender/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/sender", - "version": "8.9.13", + "version": "8.9.14", "description": "Sender wallet package for NEAR Wallet Selector.", "keywords": [ "near", @@ -21,4 +21,4 @@ "url": "https://github.com/near/wallet-selector/issues" }, "homepage": "https://github.com/near/wallet-selector/tree/main/packages/sender" -} +} \ No newline at end of file diff --git a/packages/wallet-connect/package.json b/packages/wallet-connect/package.json index 1fef3775a..c7dbaa836 100644 --- a/packages/wallet-connect/package.json +++ b/packages/wallet-connect/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/wallet-connect", - "version": "8.9.13", + "version": "8.9.14", "description": "Wallet Connect package for NEAR Wallet Selector.", "keywords": [ "near", @@ -24,4 +24,4 @@ "peerDependencies": { "near-api-js": "4.0.3" } -} +} \ No newline at end of file diff --git a/packages/wallet-connect/src/lib/wallet-connect.ts b/packages/wallet-connect/src/lib/wallet-connect.ts index 508649615..023a3cfc7 100644 --- a/packages/wallet-connect/src/lib/wallet-connect.ts +++ b/packages/wallet-connect/src/lib/wallet-connect.ts @@ -149,6 +149,18 @@ const disconnect = async ({ state }: { state: WalletConnectState }) => { }); }; +const getSignatureData = (result: Uint8Array) => { + if (result instanceof Uint8Array) { + return result; + } else if (Array.isArray(result)) { + return new Uint8Array(result); + } else if (typeof result === "object" && result !== null) { + return new Uint8Array(Object.values(result)); + } else { + throw new Error("Unexpected result type from near_signTransaction"); + } +}; + const WalletConnect: WalletBehaviourFactory< BridgeWallet, { params: WalletConnectExtraOptions } @@ -354,7 +366,11 @@ const WalletConnect: WalletBehaviourFactory< }, }); - return nearAPI.transactions.SignedTransaction.decode(Buffer.from(result)); + const signatureData = getSignatureData(result); + + return nearAPI.transactions.SignedTransaction.decode( + Buffer.from(signatureData) + ); }; const requestSignTransactions = async (transactions: Array) => { @@ -408,7 +424,11 @@ const WalletConnect: WalletBehaviourFactory< }); return results.map((result) => { - return nearAPI.transactions.SignedTransaction.decode(Buffer.from(result)); + const signatureData = getSignatureData(result); + + return nearAPI.transactions.SignedTransaction.decode( + Buffer.from(signatureData) + ); }); }; diff --git a/packages/wallet-utils/package.json b/packages/wallet-utils/package.json index 00d477ac4..6e6a21551 100644 --- a/packages/wallet-utils/package.json +++ b/packages/wallet-utils/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/wallet-utils", - "version": "8.9.13", + "version": "8.9.14", "description": "Wallet utils package for NEAR Wallet Selector.", "keywords": [ "near", @@ -22,4 +22,4 @@ "peerDependencies": { "near-api-js": "4.0.3" } -} +} \ No newline at end of file diff --git a/packages/welldone-wallet/package.json b/packages/welldone-wallet/package.json index 52a7a2efd..e97243281 100644 --- a/packages/welldone-wallet/package.json +++ b/packages/welldone-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/welldone-wallet", - "version": "8.9.13", + "version": "8.9.14", "description": "Welldone wallet package for NEAR Wallet Selector.", "keywords": [ "near", @@ -21,4 +21,4 @@ "url": "https://github.com/near/wallet-selector/issues" }, "homepage": "https://github.com/near/wallet-selector/tree/main/packages/welldone-wallet" -} +} \ No newline at end of file diff --git a/packages/xdefi/package.json b/packages/xdefi/package.json index a8b45f5ab..af4c36cb3 100644 --- a/packages/xdefi/package.json +++ b/packages/xdefi/package.json @@ -1,6 +1,6 @@ { "name": "@near-wallet-selector/xdefi", - "version": "8.9.13", + "version": "8.9.14", "description": "This is the XDEFI package for NEAR Wallet Selector.", "keywords": [ "near", @@ -20,4 +20,4 @@ "url": "https://github.com/near/wallet-selector/issues" }, "homepage": "https://github.com/near/wallet-selector/tree/main/packages/xdefi" -} +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 60c24d448..e43632469 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3686,12 +3686,12 @@ rxjs "^7.8.1" semver "^7.3.5" -"@ledgerhq/devices@^8.4.2": - version "8.4.2" - resolved "https://registry.yarnpkg.com/@ledgerhq/devices/-/devices-8.4.2.tgz#f1c56194cf1343d56cad49c8feba92ad93432e14" - integrity sha512-oWNTp3jCMaEvRHsXNYE/yo+PFMgXAJGFHLOU1UdE4/fYkniHbD9wdxwyZrZvrxr9hNw4/9wHiThyITwPtMzG7g== +"@ledgerhq/devices@^8.4.4": + version "8.4.4" + resolved "https://registry.yarnpkg.com/@ledgerhq/devices/-/devices-8.4.4.tgz#0d195c1650fe57da2fad7f0d9074a0190947cd6f" + integrity sha512-sz/ryhe/R687RHtevIE9RlKaV8kkKykUV4k29e7GAVwzHX1gqG+O75cu1NCJUHLbp3eABV5FdvZejqRUlLis9A== dependencies: - "@ledgerhq/errors" "^6.18.0" + "@ledgerhq/errors" "^6.19.1" "@ledgerhq/logs" "^6.12.0" rxjs "^7.8.1" semver "^7.3.5" @@ -3701,19 +3701,19 @@ resolved "https://registry.yarnpkg.com/@ledgerhq/errors/-/errors-6.17.0.tgz#0d56361fe6eb7de3b239e661710679f933f1fcca" integrity sha512-xnOVpy/gUUkusEORdr2Qhw3Vd0MGfjyVGgkGR9Ck6FXE26OIdIQ3tNmG5BdZN+gwMMFJJVxxS4/hr0taQfZ43w== -"@ledgerhq/errors@^6.18.0": - version "6.18.0" - resolved "https://registry.yarnpkg.com/@ledgerhq/errors/-/errors-6.18.0.tgz#d55d6a57430d7a86532a9033ce0b45103264c620" - integrity sha512-L3jQWAGyooxRDk/MRlW2v4Ji9+kloBtdmz9wBkHaj2j0n+05rweJSV3GHw9oye1BYMbVFqFffmT4H3hlXlCasw== +"@ledgerhq/errors@^6.19.1": + version "6.19.1" + resolved "https://registry.yarnpkg.com/@ledgerhq/errors/-/errors-6.19.1.tgz#d9ac45ad4ff839e468b8f63766e665537aaede58" + integrity sha512-75yK7Nnit/Gp7gdrJAz0ipp31CCgncRp+evWt6QawQEtQKYEDfGo10QywgrrBBixeRxwnMy1DP6g2oCWRf1bjw== -"@ledgerhq/hw-transport-webhid@6.29.2": - version "6.29.2" - resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-webhid/-/hw-transport-webhid-6.29.2.tgz#8ffd83a9b01377f941668aa97456799493754790" - integrity sha512-kmVsctlR3rpHmxpT2SB1mEayrBMXCc3Fb+VT9xZnpcZhMSXVDA+AdpuXamJkGl2ow72JDN+QcSPfoVT1entXwA== +"@ledgerhq/hw-transport-webhid@6.29.4": + version "6.29.4" + resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-webhid/-/hw-transport-webhid-6.29.4.tgz#5b07ed6c50140e623c8210063f348b8dd5443717" + integrity sha512-XkF37lcuyg9zVExMyfDQathWly8rRcGac13wgZATBa3nZ+hUzzWr5QVKg1pKCw10izVHGErW/9a4tbb72rUEmQ== dependencies: - "@ledgerhq/devices" "^8.4.2" - "@ledgerhq/errors" "^6.18.0" - "@ledgerhq/hw-transport" "^6.31.2" + "@ledgerhq/devices" "^8.4.4" + "@ledgerhq/errors" "^6.19.1" + "@ledgerhq/hw-transport" "^6.31.4" "@ledgerhq/logs" "^6.12.0" "@ledgerhq/hw-transport@6.30.3": @@ -3726,13 +3726,13 @@ "@ledgerhq/logs" "^6.12.0" events "^3.3.0" -"@ledgerhq/hw-transport@^6.31.2": - version "6.31.2" - resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport/-/hw-transport-6.31.2.tgz#79c95f7928a64a0e3b5bc4ea7b5be04b9f738322" - integrity sha512-B27UIzMzm2IXPGYnEB95R7eHxpXBkTBHh6MUJJQZVknt8LilEz1tfpTYUdzAKDGQ+Z5MZyYb01Eh3Zqm3kn3uw== +"@ledgerhq/hw-transport@^6.31.4": + version "6.31.4" + resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport/-/hw-transport-6.31.4.tgz#9b23a6de4a4caaa5c24b149c2dea8adde46f0eb1" + integrity sha512-6c1ir/cXWJm5dCWdq55NPgCJ3UuKuuxRvf//Xs36Bq9BwkV2YaRQhZITAkads83l07NAdR16hkTWqqpwFMaI6A== dependencies: - "@ledgerhq/devices" "^8.4.2" - "@ledgerhq/errors" "^6.18.0" + "@ledgerhq/devices" "^8.4.4" + "@ledgerhq/errors" "^6.19.1" "@ledgerhq/logs" "^6.12.0" events "^3.3.0" @@ -9708,18 +9708,18 @@ before-after-hook@^2.2.0: resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.3.tgz#c51e809c81a4e354084422b9b26bad88249c517c" integrity sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ== -better-sqlite3@11.2.1: - version "11.2.1" - resolved "https://registry.yarnpkg.com/better-sqlite3/-/better-sqlite3-11.2.1.tgz#3c6b8a8e2e12444d380e811796b59c8aba012e03" - integrity sha512-Xbt1d68wQnUuFIEVsbt6V+RG30zwgbtCGQ4QOcXVrOH0FE4eHk64FWZ9NUfRHS4/x1PXqwz/+KOrnXD7f0WieA== +better-sqlite3@11.3.0: + version "11.3.0" + resolved "https://registry.yarnpkg.com/better-sqlite3/-/better-sqlite3-11.3.0.tgz#f10b32ddff665c33176d148e707bd1e57dfd0284" + integrity sha512-iHt9j8NPYF3oKCNOO5ZI4JwThjt3Z6J6XrcwG85VNMVzv1ByqrHWv5VILEbCMFWDsoHhXvQ7oC8vgRXFAKgl9w== dependencies: bindings "^1.5.0" prebuild-install "^7.1.1" -big.js@6.2.1: - version "6.2.1" - resolved "https://registry.yarnpkg.com/big.js/-/big.js-6.2.1.tgz#7205ce763efb17c2e41f26f121c420c6a7c2744f" - integrity sha512-bCtHMwL9LeDIozFn+oNhhFoq+yQ3BNdnsLSASUxLciOb1vgvpHsIO1dsENiGMgbb4SkP5TrzWzRiLddn8ahVOQ== +big.js@6.2.2: + version "6.2.2" + resolved "https://registry.yarnpkg.com/big.js/-/big.js-6.2.2.tgz#be3bb9ac834558b53b099deef2a1d06ac6368e1a" + integrity sha512-y/ie+Faknx7sZA5MfGA2xKlu0GDv8RWrXGsmlteyJQ2lvoKv9GBK/fpRMc2qlSoBAgNxrixICFCBefIq8WCQpQ== big.js@^5.2.2: version "5.2.2"