Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start fixing TypeScript issues #244

Merged
merged 1 commit into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
"@testing-library/react": "^13.2.0",
"@types/amplitude-js": "^8.0.2",
"@types/dockerode": "^3.3.9",
"@types/dompurify": "^2.3.3",
"@types/enzyme": "^3.10.10",
"@types/history": "^5.0.0",
"@types/logfmt": "^1.2.2",
Expand Down
2 changes: 1 addition & 1 deletion src/main/transactionLogs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as sol from '@solana/web3.js';
import Electron from 'electron';
import { LogSubscriptionMap } from '@/types/types';
import { LogSubscriptionMap } from '../types/types';
import { netToURL } from '../common/strings';

const logSubscriptions: LogSubscriptionMap = {};
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/common/analytics.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import amplitude from 'amplitude-js';
import { logger } from '@/common/globals';
import store from '@/store';
import { logger } from './globals';
import store from '../store';
import { ConfigKey } from '../data/Config/configState';

const AMPLITUDE_KEY = 'f1cde3642f7e0f483afbb7ac15ae8277';
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/AccountView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { faTerminal } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import React, { useEffect, useState } from 'react';
import { useEffect, useState } from 'react';
import ButtonToolbar from 'react-bootstrap/ButtonToolbar';
import Container from 'react-bootstrap/Container';
import { Button } from 'react-bootstrap';
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/LogView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as sol from '@solana/web3.js';
import { useEffect, useState } from 'react';
import { logger } from '@/common/globals';
import { logger } from '../common/globals';
import {
NetStatus,
netToURL,
Expand Down
1 change: 0 additions & 1 deletion src/renderer/components/MintInfoView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import * as sol from '@solana/web3.js';

import Accordion from 'react-bootstrap/esm/Accordion';
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/ProgramChange.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback, useEffect, useState } from 'react';
import { setSelected } from '@/data/SelectedAccountsList/selectedAccountsState';
import { useCallback, useEffect, useState } from 'react';
import { setSelected } from '../data/SelectedAccountsList/selectedAccountsState';
import { AccountInfo } from '../data/accounts/accountInfo';
import { useAccountMeta } from '../data/accounts/accountState';
import {
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/ProgramChangeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
accountsActions,
selectAccountsListState,
setSelected,
} from '@/data/SelectedAccountsList/selectedAccountsState';
import { logger } from '@/common/globals';
} from '../data/SelectedAccountsList/selectedAccountsState';
import { logger } from '../common/globals';
import createNewAccount from '../data/accounts/account';
import { AccountInfo } from '../data/accounts/accountInfo';
import {
Expand Down
7 changes: 3 additions & 4 deletions src/renderer/components/tokens/CreateNewMintButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ import * as sol from '@solana/web3.js';

import * as walletAdapter from '@solana/wallet-adapter-react';
import { Button } from 'react-bootstrap';
import React from 'react';
import * as walletWeb3 from '../../wallet-adapter/web3';

import { logger } from '@/common/globals';
import { useAppSelector } from '@/hooks';
import { logger } from '../../common/globals';
import { useAppSelector } from '../../hooks';
import {
NetStatus,
selectValidatorNetworkState,
} from '@/data/ValidatorNetwork/validatorNetworkState';
} from '../../data/ValidatorNetwork/validatorNetworkState';

async function createNewMint(
connection: sol.Connection,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import * as sol from '@solana/web3.js';
import * as metaplex from '@metaplex/js';

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/tokens/MetaplexTokenData.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import { useState } from 'react';
import OverlayTrigger from 'react-bootstrap/OverlayTrigger';
import Popover from 'react-bootstrap/Popover';
import Button from 'react-bootstrap/Button';
Expand Down
1 change: 0 additions & 1 deletion src/renderer/components/tokens/MintTokenToButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as sol from '@solana/web3.js';

import * as walletAdapter from '@solana/wallet-adapter-react';
import { Button } from 'react-bootstrap';
import React from 'react';
import { useQueryClient } from 'react-query';
import * as walletWeb3 from '../../wallet-adapter/web3';

Expand Down
1 change: 0 additions & 1 deletion src/renderer/components/tokens/TokensListView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { Card, Accordion, Table } from 'react-bootstrap';
import * as sol from '@solana/web3.js';
import { useConnection, useWallet } from '@solana/wallet-adapter-react';
Expand Down
14 changes: 7 additions & 7 deletions src/renderer/components/tokens/TransferTokenButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import {
Popover,
Row,
} from 'react-bootstrap';
import React, { useEffect, useState } from 'react';
import { useEffect, useState } from 'react';
import * as walletWeb3 from '../../wallet-adapter/web3';

import { logger } from '@/common/globals';
import { useAppSelector } from '@/hooks';
import { logger } from '../../common/globals';
import { useAppSelector } from '../../hooks';
import {
NetStatus,
selectValidatorNetworkState,
} from '@/data/ValidatorNetwork/validatorNetworkState';
} from '../../data/ValidatorNetwork/validatorNetworkState';
import { ensureAtaFor } from './CreateNewMintButton';

async function transferTokenToReceiver(
Expand All @@ -27,7 +27,7 @@ async function transferTokenToReceiver(
mintKey: sol.PublicKey,
transferFrom: sol.PublicKey,
transferTo: sol.PublicKey,
tokenCount: int
tokenCount: number
) {
if (!transferTo) {
logger.info('no transferTo', transferTo);
Expand Down Expand Up @@ -90,7 +90,7 @@ function TransferTokenPopover(props: {
}) {
const { connection, fromKey, mintKey, transferFrom } = props;

let pubKeyVal;
let pubKeyVal = '';
if (!pubKeyVal) {
pubKeyVal = 'paste';
}
Expand Down Expand Up @@ -189,7 +189,7 @@ function TransferTokenPopover(props: {
new sol.PublicKey(mintKey),
new sol.PublicKey(transferFrom),
new sol.PublicKey(toKey),
tokenCount
parseInt(tokenCount, 10)
),
{
pending: 'Transfer submitted',
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/data/Config/configState.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import { useEffect } from 'react';
import { ConfigMap } from '@/../types/types';
import { logger } from '@/common/globals';
import { ConfigMap } from '../../../types/types';
import { logger } from '../../common/globals';
import { useAppDispatch, useAppSelector } from '../../hooks';
// https://redux.js.org/usage/usage-with-typescript#define-slice-state-and-action-types
// eslint-disable-next-line import/no-cycle
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/data/ValidatorNetwork/ValidatorNetwork.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as sol from '@solana/web3.js';
import { useEffect } from 'react';
import Dropdown from 'react-bootstrap/Dropdown';
import DropdownButton from 'react-bootstrap/DropdownButton';
import { logger } from '@/common/globals';
import { logger } from '../../common/globals';
import { useAppDispatch, useAppSelector, useInterval } from '../../hooks';
import {
Net,
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/data/accounts/account.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AnyAction, Dispatch, ThunkDispatch } from '@reduxjs/toolkit';
import { WalletContextState } from '@solana/wallet-adapter-react';
import * as sol from '@solana/web3.js';
import { logger } from '@/common/globals';
import { logger } from '../../common/globals';
import { NewKeyPairInfo } from '../../../types/types';
import { ConfigState, setConfigValue } from '../Config/configState';
import { SelectedAccountsList } from '../SelectedAccountsList/selectedAccountsState';
Expand Down
1 change: 1 addition & 0 deletions src/renderer/data/accounts/accountInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export interface AccountInfo {
count: number; // count tracks how often this account has been seen
solDelta: number; // difference between last change amount and this one
maxDelta: number; // maxDelta represents the max change in SOL seen during session
programID: string;
}
2 changes: 1 addition & 1 deletion src/renderer/data/accounts/accountState.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import * as sol from '@solana/web3.js';
import { useEffect } from 'react';
import { logger } from '@/common/globals';
import { logger } from '../../common/globals';
import { useAppDispatch, useAppSelector } from '../../hooks';
// https://redux.js.org/usage/usage-with-typescript#define-slice-state-and-action-types
// eslint-disable-next-line import/no-cycle
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/data/accounts/programChanges.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as sol from '@solana/web3.js';
import { logger } from '@/common/globals';
import { logger } from '../../common/globals';
import { Net, netToURL } from '../ValidatorNetwork/validatorNetworkState';
import { AccountInfo } from './accountInfo';
import { peekAccount, updateCache } from './getAccount';
Expand Down
1 change: 0 additions & 1 deletion src/renderer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { createRoot } from 'react-dom/client';
import { Provider } from 'react-redux';
import { HashRouter } from 'react-router-dom';
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/nav/TokenPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react';
import { useEffect, useState } from 'react';
import Split from 'react-split';

import Stack from 'react-bootstrap/Stack';
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/nav/Validator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
selectValidatorNetworkState,
} from '../data/ValidatorNetwork/validatorNetworkState';
import { useAppSelector, useInterval } from '../hooks';
import { logger } from '@/common/globals';
import { logger } from '../common/globals';

const ipcDockerToast = (dockerIPCMethod: string) => {
return toast.promise(window.promiseIpc.send(`DOCKER-${dockerIPCMethod}`), {
Expand All @@ -38,7 +38,7 @@ const Validator = () => {
const filterRef = useRef<HTMLInputElement>({} as HTMLInputElement);
const validator = useAppSelector(selectValidatorNetworkState);
const validatorImageName = 'cryptoworkbench/solana-amman';
const [validatorImageTag, setValidatorImageTag] = useState<string>('');
const [validatorImageTag, setValidatorImageTag] = useState<string | null>('');
// const [validatorImageTags, setValidatorImageTags] = useState<string[]>([]);
const [containerInspect, setContainerInspect] = useState<any>({});

Expand Down Expand Up @@ -135,7 +135,7 @@ const Validator = () => {
validatorImageTag !== '' ? validatorImageTag : 'Docker image'
}
disabled={containerInspect?.State}
onSelect={(image: string) => {
onSelect={(image: string | null) => {
logger.info(`selected image: ${image}`);
setValidatorImageTag(image);
}}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/nav/ValidatorNetworkInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useEffect, useState } from 'react';
import { Col, Row } from 'react-bootstrap';
import Container from 'react-bootstrap/Container';
import { VictoryPie } from 'victory';
import { logger } from '@/common/globals';
import { logger } from '../common/globals';
import {
netToURL,
selectValidatorNetworkState,
Expand Down