Migration Guide
This guide will cover how to set migrate your existing codebase to use Wallet Kit instead of the now deprecated Wallet Provider.
Prerequisites
- Station Chrome extension
- 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.
sh nvm install 16 nvm use 16
1. Dependency Setup
-
To get started, and uninstall deprecated Station wallet packages.
_1npm uninstall @terra-money/use-wallet @terra-money/wallet-controller @terra-money/wallet-provider -
Then, install the
@terra-money/wallet-kit
package:_1npm install @terra-money/wallet-kit @terra-money/terra-station-mobile
2. WalletProvider
setup changes
-
Navigate to your
index.js
in a code editor and change the following in yourWalletProvider
component. Instead of callinggetChainOptions
usegetInitalConfig
and pass in thedefaultNetworks
as a prop. Its reccomended to also add Station Mobile as shown in the code sample below._16import ReactDOM from 'react-dom';_16import App from './App';_16import TerraStationMobileWallet from '@terra-money/terra-station-mobile';_16import { getInitialConfig, WalletProvider } from '@terra-money/wallet-kit';_16_16getInitialConfig().then((defaultNetworks) => {_16ReactDOM.render(_16<WalletProvider_16extraWallets={[new TerraStationMobileWallet()]}_16defaultNetworks={defaultNetworks}_16>_16<App />_16</WalletProvider>,_16document.getElementById('root'),_16);_16});
3. Code changes to comply with Wallet Kit API
- Fix package imports. Import key Station wallet utility from @terra-money/wallet-kit instead of prior packages.
_1import { useWallet, useConnectedWallet } from '@terra-money/wallet-kit';
- Fix minor code changes. For example,
WalletStatus
enum now has propertiesCONNECTED
instead ofWALLET_CONNECTED
. AndavailableConnections
andavailableInstallations
have been consolidated intoavailableWallets
.
_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];