diff --git a/packages/wallet-connect-sdk-svelte/README.md b/packages/wallet-connect-sdk-svelte/README.md
index 4fee31f..58450e9 100644
--- a/packages/wallet-connect-sdk-svelte/README.md
+++ b/packages/wallet-connect-sdk-svelte/README.md
@@ -1,58 +1,51 @@
-# create-svelte
+# WalletConnect SDK Svelte
-Everything you need to build a Svelte library, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).
+- [Installation](#installation)
+- [Setup](#setup)
+- [Usage](#usage)
-Read more about creating a library [in the docs](https://kit.svelte.dev/docs/packaging).
+## Installation
-## Creating a project
+Install the dependencies on your application
-If you're seeing this, you've probably already done this step. Congrats!
+### NPM
-```bash
-# create a new project in the current directory
-npm create svelte@latest
-
-# create a new project in my-app
-npm create svelte@latest my-app
```
-
-## Developing
-
-Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
-
-```bash
-npm run dev
-
-# or start the server and open the app in a new browser tab
-npm run dev -- --open
+npm i @cityofzion/wallet-connect-sdk-svelte @walletconnect/sign-client @walletconnect/types
```
-Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
-
-## Building
-
-To build your library:
+### YARN
-```bash
-npm run package
```
-
-To create a production version of your showcase app:
-
-```bash
-npm run build
+yarn add @cityofzion/wallet-connect-sdk-svelte @walletconnect/sign-client @walletconnect/types
```
-You can preview the production build with `npm run preview`.
-
-> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
-
-## Publishing
-
-Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)).
+## Setup
+To begin development, first establish an account on the [Wallet Connect website](https://walletconnect.com/). Next,
+generate a new Project. This process is straightforward, requiring only a few form fields.
+
+### Instantiate an object of the WCSDKStore class
+
+```ts
+import { WCSDKStore } from '@cityofzion/wallet-connect-sdk-svelte'
+
+const wcOptions = {
+ projectId: '', // the ID of your project on Wallet Connect website
+ relayUrl: 'wss://relay.walletconnect.com', // we are using walletconnect's official relay server
+ metadata: {
+ name: 'MyApplicationName', // your application name to be displayed on the wallet
+ description: 'My Application description', // description to be shown on the wallet
+ url: 'https://myapplicationdescription.app/', // url to be linked on the wallet
+ icons: ['https://myapplicationdescription.app/myappicon.png'] // icon to be shown on the wallet
+ }
+};
+
+
+```
-To publish your library to [npm](https://www.npmjs.com):
+`autoManageSession` will reload the user's connected session and subscribe to the `disconnect` event. If you don't want this at startup, set the second constructor parameter to false and call the `manageSession` method at the correct time.
-```bash
-npm publish
-```
+## Usage
+Check this [Usage Guide](../../USAGE_GUIDE.md) to see how to use this SDK on your application.
\ No newline at end of file
diff --git a/packages/wallet-connect-sdk-svelte/src/WcSdkStore.ts b/packages/wallet-connect-sdk-svelte/src/WcSdkStore.ts
index 3b51986..0b1d3d5 100644
--- a/packages/wallet-connect-sdk-svelte/src/WcSdkStore.ts
+++ b/packages/wallet-connect-sdk-svelte/src/WcSdkStore.ts
@@ -30,11 +30,12 @@ export interface IWalletConnectStore extends Neo3Invoker, Neo3Signer {
* The current WalletConnect connected session
*/
session: Readable
+ setSession(session: SessionTypes.Struct): void
/**
* returns if the session is connected
*/
- readonly isConnected: Readable
+ readonly isConnected: () => boolean
/**
* returns the chain id of the connected wallet
@@ -118,13 +119,18 @@ export class WCSDKStore implements IWalletConnectStore {
private sdk: WcSdk | null
private sessionWritable: Writable = writable(null)
private signClientWritable: Writable = writable(null)
+ private autoManageSession: boolean
- constructor(options: SignClientTypes.Options) {
+ constructor(options: SignClientTypes.Options, autoManageSession?: boolean) {
this.setupWcClient(options)
this.sdk = null
+ this.autoManageSession = autoManageSession ?? true
}
- get isConnected(): Readable {
- return derived(this.sessionWritable, (session) => !!session)
+ setSession(session: SessionTypes.Struct): void {
+ this.sessionWritable.set(session)
+ }
+ isConnected(): boolean {
+ return this.sdk?.isConnected() ?? false
}
getChainId(): string | null {
return this.sdk?.getChainId() ?? null
@@ -241,7 +247,7 @@ export class WCSDKStore implements IWalletConnectStore {
}
private handleManageSession() {
- if (this.sdk) {
+ if (this.sdk && this.autoManageSession) {
this.manageSession()
}
}