Instead of importing `walletSaga`, use `createWalletSaga`:
**Saga**:
```ts
import { all } from 'redux-saga/effects'
import { createWalletSaga } from 'decentraland-dapps/dist/modules/wallet/sagas'
const walletSaga = createWalletSaga({ CHAIN_ID: process.env.chainId })
export function* rootSaga() {
yield all([
walletSaga()
// your other sagas here
])
}
```
**Actions**:
If you want to hook a callback to connect the wallet, there're two things to keep in mind. The process of connecting a wallet consists in two steps, first `enabling` it and then properly connecting it. The set of actions to keep in mind are the following (all from `decentraland-dapps/dist/modules/wallet/actions`):
```tsx
enableWalletRequest
enableWalletSuccess
enableWalletFailure
```
With it's corresponding actions and types from the same file:
```tsx
ENABLE_WALLET_REQUEST
ENABLE_WALLET_SUCCESS
ENABLE_WALLET_FAILURE
EnableWalletRequestAction
EnableWalletSuccessAction
EnableWalletFailureAction
```
The wallet saga will listen for `ENABLE_WALLET_SUCCESS` and automatically call `CONNECT_WALLET_REQUEST`. If you use `connect wallet` without enabling first it will only work if you enabled first and it'll stop working once the user disconnects the wallet from the site (if she ever does).
All of this is handled by [SignInPage](#signinpage) behind the scenes, so you can just use that instead. Remember to add [
The first parameter of `createStorageMiddleware` is the key used to store the state data in localStorage (required). The second parameter is an array of paths from the state that you want to be stored, ie: ```ts const paths = [['invites'][('user', 'name')]] ``` That will make `state.invites` and `state.user.name` persistent. This parameter is optional and you don't have to configure it to use the `Transaction` and/or `Translation` modules. The third parameter is an array of action types that will trigger a SAVE of the state in localStorage, ie: ```ts const actionTypes = [SEND_INVITE_SUCCESS] ``` This parameter is optional and is and you don't have to configure it to use the `Transaction` and/or `Translation` modules.
Taking the example of the `SEND_INVITE_SUCCESS` action type shown in the `Usage` section above, let's say we want to decrement the amount of available invites after the transaction is mined, we can do so by adding the `FETCH_TRANSACTION_SUCCESS` action type in our reducer: ```diff // modules/invite/reducer import { AnyAction } from 'redux' import { loadingReducer } from 'decentraland-dapps/dist/modules/loading/reducer' import { FETCH_INVITES_REQUEST, FETCH_INVITES_SUCCESS, FETCH_INVITES_FAILURE, FetchInvitesSuccessAction, FetchInvitesFailureAction, FetchInvitesRequestAction, + SEND_INVITE_SUCCESS } from './actions' + import { FETCH_TRANSACTION_SUCCESS, FetchTransactionSuccessAction } from 'decentraland-dapps/dist/modules/transaction/actions'; export type InviteState = { loading: AnyAction[] data: { [address: string]: number } error: null | string } export type InviteReducerAction = | FetchInvitesRequestAction | FetchInvitesSuccessAction | FetchInvitesFailureAction + | FetchTransactionSuccessAction export const INITIAL_STATE: InviteState = { loading: [], data: {}, error: null } export function invitesReducer( state: InviteState = INITIAL_STATE, action: InviteReducerAction ): InviteState { switch (action.type) { case FETCH_INVITES_REQUEST: { return { ...state, loading: loadingReducer(state.loading, action) } } case FETCH_INVITES_SUCCESS: { return { loading: loadingReducer(state.loading, action), data: { ...state.data, [action.payload.address]: action.payload.amount }, error: null } } case FETCH_INVITES_FAILURE: { return { ...state, loading: loadingReducer(state.loading, action), error: action.payload.errorMessage } } + case FETCH_TRANSACTION_SUCCESS: { + const { transaction } = action.payload + switch (transaction.actionType) { + case SEND_INVITE_SUCCESS: { + const { address } = (transaction as any).payload + return { + ...state, + data: { + ...state.data, + [address]: state.data[address] - 1 + } + } + } + default: + return state + } + } default: { return state } } } ```
After [installing the Storage module](https://github.com/decentraland/decentraland-dapps#storage) you can persist the translations by adding `'translation'` to your storage middleware paths: ```ts // store.ts const { storageMiddleware, loadStorageMiddleware } = createStorageMiddleware({ storageKey: 'my-dapp-storage', paths: ['translation'] }) ``` This will store the translation module in `localStorage`, so next time your application is started it will boot with all the translations populated before even fetching them from the server.
The modal actions allow for a generic type for the name. So say you want to type the name of your available modals, you can create a `modal` module in your dApp and add the following files:
**Types**:
```ts
// modules/types/actions.ts
import * as modals from 'components/Modals' // same import as the one use for
Say you want to override some translations in English, just include any or all of the following translations in your `en.json` locale file: ```json { "@dapps": { "navbar": { "account": { "connecting": "Connecting...", "signIn": "Sign In" }, "menu": { "agora": "Agora", "blog": "Blog", "docs": "Docs", "marketplace": "Marketplace" } } } } ```