Skip to content

Commit

Permalink
fix: cosmwasm proposals list
Browse files Browse the repository at this point in the history
Signed-off-by: Norman Meier <[email protected]>
  • Loading branch information
n0izn0iz committed Aug 3, 2023
1 parent f8e94a5 commit 1fe2cea
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/components/dao/DAOProposalModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const MessagePreview: React.FC<{
message: CosmosMsgForEmpty | string;
}> = ({ networkId, message }) => {
const socialFeedContractAddress =
getCosmosNetwork(networkId)?.socialFeedContractAddress; // FIXME
getCosmosNetwork(networkId)?.socialFeedContractAddress;
const m = cloneDeep(message);
if (typeof m === "object" && "wasm" in m && "execute" in m.wasm) {
const msg = JSON.parse(
Expand Down
11 changes: 3 additions & 8 deletions packages/hooks/dao/useDAOProposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,13 @@ export const useDAOProposals = (daoId: string | undefined) => {
const { data: gnoDAOProposals, ...gnoOther } = useQuery(
[daoProposalsQueryKey(daoId), NetworkKind.Gno],
async () => {
console.log("halo");

if (network?.kind !== NetworkKind.Gno) return [];
const provider = new GnoJSONRPCProvider(network.endpoint);

console.log("fetching proposals ", daoAddress, "GetProposalsJSON(0)");

const gnoProposals: GnoDAOProposal[] = extractGnoJSONString(
await provider.evaluateExpression(daoAddress, "GetProposalsJSON(0)")
);

console.log("gnoProposals", gnoProposals);

const proposals: AppProposalResponse[] = [];

for (let i = 0; i < gnoProposals.length; i++) {
Expand All @@ -78,7 +72,7 @@ export const useDAOProposals = (daoId: string | undefined) => {
const noVotes = prop.votes.no;
const abstainVotes = prop.votes.abstain;

// threshold should be stored in the proposal for executed proposals (maybe passed too)
// TODO: threshold should be stored in the proposal for executed proposals (maybe passed too)
const threshold =
extractGnoNumber(
await provider.evaluateExpression(
Expand All @@ -97,6 +91,7 @@ export const useDAOProposals = (daoId: string | undefined) => {
const numActions = prop.messages.length;
const actions: string[] = [];
for (let m = 0; m < numActions; m++) {
// TODO: don't do one request per message
try {
const action = extractGnoString(
await provider.evaluateExpression(
Expand Down Expand Up @@ -195,7 +190,7 @@ export const useCosmWasmDAOProposals = (daoId: string | undefined) => {

return allProposals;
},
{ staleTime: Infinity, enabled: !!(networkId || proposalModuleAddress) }
{ staleTime: Infinity, enabled: !!(networkId && proposalModuleAddress) }
);
return { daoProposals: data, ...other };
};
Expand Down
2 changes: 0 additions & 2 deletions packages/utils/gno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ export const adenaDoContract = async (
throw new Error(res.message);
}
const hash: string = res.data.hash;
console.log("waiting for tx", hash);
const { height: txHeight, index } = await client.waitForTransaction(
hash,
height
);
console.log("tx finalized", txHeight, index);
const blockResult = await client.getBlockResult(txHeight);
const deliverResults = blockResult.results.deliver_tx || [];
if (deliverResults.length <= index) {
Expand Down

0 comments on commit 1fe2cea

Please sign in to comment.