-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add signatories list dialog * Address PR comments and commit suggestions * Fix error handling for curator proxy address * Minor fixes * Linting * Improve logging --------- Co-authored-by: BlertaGalani <[email protected]>
- Loading branch information
1 parent
1e95230
commit f301dee
Showing
3 changed files
with
123 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<script lang="ts"> | ||
import { onMount } from 'svelte'; | ||
import type { Bounty } from '../../types/bounty'; | ||
import { fetchMultisigSignatories } from './fetch-signatories'; | ||
import CopyableAddress from '../common/CopyableAddress.svelte'; | ||
import Dialog from '../common/Dialog.svelte'; | ||
export let open = false; | ||
export let bounty: Bounty; | ||
export let curatorAddress = ''; | ||
let signatories: string[] | undefined; | ||
onMount(async () => { | ||
if (curatorAddress) { | ||
signatories = await fetchMultisigSignatories(curatorAddress); | ||
} else { | ||
signatories = []; | ||
} | ||
}); | ||
</script> | ||
|
||
<Dialog bind:open title="CURATORS LIST"> | ||
<div class="modal mt-5"> | ||
<div class="space-y-3"> | ||
<div class="space-y-1"> | ||
<p class="font-bold">Curator Proxy:</p> | ||
<p><CopyableAddress address={bounty.curator} /></p> | ||
</div> | ||
<section class="space-y-1"> | ||
<p class="font-bold">Signatories:</p> | ||
{#if signatories === undefined} | ||
<p>Loading...</p> | ||
{:else if signatories.length > 0} | ||
<ul> | ||
{#each signatories as address} | ||
<li><CopyableAddress {address} /></li> | ||
{/each} | ||
</ul> | ||
{:else} | ||
<p>No signatories found.</p> | ||
{/if} | ||
</section> | ||
</div> | ||
</div> | ||
</Dialog> |
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,51 @@ | ||
import { get } from 'svelte/store'; | ||
import { dotApi } from '../../stores'; | ||
|
||
async function fetchCuratorProxyAddress(accountId: string) { | ||
const api = get(dotApi); | ||
const proxy = await api.query.Proxy.Proxies.getValue(accountId); | ||
|
||
return proxy[0][0].delegate; | ||
} | ||
|
||
type GraphQLResponse = { | ||
data: { | ||
multisigAddress: { | ||
signatories: string[]; | ||
} | null; | ||
}; | ||
}; | ||
|
||
export async function fetchMultisigSignatories(curatorAddress: string): Promise<string[]> { | ||
const graphqlEndpoint = 'https://dot-gh-api.statescan.io/graphql'; | ||
|
||
try { | ||
const proxyAddress = await fetchCuratorProxyAddress(curatorAddress); | ||
|
||
const query = ` | ||
query { | ||
multisigAddress(account: "${proxyAddress}") { | ||
signatories | ||
} | ||
}`; | ||
|
||
const response = await fetch(graphqlEndpoint, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({ query }) | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error('Error fetching signatories'); | ||
} | ||
|
||
const data = (await response.json()) as GraphQLResponse; | ||
|
||
return data.data.multisigAddress?.signatories || []; | ||
} catch (error) { | ||
console.error('Error fetching signatories', error); | ||
return []; | ||
} | ||
} |