Skip to content

Commit 2fa77ed

Browse files
authored
Merge pull request #80 from lidofinance/feature/si-1936-supply-form-validation
Supply Form
2 parents b08cb5b + b66c179 commit 2fa77ed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1142
-318
lines changed

abi/weth-abi.ts

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
export const WethABI = [
2+
{
3+
constant: true,
4+
inputs: [],
5+
name: 'name',
6+
outputs: [{ name: '', type: 'string' }],
7+
payable: false,
8+
stateMutability: 'view',
9+
type: 'function',
10+
},
11+
{
12+
constant: false,
13+
inputs: [
14+
{ name: 'guy', type: 'address' },
15+
{ name: 'wad', type: 'uint256' },
16+
],
17+
name: 'approve',
18+
outputs: [{ name: '', type: 'bool' }],
19+
payable: false,
20+
stateMutability: 'nonpayable',
21+
type: 'function',
22+
},
23+
{
24+
constant: true,
25+
inputs: [],
26+
name: 'totalSupply',
27+
outputs: [{ name: '', type: 'uint256' }],
28+
payable: false,
29+
stateMutability: 'view',
30+
type: 'function',
31+
},
32+
{
33+
constant: false,
34+
inputs: [
35+
{ name: 'src', type: 'address' },
36+
{ name: 'dst', type: 'address' },
37+
{ name: 'wad', type: 'uint256' },
38+
],
39+
name: 'transferFrom',
40+
outputs: [{ name: '', type: 'bool' }],
41+
payable: false,
42+
stateMutability: 'nonpayable',
43+
type: 'function',
44+
},
45+
{
46+
constant: false,
47+
inputs: [{ name: 'wad', type: 'uint256' }],
48+
name: 'withdraw',
49+
outputs: [],
50+
payable: false,
51+
stateMutability: 'nonpayable',
52+
type: 'function',
53+
},
54+
{
55+
constant: true,
56+
inputs: [],
57+
name: 'decimals',
58+
outputs: [{ name: '', type: 'uint8' }],
59+
payable: false,
60+
stateMutability: 'view',
61+
type: 'function',
62+
},
63+
{
64+
constant: true,
65+
inputs: [{ name: '', type: 'address' }],
66+
name: 'balanceOf',
67+
outputs: [{ name: '', type: 'uint256' }],
68+
payable: false,
69+
stateMutability: 'view',
70+
type: 'function',
71+
},
72+
{
73+
constant: true,
74+
inputs: [],
75+
name: 'symbol',
76+
outputs: [{ name: '', type: 'string' }],
77+
payable: false,
78+
stateMutability: 'view',
79+
type: 'function',
80+
},
81+
{
82+
constant: false,
83+
inputs: [
84+
{ name: 'dst', type: 'address' },
85+
{ name: 'wad', type: 'uint256' },
86+
],
87+
name: 'transfer',
88+
outputs: [{ name: '', type: 'bool' }],
89+
payable: false,
90+
stateMutability: 'nonpayable',
91+
type: 'function',
92+
},
93+
{
94+
constant: false,
95+
inputs: [],
96+
name: 'deposit',
97+
outputs: [],
98+
payable: true,
99+
stateMutability: 'payable',
100+
type: 'function',
101+
},
102+
{
103+
constant: true,
104+
inputs: [
105+
{ name: '', type: 'address' },
106+
{ name: '', type: 'address' },
107+
],
108+
name: 'allowance',
109+
outputs: [{ name: '', type: 'uint256' }],
110+
payable: false,
111+
stateMutability: 'view',
112+
type: 'function',
113+
},
114+
{ payable: true, stateMutability: 'payable', type: 'fallback' },
115+
{
116+
anonymous: false,
117+
inputs: [
118+
{ indexed: true, name: 'src', type: 'address' },
119+
{ indexed: true, name: 'guy', type: 'address' },
120+
{ indexed: false, name: 'wad', type: 'uint256' },
121+
],
122+
name: 'Approval',
123+
type: 'event',
124+
},
125+
{
126+
anonymous: false,
127+
inputs: [
128+
{ indexed: true, name: 'src', type: 'address' },
129+
{ indexed: true, name: 'dst', type: 'address' },
130+
{ indexed: false, name: 'wad', type: 'uint256' },
131+
],
132+
name: 'Transfer',
133+
type: 'event',
134+
},
135+
{
136+
anonymous: false,
137+
inputs: [
138+
{ indexed: true, name: 'dst', type: 'address' },
139+
{ indexed: false, name: 'wad', type: 'uint256' },
140+
],
141+
name: 'Deposit',
142+
type: 'event',
143+
},
144+
{
145+
anonymous: false,
146+
inputs: [
147+
{ indexed: true, name: 'src', type: 'address' },
148+
{ indexed: false, name: 'wad', type: 'uint256' },
149+
],
150+
name: 'Withdrawal',
151+
type: 'event',
152+
},
153+
] as const;

features/adjustment/const.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { LIDO_TOKENS } from '@lidofinance/lido-ethereum-sdk/common';
22

33
export const TOKENS_TO_MINT = {
4-
[LIDO_TOKENS.steth]: LIDO_TOKENS.steth,
54
[LIDO_TOKENS.wsteth]: LIDO_TOKENS.wsteth,
5+
[LIDO_TOKENS.steth]: LIDO_TOKENS.steth,
66
} as const;
77

88
export type TOKENS_TO_MINT = keyof typeof TOKENS_TO_MINT;

features/adjustment/mint/form/amount-field/amount-field.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { InputGroup } from '@lidofinance/lido-ui';
2+
import { useController, useFormContext } from 'react-hook-form';
23
import { InputAmount } from 'shared/components';
4+
35
import {
46
TokenSelectHookForm,
57
TokenOption,
68
} from 'shared/hook-form/controls/token-select-hook-form/token-select-hook-form';
7-
import { TOKENS_TO_MINT } from 'features/supply/const';
8-
import { useController, useFormContext } from 'react-hook-form';
9+
import { TOKENS_TO_MINT } from 'features/adjustment/const';
910
import { useMintFormData } from 'features/adjustment/mint/mint-form-context';
1011

1112
const OPTIONS: TokenOption[] = [

features/adjustment/mint/form/form-input/form-input.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import {
44
TokenSelectHookForm,
55
TokenOption,
66
} from 'shared/hook-form/controls/token-select-hook-form/token-select-hook-form';
7-
import { TOKENS_TO_MINT } from 'features/supply/const';
7+
import { TOKENS_TO_MINT } from 'features/adjustment/const';
88

99
const OPTIONS: TokenOption[] = [
10-
{ token: TOKENS_TO_MINT.ETH },
10+
{ token: TOKENS_TO_MINT.stETH },
1111
{ token: TOKENS_TO_MINT.wstETH },
1212
];
1313

features/adjustment/mint/mint-form-context/mint-form-provider.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export const MintFormProvider: FC<{ children: ReactNode }> = ({ children }) => {
4040
const { isDappActive } = useDappStatus();
4141
const formObject = useForm<MintFormSchema>({
4242
defaultValues: {
43-
amount: undefined,
4443
token: 'stETH',
4544
recipient: '' as Address,
4645
},

features/adjustment/repay/form/form-input/form-input.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
TokenSelectHookForm,
55
TokenOption,
66
} from 'shared/hook-form/controls/token-select-hook-form/token-select-hook-form';
7-
import { TOKENS_TO_MINT } from 'features/supply/const';
7+
import { TOKENS_TO_MINT } from 'features/adjustment/const';
88
import { useController, useFormContext } from 'react-hook-form';
99
import { useRepayFormData } from '../../repay-form-context';
1010

features/supply/const.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

features/supply/fund/form/balance/balance.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
1-
import { useBalance } from 'wagmi';
2-
import { useDappStatus } from 'modules/web3';
3-
1+
import { useWatch } from 'react-hook-form';
42
import { Text, Loader } from '@lidofinance/lido-ui';
5-
import { AmountInfo, InfoRow, Wrapper } from './styles';
63

74
import { formatBalance } from 'utils';
5+
import { vaultTexts } from 'modules/vaults';
6+
7+
import { useFundForm } from '../fund-form-provider';
8+
import type { FundFormValidatedValues } from '../types';
9+
10+
import { AmountInfo, InfoRow, Wrapper } from './styles';
811

912
export const Balance = () => {
10-
const { address } = useDappStatus();
11-
const { data, isLoading, isSuccess, isError } = useBalance({
12-
address,
13-
});
13+
const { token } = useWatch<FundFormValidatedValues>();
14+
const { data, isLoading, isSuccess, isError } = useFundForm().balanceQuery;
1415

1516
return (
1617
<Wrapper>
1718
<InfoRow>
1819
<Text size="xxs" color="secondary">
19-
Available to Supply
20+
{vaultTexts.actions.supply.available}
2021
</Text>
2122
{isLoading && <Loader size="small" />}
2223
{isSuccess && !isLoading && (
23-
<AmountInfo>{formatBalance(data.value).trimmed} ETH</AmountInfo>
24+
<AmountInfo>
25+
{formatBalance(data).trimmed} {token}
26+
</AmountInfo>
2427
)}
2528
{isError && !isLoading && <AmountInfo>-</AmountInfo>}
2629
</InfoRow>

features/supply/fund/form/feature-tx-info/feature-tx-info.tsx

Lines changed: 0 additions & 23 deletions
This file was deleted.

features/supply/fund/form/feature-tx-info/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)