import Admonition from '@theme/Admonition';
This guide will cover how to migrate your existing codebase to use Wallet Kit instead of the now deprecated Wallet Provider.
- The latest version of the Station Chrome extension (Station Wallet 7.4.2 and above)
- NPM
- NVM
- Node.js version 16
Most users will need to specify Node version 16 before continuing. You can manage node versions [with NVM](https://github.com/nvm-sh/nvm).
```sh
nvm install 16 nvm use 16
```
- To get started, uninstall the deprecated Station wallet packages.
npm uninstall @terra-money/use-wallet @terra-money/wallet-controller @terra-money/wallet-provider
- Install the
@terra-money/wallet-kit
package.
npm install @terra-money/wallet-kit @terra-money/terra-station-mobile
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 Station Mobile, as shown in the code sample below.
import ReactDOM from 'react-dom';
import App from './App';
import TerraStationMobileWallet from '@terra-money/terra-station-mobile';
import { getInitialConfig, WalletProvider } from '@terra-money/wallet-kit';
getInitialConfig().then((defaultNetworks) => {
ReactDOM.render(
<WalletProvider
extraWallets={[new TerraStationMobileWallet()]}
defaultNetworks={defaultNetworks}
>
<App />
</WalletProvider>,
document.getElementById('root'),
);
});
- Fix the package imports. Import the Station Wallet utility from
@terra-money/wallet-kit
instead of prior packages.
import { useWallet, useConnectedWallet } from '@terra-money/wallet-kit';
- Fix minor code changes. The
WalletStatus
enum now has theCONNECTED
property instead ofWALLET_CONNECTED
.availableConnections
andavailableInstallations
have been consolidated intoavailableWallets
.
const { connect, availableWallets } = useWallet();
const list = [
...availableWallets
.filter(({ isInstalled }) => isInstalled)
.map(({ id, name, icon }) => ({
src: icon,
children: name,
onClick: () => connect(id),
})),
...availableWallets
.filter(({ isInstalled, website }) => !isInstalled && website)
.map(({ name, icon, website }) => ({
src: icon,
children: t(`Install ${name}`),
href: website ?? '',
})),
];
Congratulations, your migration to Wallet Kit is now complete!