utils#IChainSelection TypeScript Examples

The following examples show how to use utils#IChainSelection. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: send.ts    From frontend-v1 with GNU Affero General Public License v3.0 5 votes vote down vote up
sendSlice = createSlice({
  name: "send",
  initialState,
  reducers: {
    token: (state, action: PayloadAction<Pick<State, "token">>) => {
      state.token = action.payload.token;
      return state;
    },
    amount: (state, action: PayloadAction<Pick<State, "amount">>) => {
      state.amount = action.payload.amount;
      return state;
    },
    toChain: (state, action: PayloadAction<Pick<State, "toChain">>) => {
      state.toChain = action.payload.toChain;
      return state;
    },
    fromChain: (state, action: PayloadAction<Pick<State, "fromChain">>) => {
      state.fromChain = action.payload.fromChain;
      return state;
    },
    updateSelectedToChain: (state, action: PayloadAction<IChainSelection>) => {
      state.currentlySelectedToChain = action.payload;
      return state;
    },
    updateSelectedFromChain: (
      state,
      action: PayloadAction<IChainSelection>
    ) => {
      state.currentlySelectedFromChain = action.payload;
      return state;
    },
    toAddress: (
      state,
      action: PayloadAction<Required<Pick<State, "toAddress">>>
    ) => {
      state.toAddress = action.payload.toAddress;
      return state;
    },
    error: (state, action: PayloadAction<Pick<State, "error">>) => {
      state.error = action.payload.error;
      return state;
    },
  },
  extraReducers: (builder) =>
    builder
      .addCase(update, (state, action) => {
        // since this is hooked in from a connection update, we need to treat the address the same way. Onboard is all lowercase.
        state.toAddress = action.payload.account
          ? getAddress(action.payload.account)
          : state.toAddress;
        return state;
      })
      .addCase(toggleConfirmationScreen, (state, action) => {
        // If the confirmation screen is closed, reset some values in the state.
        if (action.payload.showConfirmationScreen === false) {
          state = {
            ...state,
            amount: ethers.constants.Zero,
            error: undefined,
          };
        }
        return state;
      }),
})