Migrate from Wallet Provider
This guide will cover how to migrate your existing codebase to use Wallet Kit instead of the now deprecated Wallet Provider.
Prerequisites
- The latest version of the Galaxy Station Chrome extension (Galaxy Station Wallet 1.0.48 and above)
- NPM
- NVM
- Node.js version 16
💡Node version 16
Most users will need to specify Node version 16 before continuing. You can manage node versions with NVM.
_1nvm install 16 nvm use 16
1. Set up dependencies
- To get started, uninstall the deprecated Galaxy Station wallet packages.
_1npm uninstall @hexxagon/use-wallet @hexxagon/wallet-controller @hexxagon/wallet-provider
- Install the
@hexxagon/wallet-kit
package.
_1npm install @hexxagon/wallet-kit @hexxagon/galaxy-station-mobile
2. Change the WalletProvider
setup
Navigate to index.js
in a code editor and change the following in the WalletProvider
component.
Instead of calling getChainOptions
, use getInitalConfig
and pass in the defaultNetworks
as a prop. It is recommended to also add Galaxy Station Mobile, as shown in the code sample below.
_16import ReactDOM from 'react-dom';_16import App from './App';_16import GalaxyStationMobileWallet from '@hexxagon/galaxy-station-mobile';_16import { getInitialConfig, WalletProvider } from '@hexxagon/wallet-kit';_16_16getInitialConfig().then((defaultNetworks) => {_16 ReactDOM.render(_16 <WalletProvider_16 extraWallets={[new GalaxyStationMobileWallet()]}_16 defaultNetworks={defaultNetworks}_16 >_16 <App />_16 </WalletProvider>,_16 document.getElementById('root'),_16 );_16});
3. Comply with the Wallet Kit API
- Fix the package imports. Import the Galaxy Station Wallet utility from
@hexxagon/wallet-kit
instead of prior packages.
_1import { useWallet, useConnectedWallet } from '@hexxagon/wallet-kit';
- Fix minor code changes. The
WalletStatus
enum now has theCONNECTED
property instead ofWALLET_CONNECTED
.availableConnections
andavailableInstallations
have been consolidated intoavailableWallets
.
📖API
You can refer to the WalletKit README for more information on the WalletKit API.
_18const { connect, availableWallets } = useWallet();_18_18const list = [_18 ...availableWallets_18 .filter(({ isInstalled }) => isInstalled)_18 .map(({ id, name, icon }) => ({_18 src: icon,_18 children: name,_18 onClick: () => connect(id),_18 })),_18 ...availableWallets_18 .filter(({ isInstalled, website }) => !isInstalled && website)_18 .map(({ name, icon, website }) => ({_18 src: icon,_18 children: t(`Install ${name}`),_18 href: website ?? '',_18 })),_18];
📱Galaxy Station mobile app
To add support for Galaxy Station mobile, follow the mobile section in the Get Started guide.
Congratulations, your migration to Wallet Kit is now complete!