Skip to content

Commit

Permalink
wip: fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
philiphacks committed Feb 11, 2024
1 parent a5a734b commit a263b08
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useFormikContext } from 'formik';

import { Action, Step } from '../../components/stacking-form-step';
import { StackingUserConfirm } from '../../components/stacking-user-confirm';
import { EditingFormValues } from '../types';
import { LiquidStackingTerms } from './liquid-stacking-terms';

interface Props {
Expand All @@ -18,7 +17,6 @@ export function ConfirmAndSubmit({
allowContractCallerTxId,
}: Props) {
const [hasUserConfirmed, setHasUserConfirmed] = useState(false);
const f = useFormikContext<EditingFormValues>();

return (
<Step title="Confirm and stack">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { pseudoBorderLeft } from '@components/styles/pseudo-border-left';

import { StackingTermItem } from '../../components/stacking-term';

export function LiquidStackingTerms({ ...rest }: StacksProps) {
export function LiquidStackingTerms({ ...rest }: StackProps) {
return (
<Stack
textStyle={['body.small', 'body.large']}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import { IconEdit } from '@tabler/icons-react';

import { MIN_DELEGATED_STACKING_AMOUNT_USTX } from '@constants/app';

import {
NetworkInstance,
NetworkInstanceToPoxContractMap,
Expand Down
19 changes: 6 additions & 13 deletions src/pages/stacking/start-liquid-stacking/start-liquid-stacking.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useEffect, useState } from 'react';
import { useState } from 'react';

import { StacksNetworkName } from '@stacks/network';
import { StackingClient } from '@stacks/stacking';
import { ClarityType } from '@stacks/transactions';
import { Form, Formik } from 'formik';

import { useAuth } from '@components/auth-provider/auth-provider';
Expand All @@ -23,9 +22,8 @@ import { ChooseStackingProtocol } from './components/choose-stacking-protocol';
import { ConfirmAndSubmit } from './components/confirm-and-stack';
import { ProtocolInfoCard } from './components/liquid-stacking-info-card';
import { LiquidStackingIntro } from './components/liquid-stacking-intro';
import { protocols } from './components/preset-protocols';
import { EditingFormValues } from './types';
import { PayoutMethod, PoxContractName, ProtocolName } from './types-preset-protocols';
import { ProtocolName } from './types-preset-protocols';

Check failure on line 26 in src/pages/stacking/start-liquid-stacking/start-liquid-stacking.tsx

View workflow job for this annotation

GitHub Actions / check-lint

'ProtocolName' is defined but never used. Allowed unused vars must match /^_/u
import { createHandleSubmit } from './utils';
import {
createHandleSubmit as createHandleStackStxSubmit,
Expand Down Expand Up @@ -82,28 +80,23 @@ function StartLiquidStackingLayout({
networkName,

Check failure on line 80 in src/pages/stacking/start-liquid-stacking/start-liquid-stacking.tsx

View workflow job for this annotation

GitHub Actions / check-lint

'networkName' is defined but never used. Allowed unused args must match /^_/u
currentAccountAddresses,
}: StartLiquidStackingProps) {
const { network, networkInstance } = useStacksNetwork();
const { network } = useStacksNetwork();
const [isContractCallExtensionPageOpen, setIsContractCallExtensionPageOpen] = useState(false);

const getSecondsUntilNextCycleQuery = useGetSecondsUntilNextCycleQuery();
const navigate = useNavigate();

const validationSchema = createValidationSchema({
networkName,
});
const validationSchema = createValidationSchema();
const handleStackStxSubmit = createHandleStackStxSubmit({
client,
network,
navigate,
setIsContractCallExtensionPageOpen,
});
const handleSubmit = createHandleSubmit({
handleStackStxSubmit,
network,
handleStackStxSubmit
});

const onProtocolChange = (protocolName: ProtocolName) => {};

if (getSecondsUntilNextCycleQuery.isLoading) return <CenteredSpinner />;

if (
Expand Down Expand Up @@ -139,7 +132,7 @@ function StartLiquidStackingLayout({
<>
<Form>
<StackingFormContainer>
<ChooseStackingProtocol onProtocolChange={onProtocolChange} />
<ChooseStackingProtocol onProtocolChange={() => {}} />

Check failure on line 135 in src/pages/stacking/start-liquid-stacking/start-liquid-stacking.tsx

View workflow job for this annotation

GitHub Actions / check-lint

Unexpected empty arrow function
<ChooseStackingAmount />
<ConfirmAndSubmit
isLoading={isContractCallExtensionPageOpen}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/stacking/start-liquid-stacking/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NetworkInstance, ProtocolName, WrapperPrincipal } from './types-preset-pools';
import { ProtocolName } from './types-preset-protocols';

interface DelegatingFormIndefiniteValues<N> {
delegationDurationType: 'indefinite';
Expand Down
12 changes: 3 additions & 9 deletions src/pages/stacking/start-liquid-stacking/utils-delegate-stx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,27 @@ import { Dispatch, SetStateAction } from 'react';
import { NavigateFunction } from 'react-router-dom';

import { ContractCallRegularOptions, openContractCall } from '@stacks/connect';
import { StacksNetwork, StacksNetworkName } from '@stacks/network';
import { PoxInfo, StackingClient, poxAddressToTuple } from '@stacks/stacking';
import { StacksNetwork } from '@stacks/network';
import { PoxInfo, StackingClient } from '@stacks/stacking';
import {
FungibleConditionCode,
contractPrincipalCV,
makeStandardSTXPostCondition,
noneCV,
uintCV,
} from '@stacks/transactions';
import { principalCV } from '@stacks/transactions/dist/clarity/types/principalCV';
import * as yup from 'yup';

import { UI_IMPOSED_MAX_STACKING_AMOUNT_USTX } from '@constants/app';
import { cyclesToBurnChainHeight } from '@utils/calculate-burn-height';
import { stxToMicroStx, toHumanReadableStx } from '@utils/unit-convert';
import { stxPrincipalSchema } from '@utils/validators/stx-address-validator';
import { stxAmountSchema } from '@utils/validators/stx-amount-validator';

import { protocols } from './components/preset-protocols';
import { EditingFormValues } from './types';
import { PoxContractName, ProtocolName } from './types-preset-protocols';
import { getNetworkInstance, getPoxContractAddressAndName } from './utils-preset-protocols';

interface Args {
networkName: StacksNetworkName;
}
export function createValidationSchema({ networkName }: Args) {
export function createValidationSchema() {
return yup.object().shape({
amount: stxAmountSchema()
.test({
Expand Down
15 changes: 2 additions & 13 deletions src/pages/stacking/start-liquid-stacking/utils.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
import { StacksNetwork } from '@stacks/network';

import { EditingFormValues } from './types';
import { getNetworkInstance, getPoxWrapperContract } from './utils-preset-protocols';

interface CreateHandleSubmitArgs {
handleStackStxSubmit: (val: EditingFormValues) => Promise<void>;
network: StacksNetwork;
}

export function createHandleSubmit({ handleStackStxSubmit, network }: CreateHandleSubmitArgs) {
export function createHandleSubmit({ handleStackStxSubmit }: CreateHandleSubmitArgs) {
return async function handleSubmit(values: EditingFormValues) {
if (values.protocolName) {
const poxWrapperContract = getPoxWrapperContract(values.protocolName, network);
const networkInstance = getNetworkInstance(network);
handleStackStxSubmit(values);
} else {
handleStackStxSubmit(values);
return;
}
handleStackStxSubmit(values);
};
}

0 comments on commit a263b08

Please sign in to comment.