@formo/analytics 1.38.1 → 1.39.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.
Files changed (60) hide show
  1. package/dist/cjs/src/FormoAnalytics.d.ts +10 -1
  2. package/dist/cjs/src/FormoAnalytics.js +20 -5
  3. package/dist/cjs/src/FormoAnalyticsProvider.js +20 -0
  4. package/dist/cjs/src/evm/EvmEventTracker.d.ts +100 -9
  5. package/dist/cjs/src/evm/EvmEventTracker.js +357 -19
  6. package/dist/cjs/src/evm/EvmProviderRegistry.d.ts +34 -2
  7. package/dist/cjs/src/evm/EvmProviderRegistry.js +61 -4
  8. package/dist/cjs/src/evm/EvmRequestTracker.d.ts +9 -4
  9. package/dist/cjs/src/evm/EvmRequestTracker.js +26 -16
  10. package/dist/cjs/src/solana/SolanaManager.d.ts +37 -9
  11. package/dist/cjs/src/solana/SolanaManager.js +135 -20
  12. package/dist/cjs/src/solana/SolanaStoreHandler.d.ts +6 -0
  13. package/dist/cjs/src/solana/SolanaStoreHandler.js +17 -8
  14. package/dist/cjs/src/solana/SolanaWalletStandardRegistry.d.ts +163 -0
  15. package/dist/cjs/src/solana/SolanaWalletStandardRegistry.js +447 -0
  16. package/dist/cjs/src/solana/index.d.ts +10 -5
  17. package/dist/cjs/src/solana/index.js +12 -6
  18. package/dist/cjs/src/solana/storeTypes.d.ts +20 -1
  19. package/dist/cjs/src/solana/types.d.ts +32 -9
  20. package/dist/cjs/src/solana/types.js +15 -0
  21. package/dist/cjs/src/solana/walletStandardTypes.d.ts +54 -0
  22. package/dist/cjs/src/solana/walletStandardTypes.js +21 -0
  23. package/dist/cjs/src/types/base.d.ts +15 -5
  24. package/dist/cjs/src/version.d.ts +1 -1
  25. package/dist/cjs/src/version.js +1 -1
  26. package/dist/cjs/src/wagmi/WagmiEventHandler.d.ts +30 -1
  27. package/dist/cjs/src/wagmi/WagmiEventHandler.js +80 -1
  28. package/dist/cjs/src/wagmi/types.d.ts +6 -0
  29. package/dist/cjs/src/wagmi/utils.js +9 -1
  30. package/dist/esm/src/FormoAnalytics.d.ts +10 -1
  31. package/dist/esm/src/FormoAnalytics.js +20 -5
  32. package/dist/esm/src/FormoAnalyticsProvider.js +20 -0
  33. package/dist/esm/src/evm/EvmEventTracker.d.ts +100 -9
  34. package/dist/esm/src/evm/EvmEventTracker.js +357 -19
  35. package/dist/esm/src/evm/EvmProviderRegistry.d.ts +34 -2
  36. package/dist/esm/src/evm/EvmProviderRegistry.js +61 -4
  37. package/dist/esm/src/evm/EvmRequestTracker.d.ts +9 -4
  38. package/dist/esm/src/evm/EvmRequestTracker.js +26 -16
  39. package/dist/esm/src/solana/SolanaManager.d.ts +37 -9
  40. package/dist/esm/src/solana/SolanaManager.js +135 -20
  41. package/dist/esm/src/solana/SolanaStoreHandler.d.ts +6 -0
  42. package/dist/esm/src/solana/SolanaStoreHandler.js +18 -9
  43. package/dist/esm/src/solana/SolanaWalletStandardRegistry.d.ts +163 -0
  44. package/dist/esm/src/solana/SolanaWalletStandardRegistry.js +444 -0
  45. package/dist/esm/src/solana/index.d.ts +10 -5
  46. package/dist/esm/src/solana/index.js +10 -5
  47. package/dist/esm/src/solana/storeTypes.d.ts +20 -1
  48. package/dist/esm/src/solana/types.d.ts +32 -9
  49. package/dist/esm/src/solana/types.js +14 -0
  50. package/dist/esm/src/solana/walletStandardTypes.d.ts +54 -0
  51. package/dist/esm/src/solana/walletStandardTypes.js +18 -0
  52. package/dist/esm/src/types/base.d.ts +15 -5
  53. package/dist/esm/src/version.d.ts +1 -1
  54. package/dist/esm/src/version.js +1 -1
  55. package/dist/esm/src/wagmi/WagmiEventHandler.d.ts +30 -1
  56. package/dist/esm/src/wagmi/WagmiEventHandler.js +80 -1
  57. package/dist/esm/src/wagmi/types.d.ts +6 -0
  58. package/dist/esm/src/wagmi/utils.js +9 -1
  59. package/dist/index.umd.min.js +1 -1
  60. package/package.json +2 -2
@@ -1,17 +1,22 @@
1
1
  /**
2
2
  * Solana integration module
3
3
  *
4
- * Provides automatic event capture for Solana wallets via framework-kit's
5
- * zustand store. Connect/disconnect and transaction events are tracked
6
- * automatically. Signature events (signMessage/signTransaction) require
7
- * explicit tracking via formo.signature() since framework-kit
8
- * doesn't track these in store state.
4
+ * Wallets are discovered through the Wallet Standard and their connect /
5
+ * disconnect events captured automatically for wallets registered with the
6
+ * page through Wallet Standard.
7
+ * Framework-kit apps can additionally pass their zustand store for
8
+ * transaction lifecycle events. Signature events (signMessage /
9
+ * signTransaction) require explicit tracking via formo.signature(), since
10
+ * neither source reports them.
9
11
  *
12
+ * @see https://github.com/wallet-standard/wallet-standard
10
13
  * @see https://github.com/solana-foundation/framework-kit
11
14
  */
12
15
  export { SolanaStoreHandler } from "./SolanaStoreHandler";
16
+ export { SolanaWalletStandardRegistry } from "./SolanaWalletStandardRegistry";
13
17
  export { SolanaManager } from "./SolanaManager";
14
18
  export * from "./types";
15
19
  export * from "./storeTypes";
20
+ export * from "./walletStandardTypes";
16
21
  export * from "./address";
17
22
  //# sourceMappingURL=index.d.ts.map
@@ -2,12 +2,15 @@
2
2
  /**
3
3
  * Solana integration module
4
4
  *
5
- * Provides automatic event capture for Solana wallets via framework-kit's
6
- * zustand store. Connect/disconnect and transaction events are tracked
7
- * automatically. Signature events (signMessage/signTransaction) require
8
- * explicit tracking via formo.signature() since framework-kit
9
- * doesn't track these in store state.
5
+ * Wallets are discovered through the Wallet Standard and their connect /
6
+ * disconnect events captured automatically for wallets registered with the
7
+ * page through Wallet Standard.
8
+ * Framework-kit apps can additionally pass their zustand store for
9
+ * transaction lifecycle events. Signature events (signMessage /
10
+ * signTransaction) require explicit tracking via formo.signature(), since
11
+ * neither source reports them.
10
12
  *
13
+ * @see https://github.com/wallet-standard/wallet-standard
11
14
  * @see https://github.com/solana-foundation/framework-kit
12
15
  */
13
16
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
@@ -25,12 +28,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
25
28
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
26
29
  };
27
30
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.SolanaManager = exports.SolanaStoreHandler = void 0;
31
+ exports.SolanaManager = exports.SolanaWalletStandardRegistry = exports.SolanaStoreHandler = void 0;
29
32
  var SolanaStoreHandler_1 = require("./SolanaStoreHandler");
30
33
  Object.defineProperty(exports, "SolanaStoreHandler", { enumerable: true, get: function () { return SolanaStoreHandler_1.SolanaStoreHandler; } });
34
+ var SolanaWalletStandardRegistry_1 = require("./SolanaWalletStandardRegistry");
35
+ Object.defineProperty(exports, "SolanaWalletStandardRegistry", { enumerable: true, get: function () { return SolanaWalletStandardRegistry_1.SolanaWalletStandardRegistry; } });
31
36
  var SolanaManager_1 = require("./SolanaManager");
32
37
  Object.defineProperty(exports, "SolanaManager", { enumerable: true, get: function () { return SolanaManager_1.SolanaManager; } });
33
38
  __exportStar(require("./types"), exports);
34
39
  __exportStar(require("./storeTypes"), exports);
40
+ __exportStar(require("./walletStandardTypes"), exports);
35
41
  __exportStar(require("./address"), exports);
36
42
  //# sourceMappingURL=index.js.map
@@ -72,13 +72,32 @@ export interface SolanaWalletConnectorMetadata {
72
72
  readonly name: string;
73
73
  readonly icon?: string;
74
74
  }
75
+ /** Cluster health as exposed by framework-kit. */
76
+ export type SolanaClusterStatus = Readonly<{
77
+ status: "idle";
78
+ }> | Readonly<{
79
+ status: "connecting";
80
+ }> | Readonly<{
81
+ status: "ready";
82
+ latencyMs?: number;
83
+ }> | Readonly<{
84
+ status: "error";
85
+ error: unknown;
86
+ }>;
87
+ /** @deprecated framework-kit emits {@link SolanaClusterStatus} objects. */
88
+ export type LegacySolanaClusterStatus = SolanaClusterStatus["status"];
75
89
  /**
76
90
  * Cluster state from the store.
77
91
  */
78
92
  export interface SolanaClusterState {
79
93
  readonly endpoint: string;
80
94
  readonly commitment?: string;
81
- readonly status: "idle" | "connecting" | "ready" | "error";
95
+ /**
96
+ * framework-kit's `ClusterStatus` is a discriminated union such as
97
+ * `{ status: 'ready', latencyMs?: number }`. The pre-1.39 string form is
98
+ * retained so custom stores and test doubles remain source-compatible.
99
+ */
100
+ readonly status: SolanaClusterStatus | LegacySolanaClusterStatus;
82
101
  }
83
102
  /**
84
103
  * The zustand vanilla store API that framework-kit exposes via `client.store`.
@@ -46,15 +46,32 @@ export interface SolanaPublicKey {
46
46
  */
47
47
  export type UnsubscribeFn = () => void;
48
48
  /**
49
- * Solana options for FormoAnalytics
49
+ * The rdns reported for a Solana wallet.
50
+ *
51
+ * The Wallet Standard has no reverse-domain identifier, so one is derived
52
+ * from the wallet's normalized name. Lowercasing and removing whitespace
53
+ * preserves the values historically reported by the framework-kit store;
54
+ * encoding keeps delimiters and other special characters safe for storage.
55
+ * Both Solana paths (Wallet Standard discovery and the framework-kit store)
56
+ * derive it the same way, so a wallet's `detect` and its `connect` share one
57
+ * rdns whichever path reported each.
58
+ */
59
+ export declare function solanaWalletRdns(walletName: string): string;
60
+ /**
61
+ * Solana options for FormoAnalytics.
62
+ *
63
+ * Wallet discovery through the Wallet Standard is on by default and needs
64
+ * none of these. They add framework-kit's store, or name the cluster.
50
65
  */
51
66
  export interface SolanaOptions {
52
67
  /**
53
- * The framework-kit client store (client.store) for automatic event tracking.
54
- * When provided, wallet connect/disconnect and transaction events are tracked
55
- * automatically by subscribing to zustand store state changes.
68
+ * The framework-kit client store (client.store).
69
+ * When provided, transaction lifecycle events and cluster switches are
70
+ * tracked from the store, and connect/disconnect come from the store
71
+ * rather than from Wallet Standard discovery.
56
72
  *
57
- * This is the recommended approach for apps using framework-kit.
73
+ * Only for apps using framework-kit (`@solana/client`). Other integrations
74
+ * do not need a store when their wallets register through Wallet Standard.
58
75
  *
59
76
  * @example
60
77
  * ```tsx
@@ -65,10 +82,16 @@ export interface SolanaOptions {
65
82
  */
66
83
  store?: import("./storeTypes").SolanaClientStore;
67
84
  /**
68
- * The Solana cluster/network.
69
- * Usually auto-detected from the store's endpoint URL.
70
- * Only needed for custom RPC URLs that don't contain a recognizable cluster name.
71
- * @default auto-detected, or "mainnet-beta" if detection fails
85
+ * The Solana cluster/network the app is on.
86
+ *
87
+ * With a store, usually auto-detected from its endpoint URL; only needed
88
+ * for custom RPC URLs that don't contain a recognizable cluster name.
89
+ * Without a store, the Wallet Standard cannot say which cluster the app
90
+ * uses, so a devnet or testnet app should set this (or call
91
+ * `formo.solana.setCluster()`); otherwise connections are reported on
92
+ * mainnet-beta.
93
+ * @default auto-detected from the store; otherwise mainnet-beta when the
94
+ * wallet supports it, or its first supported Solana cluster
72
95
  */
73
96
  cluster?: SolanaCluster;
74
97
  }
@@ -10,6 +10,7 @@
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.DEFAULT_SOLANA_CHAIN_ID = exports.SOLANA_CLUSTERS_BY_ID = exports.SOLANA_CHAIN_IDS = void 0;
12
12
  exports.isSolanaChainId = isSolanaChainId;
13
+ exports.solanaWalletRdns = solanaWalletRdns;
13
14
  /**
14
15
  * Mapping of Solana clusters to numeric chain IDs for consistency with EVM events
15
16
  * These IDs are non-standard but provide a way to identify Solana networks in our analytics
@@ -44,4 +45,18 @@ function isSolanaChainId(chainId) {
44
45
  return false;
45
46
  return Object.values(exports.SOLANA_CHAIN_IDS).includes(chainId);
46
47
  }
48
+ /**
49
+ * The rdns reported for a Solana wallet.
50
+ *
51
+ * The Wallet Standard has no reverse-domain identifier, so one is derived
52
+ * from the wallet's normalized name. Lowercasing and removing whitespace
53
+ * preserves the values historically reported by the framework-kit store;
54
+ * encoding keeps delimiters and other special characters safe for storage.
55
+ * Both Solana paths (Wallet Standard discovery and the framework-kit store)
56
+ * derive it the same way, so a wallet's `detect` and its `connect` share one
57
+ * rdns whichever path reported each.
58
+ */
59
+ function solanaWalletRdns(walletName) {
60
+ return "sol.wallet.".concat(encodeURIComponent(walletName.toLowerCase().replace(/\s+/g, "")));
61
+ }
47
62
  //# sourceMappingURL=types.js.map
@@ -0,0 +1,54 @@
1
+ /**
2
+ * The subset of the Wallet Standard this SDK reads.
3
+ *
4
+ * Duck-typed on purpose: the SDK must not depend on `@wallet-standard/*`
5
+ * packages (see the dependency policy), and a wallet is discovered through
6
+ * window events, so nothing here is ever imported from a wallet library.
7
+ * Every field is what a conforming wallet exposes; the shapes are looser
8
+ * than the reference types so a slightly off wallet is skipped, not thrown
9
+ * on.
10
+ *
11
+ * @see https://github.com/wallet-standard/wallet-standard
12
+ */
13
+ /** `namespace:reference`, e.g. `solana:mainnet` or `solana:devnet`. */
14
+ export type WalletStandardChain = string;
15
+ export interface WalletStandardAccount {
16
+ readonly address: string;
17
+ readonly publicKey?: unknown;
18
+ /** Chains this account can sign for. Absent on a non-conforming wallet. */
19
+ readonly chains?: readonly WalletStandardChain[];
20
+ readonly features?: readonly string[];
21
+ readonly label?: string;
22
+ readonly icon?: string;
23
+ }
24
+ export interface WalletStandardWallet {
25
+ readonly version?: string;
26
+ readonly name: string;
27
+ readonly icon?: string;
28
+ /** Every chain the wallet supports, NOT the one currently selected. */
29
+ readonly chains: readonly WalletStandardChain[];
30
+ readonly features: Readonly<Record<string, unknown>>;
31
+ /** Accounts the app is currently authorized for; empty until connected. */
32
+ readonly accounts: readonly WalletStandardAccount[];
33
+ }
34
+ /** What a `standard:events` `change` event carries: only what changed. */
35
+ export interface WalletStandardChangeProperties {
36
+ readonly chains?: readonly WalletStandardChain[];
37
+ readonly features?: Readonly<Record<string, unknown>>;
38
+ readonly accounts?: readonly WalletStandardAccount[];
39
+ }
40
+ /** The `standard:events` feature. */
41
+ export interface WalletStandardEventsFeature {
42
+ readonly version?: string;
43
+ on(event: "change", listener: (properties: WalletStandardChangeProperties) => void): () => void;
44
+ }
45
+ /** The API an app hands to wallets so they can announce themselves. */
46
+ export interface WalletStandardRegisterApi {
47
+ register(...wallets: WalletStandardWallet[]): () => void;
48
+ }
49
+ /** Dispatched by the app on `window`; `detail` is the register API. */
50
+ export declare const WALLET_STANDARD_APP_READY_EVENT = "wallet-standard:app-ready";
51
+ /** Dispatched by a wallet on `window`; `detail` is a callback taking the API. */
52
+ export declare const WALLET_STANDARD_REGISTER_WALLET_EVENT = "wallet-standard:register-wallet";
53
+ export declare const WALLET_STANDARD_EVENTS_FEATURE = "standard:events";
54
+ //# sourceMappingURL=walletStandardTypes.d.ts.map
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /**
3
+ * The subset of the Wallet Standard this SDK reads.
4
+ *
5
+ * Duck-typed on purpose: the SDK must not depend on `@wallet-standard/*`
6
+ * packages (see the dependency policy), and a wallet is discovered through
7
+ * window events, so nothing here is ever imported from a wallet library.
8
+ * Every field is what a conforming wallet exposes; the shapes are looser
9
+ * than the reference types so a slightly off wallet is skipped, not thrown
10
+ * on.
11
+ *
12
+ * @see https://github.com/wallet-standard/wallet-standard
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.WALLET_STANDARD_EVENTS_FEATURE = exports.WALLET_STANDARD_REGISTER_WALLET_EVENT = exports.WALLET_STANDARD_APP_READY_EVENT = void 0;
16
+ /** Dispatched by the app on `window`; `detail` is the register API. */
17
+ exports.WALLET_STANDARD_APP_READY_EVENT = "wallet-standard:app-ready";
18
+ /** Dispatched by a wallet on `window`; `detail` is a callback taking the API. */
19
+ exports.WALLET_STANDARD_REGISTER_WALLET_EVENT = "wallet-standard:register-wallet";
20
+ exports.WALLET_STANDARD_EVENTS_FEATURE = "standard:events";
21
+ //# sourceMappingURL=walletStandardTypes.js.map
@@ -246,16 +246,26 @@ export interface Options {
246
246
  */
247
247
  wagmi?: WagmiOptions;
248
248
  /**
249
- * Solana integration configuration.
250
- * Pass `store: client.store` from framework-kit for automatic tracking of
251
- * wallet connect/disconnect and transaction events.
249
+ * Solana wallet tracking.
250
+ *
251
+ * On by default: wallets are discovered through the Wallet Standard, the
252
+ * Solana analogue of EIP-6963, so connect and disconnect are autocaptured
253
+ * for compatible wallets registered with the page, including wallets used
254
+ * through Solana Kit, wallet-adapter, and framework-kit.
255
+ *
256
+ * - `false`: disable Solana wallet discovery and tracking entirely.
257
+ * - `SolanaOptions`: additionally pass `store: client.store` from
258
+ * framework-kit for transaction lifecycle events and cluster switches,
259
+ * or `cluster` to name the network a non-mainnet app is on.
252
260
  *
253
261
  * For signMessage/signTransaction, use formo.signature() directly
254
- * (framework-kit doesn't track these in the store).
262
+ * (neither the Wallet Standard nor framework-kit's store reports these).
255
263
  *
264
+ * @see https://github.com/wallet-standard/wallet-standard
256
265
  * @see https://github.com/solana-foundation/framework-kit
266
+ * @default true
257
267
  */
258
- solana?: SolanaOptions;
268
+ solana?: boolean | SolanaOptions;
259
269
  /**
260
270
  * Custom API host for sending events through your own domain to bypass ad blockers
261
271
  * - If not provided, events are sent directly to events.formo.so
@@ -1,2 +1,2 @@
1
- export declare const version = "1.38.1";
1
+ export declare const version = "1.39.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -3,5 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  // This file is auto-generated by scripts/update-version.js during npm version
5
5
  // Do not edit manually - it will be overwritten
6
- exports.version = '1.38.1';
6
+ exports.version = '1.39.0';
7
7
  //# sourceMappingURL=version.js.map
@@ -6,7 +6,7 @@
6
6
  * wrapping approach when Wagmi mode is enabled.
7
7
  */
8
8
  import { FormoAnalytics } from "../FormoAnalytics";
9
- import { WagmiConfig, QueryClient } from "./types";
9
+ import { QueryClient, WagmiConfig } from "./types";
10
10
  /**
11
11
  * How long the markers stay trustworthy after the last handler goes away.
12
12
  *
@@ -337,6 +337,35 @@ export declare class WagmiEventHandler {
337
337
  * (still connected through its own connector).
338
338
  */
339
339
  private isAddressConnected;
340
+ /**
341
+ * A specific connector's name and rdns, for the fallback-wrapped
342
+ * provider's request-derived events.
343
+ *
344
+ * The NAME is exactly what the hook path emits for that connector
345
+ * (`getConnectorName`: the live WalletConnect peer for a WalletConnect
346
+ * connector, the connector's own name otherwise), so a branded connector
347
+ * keeps its name on both paths and a session that changes wallets
348
+ * renames on both. The rdns is the connector's when wagmi knows it as
349
+ * ONE value (EIP-6963 discovered connectors carry theirs, some as a
350
+ * one-element list); a connector that matches several rdns values does
351
+ * not say which one this provider is, so nothing is passed and the
352
+ * registry keeps the sniffed one.
353
+ */
354
+ private attributionForConnector;
355
+ /**
356
+ * Resolver handed to the registry at wrap time, read at each request
357
+ * start. BOUND to the connector whose `getProvider` resolved to the
358
+ * wrapped provider, not to whichever connector is current: an app can
359
+ * keep a wallet client over a previous connector's provider and issue a
360
+ * request through it after switching, and that request belongs to the
361
+ * wallet that handles it. The peer name is still read live. A provider
362
+ * SHARED by two connectors is re-bound when the new connector's
363
+ * resolution lands (one microtask for an injected connector); a request
364
+ * issued inside that gap keeps the previous label.
365
+ */
366
+ private boundConnectorAttribution;
367
+ /** `getConnectorName` for a SPECIFIC connector, current or not. */
368
+ private nameForConnector;
340
369
  /**
341
370
  * Get the connector name from Wagmi state
342
371
  */
@@ -75,6 +75,16 @@ var RESERVED_FIELDS = new Set([
75
75
  "transactionHash",
76
76
  "function_name",
77
77
  "function_args",
78
+ // Wallet attribution. Function args are spread AFTER the attribution
79
+ // properties, so an ABI input named `providerName` would silently
80
+ // relabel the wallet on every broadcast and receipt event. `rdns` is
81
+ // reserved with it even though THIS path (wagmi mutation attribution)
82
+ // emits only the name: elsewhere in the SDK - the EIP-1193 request path
83
+ // and connect events - `rdns` is the wallet-identity key, so an ABI
84
+ // input by that name would land in the same warehouse column as real
85
+ // wallet identities.
86
+ "providerName",
87
+ "rdns",
78
88
  ]);
79
89
  /**
80
90
  * Connections already announced to a destination during this page load.
@@ -2337,6 +2347,75 @@ var WagmiEventHandler = /** @class */ (function () {
2337
2347
  });
2338
2348
  return found;
2339
2349
  };
2350
+ /**
2351
+ * A specific connector's name and rdns, for the fallback-wrapped
2352
+ * provider's request-derived events.
2353
+ *
2354
+ * The NAME is exactly what the hook path emits for that connector
2355
+ * (`getConnectorName`: the live WalletConnect peer for a WalletConnect
2356
+ * connector, the connector's own name otherwise), so a branded connector
2357
+ * keeps its name on both paths and a session that changes wallets
2358
+ * renames on both. The rdns is the connector's when wagmi knows it as
2359
+ * ONE value (EIP-6963 discovered connectors carry theirs, some as a
2360
+ * one-element list); a connector that matches several rdns values does
2361
+ * not say which one this provider is, so nothing is passed and the
2362
+ * registry keeps the sniffed one.
2363
+ */
2364
+ WagmiEventHandler.prototype.attributionForConnector = function (connector, state) {
2365
+ var name = this.nameForConnector(connector, state);
2366
+ if (!name) {
2367
+ return undefined;
2368
+ }
2369
+ var raw = connector.rdns;
2370
+ var rdns = typeof raw === "string" && raw.length > 0
2371
+ ? raw
2372
+ : Array.isArray(raw) && raw.length === 1 && typeof raw[0] === "string" && raw[0].length > 0
2373
+ ? raw[0]
2374
+ : undefined;
2375
+ return __assign({ name: name }, (rdns && { rdns: rdns }));
2376
+ };
2377
+ /**
2378
+ * Resolver handed to the registry at wrap time, read at each request
2379
+ * start. BOUND to the connector whose `getProvider` resolved to the
2380
+ * wrapped provider, not to whichever connector is current: an app can
2381
+ * keep a wallet client over a previous connector's provider and issue a
2382
+ * request through it after switching, and that request belongs to the
2383
+ * wallet that handles it. The peer name is still read live. A provider
2384
+ * SHARED by two connectors is re-bound when the new connector's
2385
+ * resolution lands (one microtask for an injected connector); a request
2386
+ * issued inside that gap keeps the previous label.
2387
+ */
2388
+ WagmiEventHandler.prototype.boundConnectorAttribution = function (connector) {
2389
+ var _this = this;
2390
+ return function () {
2391
+ if (_this.disposed)
2392
+ return undefined;
2393
+ try {
2394
+ return _this.attributionForConnector(connector, _this.getState());
2395
+ }
2396
+ catch (_a) {
2397
+ return undefined;
2398
+ }
2399
+ };
2400
+ };
2401
+ /** `getConnectorName` for a SPECIFIC connector, current or not. */
2402
+ WagmiEventHandler.prototype.nameForConnector = function (connector, state) {
2403
+ var _a;
2404
+ var cached = walletConnectPeerNames.get(connector);
2405
+ if (cached) {
2406
+ return cached;
2407
+ }
2408
+ var current = state.current
2409
+ ? (_a = state.connections.get(state.current)) === null || _a === void 0 ? void 0 : _a.connector
2410
+ : undefined;
2411
+ if (current === connector) {
2412
+ // Backstop kick, as in getConnectorName; only the current connection
2413
+ // has a session to look up.
2414
+ this.kickWalletConnectPeerLookup(state);
2415
+ }
2416
+ var name = connector.name;
2417
+ return typeof name === "string" && name.length > 0 ? name : undefined;
2418
+ };
2340
2419
  /**
2341
2420
  * Get the connector name from Wagmi state
2342
2421
  */
@@ -2474,7 +2553,7 @@ var WagmiEventHandler = /** @class */ (function () {
2474
2553
  return;
2475
2554
  }
2476
2555
  var chainId = (_b = _this.getActiveConnectionChainId(live)) !== null && _b !== void 0 ? _b : live.chainId;
2477
- var wrapped = (_d = (_c = _this.formo)._wrapWagmiProvider) === null || _d === void 0 ? void 0 : _d.call(_c, provider, typeof chainId === "number" ? chainId : undefined);
2556
+ var wrapped = (_d = (_c = _this.formo)._wrapWagmiProvider) === null || _d === void 0 ? void 0 : _d.call(_c, provider, typeof chainId === "number" ? chainId : undefined, _this.boundConnectorAttribution(connector));
2478
2557
  if (wrapped !== true) {
2479
2558
  // The provider was refused (invalid shape, frozen provider,
2480
2559
  // torn-down SDK).
@@ -31,6 +31,12 @@ export interface WagmiConnector {
31
31
  name: string;
32
32
  type: string;
33
33
  uid: string;
34
+ /**
35
+ * Any connector implementation may expose an rdns; EIP-6963 discovered
36
+ * connectors are one source. A connector matching several rdns values
37
+ * lists them all.
38
+ */
39
+ rdns?: string | readonly string[];
34
40
  }
35
41
  /**
36
42
  * Wagmi config interface
@@ -192,7 +192,15 @@ function buildSafeFunctionArgs(functionArgs, reservedFields) {
192
192
  var result = {};
193
193
  for (var _i = 0, _a = Object.entries(functionArgs); _i < _a.length; _i++) {
194
194
  var _b = _a[_i], key = _b[0], val = _b[1];
195
- var safeKey = reservedFields.has(key) ? "arg_".concat(key) : key;
195
+ // A prefixed key must not land on another argument's own name: an ABI
196
+ // with both `to` and `arg_to` would otherwise keep only one of them,
197
+ // whichever came later. Keep prefixing until the name is free.
198
+ var safeKey = key;
199
+ if (reservedFields.has(key)) {
200
+ do {
201
+ safeKey = "arg_".concat(safeKey);
202
+ } while (safeKey in functionArgs);
203
+ }
196
204
  result[safeKey] = val;
197
205
  // If the value is a nested object (struct), flatten it
198
206
  // Skip flattened keys that would overwrite existing top-level args
@@ -428,8 +428,17 @@ export declare class FormoAnalytics implements IFormoAnalytics {
428
428
  * gap. Lifecycle (connect/chain/disconnect) stays store-driven: only the
429
429
  * request wrapper installs here. Double counting is prevented in the
430
430
  * wrapper via `shouldSkipRequestCapture`.
431
+ *
432
+ * `attribution` resolves, live, the name and rdns of the connector this
433
+ * provider was wrapped for. Request-derived events are named from the
434
+ * registry, which for an unannounced provider falls back to flag
435
+ * sniffing; recording the connector's resolver here keeps them in
436
+ * agreement with the hook-driven events for that connector.
431
437
  */
432
- _wrapWagmiProvider(provider: EIP1193Provider, chainId?: number): boolean;
438
+ _wrapWagmiProvider(provider: EIP1193Provider, chainId?: number, attribution?: () => {
439
+ name: string;
440
+ rdns?: string;
441
+ } | undefined): boolean;
433
442
  /** INTERNAL. Chain updates for the fallback-wrapped provider. */
434
443
  _rememberWagmiProviderChain(provider: EIP1193Provider, chainId: number | undefined): void;
435
444
  registerProvider(provider: EIP1193Provider, info?: {
@@ -242,9 +242,12 @@ var FormoAnalytics = /** @class */ (function () {
242
242
  this.evmEvents.trackEIP1193Provider(provider);
243
243
  }
244
244
  }
245
- // Initialize Solana manager if Solana options are provided
246
- if (options.solana) {
247
- this.solanaManager = new SolanaManager(this, options.solana);
245
+ // Solana wallets are discovered through the Wallet Standard
246
+ // unconditionally, the way EVM wallets are through EIP-6963: an app
247
+ // that never configures Solana still gets its connects. `solana: false`
248
+ // is the opt-out; an object adds framework-kit's store or a cluster.
249
+ if (options.solana !== false) {
250
+ this.solanaManager = new SolanaManager(this, typeof options.solana === "object" ? options.solana : undefined);
248
251
  }
249
252
  this._currentUrl = window.location.href;
250
253
  // Seed currentAddress/currentChainId from the persisted snapshot before
@@ -1015,6 +1018,9 @@ var FormoAnalytics = /** @class */ (function () {
1015
1018
  // Drop anything already buffered so a pending timer/pagehide flush
1016
1019
  // cannot ship events after consent withdrawal.
1017
1020
  this.eventManager.clear();
1021
+ // Identity is purged below; registered sessions must be re-learned
1022
+ // on opt-in, and nothing else would retry an already-adopted one.
1023
+ this.evmEvents.markRegisteredAdoptionsPending();
1018
1024
  this.reset();
1019
1025
  logger.info("Successfully opted out of tracking");
1020
1026
  };
@@ -1265,7 +1271,9 @@ var FormoAnalytics = /** @class */ (function () {
1265
1271
  */
1266
1272
  get: function () {
1267
1273
  if (!this.solanaManager) {
1268
- this.solanaManager = new SolanaManager(this);
1274
+ // Only reachable after `solana: false` (or after cleanup). The host
1275
+ // opted out of discovery, so this manager serves the store path only.
1276
+ this.solanaManager = new SolanaManager(this, undefined, false);
1269
1277
  }
1270
1278
  return this.solanaManager;
1271
1279
  },
@@ -1360,8 +1368,14 @@ var FormoAnalytics = /** @class */ (function () {
1360
1368
  * gap. Lifecycle (connect/chain/disconnect) stays store-driven: only the
1361
1369
  * request wrapper installs here. Double counting is prevented in the
1362
1370
  * wrapper via `shouldSkipRequestCapture`.
1371
+ *
1372
+ * `attribution` resolves, live, the name and rdns of the connector this
1373
+ * provider was wrapped for. Request-derived events are named from the
1374
+ * registry, which for an unannounced provider falls back to flag
1375
+ * sniffing; recording the connector's resolver here keeps them in
1376
+ * agreement with the hook-driven events for that connector.
1363
1377
  */
1364
- FormoAnalytics.prototype._wrapWagmiProvider = function (provider, chainId) {
1378
+ FormoAnalytics.prototype._wrapWagmiProvider = function (provider, chainId, attribution) {
1365
1379
  if (this.isCleanedUp || !isValidProvider(provider))
1366
1380
  return false;
1367
1381
  try {
@@ -1371,6 +1385,7 @@ var FormoAnalytics = /** @class */ (function () {
1371
1385
  if (!this.evmRequests.registerRequestListeners(provider)) {
1372
1386
  return false;
1373
1387
  }
1388
+ this.evm.rememberAttribution(provider, attribution);
1374
1389
  if (chainId !== undefined) {
1375
1390
  this.evm.rememberChain(provider, chainId);
1376
1391
  }
@@ -69,6 +69,18 @@ var defaultContext = {
69
69
  hasOptedOutTracking: function () { return false; },
70
70
  };
71
71
  export var FormoAnalyticsContext = createContext(defaultContext);
72
+ var optionObjectIds = new WeakMap();
73
+ var nextOptionObjectId = 1;
74
+ var optionObjectId = function (value) {
75
+ if (!value)
76
+ return undefined;
77
+ var id = optionObjectIds.get(value);
78
+ if (id === undefined) {
79
+ id = nextOptionObjectId++;
80
+ optionObjectIds.set(value, id);
81
+ }
82
+ return id;
83
+ };
72
84
  /**
73
85
  * A stable key over the serializable parts of Options. The provider effect
74
86
  * re-initialises the SDK when this key changes; anything that alters SDK
@@ -92,6 +104,14 @@ export var computeOptionsKey = function (options) {
92
104
  logger: options.logger,
93
105
  referral: options.referral,
94
106
  evm: options.evm,
107
+ // `solana` is a boolean or an options object. A store is a live event
108
+ // source, so replacing it must reinitialize the SDK even when both the
109
+ // old and new options contain a store.
110
+ solana: typeof options.solana === "object" ? undefined : options.solana,
111
+ solanaStoreId: typeof options.solana === "object"
112
+ ? optionObjectId(options.solana.store)
113
+ : undefined,
114
+ solanaCluster: typeof options.solana === "object" ? options.solana.cluster : undefined,
95
115
  // For complex objects, just track their presence, not their content
96
116
  hasProvider: !!options.provider,
97
117
  hasWagmi: !!options.wagmi,