@formo/analytics 1.36.0 → 1.38.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 (44) hide show
  1. package/dist/cjs/src/FormoAnalytics.d.ts +64 -0
  2. package/dist/cjs/src/FormoAnalytics.js +155 -5
  3. package/dist/cjs/src/FormoAnalyticsProvider.js +1 -0
  4. package/dist/cjs/src/evm/EvmEventTracker.d.ts +38 -10
  5. package/dist/cjs/src/evm/EvmEventTracker.js +182 -0
  6. package/dist/cjs/src/evm/EvmProviderRegistry.js +26 -4
  7. package/dist/cjs/src/evm/EvmRequestTracker.d.ts +36 -40
  8. package/dist/cjs/src/evm/EvmRequestTracker.js +216 -115
  9. package/dist/cjs/src/evm/batch.d.ts +94 -0
  10. package/dist/cjs/src/evm/batch.js +130 -0
  11. package/dist/cjs/src/provider/detection.d.ts +30 -0
  12. package/dist/cjs/src/provider/detection.js +62 -0
  13. package/dist/cjs/src/provider/index.d.ts +1 -1
  14. package/dist/cjs/src/provider/index.js +3 -1
  15. package/dist/cjs/src/types/base.d.ts +23 -0
  16. package/dist/cjs/src/types/provider.d.ts +16 -0
  17. package/dist/cjs/src/types/provider.js +17 -1
  18. package/dist/cjs/src/version.d.ts +1 -1
  19. package/dist/cjs/src/version.js +1 -1
  20. package/dist/cjs/src/wagmi/WagmiEventHandler.d.ts +87 -0
  21. package/dist/cjs/src/wagmi/WagmiEventHandler.js +536 -13
  22. package/dist/esm/src/FormoAnalytics.d.ts +64 -0
  23. package/dist/esm/src/FormoAnalytics.js +155 -5
  24. package/dist/esm/src/FormoAnalyticsProvider.js +1 -0
  25. package/dist/esm/src/evm/EvmEventTracker.d.ts +38 -10
  26. package/dist/esm/src/evm/EvmEventTracker.js +183 -1
  27. package/dist/esm/src/evm/EvmProviderRegistry.js +27 -5
  28. package/dist/esm/src/evm/EvmRequestTracker.d.ts +36 -40
  29. package/dist/esm/src/evm/EvmRequestTracker.js +215 -114
  30. package/dist/esm/src/evm/batch.d.ts +94 -0
  31. package/dist/esm/src/evm/batch.js +123 -0
  32. package/dist/esm/src/provider/detection.d.ts +30 -0
  33. package/dist/esm/src/provider/detection.js +60 -0
  34. package/dist/esm/src/provider/index.d.ts +1 -1
  35. package/dist/esm/src/provider/index.js +1 -1
  36. package/dist/esm/src/types/base.d.ts +23 -0
  37. package/dist/esm/src/types/provider.d.ts +16 -0
  38. package/dist/esm/src/types/provider.js +16 -0
  39. package/dist/esm/src/version.d.ts +1 -1
  40. package/dist/esm/src/version.js +1 -1
  41. package/dist/esm/src/wagmi/WagmiEventHandler.d.ts +87 -0
  42. package/dist/esm/src/wagmi/WagmiEventHandler.js +536 -13
  43. package/dist/index.umd.min.js +1 -1
  44. package/package.json +4 -3
@@ -0,0 +1,94 @@
1
+ import { TransactionStatus } from "../types/events";
2
+ /**
3
+ * EIP-5792 batch settlement, shared by both capture paths.
4
+ *
5
+ * The EIP-1193 request wrapper (`EvmRequestTracker`) and the wagmi cache
6
+ * observer (`WagmiEventHandler`) each see a batch through a different
7
+ * transport, but a settled batch means the same thing in both. Keeping the
8
+ * outcome rules in one place is what stops the two paths from drifting into
9
+ * reporting the same batch differently depending on how the app happened to
10
+ * integrate the SDK.
11
+ */
12
+ /** A settled batch as `wallet_getCallsStatus` (or viem's wrapper) reports it. */
13
+ export type BatchStatusResult = {
14
+ status?: number | string;
15
+ statusCode?: number;
16
+ atomic?: boolean;
17
+ chainId?: number | string;
18
+ receipts?: BatchReceipt[];
19
+ } | null | undefined;
20
+ export type BatchReceipt = {
21
+ status?: string | number;
22
+ transactionHash?: string;
23
+ };
24
+ /**
25
+ * The batch identifier from a `wallet_sendCalls` result.
26
+ *
27
+ * EIP-5792 settled on `{ id }`, but wallets shipped against the earlier
28
+ * draft return a bare string. Both are accepted so a wallet on either
29
+ * version is still grouped.
30
+ */
31
+ export declare function readBatchId(result: unknown): string | undefined;
32
+ /**
33
+ * The numeric EIP-5792 status code from a settlement result.
34
+ *
35
+ * A wallet answers `wallet_getCallsStatus` with a numeric `status`; viem's
36
+ * `getCallsStatus` renames that to `statusCode` and puts a summary string in
37
+ * `status` instead. Both shapes arrive here depending on the capture path,
38
+ * so read the number wherever it is and never trust the string.
39
+ */
40
+ export declare function readBatchStatusCode(res: BatchStatusResult): number | undefined;
41
+ /**
42
+ * The chain a settled batch reports itself on.
43
+ *
44
+ * EIP-5792 v2 puts `chainId` in the `wallet_getCallsStatus` response as hex;
45
+ * viem returns it as a number. Either way it names the chain the batch
46
+ * actually settled on, which outranks a chain merely inferred from the
47
+ * connection at broadcast time - the wallet can move chains while the
48
+ * prompt is up.
49
+ */
50
+ export declare function readBatchChainId(res: BatchStatusResult): number | undefined;
51
+ /**
52
+ * How one call in a settled batch ended.
53
+ *
54
+ * A per-call receipt is authoritative where it exists: that is what makes a
55
+ * partially reverted non-atomic batch report honestly rather than tarring
56
+ * every call with the batch's worst outcome. A receipt whose own status is
57
+ * unreadable falls back to the batch verdict rather than being assumed good.
58
+ *
59
+ * Receipt statuses come in two spellings: raw RPC (`"0x0"`/`"0x1"`, or the
60
+ * numbers) and viem-formatted (`"reverted"`/`"success"`), because the wagmi
61
+ * path sees receipts after viem has normalised them.
62
+ *
63
+ * The codes are EIP-5792's: 200 confirmed, 400 failed BEFORE landing on
64
+ * chain, 500 reverted, 600 partially reverted. 400 is a rejection, not a
65
+ * revert - nothing was mined, so calling it reverted would misreport gas
66
+ * spent and on-chain activity that never happened.
67
+ *
68
+ * Returns undefined when the call cannot be decided, which happens on 600
69
+ * for a call the wallet gave no receipt for.
70
+ */
71
+ export declare function batchCallOutcome(code: number, receipt?: BatchReceipt): TransactionStatus | undefined;
72
+ /**
73
+ * The receipt that decides call `index`, honouring atomic execution.
74
+ *
75
+ * An atomic batch lands as ONE on-chain transaction, so the wallet returns a
76
+ * single receipt covering every call. Indexing receipts positionally there
77
+ * would hand the shared hash to call 0 and leave its siblings hashless and
78
+ * decided only by the batch verdict. Every call in an atomic batch shares
79
+ * the one receipt - same hash, same fate - which is also what makes
80
+ * `count(distinct transaction_hash)` count on-chain transactions correctly.
81
+ *
82
+ * The wallet's own `atomic` flag is authoritative in BOTH directions. An
83
+ * explicit `atomic: false` with a single receipt is a real shape - a
84
+ * non-atomic batch whose execution stopped after one call mined - and
85
+ * sharing that receipt would hand calls that never reached the chain a
86
+ * transaction hash they do not have. Only when the field is ABSENT (a
87
+ * wallet predating it, reached over raw EIP-1193; viem fills the field in,
88
+ * so the wagmi path never lands here) does the conservative inference
89
+ * apply: one receipt for several calls on a batch that is NOT partially
90
+ * reverted can only be atomic execution (600 explicitly means some calls
91
+ * reverted and others did not, which one shared transaction cannot do).
92
+ */
93
+ export declare function batchReceiptForCall(res: BatchStatusResult, index: number, callCount: number): BatchReceipt | undefined;
94
+ //# sourceMappingURL=batch.d.ts.map
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readBatchId = readBatchId;
4
+ exports.readBatchStatusCode = readBatchStatusCode;
5
+ exports.readBatchChainId = readBatchChainId;
6
+ exports.batchCallOutcome = batchCallOutcome;
7
+ exports.batchReceiptForCall = batchReceiptForCall;
8
+ var events_1 = require("../types/events");
9
+ /**
10
+ * The batch identifier from a `wallet_sendCalls` result.
11
+ *
12
+ * EIP-5792 settled on `{ id }`, but wallets shipped against the earlier
13
+ * draft return a bare string. Both are accepted so a wallet on either
14
+ * version is still grouped.
15
+ */
16
+ function readBatchId(result) {
17
+ if (typeof result === "string" && result.length > 0)
18
+ return result;
19
+ if (result && typeof result === "object") {
20
+ var id = result.id;
21
+ if (typeof id === "string" && id.length > 0)
22
+ return id;
23
+ }
24
+ return undefined;
25
+ }
26
+ /**
27
+ * The numeric EIP-5792 status code from a settlement result.
28
+ *
29
+ * A wallet answers `wallet_getCallsStatus` with a numeric `status`; viem's
30
+ * `getCallsStatus` renames that to `statusCode` and puts a summary string in
31
+ * `status` instead. Both shapes arrive here depending on the capture path,
32
+ * so read the number wherever it is and never trust the string.
33
+ */
34
+ function readBatchStatusCode(res) {
35
+ if (typeof (res === null || res === void 0 ? void 0 : res.statusCode) === "number")
36
+ return res.statusCode;
37
+ if (typeof (res === null || res === void 0 ? void 0 : res.status) === "number")
38
+ return res.status;
39
+ return undefined;
40
+ }
41
+ /**
42
+ * The chain a settled batch reports itself on.
43
+ *
44
+ * EIP-5792 v2 puts `chainId` in the `wallet_getCallsStatus` response as hex;
45
+ * viem returns it as a number. Either way it names the chain the batch
46
+ * actually settled on, which outranks a chain merely inferred from the
47
+ * connection at broadcast time - the wallet can move chains while the
48
+ * prompt is up.
49
+ */
50
+ function readBatchChainId(res) {
51
+ var raw = res === null || res === void 0 ? void 0 : res.chainId;
52
+ if (typeof raw === "number" && Number.isFinite(raw) && raw > 0)
53
+ return raw;
54
+ if (typeof raw === "string") {
55
+ var parsed = parseInt(raw, 16);
56
+ if (Number.isFinite(parsed) && parsed > 0)
57
+ return parsed;
58
+ }
59
+ return undefined;
60
+ }
61
+ /**
62
+ * How one call in a settled batch ended.
63
+ *
64
+ * A per-call receipt is authoritative where it exists: that is what makes a
65
+ * partially reverted non-atomic batch report honestly rather than tarring
66
+ * every call with the batch's worst outcome. A receipt whose own status is
67
+ * unreadable falls back to the batch verdict rather than being assumed good.
68
+ *
69
+ * Receipt statuses come in two spellings: raw RPC (`"0x0"`/`"0x1"`, or the
70
+ * numbers) and viem-formatted (`"reverted"`/`"success"`), because the wagmi
71
+ * path sees receipts after viem has normalised them.
72
+ *
73
+ * The codes are EIP-5792's: 200 confirmed, 400 failed BEFORE landing on
74
+ * chain, 500 reverted, 600 partially reverted. 400 is a rejection, not a
75
+ * revert - nothing was mined, so calling it reverted would misreport gas
76
+ * spent and on-chain activity that never happened.
77
+ *
78
+ * Returns undefined when the call cannot be decided, which happens on 600
79
+ * for a call the wallet gave no receipt for.
80
+ */
81
+ function batchCallOutcome(code, receipt) {
82
+ var receiptStatus = receipt === null || receipt === void 0 ? void 0 : receipt.status;
83
+ if (receiptStatus !== undefined) {
84
+ return receiptStatus === "0x0" ||
85
+ receiptStatus === 0 ||
86
+ receiptStatus === "reverted"
87
+ ? events_1.TransactionStatus.REVERTED
88
+ : events_1.TransactionStatus.CONFIRMED;
89
+ }
90
+ if (code >= 600)
91
+ return undefined;
92
+ if (code >= 500)
93
+ return events_1.TransactionStatus.REVERTED;
94
+ if (code >= 400)
95
+ return events_1.TransactionStatus.REJECTED;
96
+ return events_1.TransactionStatus.CONFIRMED;
97
+ }
98
+ /**
99
+ * The receipt that decides call `index`, honouring atomic execution.
100
+ *
101
+ * An atomic batch lands as ONE on-chain transaction, so the wallet returns a
102
+ * single receipt covering every call. Indexing receipts positionally there
103
+ * would hand the shared hash to call 0 and leave its siblings hashless and
104
+ * decided only by the batch verdict. Every call in an atomic batch shares
105
+ * the one receipt - same hash, same fate - which is also what makes
106
+ * `count(distinct transaction_hash)` count on-chain transactions correctly.
107
+ *
108
+ * The wallet's own `atomic` flag is authoritative in BOTH directions. An
109
+ * explicit `atomic: false` with a single receipt is a real shape - a
110
+ * non-atomic batch whose execution stopped after one call mined - and
111
+ * sharing that receipt would hand calls that never reached the chain a
112
+ * transaction hash they do not have. Only when the field is ABSENT (a
113
+ * wallet predating it, reached over raw EIP-1193; viem fills the field in,
114
+ * so the wagmi path never lands here) does the conservative inference
115
+ * apply: one receipt for several calls on a batch that is NOT partially
116
+ * reverted can only be atomic execution (600 explicitly means some calls
117
+ * reverted and others did not, which one shared transaction cannot do).
118
+ */
119
+ function batchReceiptForCall(res, index, callCount) {
120
+ var _a;
121
+ var receipts = Array.isArray(res === null || res === void 0 ? void 0 : res.receipts) ? res.receipts : [];
122
+ var code = (_a = readBatchStatusCode(res)) !== null && _a !== void 0 ? _a : 0;
123
+ var atomic = (res === null || res === void 0 ? void 0 : res.atomic) === true ||
124
+ ((res === null || res === void 0 ? void 0 : res.atomic) === undefined &&
125
+ receipts.length === 1 &&
126
+ callCount > 1 &&
127
+ code < 600);
128
+ return atomic ? receipts[0] : receipts[index];
129
+ }
130
+ //# sourceMappingURL=batch.js.map
@@ -41,6 +41,36 @@ export interface ProviderInfo {
41
41
  * ```
42
42
  */
43
43
  export declare function detectInjectedProviderInfo(provider: EIP1193Provider): ProviderInfo;
44
+ /**
45
+ * Was this error the USER declining, whatever transport delivered it?
46
+ *
47
+ * Three dialects say "the user said no":
48
+ * - EIP-1193: code 4001 (UserRejectedRequest).
49
+ * - WalletConnect sdkErrors: codes 5000-5005 (USER_REJECTED and its
50
+ * variants). A LIVE MetaMask Mobile session rejecting a transaction
51
+ * produced one of these and the SDK's 4001-only match reported nothing -
52
+ * every WalletConnect rejection was silently uncounted.
53
+ * - viem: a typed UserRejectedRequestError, sometimes without the numeric
54
+ * code surviving the wrapping.
55
+ *
56
+ * The real code often hides under `cause` (viem nests, WC wraps), so the
57
+ * chain is walked a few levels.
58
+ */
59
+ export declare function isUserRejectionError(error: unknown): boolean;
60
+ /**
61
+ * The wallet on the far side of a WalletConnect session.
62
+ *
63
+ * WalletConnect is a transport, not a wallet: the signing wallet (Ledger
64
+ * Live, MetaMask Mobile, Safe, ...) identifies itself in the session's peer
65
+ * metadata. Reporting only "WalletConnect" hides every wallet behind it -
66
+ * production showed Ledger at effectively zero while its sessions were being
67
+ * tracked under the transport's name. Reads synchronous state only; never
68
+ * issues an RPC.
69
+ */
70
+ export declare function readWalletConnectPeer(provider: EIP1193Provider): {
71
+ name: string;
72
+ url?: string;
73
+ } | undefined;
44
74
  /**
45
75
  * Validates that a provider implements the required EIP-1193 interface
46
76
  *
@@ -2,9 +2,22 @@
2
2
  /**
3
3
  * Provider detection utilities for identifying wallet providers
4
4
  */
5
+ var __assign = (this && this.__assign) || function () {
6
+ __assign = Object.assign || function(t) {
7
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
8
+ s = arguments[i];
9
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
10
+ t[p] = s[p];
11
+ }
12
+ return t;
13
+ };
14
+ return __assign.apply(this, arguments);
15
+ };
5
16
  Object.defineProperty(exports, "__esModule", { value: true });
6
17
  exports.DEFAULT_PROVIDER_ICON = void 0;
7
18
  exports.detectInjectedProviderInfo = detectInjectedProviderInfo;
19
+ exports.isUserRejectionError = isUserRejectionError;
20
+ exports.readWalletConnectPeer = readWalletConnectPeer;
8
21
  exports.isValidProvider = isValidProvider;
9
22
  /**
10
23
  * Default icon for providers without custom icons
@@ -81,6 +94,55 @@ function detectInjectedProviderInfo(provider) {
81
94
  icon: exports.DEFAULT_PROVIDER_ICON,
82
95
  };
83
96
  }
97
+ /**
98
+ * Was this error the USER declining, whatever transport delivered it?
99
+ *
100
+ * Three dialects say "the user said no":
101
+ * - EIP-1193: code 4001 (UserRejectedRequest).
102
+ * - WalletConnect sdkErrors: codes 5000-5005 (USER_REJECTED and its
103
+ * variants). A LIVE MetaMask Mobile session rejecting a transaction
104
+ * produced one of these and the SDK's 4001-only match reported nothing -
105
+ * every WalletConnect rejection was silently uncounted.
106
+ * - viem: a typed UserRejectedRequestError, sometimes without the numeric
107
+ * code surviving the wrapping.
108
+ *
109
+ * The real code often hides under `cause` (viem nests, WC wraps), so the
110
+ * chain is walked a few levels.
111
+ */
112
+ function isUserRejectionError(error) {
113
+ var cursor = error;
114
+ for (var depth = 0; cursor && depth < 5; depth++) {
115
+ var code = cursor.code;
116
+ if (code === 4001 ||
117
+ (typeof code === "number" && code >= 5000 && code <= 5005) ||
118
+ cursor.name === "UserRejectedRequestError") {
119
+ return true;
120
+ }
121
+ cursor = cursor.cause;
122
+ }
123
+ return false;
124
+ }
125
+ /**
126
+ * The wallet on the far side of a WalletConnect session.
127
+ *
128
+ * WalletConnect is a transport, not a wallet: the signing wallet (Ledger
129
+ * Live, MetaMask Mobile, Safe, ...) identifies itself in the session's peer
130
+ * metadata. Reporting only "WalletConnect" hides every wallet behind it -
131
+ * production showed Ledger at effectively zero while its sessions were being
132
+ * tracked under the transport's name. Reads synchronous state only; never
133
+ * issues an RPC.
134
+ */
135
+ function readWalletConnectPeer(provider) {
136
+ var _a;
137
+ var session = provider.session;
138
+ var metadata = (_a = session === null || session === void 0 ? void 0 : session.peer) === null || _a === void 0 ? void 0 : _a.metadata;
139
+ if (!metadata || typeof metadata.name !== "string" || metadata.name.length === 0) {
140
+ return undefined;
141
+ }
142
+ return __assign({ name: metadata.name }, (typeof metadata.url === "string" && metadata.url.length > 0
143
+ ? { url: metadata.url }
144
+ : {}));
145
+ }
84
146
  /**
85
147
  * Validates that a provider implements the required EIP-1193 interface
86
148
  *
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Provider-related exports
3
3
  */
4
- export { detectInjectedProviderInfo, isValidProvider, DEFAULT_PROVIDER_ICON, } from './detection';
4
+ export { detectInjectedProviderInfo, isValidProvider, readWalletConnectPeer, isUserRejectionError, DEFAULT_PROVIDER_ICON, } from './detection';
5
5
  export type { WalletProviderFlags, ProviderInfo, } from './detection';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -3,9 +3,11 @@
3
3
  * Provider-related exports
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DEFAULT_PROVIDER_ICON = exports.isValidProvider = exports.detectInjectedProviderInfo = void 0;
6
+ exports.DEFAULT_PROVIDER_ICON = exports.isUserRejectionError = exports.readWalletConnectPeer = exports.isValidProvider = exports.detectInjectedProviderInfo = void 0;
7
7
  var detection_1 = require("./detection");
8
8
  Object.defineProperty(exports, "detectInjectedProviderInfo", { enumerable: true, get: function () { return detection_1.detectInjectedProviderInfo; } });
9
9
  Object.defineProperty(exports, "isValidProvider", { enumerable: true, get: function () { return detection_1.isValidProvider; } });
10
+ Object.defineProperty(exports, "readWalletConnectPeer", { enumerable: true, get: function () { return detection_1.readWalletConnectPeer; } });
11
+ Object.defineProperty(exports, "isUserRejectionError", { enumerable: true, get: function () { return detection_1.isUserRejectionError; } });
10
12
  Object.defineProperty(exports, "DEFAULT_PROVIDER_ICON", { enumerable: true, get: function () { return detection_1.DEFAULT_PROVIDER_ICON; } });
11
13
  //# sourceMappingURL=index.js.map
@@ -19,6 +19,17 @@ export interface IFormoAnalytics {
19
19
  page(category?: string, name?: string, properties?: IFormoEventProperties, context?: IFormoEventContext, callback?: (...args: unknown[]) => void): Promise<void>;
20
20
  reset(): void;
21
21
  cleanup(): void;
22
+ /**
23
+ * Track a constructed (non-injected) EIP-1193 provider, such as a
24
+ * WalletConnect or Ledger provider the app built itself. Returns true when
25
+ * the provider is tracked, false when refused (wagmi mode, EVM disabled,
26
+ * or not a valid provider).
27
+ */
28
+ registerProvider(provider: EIP1193Provider, info?: {
29
+ name?: string;
30
+ rdns?: string;
31
+ icon?: `data:image/${string}`;
32
+ }): boolean;
22
33
  detect(params: {
23
34
  rdns: string;
24
35
  providerName: string;
@@ -171,6 +182,18 @@ export interface ReferralOptions {
171
182
  * Allows the SDK to hook into Wagmi v2 wallet events instead of wrapping EIP-1193 providers
172
183
  */
173
184
  export interface WagmiOptions {
185
+ /**
186
+ * OPT-IN: fall back to the EIP-1193 request wrapper for wallet calls the
187
+ * wagmi caches cannot see - imperative viem calls
188
+ * (walletClient.sendTransaction, .signMessage, .writeContract, raw
189
+ * request) that create no mutation. The active connector's provider gets
190
+ * the same wrapper the SDK's default mode uses. Off by default: wagmi
191
+ * mode's baseline contract is observing wagmi state and caches without
192
+ * touching the signing transport, and enabling this is an explicit,
193
+ * auditable decision. Hook-driven calls are never double-counted (a
194
+ * pending wagmi mutation stands the wrapper down).
195
+ */
196
+ eip1193Fallback?: boolean;
174
197
  /**
175
198
  * Wagmi config instance from createConfig()
176
199
  * The SDK will subscribe to this config's state changes to track wallet events
@@ -20,6 +20,22 @@ export type WrappedRequestFunction = (<T>(args: RequestArguments) => Promise<T |
20
20
  [WRAPPED_REQUEST_SYMBOL]?: boolean;
21
21
  };
22
22
  export declare const WRAPPED_REQUEST_REF_SYMBOL: unique symbol;
23
+ /**
24
+ * The SDK instance a provider's installed wrapper currently reports to.
25
+ *
26
+ * The wrapper survives an SDK rebuild (nothing restores `provider.request`),
27
+ * and its closure holds the instance that installed it - whose event queue
28
+ * is CLOSED after cleanup. Without this slot, a rebuilt instance saw
29
+ * "already wrapped", reported success, and every request-derived event
30
+ * silently died in the old instance's queue. The slot holds the LIST of
31
+ * instances that registered this provider, in registration order; the
32
+ * wrapper routes each call to the newest one still live. A list rather
33
+ * than a single ref for two reasons: with several live instances (multi
34
+ * write-key pages) a cleanup degrades to newest-live-wins instead of
35
+ * dead-instance-wins, and the list is attached at install time, so
36
+ * rebinding mutates it and works even on a provider frozen AFTER wrapping.
37
+ */
38
+ export declare const WRAPPED_REQUEST_OWNER_SYMBOL: unique symbol;
23
39
  export interface WrappedEIP1193Provider extends EIP1193Provider {
24
40
  [WRAPPED_REQUEST_REF_SYMBOL]?: WrappedRequestFunction;
25
41
  }
@@ -1,6 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WRAPPED_REQUEST_REF_SYMBOL = exports.WRAPPED_REQUEST_SYMBOL = void 0;
3
+ exports.WRAPPED_REQUEST_OWNER_SYMBOL = exports.WRAPPED_REQUEST_REF_SYMBOL = exports.WRAPPED_REQUEST_SYMBOL = void 0;
4
4
  exports.WRAPPED_REQUEST_SYMBOL = Symbol("formoWrappedRequest");
5
5
  exports.WRAPPED_REQUEST_REF_SYMBOL = Symbol("formoWrappedRequestRef");
6
+ /**
7
+ * The SDK instance a provider's installed wrapper currently reports to.
8
+ *
9
+ * The wrapper survives an SDK rebuild (nothing restores `provider.request`),
10
+ * and its closure holds the instance that installed it - whose event queue
11
+ * is CLOSED after cleanup. Without this slot, a rebuilt instance saw
12
+ * "already wrapped", reported success, and every request-derived event
13
+ * silently died in the old instance's queue. The slot holds the LIST of
14
+ * instances that registered this provider, in registration order; the
15
+ * wrapper routes each call to the newest one still live. A list rather
16
+ * than a single ref for two reasons: with several live instances (multi
17
+ * write-key pages) a cleanup degrades to newest-live-wins instead of
18
+ * dead-instance-wins, and the list is attached at install time, so
19
+ * rebinding mutates it and works even on a provider frozen AFTER wrapping.
20
+ */
21
+ exports.WRAPPED_REQUEST_OWNER_SYMBOL = Symbol("formoWrappedRequestOwner");
6
22
  //# sourceMappingURL=provider.js.map
@@ -1,2 +1,2 @@
1
- export declare const version = "1.36.0";
1
+ export declare const version = "1.38.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.36.0';
6
+ exports.version = '1.38.0';
7
7
  //# sourceMappingURL=version.js.map
@@ -96,6 +96,8 @@ export declare class WagmiEventHandler {
96
96
  * broadcast to match the receipt against.
97
97
  */
98
98
  private get pendingTransactions();
99
+ /** Broadcast batches awaiting `callsStatus`, shared like the map above. */
100
+ private get pendingBatches();
99
101
  constructor(formoAnalytics: FormoAnalytics, wagmiConfig: WagmiConfig, queryClient?: QueryClient);
100
102
  /**
101
103
  * Set up listeners for wallet connection, disconnection, and chain changes
@@ -202,6 +204,7 @@ export declare class WagmiEventHandler {
202
204
  * already recorded the new address synchronously by the time this runs. The
203
205
  * `lastAddress` check below is what makes the two paths mutually exclusive.
204
206
  */
207
+ private handleActiveAddressChangeEntryKick;
205
208
  private handleActiveAddressChange;
206
209
  /**
207
210
  * Record and emit a chain move for the wallet already being tracked.
@@ -228,6 +231,30 @@ export declare class WagmiEventHandler {
228
231
  * Handle query cache events (transaction confirmations)
229
232
  */
230
233
  private handleQueryEvent;
234
+ /**
235
+ * Settle a just-registered batch from a status query that already ran.
236
+ *
237
+ * Best-effort by design: the minimal QueryClient interface the SDK
238
+ * accepts is not guaranteed to expose cache lookup, and a missing
239
+ * `getAll` just means settlement waits for the next query event, which
240
+ * is where it normally comes from anyway.
241
+ */
242
+ private settleFromCachedCallsStatus;
243
+ /**
244
+ * Settle an EIP-5792 batch from a `callsStatus` query.
245
+ *
246
+ * Only batches whose broadcast this SDK observed are settled: the batch id
247
+ * must be in `pendingBatches`, for the same reason receipt queries are
248
+ * gated on an observed hash - queries are visible to any code sharing the
249
+ * QueryClient, and emitting for an id we never saw broadcast would let a
250
+ * forged query invent transactions.
251
+ *
252
+ * Outcome semantics are shared with the EIP-1193 path (`src/evm/batch.ts`):
253
+ * per-call receipts outrank the batch verdict, an atomic batch's single
254
+ * receipt reaches every call, and a 600 leaves receipt-less calls
255
+ * unsettled rather than guessed.
256
+ */
257
+ private handleCallsStatusQuery;
231
258
  /**
232
259
  * Handle waitForTransactionReceipt query completion
233
260
  * Emits CONFIRMED or REVERTED transaction status
@@ -240,11 +267,48 @@ export declare class WagmiEventHandler {
240
267
  /**
241
268
  * Handle signature mutations (signMessage, signTypedData)
242
269
  */
270
+ /**
271
+ * Is a PENDING wagmi mutation already covering this wallet request?
272
+ *
273
+ * The hybrid-capture dedup. TanStack dispatches `pending` BEFORE the
274
+ * mutationFn issues the wallet call (verified against query-core), so a
275
+ * hook-driven request always finds its mutation here and the request
276
+ * wrapper stands down; an imperative viem call never does, and the
277
+ * wrapper captures it. Matching is by mutation type, refined with cheap
278
+ * parameter checks where the shapes allow, and errs toward NOT skipping:
279
+ * a duplicate is visible and diagnosable, a silent loss is neither.
280
+ */
281
+ hasMatchingPendingMutation(method: string, params: unknown[]): boolean;
282
+ /**
283
+ * Wallet attribution for mutation- and query-derived events.
284
+ *
285
+ * Mid-session events (signatures, transactions) fire after the peer
286
+ * lookup has resolved, so a WalletConnect connector names its actual
287
+ * signer here - the first observable consumer of the peer cache.
288
+ */
289
+ private mutationAttribution;
243
290
  private handleSignatureMutation;
244
291
  /**
245
292
  * Handle transaction mutations (sendTransaction, writeContract)
246
293
  */
247
294
  private handleTransactionMutation;
295
+ /**
296
+ * One `transaction` event per call in an EIP-5792 batch, wagmi path.
297
+ *
298
+ * Mirrors `EvmRequestTracker.trackBatchedCalls` exactly: the CALL is the
299
+ * unit of attribution, so each call gets its own STARTED at pending and
300
+ * BROADCASTED (with `batch_id`) when the wallet returns an id. The batch's
301
+ * on-chain outcome arrives through the `callsStatus` query, handled in
302
+ * `handleCallsStatusQuery`.
303
+ *
304
+ * Rejection matches the 1193 path's rule: only a user rejection (4001
305
+ * anywhere in the error chain) marks the calls rejected - one dismissal
306
+ * dismisses the whole prompt, so every call in it is rejected, and
307
+ * reporting only the first would undercount. Any other error (a wallet
308
+ * without EIP-5792 support, a transport failure) emits nothing further:
309
+ * inventing a rejection the user never made would be worse.
310
+ */
311
+ private handleSendCallsMutation;
248
312
  /**
249
313
  * Get the current Wagmi state
250
314
  * Supports both getState() method and direct state property access
@@ -277,6 +341,29 @@ export declare class WagmiEventHandler {
277
341
  * Get the connector name from Wagmi state
278
342
  */
279
343
  private getConnectorName;
344
+ /**
345
+ * Start resolving the wallet behind a WalletConnect connection.
346
+ *
347
+ * Fire-and-forget on purpose: emission paths are synchronous by design
348
+ * and must never wait (see the connect marker comment). Called at the
349
+ * START of the status/address flows rather than only at read time - the
350
+ * lookup is one microtask for an initialised connector, and the emission
351
+ * sits behind several awaits, so kicking early usually means even the
352
+ * FIRST connect names the real wallet. When the race is lost the event
353
+ * honestly says "WalletConnect" and every later event names the peer.
354
+ */
355
+ /**
356
+ * Install the request wrapper on the active connector's provider.
357
+ *
358
+ * This is what lets wagmi mode capture IMPERATIVE viem calls
359
+ * (walletClient.sendTransaction / .signMessage / .writeContract / raw
360
+ * request), which create no mutation and were silently lost. Hook-driven
361
+ * calls stay owned by the mutation handlers via the pending-mutation
362
+ * dedup. Fire-and-forget per connection; a provider that cannot be
363
+ * produced simply keeps mutation-only capture.
364
+ */
365
+ private wrapActiveConnectorProvider;
366
+ private kickWalletConnectPeerLookup;
280
367
  /**
281
368
  * Clean up all subscriptions
282
369
  */