Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Szegoo committed Oct 24, 2023
1 parent d290b63 commit d861cc9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 22 deletions.
3 changes: 0 additions & 3 deletions __tests__/identityKey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ describe("IdentityKey", () => {

// The polkadot cipher shouldn't be affected.
expect(IdentityKey.getChainCipher(identityKey, polkadotChainId, "polkadot")).toBe(polkadotCipher);

// Cannot update a cipher of a chain that does not exist.
expect(() => IdentityKey.updateCipher(identityKey, 42, "polkadot")).toThrow("Cannot find chainId");
});

test("Encryption and decryption works", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Modals/ShareIdentity/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const ShareIdentityModal = ({
setChains(result);
}
getChains();
}, []);
}, [getAllChains, identityNo]);

useEffect(() => {
if (identityNo === null) return;
Expand Down Expand Up @@ -78,7 +78,7 @@ export const ShareIdentityModal = ({
} catch (e: any) {
toastError(`Failed to get the identity key. Error: ${e.message}`);
}
}, [checks, identityNo, chains, sharedKey]);
}, [checks, identityNo, chains, sharedKey, toastError]);

useEffect(() => setChecks({}), [open]);

Expand Down
8 changes: 5 additions & 3 deletions src/contexts/RelayApi/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,15 @@ const defaultValue = {

type Relay = {
relay: "polkadot" | "kusama",
setRelay(value: string): void
// eslint-disable-next-line @typescript-eslint/no-unused-vars
setRelay(_value: string): void
}

const DEFAULT_RELAY = "kusama";

const RelayContext = React.createContext(
{ relay: "polkadot", setRelay: (_: string) => { } } as Relay
// eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-unused-vars
{ relay: "polkadot", setRelay: (_value: string) => { } } as Relay
);

const RelayContextProvider = (props: any) => {
Expand Down Expand Up @@ -128,4 +130,4 @@ const RelayApiContextProvider = (props: any) => {

const useRelayApi = () => useContext(RelayApiContext);

export { RelayApiContextProvider, RelayContextProvider, useRelay,useRelayApi };
export { RelayApiContextProvider, RelayContextProvider, useRelay, useRelayApi };
17 changes: 3 additions & 14 deletions src/pages/transfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { getTeleportableAssets } from '@/utils/xcmTransfer/teleportableRoutes';
import { Fungible } from '@/utils/xcmTransfer/types';

import { chainsSupportingXcmExecute } from '@/consts';
import { RelayContextProvider, useRelay, useRelayApi } from '@/contexts/RelayApi';
import { useRelay, useRelayApi } from '@/contexts/RelayApi';
import { useToast } from '@/contexts/Toast';
import { useIdentity } from '@/contracts';
import { useAddressBook } from '@/contracts/addressbook/context';
Expand Down Expand Up @@ -102,15 +102,13 @@ const TransferPage = () => {
}
} else {
const chaindata = new Chaindata();
console.log(relay);
const chain = await chaindata.getChain(sourceChainId, relay);

const _assets = [];
if (chain) {
const allTokens = (await chaindata.getTokens((chain.id === "kusama" || chain.id === "polkadot") ? null : relay));
const tokens = allTokens.filter((token) => {
const prefix = `${chain.id}-${token.data.type}`;
console.log(`${chain.id}-${token.data.type}`);
const isPartOfSourceChain = token.data.id.startsWith(prefix);
return isPartOfSourceChain;
});
Expand All @@ -136,7 +134,7 @@ const TransferPage = () => {
}

setLoadingAssets(false);
}, [sourceChainId, destChainId, relayApi, relay]);
}, [sourceChainId, destChainId, chains]);

useEffect(() => {
loadAssets();
Expand Down Expand Up @@ -515,13 +513,4 @@ const TransferPage = () => {
);
};


const TransferPageWrapped = () => {
return (
<RelayContextProvider>
<TransferPage />
</RelayContextProvider>
)
}

export default TransferPageWrapped;
export default TransferPage;

0 comments on commit d861cc9

Please sign in to comment.