Skip to content

Commit

Permalink
fixed types for vote-proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
pyramation committed Apr 5, 2024
1 parent b4947a6 commit 0e04513
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .yarnrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ lastUpdateCheck 1700470015338
save-exact true
save-prefix false
workspaces-experimental true
yarn-path ".yarn/releases/yarn-1.22.21.js"
# yarn-path ".yarn/releases/yarn-1.22.21.js"
2 changes: 0 additions & 2 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.1.0.cjs
55 changes: 25 additions & 30 deletions examples/vote-proposal/components/voting/Proposal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function Proposal({
proposal,
chainName,
bondedTokens,
onVoteSuccess = () => {},
onVoteSuccess = () => { },
}: ProposalProps) {
const vote = votes?.[proposal.proposalId.toString()];

Expand Down Expand Up @@ -155,8 +155,8 @@ export function Proposal({
borderRadius="$lg"
>
<Box display="flex" justifyContent="space-between">
{timepoints.map((timepoint) => (
<Stack direction="vertical" space="$1">
{timepoints.map((timepoint, i) => (
<Stack key={i} direction="vertical" space="$1">
<Text
color="$textSecondary"
fontSize="$sm"
Expand Down Expand Up @@ -253,9 +253,8 @@ export function Proposal({
px: "$2",
}}
>
{`Minimum of staked ${minStakedTokens} ${coin.symbol}(${
quorum * 100
}%) need to vote
{`Minimum of staked ${minStakedTokens} ${coin.symbol}(${quorum * 100
}%) need to vote
for this proposal to pass.`}
</Text>
</Text>
Expand All @@ -269,34 +268,31 @@ export function Proposal({
voteType="yes"
title="Yes"
votePercentage={percent(proposal.finalTallyResult?.yes, total)}
description={`${
exponentiate(
proposal.finalTallyResult?.yes,
-exponent,
).toFixed(2)
} ${coin.symbol}`}
description={`${exponentiate(
proposal.finalTallyResult?.yes,
-exponent,
).toFixed(2)
} ${coin.symbol}`}
/>
<GovernanceVoteBreakdown
voteType="abstain"
title="Abstain"
votePercentage={percent(proposal.finalTallyResult?.abstain, total)}
description={`${
exponentiate(
proposal.finalTallyResult?.abstain,
-exponent,
).toFixed(2)
} ${coin.symbol}`}
description={`${exponentiate(
proposal.finalTallyResult?.abstain,
-exponent,
).toFixed(2)
} ${coin.symbol}`}
/>
<GovernanceVoteBreakdown
voteType="no"
title="No"
votePercentage={percent(proposal.finalTallyResult?.no, total)}
description={`${
exponentiate(
proposal.finalTallyResult?.no,
-exponent,
).toFixed(2)
} ${coin.symbol}`}
description={`${exponentiate(
proposal.finalTallyResult?.no,
-exponent,
).toFixed(2)
} ${coin.symbol}`}
/>
<GovernanceVoteBreakdown
voteType="noWithVeto"
Expand All @@ -305,12 +301,11 @@ export function Proposal({
proposal.finalTallyResult?.noWithVeto,
total,
)}
description={`${
exponentiate(
proposal.finalTallyResult?.noWithVeto,
-exponent,
).toFixed(2)
} ${coin.symbol}`}
description={`${exponentiate(
proposal.finalTallyResult?.noWithVeto,
-exponent,
).toFixed(2)
} ${coin.symbol}`}
/>
</Box>
<Box display="flex" flexDirection="column" gap="$12">
Expand Down
2 changes: 2 additions & 0 deletions examples/vote-proposal/components/voting/Voting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function Voting({ chainName }: VotingProps) {
const proposal = data.proposals![index];
openModal();
setProposal(proposal);
// @ts-ignore
setTitle(`#${proposal.proposalId?.toString()} ${proposal.content?.title}`);
}

Expand Down Expand Up @@ -91,6 +92,7 @@ export function Voting({ chainName }: VotingProps) {
<GovernanceProposalItem
id={`# ${proposal.proposalId?.toString()}`}
key={proposal.submitTime?.getTime()}
// @ts-ignore
title={proposal.content?.title || ""}
status={status(proposal.status)}
votes={votes(proposal.finalTallyResult!)}
Expand Down
10 changes: 6 additions & 4 deletions examples/vote-proposal/hooks/useTx.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cosmos } from 'interchain-query';
import { cosmos } from 'osmo-query';
import { useChain } from '@cosmos-kit/react';
import { DeliverTxResponse, isDeliverTxSuccess, StdFee } from '@cosmjs/stargate';

Expand Down Expand Up @@ -60,9 +60,11 @@ export function useTx(chainName: string) {
if (!signed) return new TxResult({ error: new TxError('Invalid transaction') });

const response = await client.broadcastTx(Uint8Array.from(txRaw.encode(signed).finish()));
return isDeliverTxSuccess(response)
? new TxResult({ response })
: new TxResult({ response, error: new TxError(response.rawLog) });
// Type error: Argument of type 'import("/Users/redacted/code/cosmology/products/create-cosmos-app/node_modules/@cosmos-kit/core/node_modules/@cosmjs/stargate/build/stargateclient").DeliverTxResponse' is not assignable to parameter of type 'import("/Users/redacted/code/cosmology/products/create-cosmos-app/node_modules/@cosmjs/stargate/build/stargateclient").DeliverTxResponse'.
// Types of property 'gasUsed' are incompatible.
// Type 'bigint' is not assignable to type 'number'.
// @ts-ignore
return isDeliverTxSuccess(response) ? new TxResult({ response }) : new TxResult({ response, error: new TxError(response.rawLog) });
} catch (e: any) {
return new TxResult({ error: new TxError(e.message || 'Tx Error') });
}
Expand Down
1 change: 1 addition & 0 deletions examples/vote-proposal/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function CreateCosmosApp({ Component, pageProps }: AppProps) {
minHeight="100dvh"
backgroundColor={useColorModeValue('$white', '$background')}
>
{/* @ts-ignore */}
<Component {...pageProps} />
</Box>
</QueryClientProvider>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@
"url": "https://github.com/cosmology-tech/create-cosmos-app"
},
"packageManager": "[email protected]"
}
}

0 comments on commit 0e04513

Please sign in to comment.