@moon-x/react-native-sdk 0.20.1 → 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/dist/index.js CHANGED
@@ -566,6 +566,7 @@ var RETRYABLE_METHODS = /* @__PURE__ */ new Set([
566
566
  "IS_AUTHENTICATED",
567
567
  "GET_PASSKEY_STATUS",
568
568
  "GET_DEK_INFO",
569
+ // Only metadata reads. send excludes the signing variant.
569
570
  "LIST_EPHEMERAL_SIGNERS"
570
571
  ]);
571
572
  var RETRY_ATTEMPT_TIMEOUTS_MS = [
@@ -709,7 +710,8 @@ var WebViewBridge = class {
709
710
  // Idempotent reads (see RETRYABLE_METHODS) are auto-retried on timeout to
710
711
  // ride out the iframe-app mount race; everything else makes a single attempt.
711
712
  async send(type, method, payload) {
712
- if (!RETRYABLE_METHODS.has(method)) {
713
+ const isSigningPreparation = method === "GET_DEK_INFO" && payload !== null && typeof payload === "object" && "signingWalletId" in payload && payload.signingWalletId !== void 0;
714
+ if (isSigningPreparation || !RETRYABLE_METHODS.has(method)) {
713
715
  return this.sendOnce(
714
716
  type,
715
717
  method,
package/dist/index.mjs CHANGED
@@ -544,6 +544,7 @@ var RETRYABLE_METHODS = /* @__PURE__ */ new Set([
544
544
  "IS_AUTHENTICATED",
545
545
  "GET_PASSKEY_STATUS",
546
546
  "GET_DEK_INFO",
547
+ // Only metadata reads. send excludes the signing variant.
547
548
  "LIST_EPHEMERAL_SIGNERS"
548
549
  ]);
549
550
  var RETRY_ATTEMPT_TIMEOUTS_MS = [
@@ -687,7 +688,8 @@ var WebViewBridge = class {
687
688
  // Idempotent reads (see RETRYABLE_METHODS) are auto-retried on timeout to
688
689
  // ride out the iframe-app mount race; everything else makes a single attempt.
689
690
  async send(type, method, payload) {
690
- if (!RETRYABLE_METHODS.has(method)) {
691
+ const isSigningPreparation = method === "GET_DEK_INFO" && payload !== null && typeof payload === "object" && "signingWalletId" in payload && payload.signingWalletId !== void 0;
692
+ if (isSigningPreparation || !RETRYABLE_METHODS.has(method)) {
691
693
  return this.sendOnce(
692
694
  type,
693
695
  method,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moon-x/react-native-sdk",
3
- "version": "0.20.1",
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.1"
65
+ "@moon-x/core": "0.28.0"
66
66
  },
67
67
  "peerDependencies": {
68
68
  "@expo/config-plugins": ">=10.0.0",