Skip to content

Commit

Permalink
Merge branch 'bugs/stake-tokens' into eason/bugfixing
Browse files Browse the repository at this point in the history
  • Loading branch information
Eason Smith committed Aug 6, 2024
2 parents 135959a + fa15db5 commit c5fc3af
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 92 deletions.
31 changes: 13 additions & 18 deletions examples/stake-tokens/components/staking/DelegateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export const DelegateModal = ({
const [isDelegating, setIsDelegating] = useState(false);
const [isSimulating, setIsSimulating] = useState(false);
const [maxAmountAndFee, setMaxAmountAndFee] = useState<MaxAmountAndFee>();
const [, forceUpdate] = useState(0);

const coin = getCoin(chainName);
const exp = getExponent(chainName);
Expand Down Expand Up @@ -193,34 +192,30 @@ export const DelegateModal = ({
notionalValue: amount
? calcDollarValue(coin.base, amount, prices)
: undefined,
minValue: 0,
maxValue: maxAmountAndFee?.maxAmount ?? Number(balance),
value: amount,
onValueInput: (val) => {
if (!val) {
setAmount(undefined);
return;
}

const max = maxAmountAndFee?.maxAmount || balance;

if (new BigNumber(val).gt(max)) {
setAmount(Number(max));
forceUpdate((n) => n + 1);
return;
}

setAmount(Number(val));
onValueChange: (val) => {
setAmount(val);
},
partials: [
{
label: '1/2',
onClick: () => {
setAmount(new BigNumber(balance).dividedBy(2).toNumber());
const newAmount = new BigNumber(balance)
.dividedBy(2)
.toNumber();
setAmount(newAmount);
},
},
{
label: '1/3',
onClick: () => {
setAmount(new BigNumber(balance).dividedBy(3).toNumber());
const newAmount = new BigNumber(balance)
.dividedBy(3)
.toNumber();

setAmount(newAmount);
},
},
{
Expand Down
31 changes: 18 additions & 13 deletions examples/stake-tokens/components/staking/RedelegateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,29 @@ export const RedelegateModal = ({
tokenName: coin.symbol,
tokenIconUrl: getAssetLogoUrl(coin),
}}
minValue={0}
maxValue={Number(maxAmount)}
value={amount}
notionalValue={
amount ? calcDollarValue(coin.base, amount, prices) : undefined
}
onValueInput={(val) => {
if (!val) {
setAmount(undefined);
return;
}

if (new BigNumber(val).gt(maxAmount)) {
setAmount(Number(maxAmount));
forceUpdate((n) => n + 1);
return;
}

setAmount(Number(val));
onValueChange={(val) => {
setAmount(val);
}}
// onValueInput={(val) => {
// if (!val) {
// setAmount(undefined);
// return;
// }

// if (new BigNumber(val).gt(maxAmount)) {
// setAmount(Number(maxAmount));
// forceUpdate((n) => n + 1);
// return;
// }

// setAmount(Number(val));
// }}
partials={[
{
label: '1/2',
Expand Down
29 changes: 17 additions & 12 deletions examples/stake-tokens/components/staking/UndelegateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,25 @@ export const UndelegateModal = ({
? calcDollarValue(coin.base, amount, prices)
: undefined,
value: amount,
onValueInput: (val) => {
if (!val) {
setAmount(undefined);
return;
}
minValue: 0,
maxValue: Number(maxAmount),
onValueChange: (val) => {
setAmount(val);
},
// onValueInput: (val) => {
// if (!val) {
// setAmount(undefined);
// return;
// }

if (new BigNumber(val).gt(maxAmount)) {
setAmount(Number(maxAmount));
forceUpdate((n) => n + 1);
return;
}
// if (new BigNumber(val).gt(maxAmount)) {
// setAmount(Number(maxAmount));
// forceUpdate((n) => n + 1);
// return;
// }

setAmount(Number(val));
},
// setAmount(Number(val));
// },
partials: [
{
label: '1/2',
Expand Down
2 changes: 1 addition & 1 deletion examples/stake-tokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"eslint": "8.56.0",
"eslint-config-next": "14.1.0",
"generate-lockfile": "0.0.12",
"typescript": "^5.1.6"
"typescript": "^5.5.4"
},
"packageManager": "yarn@4.3.0"
}
11 changes: 8 additions & 3 deletions examples/stake-tokens/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"compilerOptions": {
"target": "ES2020",
"target": "ESNext",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
Expand All @@ -14,11 +13,17 @@
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"types": ["node", "react"],
"plugins": [
{
"name": "next"
}
],
"baseUrl": ".",
"paths": {
"@/*": ["*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
18 changes: 9 additions & 9 deletions examples/stake-tokens/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ __metadata:
react: "npm:18.2.0"
react-dom: "npm:18.2.0"
react-icons: "npm:4.6.0"
typescript: "npm:^5.1.6"
typescript: "npm:^5.5.4"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -10334,23 +10334,23 @@ __metadata:
languageName: node
linkType: hard

"typescript@npm:^5.1.6":
version: 5.4.5
resolution: "typescript@npm:5.4.5"
"typescript@npm:^5.5.4":
version: 5.5.4
resolution: "typescript@npm:5.5.4"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/2954022ada340fd3d6a9e2b8e534f65d57c92d5f3989a263754a78aba549f7e6529acc1921913560a4b816c46dce7df4a4d29f9f11a3dc0d4213bb76d043251e
checksum: 10c0/422be60f89e661eab29ac488c974b6cc0a660fb2228003b297c3d10c32c90f3bcffc1009b43876a082515a3c376b1eefcce823d6e78982e6878408b9a923199c
languageName: node
linkType: hard

"typescript@patch:typescript@npm%3A^5.1.6#optional!builtin<compat/typescript>":
version: 5.4.5
resolution: "typescript@patch:typescript@npm%3A5.4.5#optional!builtin<compat/typescript>::version=5.4.5&hash=5adc0c"
"typescript@patch:typescript@npm%3A^5.5.4#optional!builtin<compat/typescript>":
version: 5.5.4
resolution: "typescript@patch:typescript@npm%3A5.5.4#optional!builtin<compat/typescript>::version=5.5.4&hash=b45daf"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/db2ad2a16ca829f50427eeb1da155e7a45e598eec7b086d8b4e8ba44e5a235f758e606d681c66992230d3fc3b8995865e5fd0b22a2c95486d0b3200f83072ec9
checksum: 10c0/10dd9881baba22763de859e8050d6cb6e2db854197495c6f1929b08d1eb2b2b00d0b5d9b0bcee8472f1c3f4a7ef6a5d7ebe0cfd703f853aa5ae465b8404bc1ba
languageName: node
linkType: hard

Expand Down
37 changes: 1 addition & 36 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6861,7 +6861,7 @@ __metadata:
"@cosmos-kit/react": "npm:2.17.0"
"@emotion/react": "npm:11.10.6"
"@emotion/styled": "npm:11.10.6"
"@interchain-ui/react": "npm:1.23.29"
"@interchain-ui/react": "npm:1.23.22"
"@interchain-ui/react-no-ssr": "npm:^0.1.6"
"@tanstack/react-query": "npm:4.32.0"
"@tanstack/react-query-devtools": "npm:4.32.0"
Expand Down Expand Up @@ -10036,41 +10036,6 @@ __metadata:
languageName: node
linkType: hard

"@interchain-ui/react@npm:1.23.29, @interchain-ui/react@npm:^1.23.29":
version: 1.23.29
resolution: "@interchain-ui/react@npm:1.23.29"
dependencies:
"@floating-ui/core": "npm:^1.6.4"
"@floating-ui/dom": "npm:^1.6.7"
"@floating-ui/react": "npm:^0.26.19"
"@floating-ui/react-dom": "npm:^2.1.1"
"@floating-ui/utils": "npm:^0.2.4"
"@formkit/auto-animate": "npm:^0.8.2"
"@react-aria/listbox": "npm:^3.12.1"
"@react-aria/overlays": "npm:^3.22.1"
"@react-aria/utils": "npm:^3.24.1"
"@tanstack/react-virtual": "npm:^3.8.3"
"@vanilla-extract/css": "npm:^1.15.3"
"@vanilla-extract/dynamic": "npm:^2.1.1"
"@vanilla-extract/recipes": "npm:^0.5.3"
animejs: "npm:^3.2.2"
bignumber.js: "npm:^9.1.2"
client-only: "npm:^0.0.1"
clsx: "npm:^2.1.1"
copy-to-clipboard: "npm:^3.3.3"
immer: "npm:^10.1.1"
lodash: "npm:^4.17.21"
rainbow-sprinkles: "npm:^0.17.2"
react-aria: "npm:^3.33.1"
react-stately: "npm:^3.31.1"
zustand: "npm:^4.5.4"
peerDependencies:
react: ^16.14.0 || ^17.0.0 || ^18.0.0
react-dom: ^16.14.0 || ^17.0.0 || ^18.0.0
checksum: 10c0/013d8f56f0db143bc76f7e6f2509aab4ebb249a770e615df77b29748b07e743fff850d6a4599cbacc98ba7c047947e583eeb8e892f5796358243a37eb6d772d2
languageName: node
linkType: hard

"@internationalized/date@npm:^3.5.4":
version: 3.5.4
resolution: "@internationalized/date@npm:3.5.4"
Expand Down

0 comments on commit c5fc3af

Please sign in to comment.