Skip to content

Commit

Permalink
chore: fix type checking
Browse files Browse the repository at this point in the history
  • Loading branch information
philiphacks committed Feb 11, 2024
1 parent 73b2870 commit 5c36357
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ interface ChooseStackingProtocolProps {
}
export function ChooseStackingProtocol({ onProtocolChange }: ChooseStackingProtocolProps) {
const [fieldProtocolName, , helpersProtocolName] = useField('protocolName');
const [, , helpersDelegationDurationType] = useField('delegationDurationType');
const onChange = (protocolName: ProtocolName) => {
helpersDelegationDurationType.setValue('indefinite');
helpersProtocolName.setValue(protocolName);
onProtocolChange(protocolName);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export function ProtocolInfoCard(props: FlexProps) {
const { networkName, networkInstance } = useStacksNetwork();

const amount = f.values.amount;
const delegationType = f.values.delegationDurationType;
const protocolName = f.values.protocolName;
const protocol = protocolName ? protocols[protocolName] : undefined;
const protocolStxAddress =
Expand All @@ -40,18 +39,7 @@ export function ProtocolInfoCard(props: FlexProps) {
(protocol?.poxContract
? getPoxWrapperContract2(networkInstance, protocol.poxContract)
: undefined) || poxInfoQuery.data?.contract_id;
const durationInCycles =
f.values.delegationDurationType === 'limited' ? f.values.numberOfCycles : null;

const burnHeight =
durationInCycles && poxInfoQuery.data
? cyclesToBurnChainHeight({
cycles: durationInCycles,
rewardCycleLength: poxInfoQuery.data.reward_cycle_length,
currentCycleId: poxInfoQuery.data.current_cycle.id,
firstBurnchainBlockHeight: poxInfoQuery.data.first_burnchain_block_height,
})
: null;
const amountText = createAmountText(amount);

return (
Expand All @@ -65,37 +53,15 @@ export function ProtocolInfoCard(props: FlexProps) {
<Group mt="base-loose" mb="extra-loose">
<Section>
<Row>
<Label explainer="How long you want to delegate to the protocol. This is not necessarily the locking duration. However, the locking period cannot be longer than the delegation duration.">
<Label explainer="How long you will liquid stack with the protocol. By default, any liquid stacking protocol will stack your STX indefinitely until you decide to unstack.">
Duration
</Label>
<Value>
{!delegationType && '—'}
{delegationType === 'limited' && formatCycles(durationInCycles ?? 0)}
{delegationType === 'indefinite' && 'Indefinite'}
Indefinite
</Value>
</Row>
</Section>

<Section>
<Row>
<Label explainer="How you want to delegate to the protocol. This is not necessarily the locking duration. However, the locking period cannot be longer than the delegation duration.">
Type
</Label>
<Value>
{delegationType === null && '—'}
{delegationType === 'limited' && 'Limited permission'}
{delegationType === 'indefinite' && 'Indefinite'}
</Value>
</Row>

{burnHeight && (
<Row>
<Label>Burn height</Label>
<Value>{burnHeight}</Value>
</Row>
)}
</Section>

<Section>
<Row>
<Label explainer="This address is provided to you by your chosen protocol for liquid stacking specifically.">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { NetworkInstance } from 'src/pages/stacking/start-pooled-stacking/types-preset-pools';

import {
NetworkInstance,
NetworkInstanceToPoxContractMap,
PayoutMethod,
PoxContractName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ const initialDelegatingFormValues: Partial<EditingFormValues> = {
amount: '',
stxAddress: '',
protocolAddress: '',
delegationDurationType: undefined,
numberOfCycles: 1,
};

export function StartLiquidStacking() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
export const enum NetworkInstance {
mainnet = 'mainnet',
testnet = 'testnet',
devnet = 'devnet',
}
import { NetworkInstance } from 'src/pages/stacking/start-pooled-stacking/types-preset-pools';

export const enum ProtocolName {
StackingDao = 'StackingDAO',
Expand Down
1 change: 0 additions & 1 deletion src/pages/stacking/start-liquid-stacking/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ProtocolName } from './types-preset-protocols';

interface LiquidStackingFormValues<N> {
delegationDurationType: 'limited';
amount: N;
protocolAddress: string;
stxAddress: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ export function createValidationSchema() {
const enteredAmount = stxToMicroStx(value);
return enteredAmount.isLessThanOrEqualTo(UI_IMPOSED_MAX_STACKING_AMOUNT_USTX);
},
}),
delegationDurationType: yup.string().required('Please select the delegation duration type.'),
})
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ChainID } from '@stacks/common';
import { StacksNetwork } from '@stacks/network';
import { DEFAULT_DEVNET_SERVER } from 'src/constants';
import { NetworkInstance } from 'src/pages/stacking/start-pooled-stacking/types-preset-pools';

import { protocols } from './components/preset-protocols';
import {
NetworkInstance,
NetworkInstanceToPoxContractMap,
PoxContractName,
PoxContractType,
Expand Down

0 comments on commit 5c36357

Please sign in to comment.