chore: fix lint warnings

This commit is contained in:
Sebastian.Bor 2021-04-22 22:27:22 +01:00
parent 3eba1d580a
commit 690ebd85c4
11 changed files with 70 additions and 55 deletions

View File

@ -1,7 +1,6 @@
import { import {
Account, Account,
Connection, Connection,
Message,
PublicKey, PublicKey,
SystemProgram, SystemProgram,
TransactionInstruction, TransactionInstruction,
@ -16,7 +15,7 @@ import {
import { addCustomSingleSignerTransactionInstruction } from '../models/addCustomSingleSignerTransaction'; import { addCustomSingleSignerTransactionInstruction } from '../models/addCustomSingleSignerTransaction';
const { sendTransaction } = contexts.Connection; const { sendTransaction } = contexts.Connection;
const { notify, toUTF8Array, fromUTF8Array } = utils; const { notify } = utils;
const { approve } = models; const { approve } = models;
export const addCustomSingleSignerTransaction = async ( export const addCustomSingleSignerTransaction = async (

View File

@ -1,47 +1,57 @@
import * as CANNON from 'cannon' import * as CANNON from 'cannon';
import ReactDOM from 'react-dom' import React, { useEffect, useState } from 'react';
import React, { useEffect, useState } from 'react' import { Canvas } from 'react-three-fiber';
import { Canvas } from 'react-three-fiber' import { useCannon, Provider } from './useCannon';
import { useCannon, Provider } from './useCannon' import './styles.less';
import './styles.less'
function Plane({ position }: { position: any}) { function Plane({ position }: { position: any }) {
// Register plane as a physics body with zero mass // Register plane as a physics body with zero mass
const ref = useCannon({ mass: 0 }, (body: any) => { const ref = useCannon({ mass: 0 }, (body: any) => {
body.addShape(new CANNON.Plane()) body.addShape(new CANNON.Plane());
body.position.set(...position) body.position.set(...position);
}) });
return ( return (
<mesh ref={ref} receiveShadow> <mesh ref={ref} receiveShadow>
<planeBufferGeometry attach="geometry" args={[1000, 1000]} /> <planeBufferGeometry attach="geometry" args={[1000, 1000]} />
<meshPhongMaterial attach="material" color="#272727" /> <meshPhongMaterial attach="material" color="#272727" />
</mesh> </mesh>
) );
} }
function Box({ position }: { position: any}) { function Box({ position }: { position: any }) {
// Register box as a physics body with mass // Register box as a physics body with mass
const ref = useCannon({ mass: 100000 }, (body: any) => { const ref = useCannon({ mass: 100000 }, (body: any) => {
body.addShape(new CANNON.Box(new CANNON.Vec3(1, 1, 1))) body.addShape(new CANNON.Box(new CANNON.Vec3(1, 1, 1)));
body.position.set(...position) body.position.set(...position);
}) });
return ( return (
<mesh ref={ref} castShadow receiveShadow> <mesh ref={ref} castShadow receiveShadow>
<boxGeometry attach="geometry" args={[2, 2, 2]} /> <boxGeometry attach="geometry" args={[2, 2, 2]} />
<meshStandardMaterial attach="material" /> <meshStandardMaterial attach="material" />
</mesh> </mesh>
) );
} }
export const Background = () => { export const Background = () => {
const [showPlane, set] = useState(true) const [showPlane, set] = useState(true);
// When React removes (unmounts) the upper plane after 5 sec, objects should drop ... // When React removes (unmounts) the upper plane after 5 sec, objects should drop ...
// This may seem like magic, but as the plane unmounts it removes itself from cannon and that's that // This may seem like magic, but as the plane unmounts it removes itself from cannon and that's that
useEffect(() => void setTimeout(() => set(false), 3000), []) useEffect(() => void setTimeout(() => set(false), 3000), []);
return ( return (
<Canvas className="main" shadowMap camera={{ position: [0, 0, 15] }} style={{ width: '100%', height: 400, marginTop: -120, zIndex: 1 }}> <Canvas
className="main"
shadowMap
camera={{ position: [0, 0, 15] }}
style={{ width: '100%', height: 400, marginTop: -120, zIndex: 1 }}
>
<ambientLight intensity={0.5} /> <ambientLight intensity={0.5} />
<spotLight intensity={0.6} position={[30, 30, 50]} angle={0.2} penumbra={1} castShadow /> <spotLight
intensity={0.6}
position={[30, 30, 50]}
angle={0.2}
penumbra={1}
castShadow
/>
<Provider> <Provider>
<Plane position={[0, 0, -10]} /> <Plane position={[0, 0, -10]} />
{showPlane && <Plane position={[0, 0, 0]} />} {showPlane && <Plane position={[0, 0, 0]} />}
@ -54,5 +64,5 @@ export const Background = () => {
{!showPlane && <Box position={[0.5, 1.0, 20]} />} {!showPlane && <Box position={[0.5, 1.0, 20]} />}
</Provider> </Provider>
</Canvas> </Canvas>
) );
}; };

View File

@ -4,15 +4,13 @@ import { Breadcrumb, Layout } from 'antd';
import { Link, useLocation } from 'react-router-dom'; import { Link, useLocation } from 'react-router-dom';
import { LABELS } from '../../constants'; import { LABELS } from '../../constants';
import { contexts, components } from '@oyster/common'; import { components } from '@oyster/common';
import { Content, Header } from 'antd/lib/layout/layout'; import { Content, Header } from 'antd/lib/layout/layout';
import Logo from './dark-horizontal-combined-rainbow.inline.svg'; import Logo from './dark-horizontal-combined-rainbow.inline.svg';
const { AppBar } = components; const { AppBar } = components;
const { useConnectionConfig } = contexts.Connection;
export const AppLayout = React.memo((props: any) => { export const AppLayout = React.memo((props: any) => {
const { env } = useConnectionConfig();
const location = useLocation(); const location = useLocation();
const breadcrumbNameMap: any = { const breadcrumbNameMap: any = {
@ -44,19 +42,13 @@ export const AppLayout = React.memo((props: any) => {
<div className="App"> <div className="App">
<Layout title={LABELS.APP_TITLE}> <Layout title={LABELS.APP_TITLE}>
<Header className="App-Bar"> <Header className="App-Bar">
<div className="app-title"> <div className="app-title">
<Link to="/"> <Link to="/">
<img <img alt={`Solana Logo`} src={Logo} style={{ height: 40 }} />
alt={`Solana Logo Image`} </Link>
src={Logo} </div>
style={{ height: 40 }} <AppBar useWalletBadge={true} />
/> </Header>
</Link>
</div>
<AppBar
useWalletBadge={true}
/>
</Header>
<Content> <Content>
{/* <Breadcrumb>{breadcrumbItems}</Breadcrumb> */} {/* <Breadcrumb>{breadcrumbItems}</Breadcrumb> */}
{props.children} {props.children}

View File

@ -108,9 +108,13 @@ function PlayStatusButton({
useEffect(() => { useEffect(() => {
if (ineligibleToSee) { if (ineligibleToSee) {
const id = setTimeout(() => { const timer = setTimeout(() => {
connection.getSlot().then(setCurrSlot); connection.getSlot().then(setCurrSlot);
}, 5000); }, 5000);
return () => {
clearTimeout(timer);
};
} }
}, [ineligibleToSee, connection, currSlot]); }, [ineligibleToSee, connection, currSlot]);
@ -127,8 +131,8 @@ function PlayStatusButton({
}; };
if ( if (
state.info.status != TimelockStateStatus.Executing && state.info.status !== TimelockStateStatus.Executing &&
state.info.status != TimelockStateStatus.Completed state.info.status !== TimelockStateStatus.Completed
) )
return null; return null;
if (ineligibleToSee) return null; if (ineligibleToSee) return null;

View File

@ -57,7 +57,7 @@ export default function MintSourceTokens({
let failedSourcesHold: SourceEntryInterface[] = []; let failedSourcesHold: SourceEntryInterface[] = [];
const zeroKey = PROGRAM_IDS.system; const zeroKey = PROGRAM_IDS.system;
sourceHoldersAndCounts.forEach((value: string, index: number) => { sourceHoldersAndCounts.forEach((value: string, index: number) => {
if (index % 2 == 0) if (index % 2 === 0)
sourceHolders.push({ sourceHolders.push({
owner: value ? new PublicKey(value) : zeroKey, owner: value ? new PublicKey(value) : zeroKey,
tokenAmount: 0, tokenAmount: 0,
@ -75,7 +75,7 @@ export default function MintSourceTokens({
sourceAccount: undefined, sourceAccount: undefined,
}); });
if (!sourceHolders.find(v => v.owner != zeroKey)) { if (!sourceHolders.find(v => v.owner !== zeroKey)) {
notify({ notify({
message: LABELS.ENTER_AT_LEAST_ONE_PUB_KEY, message: LABELS.ENTER_AT_LEAST_ONE_PUB_KEY,
type: 'error', type: 'error',

View File

@ -90,7 +90,7 @@ export const VoterTable = (props: IVoterTable) => {
render: (count: number, record: VoterDisplayData) => ( render: (count: number, record: VoterDisplayData) => (
<span <span
style={ style={
record.group == VoteType.Undecided record.group === VoteType.Undecided
? { color: 'grey' } ? { color: 'grey' }
: { color: record.group === VoteType.Yes ? 'green' : 'red' } : { color: record.group === VoteType.Yes ? 'green' : 'red' }
} }
@ -102,12 +102,12 @@ export const VoterTable = (props: IVoterTable) => {
{ {
title: LABELS.PERCENTAGE, title: LABELS.PERCENTAGE,
dataIndex: 'value', dataIndex: 'value',
key: 'value', key: 'percentage',
align: 'center', align: 'center',
render: (count: number, record: VoterDisplayData) => ( render: (count: number, record: VoterDisplayData) => (
<span <span
style={ style={
record.group == VoteType.Undecided record.group === VoteType.Undecided
? { color: 'grey' } ? { color: 'grey' }
: { color: record.group === VoteType.Yes ? 'green' : 'red' } : { color: record.group === VoteType.Yes ? 'green' : 'red' }
} }

View File

@ -32,7 +32,7 @@ export async function getGovernanceVotingRecords(
{ dataSize: GovernanceVotingRecordLayout.span }, { dataSize: GovernanceVotingRecordLayout.span },
{ {
memcmp: { memcmp: {
// Proposal key is first thing in the account data // Proposal key is second thing in the account data
offset: 1, offset: 1,
bytes: proposal.toString(), bytes: proposal.toString(),
}, },

View File

@ -23,7 +23,7 @@ export const HomeView = () => {
(acc, proposalKey) => { (acc, proposalKey) => {
let proposal = proposals[proposalKey]; let proposal = proposals[proposalKey];
let state = states[proposal.info.state.toBase58()]; let state = states[proposal.info.state.toBase58()];
if (proposal.info.config.toBase58() == configKey) { if (proposal.info.config.toBase58() === configKey) {
acc.active = acc.active =
acc.active + acc.active +
(state.info.status === TimelockStateStatus.Voting || (state.info.status === TimelockStateStatus.Voting ||

View File

@ -113,7 +113,7 @@ function useLoadGist({
} }
fetch(toFetch) fetch(toFetch)
.then(async resp => { .then(async resp => {
if (resp.status == 200) { if (resp.status === 200) {
if (isGist) { if (isGist) {
const jsonContent = await resp.json(); const jsonContent = await resp.json();
const nextUrlFileName = Object.keys(jsonContent['files'])[0]; const nextUrlFileName = Object.keys(jsonContent['files'])[0];
@ -123,7 +123,7 @@ function useLoadGist({
); );
} else setContent(await resp.text()); } else setContent(await resp.text());
} else { } else {
if (resp.status == 403 && isGist) if (resp.status === 403 && isGist)
setMsg(LABELS.GIT_CONTENT_EXCEEDED); setMsg(LABELS.GIT_CONTENT_EXCEEDED);
setFailed(true); setFailed(true);
} }
@ -408,7 +408,11 @@ function InnerProposalView({
failed ? ( failed ? (
<p> <p>
{LABELS.DESCRIPTION}:{' '} {LABELS.DESCRIPTION}:{' '}
<a href={timelockState.info.descLink} target="_blank"> <a
href={timelockState.info.descLink}
target="_blank"
rel="noopener noreferrer"
>
{msg ? msg : LABELS.NO_LOAD} {msg ? msg : LABELS.NO_LOAD}
</a> </a>
</p> </p>

View File

@ -138,7 +138,9 @@ export function NewForm({
> >
<Select placeholder={LABELS.SELECT_CONFIG}> <Select placeholder={LABELS.SELECT_CONFIG}>
{configs.map(c => ( {configs.map(c => (
<Option value={c.pubkey.toBase58()}>{c.info.name}</Option> <Option value={c.pubkey.toBase58()} key={c.pubkey.toBase58()}>
{c.info.name}
</Option>
))} ))}
</Select> </Select>
</Form.Item> </Form.Item>

View File

@ -13,7 +13,7 @@ export const ProposalsView = () => {
const history = useHistory(); const history = useHistory();
const { proposals, states } = useProposals(); const { proposals, states } = useProposals();
const config = useConfig(id); const config = useConfig(id);
const [page, setPage] = useState(0); const [, setPage] = useState(0);
const { tokenMap } = useConnectionConfig(); const { tokenMap } = useConnectionConfig();
const { connected } = useWallet(); const { connected } = useWallet();
const token = tokenMap.get( const token = tokenMap.get(
@ -65,7 +65,11 @@ export const ProposalsView = () => {
/> />
<div> <div>
<h1>{config?.info.name}</h1> <h1>{config?.info.name}</h1>
<a href={tokenMap.get(mint)?.extensions?.website} target="_blank"> <a
href={tokenMap.get(mint)?.extensions?.website}
target="_blank"
rel="noopener noreferrer"
>
{tokenMap.get(mint)?.extensions?.website} {tokenMap.get(mint)?.extensions?.website}
</a> </a>
</div> </div>