Skip to content

Commit f4304d1

Browse files
author
Eason Smith
committed
Merge branch 'bugs/stake-tokens' into eason/bugfixing
2 parents 8411576 + 51d14bd commit f4304d1

File tree

7 files changed

+67
-92
lines changed

7 files changed

+67
-92
lines changed

examples/stake-tokens/components/staking/DelegateModal.tsx

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ export const DelegateModal = ({
6363
const [isDelegating, setIsDelegating] = useState(false);
6464
const [isSimulating, setIsSimulating] = useState(false);
6565
const [maxAmountAndFee, setMaxAmountAndFee] = useState<MaxAmountAndFee>();
66-
const [, forceUpdate] = useState(0);
6766

6867
const coin = getCoin(chainName);
6968
const exp = getExponent(chainName);
@@ -193,34 +192,30 @@ export const DelegateModal = ({
193192
notionalValue: amount
194193
? calcDollarValue(coin.base, amount, prices)
195194
: undefined,
195+
minValue: 0,
196+
maxValue: maxAmountAndFee?.maxAmount ?? Number(balance),
196197
value: amount,
197-
onValueInput: (val) => {
198-
if (!val) {
199-
setAmount(undefined);
200-
return;
201-
}
202-
203-
const max = maxAmountAndFee?.maxAmount || balance;
204-
205-
if (new BigNumber(val).gt(max)) {
206-
setAmount(Number(max));
207-
forceUpdate((n) => n + 1);
208-
return;
209-
}
210-
211-
setAmount(Number(val));
198+
onValueChange: (val) => {
199+
setAmount(val);
212200
},
213201
partials: [
214202
{
215203
label: '1/2',
216204
onClick: () => {
217-
setAmount(new BigNumber(balance).dividedBy(2).toNumber());
205+
const newAmount = new BigNumber(balance)
206+
.dividedBy(2)
207+
.toNumber();
208+
setAmount(newAmount);
218209
},
219210
},
220211
{
221212
label: '1/3',
222213
onClick: () => {
223-
setAmount(new BigNumber(balance).dividedBy(3).toNumber());
214+
const newAmount = new BigNumber(balance)
215+
.dividedBy(3)
216+
.toNumber();
217+
218+
setAmount(newAmount);
224219
},
225220
},
226221
{

examples/stake-tokens/components/staking/RedelegateModal.tsx

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,24 +114,29 @@ export const RedelegateModal = ({
114114
tokenName: coin.symbol,
115115
tokenIconUrl: getAssetLogoUrl(coin),
116116
}}
117+
minValue={0}
118+
maxValue={Number(maxAmount)}
117119
value={amount}
118120
notionalValue={
119121
amount ? calcDollarValue(coin.base, amount, prices) : undefined
120122
}
121-
onValueInput={(val) => {
122-
if (!val) {
123-
setAmount(undefined);
124-
return;
125-
}
126-
127-
if (new BigNumber(val).gt(maxAmount)) {
128-
setAmount(Number(maxAmount));
129-
forceUpdate((n) => n + 1);
130-
return;
131-
}
132-
133-
setAmount(Number(val));
123+
onValueChange={(val) => {
124+
setAmount(val);
134125
}}
126+
// onValueInput={(val) => {
127+
// if (!val) {
128+
// setAmount(undefined);
129+
// return;
130+
// }
131+
132+
// if (new BigNumber(val).gt(maxAmount)) {
133+
// setAmount(Number(maxAmount));
134+
// forceUpdate((n) => n + 1);
135+
// return;
136+
// }
137+
138+
// setAmount(Number(val));
139+
// }}
135140
partials={[
136141
{
137142
label: '1/2',

examples/stake-tokens/components/staking/UndelegateModal.tsx

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,25 @@ export const UndelegateModal = ({
133133
? calcDollarValue(coin.base, amount, prices)
134134
: undefined,
135135
value: amount,
136-
onValueInput: (val) => {
137-
if (!val) {
138-
setAmount(undefined);
139-
return;
140-
}
136+
minValue: 0,
137+
maxValue: Number(maxAmount),
138+
onValueChange: (val) => {
139+
setAmount(val);
140+
},
141+
// onValueInput: (val) => {
142+
// if (!val) {
143+
// setAmount(undefined);
144+
// return;
145+
// }
141146

142-
if (new BigNumber(val).gt(maxAmount)) {
143-
setAmount(Number(maxAmount));
144-
forceUpdate((n) => n + 1);
145-
return;
146-
}
147+
// if (new BigNumber(val).gt(maxAmount)) {
148+
// setAmount(Number(maxAmount));
149+
// forceUpdate((n) => n + 1);
150+
// return;
151+
// }
147152

148-
setAmount(Number(val));
149-
},
153+
// setAmount(Number(val));
154+
// },
150155
partials: [
151156
{
152157
label: '1/2',

examples/stake-tokens/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"eslint": "8.56.0",
3838
"eslint-config-next": "14.1.0",
3939
"generate-lockfile": "0.0.12",
40-
"typescript": "^5.1.6"
40+
"typescript": "^5.5.4"
4141
},
4242
"packageManager": "[email protected]"
4343
}
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
{
22
"compilerOptions": {
3-
"target": "ES2020",
3+
"target": "ESNext",
44
"lib": ["dom", "dom.iterable", "esnext"],
55
"allowJs": true,
66
"skipLibCheck": true,
77
"strict": true,
8-
"forceConsistentCasingInFileNames": true,
98
"noEmit": true,
109
"esModuleInterop": true,
1110
"module": "esnext",
@@ -14,11 +13,17 @@
1413
"isolatedModules": true,
1514
"jsx": "preserve",
1615
"incremental": true,
16+
"types": ["node", "react"],
17+
"plugins": [
18+
{
19+
"name": "next"
20+
}
21+
],
1722
"baseUrl": ".",
1823
"paths": {
1924
"@/*": ["*"]
2025
}
2126
},
22-
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
27+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
2328
"exclude": ["node_modules"]
2429
}

examples/stake-tokens/yarn.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ __metadata:
657657
react: "npm:18.2.0"
658658
react-dom: "npm:18.2.0"
659659
react-icons: "npm:4.6.0"
660-
typescript: "npm:^5.1.6"
660+
typescript: "npm:^5.5.4"
661661
languageName: unknown
662662
linkType: soft
663663

@@ -10334,23 +10334,23 @@ __metadata:
1033410334
languageName: node
1033510335
linkType: hard
1033610336

10337-
"typescript@npm:^5.1.6":
10338-
version: 5.4.5
10339-
resolution: "typescript@npm:5.4.5"
10337+
"typescript@npm:^5.5.4":
10338+
version: 5.5.4
10339+
resolution: "typescript@npm:5.5.4"
1034010340
bin:
1034110341
tsc: bin/tsc
1034210342
tsserver: bin/tsserver
10343-
checksum: 10c0/2954022ada340fd3d6a9e2b8e534f65d57c92d5f3989a263754a78aba549f7e6529acc1921913560a4b816c46dce7df4a4d29f9f11a3dc0d4213bb76d043251e
10343+
checksum: 10c0/422be60f89e661eab29ac488c974b6cc0a660fb2228003b297c3d10c32c90f3bcffc1009b43876a082515a3c376b1eefcce823d6e78982e6878408b9a923199c
1034410344
languageName: node
1034510345
linkType: hard
1034610346

10347-
"typescript@patch:typescript@npm%3A^5.1.6#optional!builtin<compat/typescript>":
10348-
version: 5.4.5
10349-
resolution: "typescript@patch:typescript@npm%3A5.4.5#optional!builtin<compat/typescript>::version=5.4.5&hash=5adc0c"
10347+
"typescript@patch:typescript@npm%3A^5.5.4#optional!builtin<compat/typescript>":
10348+
version: 5.5.4
10349+
resolution: "typescript@patch:typescript@npm%3A5.5.4#optional!builtin<compat/typescript>::version=5.5.4&hash=b45daf"
1035010350
bin:
1035110351
tsc: bin/tsc
1035210352
tsserver: bin/tsserver
10353-
checksum: 10c0/db2ad2a16ca829f50427eeb1da155e7a45e598eec7b086d8b4e8ba44e5a235f758e606d681c66992230d3fc3b8995865e5fd0b22a2c95486d0b3200f83072ec9
10353+
checksum: 10c0/10dd9881baba22763de859e8050d6cb6e2db854197495c6f1929b08d1eb2b2b00d0b5d9b0bcee8472f1c3f4a7ef6a5d7ebe0cfd703f853aa5ae465b8404bc1ba
1035410354
languageName: node
1035510355
linkType: hard
1035610356

yarn.lock

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6861,7 +6861,7 @@ __metadata:
68616861
"@cosmos-kit/react": "npm:2.17.0"
68626862
"@emotion/react": "npm:11.10.6"
68636863
"@emotion/styled": "npm:11.10.6"
6864-
"@interchain-ui/react": "npm:1.23.29"
6864+
"@interchain-ui/react": "npm:1.23.22"
68656865
"@interchain-ui/react-no-ssr": "npm:^0.1.6"
68666866
"@tanstack/react-query": "npm:4.32.0"
68676867
"@tanstack/react-query-devtools": "npm:4.32.0"
@@ -10036,41 +10036,6 @@ __metadata:
1003610036
languageName: node
1003710037
linkType: hard
1003810038

10039-
"@interchain-ui/react@npm:1.23.29, @interchain-ui/react@npm:^1.23.29":
10040-
version: 1.23.29
10041-
resolution: "@interchain-ui/react@npm:1.23.29"
10042-
dependencies:
10043-
"@floating-ui/core": "npm:^1.6.4"
10044-
"@floating-ui/dom": "npm:^1.6.7"
10045-
"@floating-ui/react": "npm:^0.26.19"
10046-
"@floating-ui/react-dom": "npm:^2.1.1"
10047-
"@floating-ui/utils": "npm:^0.2.4"
10048-
"@formkit/auto-animate": "npm:^0.8.2"
10049-
"@react-aria/listbox": "npm:^3.12.1"
10050-
"@react-aria/overlays": "npm:^3.22.1"
10051-
"@react-aria/utils": "npm:^3.24.1"
10052-
"@tanstack/react-virtual": "npm:^3.8.3"
10053-
"@vanilla-extract/css": "npm:^1.15.3"
10054-
"@vanilla-extract/dynamic": "npm:^2.1.1"
10055-
"@vanilla-extract/recipes": "npm:^0.5.3"
10056-
animejs: "npm:^3.2.2"
10057-
bignumber.js: "npm:^9.1.2"
10058-
client-only: "npm:^0.0.1"
10059-
clsx: "npm:^2.1.1"
10060-
copy-to-clipboard: "npm:^3.3.3"
10061-
immer: "npm:^10.1.1"
10062-
lodash: "npm:^4.17.21"
10063-
rainbow-sprinkles: "npm:^0.17.2"
10064-
react-aria: "npm:^3.33.1"
10065-
react-stately: "npm:^3.31.1"
10066-
zustand: "npm:^4.5.4"
10067-
peerDependencies:
10068-
react: ^16.14.0 || ^17.0.0 || ^18.0.0
10069-
react-dom: ^16.14.0 || ^17.0.0 || ^18.0.0
10070-
checksum: 10c0/013d8f56f0db143bc76f7e6f2509aab4ebb249a770e615df77b29748b07e743fff850d6a4599cbacc98ba7c047947e583eeb8e892f5796358243a37eb6d772d2
10071-
languageName: node
10072-
linkType: hard
10073-
1007410039
"@internationalized/date@npm:^3.5.4":
1007510040
version: 3.5.4
1007610041
resolution: "@internationalized/date@npm:3.5.4"

0 commit comments

Comments
 (0)