@thru/browser-sdk 0.0.7 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +48 -0
  2. package/package.json +5 -5
package/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # @thru/browser-sdk
2
+
3
+ Low-level browser SDK for embedding the Thru wallet experience. It manages the iframe-based embedded provider, forwards lifecycle events, and exposes a ready-to-use `Thru` RPC client alongside wallet account management utilities.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @thru/browser-sdk
9
+ ```
10
+
11
+ ## Basic Usage
12
+
13
+ ```ts
14
+ import { BrowserSDK } from '@thru/browser-sdk';
15
+
16
+ // Configure the wallet iframe location and the RPC endpoint to talk to
17
+ const sdk = new BrowserSDK({
18
+ iframeUrl: 'https://thru-wallet.up.railway.app/embedded',
19
+ rpcUrl: 'https://grpc-web.alphanet.thruput.org',
20
+ });
21
+
22
+ await sdk.initialize(); // injects the iframe once
23
+
24
+ // Observe lifecycle events
25
+ sdk.on('connect', ({ accounts }) => {
26
+ console.log('Connected accounts', accounts);
27
+ });
28
+ sdk.on('disconnect', () => console.log('Wallet disconnected'));
29
+ sdk.on('error', (err) => console.error('Wallet error', err));
30
+
31
+ // Trigger the wallet connect flow
32
+ const result = await sdk.connect();
33
+ const primary = result.accounts[0];
34
+
35
+ // Use the embedded Thru RPC client
36
+ const thru = sdk.getThru();
37
+ const account = await thru.accounts.get(primary.address);
38
+
39
+ // Disconnect when finished
40
+ await sdk.disconnect();
41
+ ```
42
+
43
+ ### Key Capabilities
44
+
45
+ - Handles iframe creation and cleanup (`initialize`, `destroy`)
46
+ - Connection helpers (`connect`, `disconnect`, `isConnected`, `selectAccount`)
47
+ - Event emitter for wallet state changes (`connect`, `disconnect`, `lock`, `error`, `accountChanged`)
48
+ - Access to a typed Thru RPC client via `sdk.getThru()` for querying on-chain data or submitting transactions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thru/browser-sdk",
3
- "version": "0.0.7",
3
+ "version": "0.0.10",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -11,10 +11,10 @@
11
11
  }
12
12
  },
13
13
  "dependencies": {
14
- "@thru/embedded-provider": "0.0.7",
15
- "@thru/chain-interfaces": "0.0.7",
16
- "@thru/protocol": "0.0.7",
17
- "@thru/thru-sdk": "0.0.7"
14
+ "@thru/embedded-provider": "0.0.10",
15
+ "@thru/chain-interfaces": "0.0.10",
16
+ "@thru/protocol": "0.0.10",
17
+ "@thru/thru-sdk": "0.0.10"
18
18
  },
19
19
  "scripts": {
20
20
  "build": "tsup",