Skip to content

Commit

Permalink
bug/591 - Staking should use correct chain ID (#593)
Browse files Browse the repository at this point in the history
* fix: staking should use correct chain ID

* fix: chain ID validation message
  • Loading branch information
jurevans authored Jan 30, 2024
1 parent 47100a0 commit e38859c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion apps/extension/src/App/Settings/Network.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const Network = (): JSX.Element => {
type="text"
value={chainId}
onChange={(e) => setChainId(e.target.value)}
error={chainId.length === 0 ? "URL is required!" : ""}
error={chainId.length === 0 ? "Chain ID required!" : ""}
/>
<Input
label="URL"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
Select,
} from "@namada/components";
import { chains } from "@namada/chains";
import { TokenType, Tokens } from "@namada/types";
import { Chain, TokenType, Tokens } from "@namada/types";
import BigNumber from "bignumber.js";
import { useState } from "react";
import { Account, AccountsState } from "slices/accounts";
Expand Down Expand Up @@ -45,6 +45,7 @@ const toTokenData = (

export const EthereumBridge = (): JSX.Element => {
const { derived } = useAppSelector<AccountsState>((state) => state.accounts);
const { id, chainId } = useAppSelector<Chain>((state) => state.chain.config);
const [recipient, setRecipient] = useState("");
const [amount, setAmount] = useState<BigNumber>(new BigNumber(0));
const [feeAmount, setFeeAmount] = useState<BigNumber>(new BigNumber(0));
Expand Down Expand Up @@ -75,7 +76,7 @@ export const EthereumBridge = (): JSX.Element => {
(account) => account?.details?.address === accountId
) as Account;

const integration = getIntegration(chains.namada.id);
const integration = getIntegration(id);
await integration.submitBridgeTransfer(
{
bridgeProps: {
Expand All @@ -92,7 +93,7 @@ export const EthereumBridge = (): JSX.Element => {
feeAmount: new BigNumber(0),
gasLimit: new BigNumber(20_000),
publicKey: account.details.publicKey,
chainId: chains.namada.chainId,
chainId,
},
},
account.details.type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ export const postNewBonding = createAsyncThunk<
{ state: RootState }
>(POST_NEW_STAKING, async (change, thunkApi) => {
const { derived } = thunkApi.getState().accounts;
const { id, chainId } = thunkApi.getState().chain.config;
const integration = getIntegration(chains.namada.id);
const signer = integration.signer() as Signer;
const { owner: source, validatorId: validator, amount } = change;
const { id, chainId } = chains.namada;
const account = derived[id][source];
const { type, publicKey } = account.details;

Expand Down Expand Up @@ -272,7 +272,8 @@ export const postNewUnbonding = createAsyncThunk<
{ state: RootState }
>(POST_UNSTAKING, async (change, thunkApi) => {
const { derived } = thunkApi.getState().accounts;
const { chainId, id } = chains.namada
const { id, chainId } = thunkApi.getState().chain.config;

const integration = getIntegration(id);
const signer = integration.signer() as Signer;
const { owner: source, validatorId: validator, amount } = change;
Expand Down Expand Up @@ -303,7 +304,8 @@ export const postNewWithdraw = createAsyncThunk<
{ state: RootState }
>(POST_UNSTAKING, async ({ owner, validatorId }, thunkApi) => {
const { derived } = thunkApi.getState().accounts;
const { id, chainId } = chains.namada
const { id, chainId } = thunkApi.getState().chain.config;

const integration = getIntegration(id);
const signer = integration.signer() as Signer;
const {
Expand Down
2 changes: 1 addition & 1 deletion apps/namada-interface/src/slices/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit";
export type Channel = string;

type ChannelsByChain = {
[chainId: string]: Record<string, Channel[]>;
[chainKey: string]: Record<string, Channel[]>;
};

export type ChannelsState = {
Expand Down

0 comments on commit e38859c

Please sign in to comment.