diff --git a/src/lib/components/Composite.svelte b/src/lib/components/Composite.svelte index e8d0e5f..c475645 100644 --- a/src/lib/components/Composite.svelte +++ b/src/lib/components/Composite.svelte @@ -29,7 +29,7 @@ `; function initializeComponentState(child) { - child.store = createComponentStore(child.id, child.state || {}); + child.store = createComponentStore(child.id, child.store || {}); if (child.children) { child.children.forEach(initializeComponentState); diff --git a/src/lib/components/HelloEarth/HelloEarth.svelte b/src/lib/components/HelloEarth/HelloEarth.svelte index bb9eb2c..90fa10d 100644 --- a/src/lib/components/HelloEarth/HelloEarth.svelte +++ b/src/lib/components/HelloEarth/HelloEarth.svelte @@ -5,14 +5,13 @@ import { onMount } from 'svelte'; const store = getComponentStore(id); - $: console.log('store:', $store); export let helloEarthAlert; onMount(async () => { helloEarthAlert.alertMe(); - console.log('hello Earth'); + console.log('should alerted by now'); }); -
Hello Earth {JSON.stringify($store)}
+
Hello Earth {JSON.stringify($store.pkpWallet.address)}
diff --git a/src/lib/components/Wallet/Wallet.svelte b/src/lib/components/Wallet/Wallet.svelte index d730e25..ae455f6 100644 --- a/src/lib/components/Wallet/Wallet.svelte +++ b/src/lib/components/Wallet/Wallet.svelte @@ -3,20 +3,17 @@ import { connectWallet } from '$lib/services/wallet/wallet'; import { getComponentStore } from '$lib/stores/componentStores.ts'; - // please abstract this. export let id; const store = getComponentStore(id); - export let pkpWallet = null; - onMount(async () => { - pkpWallet = await connectWallet($store.pkpPubKey, $store.rpcURL); + $store.pkpWallet = await connectWallet($store.pkpPubKey, $store.rpcURL); }); PkpWallet -{#if pkpWallet} +{#if $store.pkpWallet}
- PKP Wallet: {pkpWallet.address} + PKP Wallet: {$store.pkpWallet.address}
{/if} diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index f98f3e0..dad1c34 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -4,11 +4,11 @@ let componentsData = { layout: { areas: ` - "header header header" - "main main aside" - "footer footer footer"; + "header main" + "aside main" + "footer footer"; `, - columns: '1fr 1fr 1fr', + columns: '1fr 1fr', rows: 'auto 1fr auto' }, children: [ @@ -19,15 +19,20 @@ services: ['setupLit'] }, { - id: '2', + id: 'messages', componentName: 'Messages', - slot: 'main' + slot: 'main', + store: { + prop1: 'prop1', + prop2: 'prop2' + } }, { - id: '4', + id: 'wallet', componentName: 'Wallet', slot: 'aside', - state: { + store: { + pkpWallet: '', rpcURL: 'https://rpc.gnosischain.com/', pkpPubKey: '046da3ba67065fd1e2726242ca01cd4601524893f4aa4b0042578fa6cbec28fa8c9a28eb9f7893932fc09717edc9e1db57e157a21eed346247c1db5a722a01f571'