-
Notifications
You must be signed in to change notification settings - Fork 0
/
+page.svelte
39 lines (33 loc) 路 1.22 KB
/
+page.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<script lang="ts">
import { onMount } from 'svelte';
import { DIDArComponent } from '@peerpiper/did-ar';
import { Web3WalletMenu } from '@peerpiper/web3-wallet-connector';
// @ts-ignore
import type { handlers } from '@peerpiper/iframe-wallet-sdk';
let wallet: handlers;
let RSAPublicKey: { kty: string; n: string; e: string; kid?: string };
let Ed25519PublicKey: Uint8Array;
let srcTx: string | null;
let ready: boolean;
const walletReady = async (e: CustomEvent) => {
wallet = e.detail.wallet;
RSAPublicKey = await wallet.arweaveWalletAPI.getActivePublicKey();
Ed25519PublicKey = await wallet.proxcryptor.getPublicKey();
};
onMount(async () => {
// check if localStorage has srcTx, else leave as null
srcTx = localStorage.getItem('srcTx'); // || 'SoPGF6d-5oLy6-uKpJD2J2tT0ytM9LsXWbP5YQnVT6Q'; // https://sonar.warp.cc/#/app/source/0BkUeNAfOF6NzYmVJ__4eDdeKoFshJ5BzxOxOitJmXk#code
ready = true;
});
$: if (srcTx) {
// svae to localstorage
localStorage.setItem('srcTx', srcTx);
console.log({ srcTx });
}
</script>
<Web3WalletMenu on:walletReady={walletReady} />
<div class="flex flex-col items-center m-2 p-2">
{#if ready}
<DIDArComponent {wallet} {RSAPublicKey} {Ed25519PublicKey} bind:srcTx />
{/if}
</div>