Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions examples/svelte-stellar-app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Wraith SDK Svelte Example</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
21 changes: 21 additions & 0 deletions examples/svelte-stellar-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "svelte-stellar-app",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"svelte": "^5.0.0",
"@wraith-protocol/sdk-svelte": "workspace:*",
"@wraith-protocol/sdk": "workspace:*"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^5.0.0",
"vite": "^6.0.0",
"typescript": "^5.7.0"
}
}
93 changes: 93 additions & 0 deletions examples/svelte-stellar-app/src/App.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<script lang="ts">
import { useStellarStealthKeys, useStealthMetaAddress } from '@wraith-protocol/sdk-svelte';

const stellar = useStellarStealthKeys();
const meta = useStealthMetaAddress();

let signatureInput = $state('');

function handleDerive() {
const hex = signatureInput.replace(/^0x/i, '');
const bytes = new Uint8Array(hex.length / 2);
for (let i = 0; i < bytes.length; i++) {
bytes[i] = Number.parseInt(hex.slice(i * 2, i * 2 + 2), 16);
}
if (bytes.length < 32) return;

const k = stellar.deriveKeys(bytes);
console.log('Derived keys:', k);
const addr = stellar.generateAddress(k.spendingPubKey, k.viewingPubKey);
console.log('Stealth address:', addr);
stellar.encodeMetaAddress(k.spendingPubKey, k.viewingPubKey);
}

function handleDecode() {
if ($stellar.metaAddress) {
meta.decode($stellar.metaAddress);
}
}
</script>

<div class="container">
<h1>Wraith SDK &mdash; Svelte 5 Example</h1>

<section>
<h2>Stellar Stealth Keys</h2>
<label>
Signature (hex):
<input bind:value={signatureInput} placeholder="e.g. deadbeef..." />
</label>
<button onclick={handleDerive}>
Derive Keys & Generate Address
</button>

{#if $stellar.error}
<p class="error">{$stellar.error}</p>
{/if}

{#if $stellar.keys}
<div>
<h3>Keys</h3>
<pre>{JSON.stringify($stellar.keys, (_, v) => (v instanceof Uint8Array ? Array.from(v) : v), 2)}</pre>
</div>
{/if}

{#if $stellar.stealthAddress}
<div>
<h3>Stealth Address</h3>
<pre>{JSON.stringify($stellar.stealthAddress, (_, v) => (v instanceof Uint8Array ? Array.from(v) : v), 2)}</pre>
</div>
{/if}

{#if $stellar.metaAddress}
<div>
<h3>Meta Address</h3>
<code>{$stellar.metaAddress}</code>
<button onclick={handleDecode}>Decode</button>
</div>
{/if}

{#if $meta.decoded}
<div>
<h3>Decoded Meta Address</h3>
<pre>{JSON.stringify($meta.decoded, (_, v) => (v instanceof Uint8Array ? Array.from(v) : v), 2)}</pre>
</div>
{/if}
</section>
</div>

<style>
.container {
padding: 2rem;
font-family: system-ui, sans-serif;
}
input {
width: 100%;
}
.error {
color: red;
}
button {
margin-top: 0.5rem;
}
</style>
6 changes: 6 additions & 0 deletions examples/svelte-stellar-app/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import App from './App.svelte';
import { mount } from 'svelte';

const app = mount(App, { target: document.getElementById('app')! });

export default app;
5 changes: 5 additions & 0 deletions examples/svelte-stellar-app/svelte.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

export default {
preprocess: vitePreprocess(),
};
14 changes: 14 additions & 0 deletions examples/svelte-stellar-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"skipLibCheck": true,
"paths": {
"@wraith-protocol/sdk": ["../../src"],
"@wraith-protocol/sdk-svelte": ["../../packages/sdk-svelte/src"]
}
},
"include": ["src"]
}
6 changes: 6 additions & 0 deletions examples/svelte-stellar-app/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineConfig } from 'vite';
import { svelte } from '@sveltejs/vite-plugin-svelte';

export default defineConfig({
plugins: [svelte()],
});
12 changes: 12 additions & 0 deletions examples/vue-stellar-app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Wraith SDK Vue Example</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
22 changes: 22 additions & 0 deletions examples/vue-stellar-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "vue-stellar-app",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.5.0",
"@wraith-protocol/sdk-vue": "workspace:*",
"@wraith-protocol/sdk": "workspace:*"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.0",
"vite": "^6.0.0",
"vue-tsc": "^2.0.0",
"typescript": "^5.7.0"
}
}
88 changes: 88 additions & 0 deletions examples/vue-stellar-app/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<script setup lang="ts">
import { useStellarStealthKeys, useStealthMetaAddress } from '@wraith-protocol/sdk-vue';
import { ref, computed } from 'vue';

const signatureInput = ref('');
const {
keys,
stealthAddress,
deriveKeys,
generateAddress,
metaAddress,
encodeMetaAddress,
error,
loading,
} = useStellarStealthKeys();

const { encode, decode, decoded, detectChain } = useStealthMetaAddress();

const signatureBytes = computed(() => {
const hex = signatureInput.value.replace(/^0x/i, '');
const bytes = new Uint8Array(hex.length / 2);
for (let i = 0; i < bytes.length; i++) {
bytes[i] = Number.parseInt(hex.slice(i * 2, i * 2 + 2), 16);
}
return bytes;
});

function handleDerive() {
if (signatureInput.value.length < 64) return;
const k = deriveKeys(signatureBytes.value);
console.log('Derived keys:', k);
const addr = generateAddress(k.spendingPubKey, k.viewingPubKey);
console.log('Stealth address:', addr);
encodeMetaAddress(k.spendingPubKey, k.viewingPubKey);
}

function handleDecode() {
if (!metaAddress.value) return;
decode(metaAddress.value);
detectChain(metaAddress.value);
}
</script>

<template>
<div style="padding: 2rem; font-family: system-ui, sans-serif">
<h1>Wraith SDK &mdash; Vue 3 Example</h1>

<section>
<h2>Stellar Stealth Keys</h2>
<label>
Signature (hex):
<input v-model="signatureInput" placeholder="e.g. deadbeef..." style="width: 100%" />
</label>
<button :disabled="loading" @click="handleDerive">
{{ loading ? 'Deriving...' : 'Derive Keys & Generate Address' }}
</button>

<div v-if="error" style="color: red">{{ error }}</div>

<div v-if="keys" style="margin-top: 1rem">
<h3>Keys</h3>
<pre>{{
JSON.stringify(keys, (_, v) => (v instanceof Uint8Array ? Array.from(v) : v), 2)
}}</pre>
</div>

<div v-if="stealthAddress" style="margin-top: 1rem">
<h3>Stealth Address</h3>
<pre>{{
JSON.stringify(stealthAddress, (_, v) => (v instanceof Uint8Array ? Array.from(v) : v), 2)
}}</pre>
</div>

<div v-if="metaAddress" style="margin-top: 1rem">
<h3>Meta Address</h3>
<code>{{ metaAddress }}</code>
<button @click="handleDecode">Decode</button>
</div>

<div v-if="decoded" style="margin-top: 1rem">
<h3>Decoded Meta Address</h3>
<pre>{{
JSON.stringify(decoded, (_, v) => (v instanceof Uint8Array ? Array.from(v) : v), 2)
}}</pre>
</div>
</section>
</div>
</template>
4 changes: 4 additions & 0 deletions examples/vue-stellar-app/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { createApp } from 'vue';
import App from './App.vue';

createApp(App).mount('#app');
15 changes: 15 additions & 0 deletions examples/vue-stellar-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"jsx": "preserve",
"skipLibCheck": true,
"paths": {
"@wraith-protocol/sdk": ["../../src"],
"@wraith-protocol/sdk-vue": ["../../packages/sdk-vue/src"]
}
},
"include": ["src"]
}
6 changes: 6 additions & 0 deletions examples/vue-stellar-app/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';

export default defineConfig({
plugins: [vue()],
});
Loading