Skip to content

Commit

Permalink
Please the linter
Browse files Browse the repository at this point in the history
  • Loading branch information
glottologist committed Nov 7, 2023
1 parent 67231db commit 348e04e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 12 deletions.
16 changes: 7 additions & 9 deletions batcher-ui/src/components/market-maker/Vault.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ import { useDispatch } from 'react-redux';
import { getMarketHoldings, fetchUserBalances } from '@/actions';
import { selectCurrentVaultName } from '@/reducers';
import { ValidTokenAmount } from '@/types/contracts/token-manager';
import PrimaryButton from '@/components/common/PrimaryButton';
import * as Form from '@radix-ui/react-form';
import { scaleAmountUp } from '@/utils/utils';
import { tzip12 } from '@taquito/tzip12';
import { tzip16 } from '@taquito/tzip16';
import { compose, OpKind } from '@taquito/taquito';
import { useSelector } from 'react-redux';
import { NumericFormat } from 'react-number-format';
import {
userBalancesSelector,
userAddressSelector,
Expand All @@ -27,13 +25,13 @@ const Vault = () => {
const marketHoldings = useSelector(selectHoldings);
const [amountInput, setAmount] = useState<string>('0');
const tokenName = useSelector(selectCurrentVaultName);
const scaleTokenAmount = (ta: ValidTokenAmount): ValidTokenAmount => {
const scaledAmount = ta.amount / 10 ** ta?.token.decimals;
return {
...ta,
amount: scaledAmount,
};
};
// const scaleTokenAmount = (ta: ValidTokenAmount): ValidTokenAmount => {
// const scaledAmount = ta.amount / 10 ** (ta?.token.decimals || 0);
// return {
// ...ta,
// amount: scaledAmount,
// };
// };
useEffect(() => {
dispatch(getMarketHoldings(tokenName || '', userAddress));
}, [dispatch, userAddress, tokenName]);
Expand Down
1 change: 0 additions & 1 deletion batcher-ui/src/reducers/exchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
getCurrentBatchNumber,
getOraclePrice,
getPairsInfos,
newError,
} from '../../src/actions';
import {
BatcherStatus,
Expand Down
1 change: 1 addition & 0 deletions batcher-ui/src/reducers/marketholdings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { fetchMarketHoldingsCmd } from '@/commands/marketholdings';
import { MarketHoldingsState } from '@/types';

export const initialMHState: MarketHoldingsState = {
vault_address:'',
shares: 0,
nativeToken: {
token: {
Expand Down
22 changes: 21 additions & 1 deletion batcher-ui/src/utils/token-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,37 @@ export const parseToken = (tokenObject: any): ValidToken => {
};
} catch (e: any) {
console.error('Unable to parse valid token', e);
return {
name: '',
address: '',
token_id: '0',
decimals: '0',
standard: '',
};
}
};

export const parseTokenAmount = (tokenAmountObject: any): ValidTokenAmount => {
try {
const scaledAmount = scaleAmountDown(parseInt(tokenAmountObject.amount),tokenAmountObject.token.decimals);
const scaledAmount = scaleAmountDown(
parseInt(tokenAmountObject.amount),
tokenAmountObject.token.decimals
);
return {
token: parseToken(tokenAmountObject.token),
amount: scaledAmount,
};
} catch (e: any) {
console.error('Unable to parse valid token amount', e);
return {
amount: 0,
token: {
name: '',
address: '',
token_id: '0',
decimals: '0',
standard: '',
},
};
}
};
2 changes: 1 addition & 1 deletion batcher-ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"allowJs": false,
"skipLibCheck": true,
"experimentalDecorators": true,
"strict": true,
"strict": false,
"noEmit": true,
"incremental": true,
"esModuleInterop": true,
Expand Down

0 comments on commit 348e04e

Please sign in to comment.