@moon-x/react-native-sdk 0.20.2 → 0.21.0

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.
package/README.md CHANGED
@@ -231,6 +231,27 @@ the backend's 64-token ceremony limit.
231
231
 
232
232
  ### Wallets
233
233
 
234
+ `useMoonX().createWallet(chain)` always creates a new wallet, including concurrent
235
+ calls. `useMoonX().findOrCreateWallet(chain)` returns the first existing wallet
236
+ for that chain, or creates one if none exists. Both return `{ wallet }`. For
237
+ Bitcoin, pass `{ addressType }` to find or create a wallet of that type (`p2tr` by
238
+ default). `findOrCreateWallet()` rejects with `wallets_unavailable` rather than
239
+ creating a wallet when the existing list can't be read.
240
+
241
+ Only `findOrCreateWallet()` shares concurrent requests. Sharing requires the same
242
+ transport, publishable key, login, and chain (and address type for Bitcoin).
243
+ Separate devices and SDK transports can still race. A routine access-token
244
+ refresh does not interrupt the operation; the helper rejects with
245
+ `session_changed` only if a different login replaces the session while it runs. If a different login replaces the session during creation, the wallet can
246
+ already exist on the earlier login when the call rejects. After `session_changed`,
247
+ confirm the intended account before you retry with `findOrCreateWallet()`, not
248
+ `createWallet()`. The retry searches the current account before it creates a wallet.
249
+ If the new login is the same account, the retry finds the wallet that the first
250
+ call created.
251
+
252
+ The generic `useCreateWallet()` hook also returns both methods. Existing
253
+ `createWallet()` callers need no new option.
254
+
234
255
  | Hook | What it does |
235
256
  |---|---|
236
257
  | `useWallets(walletType)` | Generic chain-aware list hook for Ethereum, Solana, or Tron. Chain subpaths provide pinned `useWallets()` variants. |
package/dist/index.d.mts CHANGED
@@ -118,6 +118,12 @@ interface RNAuthSDK {
118
118
  }) => Promise<{
119
119
  wallet: PublicWallet;
120
120
  }>;
121
+ /** Return an existing wallet or create one. Concurrent calls share work within the same transport and session. */
122
+ findOrCreateWallet: (walletType: "solana" | "ethereum" | "tron" | "bitcoin", options?: {
123
+ addressType?: "p2tr" | "p2wpkh" | "p2pkh";
124
+ }) => Promise<{
125
+ wallet: PublicWallet;
126
+ }>;
121
127
  importKey: (walletType: "solana" | "ethereum" | "tron" | "bitcoin", source: string | WalletImportSource, options?: {
122
128
  addressType?: "p2tr" | "p2wpkh" | "p2pkh";
123
129
  }) => Promise<{
package/dist/index.d.ts CHANGED
@@ -118,6 +118,12 @@ interface RNAuthSDK {
118
118
  }) => Promise<{
119
119
  wallet: PublicWallet;
120
120
  }>;
121
+ /** Return an existing wallet or create one. Concurrent calls share work within the same transport and session. */
122
+ findOrCreateWallet: (walletType: "solana" | "ethereum" | "tron" | "bitcoin", options?: {
123
+ addressType?: "p2tr" | "p2wpkh" | "p2pkh";
124
+ }) => Promise<{
125
+ wallet: PublicWallet;
126
+ }>;
121
127
  importKey: (walletType: "solana" | "ethereum" | "tron" | "bitcoin", source: string | WalletImportSource, options?: {
122
128
  addressType?: "p2tr" | "p2wpkh" | "p2pkh";
123
129
  }) => Promise<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moon-x/react-native-sdk",
3
- "version": "0.20.2",
3
+ "version": "0.21.0",
4
4
  "description": "Headless MoonX React Native SDK with WebView-backed transport, native passkeys, and app-owned UI.",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/index.js",
@@ -62,7 +62,7 @@
62
62
  "vitest": "4.1.0"
63
63
  },
64
64
  "dependencies": {
65
- "@moon-x/core": "0.27.2"
65
+ "@moon-x/core": "0.28.0"
66
66
  },
67
67
  "peerDependencies": {
68
68
  "@expo/config-plugins": ">=10.0.0",