Skip to content

Commit

Permalink
couple small tweaks to the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
kalepail committed Jul 9, 2024
1 parent 89e7240 commit 075d715
Showing 1 changed file with 31 additions and 16 deletions.
47 changes: 31 additions & 16 deletions demo/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
let keyId: string;
let contractId: string;
let admins: number;
let adminKeyId: string | undefined;
let balance: string;
let signers: { id: string, pk: string, admin: boolean }[] = [];
let signers: { id: string; pk: string; admin: boolean }[] = [];
let keyName: string = '';
let keyName: string = "";
let keyAdmin: boolean = false;
const account = new PasskeyKit({
Expand Down Expand Up @@ -97,7 +98,7 @@
const { built } = await account.wallet!.add({
id,
pk,
admin: keyAdmin
admin: keyAdmin,
});
const xdr = await account.sign(built!, { keyId: adminKeyId });
Expand All @@ -107,8 +108,8 @@
await getWalletSigners();
keyName = '';
keyAdmin = false
keyName = "";
keyAdmin = false;
}
async function removeSigner(signer: string) {
const { built } = await account.wallet!.remove({
Expand All @@ -131,6 +132,7 @@
signers = await getSigners(contractId);
console.log(signers);
adminKeyId = signers.find(({ admin }) => admin)?.id;
admins = signers.filter(({ admin }) => admin).length;
}
async function fundWallet() {
Expand Down Expand Up @@ -194,10 +196,21 @@

<form on:submit|preventDefault>
<ul style="list-style: none; padding: 0;">
<li><input type="text" placeholder="Signer name" bind:value={keyName}></li>
<li>
<input
type="text"
placeholder="Signer name"
bind:value={keyName}
/>
</li>
<li>
<label for="admin">Make admin?</label>
<input type="checkbox" id="admin" name="admin" bind:checked={keyAdmin}>
<input
type="checkbox"
id="admin"
name="admin"
bind:checked={keyAdmin}
/>
</li>
<li>
<button on:click={() => addSigner()}>Add Signer</button>
Expand All @@ -211,27 +224,29 @@
<li>
{#if admin}
<button disabled>
{#if adminKeyId === id} ◉ {/if}&nbsp;
ADMIN
{#if adminKeyId === id}
{/if}&nbsp; ADMIN
</button>
{:else}
<button disabled>SESSION</button>
{/if}

{ id }
{id}

<button on:click={() => walletTransfer(id)}
>Transfer 1 XLM</button
>

{#if !admin || admins > 1}
<button on:click={() => removeSigner(id)}>Remove</button>
{/if}

{#if account.keyExpired && id === account.keyId}
<button on:click={() => addSigner(pk)}
>Reload</button
>
<button on:click={() => addSigner(pk)}>Reload</button>
{:else if admin && id !== adminKeyId}
<button on:click={() => adminKeyId = id}>Set Active Admin</button>
{:else}
<button on:click={() => removeSigner(id)}>Remove</button
<button on:click={() => (adminKeyId = id)}
>Set Active Admin</button
>
{/if}
</li>
Expand Down

0 comments on commit 075d715

Please sign in to comment.