-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Very basic proposals loading per-account
- Loading branch information
Showing
7 changed files
with
84 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/routes/[network]/(explorer)/account/[name]/proposals/+page.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<script lang="ts"> | ||
import Card from '$lib/components/layout/box/card.svelte'; | ||
const { data } = $props(); | ||
</script> | ||
|
||
{#each data.proposals as proposal} | ||
<Card> | ||
<h2> | ||
<a href={`/${data.network}/msig/${data.name}/${proposal.proposal_name}`} | ||
>{proposal.proposal_name}</a | ||
> | ||
</h2> | ||
</Card> | ||
{/each} |
21 changes: 21 additions & 0 deletions
21
src/routes/[network]/(explorer)/account/[name]/proposals/+page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { error } from '@sveltejs/kit'; | ||
import type { PageLoad } from './$types'; | ||
|
||
export const load: PageLoad = async ({ fetch, params, parent }) => { | ||
const { network } = await parent(); | ||
const response = await fetch(`/${params.network}/api/msig/${params.name}`); | ||
const json = await response.json(); | ||
|
||
if ('error' in json) { | ||
error(404, json.error); | ||
} | ||
|
||
return { | ||
proposals: json.proposals, | ||
subtitle: `Multisig proposals by ${params.name} on the ${network.chain.name} Network.`, | ||
pageMetaTags: { | ||
title: `Multisig Proposals | ${params.name} | ${network.chain.name} Network`, | ||
description: `Multisig proposals by ${params.name} on the ${network.chain.name} Network.` | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { json, type RequestEvent } from '@sveltejs/kit'; | ||
|
||
import { getChainDefinitionFromParams } from '$lib/state/network.svelte'; | ||
import { Name } from '@wharfkit/antelope'; | ||
import { getCacheHeaders } from '$lib/utils'; | ||
import { getBackendNetwork } from '$lib/wharf/client/ssr.js'; | ||
|
||
export async function GET({ fetch, params }: RequestEvent) { | ||
const chain = getChainDefinitionFromParams(String(params.network)); | ||
if (!chain) { | ||
return json({ error: 'Invalid chain specified' }, { status: 400 }); | ||
} | ||
if (!params.proposer) { | ||
return json({ error: 'Proposer must be specified' }, { status: 400 }); | ||
} | ||
|
||
const network = getBackendNetwork(chain, fetch); | ||
|
||
const scope = Name.from(params.proposer); | ||
|
||
const proposals = await network.contracts.msig.table('proposal', scope).all(); | ||
|
||
return json( | ||
{ | ||
ts: new Date(), | ||
proposer: params.proposer, | ||
name: params.proposal, | ||
proposals | ||
}, | ||
{ | ||
headers: getCacheHeaders(5) | ||
} | ||
); | ||
} |