@bubolabs/wallet-wasm 0.1.0 → 0.1.1

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 +119 -46
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -9,39 +9,63 @@ browser binding and distribution layer.
9
9
  Current browser targets: ETH, BTC, Solana, TON, TRON, NEAR, Cosmos,
10
10
  Cardano, Aptos, Polkadot, Dogecoin, Starknet, Stellar, Sui, and XRPL.
11
11
 
12
- ## Build
12
+ ## Install
13
13
 
14
- Install `wasm-pack`, then run from this package directory:
14
+ For a browser app, install the published npm package:
15
15
 
16
16
  ```bash
17
- npm run build
17
+ npm install @bubolabs/wallet-wasm
18
18
  ```
19
19
 
20
- The build writes generated WASM artifacts to:
21
-
22
- - `pkg/` for the core module: all supported browser chains except Cardano
23
- - `pkg-cardano/` for Cardano
24
-
25
- Cardano is packaged as a separate WASM module because upstream
26
- `cardano-serialization-lib` and Solana's wasm-enabled crates both export a
27
- `Transaction` class through `wasm-bindgen`, which causes duplicate linker
28
- symbols when they are placed in one `.wasm` file. The JavaScript wrapper keeps
29
- one public API and routes Cardano calls to the Cardano module internally.
30
- BTC support uses the `bitcoin` crate's secp256k1 backend. On macOS, install
31
- LLVM via Homebrew if Apple's clang cannot compile `wasm32-unknown-unknown`:
20
+ or:
32
21
 
33
22
  ```bash
34
- brew install llvm
23
+ yarn add @bubolabs/wallet-wasm
24
+ pnpm add @bubolabs/wallet-wasm
35
25
  ```
36
26
 
37
- The package build script automatically uses `/opt/homebrew/opt/llvm/bin/clang`
38
- or `/usr/local/opt/llvm/bin/clang` when present.
27
+ Consumers do not need to compile Rust or run `wasm-pack`. The published package
28
+ already includes the generated `.wasm` files.
39
29
 
40
30
  ## Usage
41
31
 
32
+ Use the package from a browser bundler that supports WebAssembly assets, such
33
+ as Vite, Webpack, or Rollup.
34
+
35
+ ```js
36
+ import { init, eth, ton, tron } from "@bubolabs/wallet-wasm";
37
+
38
+ await init();
39
+
40
+ const mnemonic =
41
+ "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about";
42
+
43
+ const ethWallet = eth.deriveWallet({
44
+ mnemonic,
45
+ account: 0,
46
+ index: 0,
47
+ });
48
+
49
+ const tonAddress = ton.deriveAddress({
50
+ mnemonic,
51
+ account: 0,
52
+ index: 0,
53
+ walletVersion: "v5r1",
54
+ });
55
+
56
+ const tronAddress = tron.deriveAddress({
57
+ mnemonic,
58
+ account: 0,
59
+ index: 0,
60
+ });
61
+
62
+ console.log({ ethWallet, tonAddress, tronAddress });
63
+ ```
64
+
65
+ All supported chains are exported as namespaces:
66
+
42
67
  ```js
43
68
  import {
44
- init,
45
69
  aptos,
46
70
  btc,
47
71
  cardano,
@@ -58,39 +82,88 @@ import {
58
82
  tron,
59
83
  xrpl,
60
84
  } from "@bubolabs/wallet-wasm";
85
+ ```
61
86
 
62
- await init();
87
+ Most chains support the same core calls where available:
63
88
 
64
- const mnemonic =
65
- "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about";
66
- const wallet = eth.deriveWallet({
89
+ ```js
90
+ const wallet = solana.deriveWallet({ mnemonic, account: 0, index: 0 });
91
+ const signature = solana.signBytes({
67
92
  mnemonic,
93
+ account: 0,
94
+ index: 0,
95
+ bytes: "00112233445566778899aabbccddeeff",
96
+ bytesEncoding: "hex",
68
97
  });
98
+ ```
69
99
 
70
- const supported = eth.verifyMessageSignature({
71
- message: "hello",
72
- address: wallet.address,
73
- signatureHex: "0x...",
74
- });
100
+ ## Build From Source
75
101
 
76
- const btcAddress = btc.deriveAddress({ mnemonic });
77
- const solanaAddress = solana.deriveAddress({ mnemonic });
78
- const tonAddress = ton.deriveAddress({ mnemonic });
79
- const tonStateInit = ton.buildWalletStateInit({
80
- mnemonic,
81
- walletVersion: "v5r1",
82
- });
83
- const tronAddress = tron.deriveAddress({ mnemonic });
84
- const nearAddress = near.deriveAddress({ mnemonic });
85
- const cosmosAddress = cosmos.deriveAddress({ mnemonic });
86
- const cardanoAddress = cardano.deriveAddress({ mnemonic });
87
- const aptosAddress = aptos.deriveAddress({ mnemonic });
88
- const polkadotAddress = polkadot.deriveAddress({ mnemonic });
89
- const dogecoinAddress = dogecoin.deriveAddress({ mnemonic });
90
- const starknetAddress = starknet.deriveAddress({ mnemonic });
91
- const stellarAddress = stellar.deriveAddress({ mnemonic });
92
- const suiAddress = sui.deriveAddress({ mnemonic });
93
- const xrplAddress = xrpl.deriveAddress({ mnemonic });
102
+ Only build from source when developing this repository or changing Rust chain
103
+ code. From `packages/wasm-sdk`:
104
+
105
+ ```bash
106
+ npm install
107
+ npm run build
108
+ ```
109
+
110
+ The build writes generated WASM artifacts to:
111
+
112
+ - `pkg/` for the core module: all supported browser chains except Cardano
113
+ - `pkg-cardano/` for Cardano
114
+
115
+ Cardano is packaged as a separate WASM module because upstream
116
+ `cardano-serialization-lib` and Solana's wasm-enabled crates both export a
117
+ `Transaction` class through `wasm-bindgen`, which causes duplicate linker
118
+ symbols when they are placed in one `.wasm` file. The JavaScript wrapper keeps
119
+ one public API and routes Cardano calls to the Cardano module internally.
120
+ BTC support uses the `bitcoin` crate's secp256k1 backend. On macOS, install
121
+ LLVM via Homebrew if Apple's clang cannot compile `wasm32-unknown-unknown`:
122
+
123
+ ```bash
124
+ brew install llvm
125
+ ```
126
+
127
+ The package build script automatically uses `/opt/homebrew/opt/llvm/bin/clang`
128
+ or `/usr/local/opt/llvm/bin/clang` when present.
129
+
130
+ ## Example Project
131
+
132
+ This repository includes a browser example in `example-wasm`.
133
+
134
+ For local repository development, the example uses a file dependency:
135
+
136
+ ```json
137
+ {
138
+ "dependencies": {
139
+ "@bubolabs/wallet-wasm": "file:../packages/wasm-sdk"
140
+ }
141
+ }
142
+ ```
143
+
144
+ That lets the example consume the local package output. Build the WASM package
145
+ first, then run the example:
146
+
147
+ ```bash
148
+ cd packages/wasm-sdk
149
+ npm install
150
+ npm run build
151
+
152
+ cd ../../example-wasm
153
+ npm install
154
+ npm run dev
155
+ ```
156
+
157
+ Open:
158
+
159
+ ```text
160
+ http://127.0.0.1:4180/
161
+ ```
162
+
163
+ In a real app, use the published package instead:
164
+
165
+ ```bash
166
+ npm install @bubolabs/wallet-wasm
94
167
  ```
95
168
 
96
169
  ## Boundary
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bubolabs/wallet-wasm",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Browser WASM SDK for bubo wallet offline chain adapters",
5
5
  "type": "module",
6
6
  "main": "index.js",