@formo/analytics 1.37.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.
- package/dist/cjs/src/FormoAnalytics.d.ts +64 -0
- package/dist/cjs/src/FormoAnalytics.js +155 -5
- package/dist/cjs/src/FormoAnalyticsProvider.js +1 -0
- package/dist/cjs/src/evm/EvmEventTracker.d.ts +38 -10
- package/dist/cjs/src/evm/EvmEventTracker.js +182 -0
- package/dist/cjs/src/evm/EvmProviderRegistry.js +26 -4
- package/dist/cjs/src/evm/EvmRequestTracker.d.ts +28 -10
- package/dist/cjs/src/evm/EvmRequestTracker.js +199 -55
- package/dist/cjs/src/provider/detection.d.ts +30 -0
- package/dist/cjs/src/provider/detection.js +62 -0
- package/dist/cjs/src/provider/index.d.ts +1 -1
- package/dist/cjs/src/provider/index.js +3 -1
- package/dist/cjs/src/types/base.d.ts +23 -0
- package/dist/cjs/src/types/provider.d.ts +16 -0
- package/dist/cjs/src/types/provider.js +17 -1
- package/dist/cjs/src/version.d.ts +1 -1
- package/dist/cjs/src/version.js +1 -1
- package/dist/cjs/src/wagmi/WagmiEventHandler.d.ts +44 -0
- package/dist/cjs/src/wagmi/WagmiEventHandler.js +306 -34
- package/dist/esm/src/FormoAnalytics.d.ts +64 -0
- package/dist/esm/src/FormoAnalytics.js +155 -5
- package/dist/esm/src/FormoAnalyticsProvider.js +1 -0
- package/dist/esm/src/evm/EvmEventTracker.d.ts +38 -10
- package/dist/esm/src/evm/EvmEventTracker.js +183 -1
- package/dist/esm/src/evm/EvmProviderRegistry.js +27 -5
- package/dist/esm/src/evm/EvmRequestTracker.d.ts +28 -10
- package/dist/esm/src/evm/EvmRequestTracker.js +198 -54
- package/dist/esm/src/provider/detection.d.ts +30 -0
- package/dist/esm/src/provider/detection.js +60 -0
- package/dist/esm/src/provider/index.d.ts +1 -1
- package/dist/esm/src/provider/index.js +1 -1
- package/dist/esm/src/types/base.d.ts +23 -0
- package/dist/esm/src/types/provider.d.ts +16 -0
- package/dist/esm/src/types/provider.js +16 -0
- package/dist/esm/src/version.d.ts +1 -1
- package/dist/esm/src/version.js +1 -1
- package/dist/esm/src/wagmi/WagmiEventHandler.d.ts +44 -0
- package/dist/esm/src/wagmi/WagmiEventHandler.js +306 -34
- package/dist/index.umd.min.js +1 -1
- package/package.json +2 -2
|
@@ -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.
|
|
1
|
+
export declare const version = "1.38.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/cjs/src/version.js
CHANGED
|
@@ -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.
|
|
6
|
+
exports.version = '1.38.0';
|
|
7
7
|
//# sourceMappingURL=version.js.map
|
|
@@ -204,6 +204,7 @@ export declare class WagmiEventHandler {
|
|
|
204
204
|
* already recorded the new address synchronously by the time this runs. The
|
|
205
205
|
* `lastAddress` check below is what makes the two paths mutually exclusive.
|
|
206
206
|
*/
|
|
207
|
+
private handleActiveAddressChangeEntryKick;
|
|
207
208
|
private handleActiveAddressChange;
|
|
208
209
|
/**
|
|
209
210
|
* Record and emit a chain move for the wallet already being tracked.
|
|
@@ -266,6 +267,26 @@ export declare class WagmiEventHandler {
|
|
|
266
267
|
/**
|
|
267
268
|
* Handle signature mutations (signMessage, signTypedData)
|
|
268
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;
|
|
269
290
|
private handleSignatureMutation;
|
|
270
291
|
/**
|
|
271
292
|
* Handle transaction mutations (sendTransaction, writeContract)
|
|
@@ -320,6 +341,29 @@ export declare class WagmiEventHandler {
|
|
|
320
341
|
* Get the connector name from Wagmi state
|
|
321
342
|
*/
|
|
322
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;
|
|
323
367
|
/**
|
|
324
368
|
* Clean up all subscriptions
|
|
325
369
|
*/
|
|
@@ -58,6 +58,7 @@ exports.WagmiEventHandler = exports.MARKER_GRACE_MS = void 0;
|
|
|
58
58
|
exports.__resetSeededWallet = __resetSeededWallet;
|
|
59
59
|
var events_1 = require("../types/events");
|
|
60
60
|
var logger_1 = require("../logger");
|
|
61
|
+
var provider_1 = require("../provider");
|
|
61
62
|
var batch_1 = require("../evm/batch");
|
|
62
63
|
var utils_1 = require("./utils");
|
|
63
64
|
/**
|
|
@@ -201,25 +202,48 @@ var ownerKey = function (writeKey, config) {
|
|
|
201
202
|
}
|
|
202
203
|
return "".concat(writeKey, ":").concat(id);
|
|
203
204
|
};
|
|
205
|
+
// User-rejection detection is shared with the EIP-1193 path (4001, the
|
|
206
|
+
// WalletConnect 5000-family, and viem's typed error): see
|
|
207
|
+
// provider/detection.ts for the dialects and why 4001 alone missed every
|
|
208
|
+
// WalletConnect rejection.
|
|
209
|
+
var isUserRejection = provider_1.isUserRejectionError;
|
|
204
210
|
/**
|
|
205
|
-
*
|
|
211
|
+
* Real wallet names behind WalletConnect connectors, resolved lazily.
|
|
206
212
|
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
213
|
+
* WalletConnect is a transport: the signing wallet (Ledger Live, MetaMask
|
|
214
|
+
* Mobile, Safe, ...) names itself in the session's peer metadata, reachable
|
|
215
|
+
* only through the connector's async `getProvider()`. Connect emission is
|
|
216
|
+
* deliberately synchronous (see the marker comments below), so the lookup
|
|
217
|
+
* can never be awaited in line - it is kicked fire-and-forget the first
|
|
218
|
+
* time a WalletConnect connector is seen, and every event after resolution
|
|
219
|
+
* carries the real wallet's name. The first connect may still say
|
|
220
|
+
* "WalletConnect"; that is the honest state at that instant.
|
|
221
|
+
*
|
|
222
|
+
* HONEST STATUS: with the new-connection invalidation below, no event the
|
|
223
|
+
* wagmi path emits TODAY observably carries the resolved name - connects
|
|
224
|
+
* fire before resolution and rebuilds suppress re-emission. The cache
|
|
225
|
+
* exists for the attribution work (wallet names on signature and
|
|
226
|
+
* transaction events), which fires mid-session, after resolution.
|
|
227
|
+
*
|
|
228
|
+
* Names are keyed by the CONNECTOR (stable across a page's sessions) so
|
|
229
|
+
* they actually serve reads; lookups are guarded per CONNECTION (wagmi
|
|
230
|
+
* replaces the connection object per session), so every new session
|
|
231
|
+
* re-resolves and OVERWRITES the name. A reconnect through the same
|
|
232
|
+
* connector to a different wallet can therefore mislabel at most the one
|
|
233
|
+
* event that fires between the new session's start and its resolution -
|
|
234
|
+
* one microtask for an initialised connector - and self-corrects. The
|
|
235
|
+
* alternative, keying names by connection, was tried and kept the name
|
|
236
|
+
* from ever surfacing: the only reader that fires per session runs before
|
|
237
|
+
* any lookup can resolve. WeakMaps, so nothing outlives its object.
|
|
212
238
|
*/
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
return false;
|
|
222
|
-
}
|
|
239
|
+
var walletConnectPeerNames = new WeakMap();
|
|
240
|
+
var walletConnectPeerLookups = new WeakSet();
|
|
241
|
+
/** The connection whose lookup may write the connector's name: always the
|
|
242
|
+
* newest kicked one, so a slow resolution from a PREVIOUS session cannot
|
|
243
|
+
* land after the current session's and overwrite it. */
|
|
244
|
+
var walletConnectPeerLatest = new WeakMap();
|
|
245
|
+
/** Connections whose provider already has the hybrid-capture wrapper. */
|
|
246
|
+
var wagmiWrappedConnections = new WeakSet();
|
|
223
247
|
/**
|
|
224
248
|
* Pending transactions, shared per destination rather than per handler.
|
|
225
249
|
*
|
|
@@ -615,6 +639,17 @@ var WagmiEventHandler = /** @class */ (function () {
|
|
|
615
639
|
*/
|
|
616
640
|
WagmiEventHandler.prototype.seedFromCurrentState = function () {
|
|
617
641
|
var _a, _b;
|
|
642
|
+
// Fire-and-forget here: the seed is synchronous by design, so its own
|
|
643
|
+
// connect may carry the generic name; the status flow awaits instead.
|
|
644
|
+
// A throwing store must not break construction.
|
|
645
|
+
try {
|
|
646
|
+
var snapshot = this.getState();
|
|
647
|
+
this.kickWalletConnectPeerLookup(snapshot);
|
|
648
|
+
this.wrapActiveConnectorProvider(snapshot);
|
|
649
|
+
}
|
|
650
|
+
catch (_c) {
|
|
651
|
+
/* the seed continues; names fall back to the connector's own */
|
|
652
|
+
}
|
|
618
653
|
try {
|
|
619
654
|
var state = this.getState();
|
|
620
655
|
if (state.status !== "connected") {
|
|
@@ -867,7 +902,7 @@ var WagmiEventHandler = /** @class */ (function () {
|
|
|
867
902
|
*/
|
|
868
903
|
WagmiEventHandler.prototype.handleStatusChange = function (status, prevStatus) {
|
|
869
904
|
return __awaiter(this, void 0, void 0, function () {
|
|
870
|
-
var state, address, chainId, disconnectedAddress, disconnectedChainId, walletKey, connection, connectorName, error_1, error_2;
|
|
905
|
+
var snapshot, state, address, chainId, disconnectedAddress, disconnectedChainId, walletKey, connection, connectorName, error_1, error_2;
|
|
871
906
|
var _a, _b, _c, _d;
|
|
872
907
|
return __generator(this, function (_e) {
|
|
873
908
|
switch (_e.label) {
|
|
@@ -888,6 +923,18 @@ var WagmiEventHandler = /** @class */ (function () {
|
|
|
888
923
|
return [2 /*return*/];
|
|
889
924
|
}
|
|
890
925
|
this.trackingState.isProcessing = true;
|
|
926
|
+
// Start resolving the wallet behind a WalletConnect session. NEVER
|
|
927
|
+
// awaited: every path from a store signal to its emission is
|
|
928
|
+
// synchronous by design, and an await here reorders transitions (it
|
|
929
|
+
// demonstrably drops connects under rapid connect/disconnect cycles).
|
|
930
|
+
try {
|
|
931
|
+
snapshot = this.getState();
|
|
932
|
+
this.kickWalletConnectPeerLookup(snapshot);
|
|
933
|
+
this.wrapActiveConnectorProvider(snapshot);
|
|
934
|
+
}
|
|
935
|
+
catch (_f) {
|
|
936
|
+
// A throwing store must not break the status flow.
|
|
937
|
+
}
|
|
891
938
|
// A status change outranks any connection transition still in flight. A
|
|
892
939
|
// full disconnect advances no ticket of its own, so without this an older
|
|
893
940
|
// fallback continuation could resume and announce a wallet wagmi no longer
|
|
@@ -1155,6 +1202,16 @@ var WagmiEventHandler = /** @class */ (function () {
|
|
|
1155
1202
|
* already recorded the new address synchronously by the time this runs. The
|
|
1156
1203
|
* `lastAddress` check below is what makes the two paths mutually exclusive.
|
|
1157
1204
|
*/
|
|
1205
|
+
WagmiEventHandler.prototype.handleActiveAddressChangeEntryKick = function () {
|
|
1206
|
+
// An account switch replaces the connection object; kick a lookup for
|
|
1207
|
+
// the new one so events that follow can name the wallet.
|
|
1208
|
+
try {
|
|
1209
|
+
this.kickWalletConnectPeerLookup(this.getState());
|
|
1210
|
+
}
|
|
1211
|
+
catch (_a) {
|
|
1212
|
+
/* a throwing store must not break the flow */
|
|
1213
|
+
}
|
|
1214
|
+
};
|
|
1158
1215
|
WagmiEventHandler.prototype.handleActiveAddressChange = function (address, prevAddress) {
|
|
1159
1216
|
return __awaiter(this, void 0, void 0, function () {
|
|
1160
1217
|
var state, trackedConnectionId, trackedConnectionGone, connectionChanged, liveChain, generation, chainId, stillConnected, goneChainId, error_3, liveNow, stillCurrent, walletKey, connection, alreadyAnnounced, connectorName, error_4;
|
|
@@ -1162,6 +1219,7 @@ var WagmiEventHandler = /** @class */ (function () {
|
|
|
1162
1219
|
return __generator(this, function (_g) {
|
|
1163
1220
|
switch (_g.label) {
|
|
1164
1221
|
case 0:
|
|
1222
|
+
this.handleActiveAddressChangeEntryKick();
|
|
1165
1223
|
state = this.getState();
|
|
1166
1224
|
if (state.status !== "connected")
|
|
1167
1225
|
return [2 /*return*/];
|
|
@@ -1632,11 +1690,9 @@ var WagmiEventHandler = /** @class */ (function () {
|
|
|
1632
1690
|
return;
|
|
1633
1691
|
_this.formo.transaction(__assign(__assign(__assign(__assign({ status: outcome, chainId: settledChainId_1 || 0, address: pending.address }, (call.data && { data: call.data })), (call.to && { to: call.to })), (call.value && { value: call.value })), ((receipt === null || receipt === void 0 ? void 0 : receipt.transactionHash)
|
|
1634
1692
|
? { transactionHash: receipt.transactionHash }
|
|
1635
|
-
: {})), {
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
batch_id: batchId,
|
|
1639
|
-
});
|
|
1693
|
+
: {})), __assign({ batch_size: pending.calls.length, batch_index: index, batch_id: batchId }, (pending.providerName
|
|
1694
|
+
? { providerName: pending.providerName }
|
|
1695
|
+
: {})));
|
|
1640
1696
|
});
|
|
1641
1697
|
// Settled; a later refetch of the same query must not re-emit.
|
|
1642
1698
|
this.pendingBatches.delete(batchId);
|
|
@@ -1719,9 +1775,9 @@ var WagmiEventHandler = /** @class */ (function () {
|
|
|
1719
1775
|
chainId: chainId,
|
|
1720
1776
|
blockNumber: (_b = receipt === null || receipt === void 0 ? void 0 : receipt.blockNumber) === null || _b === void 0 ? void 0 : _b.toString(),
|
|
1721
1777
|
});
|
|
1722
|
-
this.formo.transaction(__assign(__assign(__assign(__assign(__assign({ status: txStatus, chainId: chainId || 0, address: address, transactionHash: transactionHash }, ((pendingTx === null || pendingTx === void 0 ? void 0 : pendingTx.data) && { data: pendingTx.data })), ((pendingTx === null || pendingTx === void 0 ? void 0 : pendingTx.to) && { to: pendingTx.to })), ((pendingTx === null || pendingTx === void 0 ? void 0 : pendingTx.value) && { value: pendingTx.value })), ((pendingTx === null || pendingTx === void 0 ? void 0 : pendingTx.function_name) && { function_name: pendingTx.function_name })), ((pendingTx === null || pendingTx === void 0 ? void 0 : pendingTx.function_args) && { function_args: pendingTx.function_args })),
|
|
1723
|
-
|
|
1724
|
-
|
|
1778
|
+
this.formo.transaction(__assign(__assign(__assign(__assign(__assign({ status: txStatus, chainId: chainId || 0, address: address, transactionHash: transactionHash }, ((pendingTx === null || pendingTx === void 0 ? void 0 : pendingTx.data) && { data: pendingTx.data })), ((pendingTx === null || pendingTx === void 0 ? void 0 : pendingTx.to) && { to: pendingTx.to })), ((pendingTx === null || pendingTx === void 0 ? void 0 : pendingTx.value) && { value: pendingTx.value })), ((pendingTx === null || pendingTx === void 0 ? void 0 : pendingTx.function_name) && { function_name: pendingTx.function_name })), ((pendingTx === null || pendingTx === void 0 ? void 0 : pendingTx.function_args) && { function_args: pendingTx.function_args })), __assign(__assign({}, ((pendingTx === null || pendingTx === void 0 ? void 0 : pendingTx.providerName)
|
|
1779
|
+
? { providerName: pendingTx.providerName }
|
|
1780
|
+
: this.mutationAttribution())), pendingTx === null || pendingTx === void 0 ? void 0 : pendingTx.safeFunctionArgs));
|
|
1725
1781
|
// Clean up the pending transaction after confirmation
|
|
1726
1782
|
this.pendingTransactions.delete(normalizedHash);
|
|
1727
1783
|
}
|
|
@@ -1787,6 +1843,76 @@ var WagmiEventHandler = /** @class */ (function () {
|
|
|
1787
1843
|
/**
|
|
1788
1844
|
* Handle signature mutations (signMessage, signTypedData)
|
|
1789
1845
|
*/
|
|
1846
|
+
/**
|
|
1847
|
+
* Is a PENDING wagmi mutation already covering this wallet request?
|
|
1848
|
+
*
|
|
1849
|
+
* The hybrid-capture dedup. TanStack dispatches `pending` BEFORE the
|
|
1850
|
+
* mutationFn issues the wallet call (verified against query-core), so a
|
|
1851
|
+
* hook-driven request always finds its mutation here and the request
|
|
1852
|
+
* wrapper stands down; an imperative viem call never does, and the
|
|
1853
|
+
* wrapper captures it. Matching is by mutation type, refined with cheap
|
|
1854
|
+
* parameter checks where the shapes allow, and errs toward NOT skipping:
|
|
1855
|
+
* a duplicate is visible and diagnosable, a silent loss is neither.
|
|
1856
|
+
*/
|
|
1857
|
+
WagmiEventHandler.prototype.hasMatchingPendingMutation = function (method, params) {
|
|
1858
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1859
|
+
try {
|
|
1860
|
+
var cache = (_a = this.queryClient) === null || _a === void 0 ? void 0 : _a.getMutationCache();
|
|
1861
|
+
var mutations = (_b = cache === null || cache === void 0 ? void 0 : cache.getAll) === null || _b === void 0 ? void 0 : _b.call(cache);
|
|
1862
|
+
if (!Array.isArray(mutations))
|
|
1863
|
+
return false;
|
|
1864
|
+
var wanted = {
|
|
1865
|
+
personal_sign: ["signMessage"],
|
|
1866
|
+
eth_signTypedData_v4: ["signTypedData"],
|
|
1867
|
+
eth_sendTransaction: ["sendTransaction", "writeContract"],
|
|
1868
|
+
wallet_sendCalls: ["sendCalls"],
|
|
1869
|
+
};
|
|
1870
|
+
var types = wanted[method];
|
|
1871
|
+
if (!types)
|
|
1872
|
+
return false;
|
|
1873
|
+
for (var _i = 0, mutations_1 = mutations; _i < mutations_1.length; _i++) {
|
|
1874
|
+
var mutation = mutations_1[_i];
|
|
1875
|
+
if (((_c = mutation === null || mutation === void 0 ? void 0 : mutation.state) === null || _c === void 0 ? void 0 : _c.status) !== "pending")
|
|
1876
|
+
continue;
|
|
1877
|
+
var key = (_e = (_d = mutation === null || mutation === void 0 ? void 0 : mutation.options) === null || _d === void 0 ? void 0 : _d.mutationKey) === null || _e === void 0 ? void 0 : _e[0];
|
|
1878
|
+
if (typeof key !== "string" || !types.includes(key))
|
|
1879
|
+
continue;
|
|
1880
|
+
// Cheap refinements. On mismatch keep scanning; on no basis to
|
|
1881
|
+
// compare, treat the type-level match as decisive.
|
|
1882
|
+
var variables = (_f = mutation.state) === null || _f === void 0 ? void 0 : _f.variables;
|
|
1883
|
+
if (key === "sendTransaction" && variables) {
|
|
1884
|
+
var req = (Array.isArray(params) ? params[0] : undefined);
|
|
1885
|
+
var mutTo = variables.to;
|
|
1886
|
+
if (typeof (req === null || req === void 0 ? void 0 : req.to) === "string" &&
|
|
1887
|
+
typeof mutTo === "string" &&
|
|
1888
|
+
req.to.toLowerCase() !== mutTo.toLowerCase()) {
|
|
1889
|
+
continue;
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
return true;
|
|
1893
|
+
}
|
|
1894
|
+
return false;
|
|
1895
|
+
}
|
|
1896
|
+
catch (_g) {
|
|
1897
|
+
return false;
|
|
1898
|
+
}
|
|
1899
|
+
};
|
|
1900
|
+
/**
|
|
1901
|
+
* Wallet attribution for mutation- and query-derived events.
|
|
1902
|
+
*
|
|
1903
|
+
* Mid-session events (signatures, transactions) fire after the peer
|
|
1904
|
+
* lookup has resolved, so a WalletConnect connector names its actual
|
|
1905
|
+
* signer here - the first observable consumer of the peer cache.
|
|
1906
|
+
*/
|
|
1907
|
+
WagmiEventHandler.prototype.mutationAttribution = function () {
|
|
1908
|
+
try {
|
|
1909
|
+
var name_1 = this.getConnectorName(this.getState());
|
|
1910
|
+
return name_1 ? { providerName: name_1 } : undefined;
|
|
1911
|
+
}
|
|
1912
|
+
catch (_a) {
|
|
1913
|
+
return undefined;
|
|
1914
|
+
}
|
|
1915
|
+
};
|
|
1790
1916
|
WagmiEventHandler.prototype.handleSignatureMutation = function (mutationType, mutation) {
|
|
1791
1917
|
var _a, _b, _c, _d;
|
|
1792
1918
|
if (!this.formo.isAutocaptureEnabled("signature")) {
|
|
@@ -1847,7 +1973,7 @@ var WagmiEventHandler = /** @class */ (function () {
|
|
|
1847
1973
|
chainId: chainId,
|
|
1848
1974
|
address: address,
|
|
1849
1975
|
message: message,
|
|
1850
|
-
});
|
|
1976
|
+
}, this.mutationAttribution());
|
|
1851
1977
|
}
|
|
1852
1978
|
catch (error) {
|
|
1853
1979
|
logger_1.logger.error("WagmiEventHandler: Error handling signature mutation:", error);
|
|
@@ -1857,7 +1983,7 @@ var WagmiEventHandler = /** @class */ (function () {
|
|
|
1857
1983
|
* Handle transaction mutations (sendTransaction, writeContract)
|
|
1858
1984
|
*/
|
|
1859
1985
|
WagmiEventHandler.prototype.handleTransactionMutation = function (mutationType, mutation) {
|
|
1860
|
-
var _a;
|
|
1986
|
+
var _a, _b;
|
|
1861
1987
|
if (!this.formo.isAutocaptureEnabled("transaction")) {
|
|
1862
1988
|
return;
|
|
1863
1989
|
}
|
|
@@ -1948,7 +2074,7 @@ var WagmiEventHandler = /** @class */ (function () {
|
|
|
1948
2074
|
// Include the sender address to handle wallet switches between broadcast and confirmation
|
|
1949
2075
|
if (status_2 === events_1.TransactionStatus.BROADCASTED && transactionHash) {
|
|
1950
2076
|
var normalizedHash = transactionHash.toLowerCase();
|
|
1951
|
-
var txDetails = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({ address: userAddress }, (chainId !== undefined && { chainId: chainId })), { chainIdWasExplicit: explicitChainId !== undefined }), (data && { data: data })), (to && { to: to })), (value && { value: value })), (function_name && { function_name: function_name })), (function_args && { function_args: function_args })), (safeFunctionArgs && { safeFunctionArgs: safeFunctionArgs }));
|
|
2077
|
+
var txDetails = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({ address: userAddress }, ((_b = this.mutationAttribution()) !== null && _b !== void 0 ? _b : {})), (chainId !== undefined && { chainId: chainId })), { chainIdWasExplicit: explicitChainId !== undefined }), (data && { data: data })), (to && { to: to })), (value && { value: value })), (function_name && { function_name: function_name })), (function_args && { function_args: function_args })), (safeFunctionArgs && { safeFunctionArgs: safeFunctionArgs }));
|
|
1952
2078
|
this.pendingTransactions.set(normalizedHash, txDetails);
|
|
1953
2079
|
logger_1.logger.debug("WagmiEventHandler: Stored pending transaction for confirmation", {
|
|
1954
2080
|
transactionHash: normalizedHash,
|
|
@@ -1962,9 +2088,7 @@ var WagmiEventHandler = /** @class */ (function () {
|
|
|
1962
2088
|
}
|
|
1963
2089
|
}
|
|
1964
2090
|
}
|
|
1965
|
-
this.formo.transaction(__assign(__assign(__assign(__assign(__assign(__assign({ status: status_2, chainId: chainId || 0, address: userAddress }, (data && { data: data })), (to && { to: to })), (value && { value: value })), (transactionHash && { transactionHash: transactionHash })), (function_name && { function_name: function_name })), (function_args && { function_args: function_args })),
|
|
1966
|
-
// Spread function args as additional properties (only colliding keys are prefixed)
|
|
1967
|
-
safeFunctionArgs);
|
|
2091
|
+
this.formo.transaction(__assign(__assign(__assign(__assign(__assign(__assign({ status: status_2, chainId: chainId || 0, address: userAddress }, (data && { data: data })), (to && { to: to })), (value && { value: value })), (transactionHash && { transactionHash: transactionHash })), (function_name && { function_name: function_name })), (function_args && { function_args: function_args })), __assign(__assign({}, this.mutationAttribution()), safeFunctionArgs));
|
|
1968
2092
|
}
|
|
1969
2093
|
catch (error) {
|
|
1970
2094
|
logger_1.logger.error("WagmiEventHandler: Error handling transaction mutation:", error);
|
|
@@ -2013,9 +2137,10 @@ var WagmiEventHandler = /** @class */ (function () {
|
|
|
2013
2137
|
value: (call === null || call === void 0 ? void 0 : call.value) !== undefined ? String(call.value) : undefined,
|
|
2014
2138
|
data: call === null || call === void 0 ? void 0 : call.data,
|
|
2015
2139
|
}); });
|
|
2140
|
+
var attribution_1 = this.mutationAttribution();
|
|
2016
2141
|
var emitAll = function (status, extra) {
|
|
2017
2142
|
calls_1.forEach(function (call, index) {
|
|
2018
|
-
_this.formo.transaction(__assign(__assign(__assign({ status: status, chainId: chainId || 0, address: userAddress }, (call.data && { data: call.data })), (call.to && { to: call.to })), (call.value && { value: call.value })), __assign({ batch_size: calls_1.length, batch_index: index }, extra));
|
|
2143
|
+
_this.formo.transaction(__assign(__assign(__assign({ status: status, chainId: chainId || 0, address: userAddress }, (call.data && { data: call.data })), (call.to && { to: call.to })), (call.value && { value: call.value })), __assign(__assign({ batch_size: calls_1.length, batch_index: index }, attribution_1), extra));
|
|
2019
2144
|
});
|
|
2020
2145
|
};
|
|
2021
2146
|
if (state.status === "pending") {
|
|
@@ -2029,7 +2154,7 @@ var WagmiEventHandler = /** @class */ (function () {
|
|
|
2029
2154
|
logger_1.logger.debug("WagmiEventHandler: sendCalls broadcast", { batchId: batchId });
|
|
2030
2155
|
emitAll(events_1.TransactionStatus.BROADCASTED, batchId ? { batch_id: batchId } : undefined);
|
|
2031
2156
|
if (batchId) {
|
|
2032
|
-
this.pendingBatches.set(batchId, __assign(__assign({ address: userAddress }, (chainId !== undefined && { chainId: chainId })), { chainIdWasExplicit: explicitChainId !== undefined, calls: calls_1 }));
|
|
2157
|
+
this.pendingBatches.set(batchId, __assign(__assign(__assign({ address: userAddress }, (attribution_1 !== null && attribution_1 !== void 0 ? attribution_1 : {})), (chainId !== undefined && { chainId: chainId })), { chainIdWasExplicit: explicitChainId !== undefined, calls: calls_1 }));
|
|
2033
2158
|
// Same bound as pendingTransactions, same reason.
|
|
2034
2159
|
if (this.pendingBatches.size > 100) {
|
|
2035
2160
|
var keys = Array.from(this.pendingBatches.keys());
|
|
@@ -2133,7 +2258,154 @@ var WagmiEventHandler = /** @class */ (function () {
|
|
|
2133
2258
|
return undefined;
|
|
2134
2259
|
}
|
|
2135
2260
|
var connection = state.connections.get(state.current);
|
|
2136
|
-
|
|
2261
|
+
var connector = connection === null || connection === void 0 ? void 0 : connection.connector;
|
|
2262
|
+
if (!connection || !connector) {
|
|
2263
|
+
return undefined;
|
|
2264
|
+
}
|
|
2265
|
+
var cached = walletConnectPeerNames.get(connector);
|
|
2266
|
+
if (cached) {
|
|
2267
|
+
return cached;
|
|
2268
|
+
}
|
|
2269
|
+
// Backstop kick; the flow entry points kick earlier so the lookup has
|
|
2270
|
+
// usually resolved by the time an emission reads the name.
|
|
2271
|
+
this.kickWalletConnectPeerLookup(state);
|
|
2272
|
+
return connector.name;
|
|
2273
|
+
};
|
|
2274
|
+
/**
|
|
2275
|
+
* Start resolving the wallet behind a WalletConnect connection.
|
|
2276
|
+
*
|
|
2277
|
+
* Fire-and-forget on purpose: emission paths are synchronous by design
|
|
2278
|
+
* and must never wait (see the connect marker comment). Called at the
|
|
2279
|
+
* START of the status/address flows rather than only at read time - the
|
|
2280
|
+
* lookup is one microtask for an initialised connector, and the emission
|
|
2281
|
+
* sits behind several awaits, so kicking early usually means even the
|
|
2282
|
+
* FIRST connect names the real wallet. When the race is lost the event
|
|
2283
|
+
* honestly says "WalletConnect" and every later event names the peer.
|
|
2284
|
+
*/
|
|
2285
|
+
/**
|
|
2286
|
+
* Install the request wrapper on the active connector's provider.
|
|
2287
|
+
*
|
|
2288
|
+
* This is what lets wagmi mode capture IMPERATIVE viem calls
|
|
2289
|
+
* (walletClient.sendTransaction / .signMessage / .writeContract / raw
|
|
2290
|
+
* request), which create no mutation and were silently lost. Hook-driven
|
|
2291
|
+
* calls stay owned by the mutation handlers via the pending-mutation
|
|
2292
|
+
* dedup. Fire-and-forget per connection; a provider that cannot be
|
|
2293
|
+
* produced simply keeps mutation-only capture.
|
|
2294
|
+
*/
|
|
2295
|
+
WagmiEventHandler.prototype.wrapActiveConnectorProvider = function (state) {
|
|
2296
|
+
var _this = this;
|
|
2297
|
+
var _a, _b;
|
|
2298
|
+
// OPT-IN only. Wagmi mode's baseline never touches the signing
|
|
2299
|
+
// transport; instrumenting the provider is an explicit integrator
|
|
2300
|
+
// decision (options.wagmi.eip1193Fallback), made auditable in
|
|
2301
|
+
// configuration rather than implied by a version bump.
|
|
2302
|
+
var optedIn = ((_b = (_a = this.formo.options) === null || _a === void 0 ? void 0 : _a.wagmi) === null || _b === void 0 ? void 0 : _b.eip1193Fallback) === true;
|
|
2303
|
+
if (!optedIn) {
|
|
2304
|
+
return;
|
|
2305
|
+
}
|
|
2306
|
+
var connection = state.current
|
|
2307
|
+
? state.connections.get(state.current)
|
|
2308
|
+
: undefined;
|
|
2309
|
+
var connector = connection === null || connection === void 0 ? void 0 : connection.connector;
|
|
2310
|
+
if (!connection ||
|
|
2311
|
+
typeof (connector === null || connector === void 0 ? void 0 : connector.getProvider) !== "function" ||
|
|
2312
|
+
wagmiWrappedConnections.has(connection)) {
|
|
2313
|
+
return;
|
|
2314
|
+
}
|
|
2315
|
+
wagmiWrappedConnections.add(connection);
|
|
2316
|
+
connector
|
|
2317
|
+
.getProvider()
|
|
2318
|
+
.then(function (provider) {
|
|
2319
|
+
var _a, _b;
|
|
2320
|
+
(_b = (_a = _this.formo)._wrapWagmiProvider) === null || _b === void 0 ? void 0 : _b.call(_a, provider);
|
|
2321
|
+
})
|
|
2322
|
+
.catch(function () {
|
|
2323
|
+
// Mutation-only capture remains; retry on the next connection.
|
|
2324
|
+
wagmiWrappedConnections.delete(connection);
|
|
2325
|
+
});
|
|
2326
|
+
};
|
|
2327
|
+
WagmiEventHandler.prototype.kickWalletConnectPeerLookup = function (state) {
|
|
2328
|
+
var _a, _b;
|
|
2329
|
+
var connection = state.current
|
|
2330
|
+
? state.connections.get(state.current)
|
|
2331
|
+
: undefined;
|
|
2332
|
+
var connector = connection === null || connection === void 0 ? void 0 : connection.connector;
|
|
2333
|
+
if (!connection ||
|
|
2334
|
+
!connector ||
|
|
2335
|
+
typeof connector.name !== "string" ||
|
|
2336
|
+
!/walletconnect/i.test(connector.name) ||
|
|
2337
|
+
typeof connector.getProvider !== "function" ||
|
|
2338
|
+
walletConnectPeerLookups.has(connection)) {
|
|
2339
|
+
return;
|
|
2340
|
+
}
|
|
2341
|
+
walletConnectPeerLookups.add(connection);
|
|
2342
|
+
// A NEW connection invalidates the cached name SYNCHRONOUSLY. The
|
|
2343
|
+
// connect flow reads the cache in the same tick it kicks the lookup,
|
|
2344
|
+
// so retaining the previous session's name here deterministically
|
|
2345
|
+
// attributed a reconnect-to-a-different-wallet to the OLD wallet.
|
|
2346
|
+
// Wrong is worse than generic: the new session's connect now says
|
|
2347
|
+
// "WalletConnect" and the resolved peer serves the session's LATER
|
|
2348
|
+
// events (signatures, transactions - the attribution work) instead.
|
|
2349
|
+
// A rebuild over the SAME connection does not re-kick (guard above),
|
|
2350
|
+
// so it keeps its already-proven name.
|
|
2351
|
+
if (walletConnectPeerLatest.get(connector) !== connection) {
|
|
2352
|
+
walletConnectPeerNames.delete(connector);
|
|
2353
|
+
}
|
|
2354
|
+
walletConnectPeerLatest.set(connector, connection);
|
|
2355
|
+
var settled = false;
|
|
2356
|
+
// A cached name from a PREVIOUS session is unproven for this one. It
|
|
2357
|
+
// keeps serving only until this session's lookup settles or the grace
|
|
2358
|
+
// timer fires - whichever ends the uncertainty first - so a hung
|
|
2359
|
+
// lookup cannot leave the old wallet's name attached indefinitely.
|
|
2360
|
+
var staleTimer = setTimeout(function () {
|
|
2361
|
+
if (!settled &&
|
|
2362
|
+
walletConnectPeerLatest.get(connector) === connection) {
|
|
2363
|
+
walletConnectPeerNames.delete(connector);
|
|
2364
|
+
}
|
|
2365
|
+
}, 3000);
|
|
2366
|
+
(_b = (_a = staleTimer).unref) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
2367
|
+
connector
|
|
2368
|
+
.getProvider()
|
|
2369
|
+
.then(function (provider) {
|
|
2370
|
+
settled = true;
|
|
2371
|
+
clearTimeout(staleTimer);
|
|
2372
|
+
// Only the NEWEST session's lookup may write. A previous session's
|
|
2373
|
+
// slow resolution landing late would otherwise overwrite the
|
|
2374
|
+
// current wallet's name with the old one.
|
|
2375
|
+
if (walletConnectPeerLatest.get(connector) !== connection) {
|
|
2376
|
+
return;
|
|
2377
|
+
}
|
|
2378
|
+
var peer = (0, provider_1.readWalletConnectPeer)(provider);
|
|
2379
|
+
if (peer === null || peer === void 0 ? void 0 : peer.name) {
|
|
2380
|
+
walletConnectPeerNames.set(connector, peer.name);
|
|
2381
|
+
logger_1.logger.debug("WagmiEventHandler: WalletConnect peer resolved", {
|
|
2382
|
+
peer: peer.name,
|
|
2383
|
+
});
|
|
2384
|
+
}
|
|
2385
|
+
else {
|
|
2386
|
+
// Resolved WITHOUT peer metadata: the previous wallet's name is
|
|
2387
|
+
// disproven for this session, not merely unproven. Drop it, and
|
|
2388
|
+
// let a later event retry the lookup - the session may simply
|
|
2389
|
+
// not have populated its peer yet.
|
|
2390
|
+
walletConnectPeerNames.delete(connector);
|
|
2391
|
+
walletConnectPeerLookups.delete(connection);
|
|
2392
|
+
}
|
|
2393
|
+
})
|
|
2394
|
+
.catch(function () {
|
|
2395
|
+
settled = true;
|
|
2396
|
+
clearTimeout(staleTimer);
|
|
2397
|
+
// The new session could not be inspected, so the PREVIOUS wallet's
|
|
2398
|
+
// name must not keep serving: drop it and fall back to the
|
|
2399
|
+
// connector's own name until a later session resolves. Guarded so
|
|
2400
|
+
// an old session's late failure cannot clear a newer resolution.
|
|
2401
|
+
if (walletConnectPeerLatest.get(connector) === connection) {
|
|
2402
|
+
walletConnectPeerNames.delete(connector);
|
|
2403
|
+
}
|
|
2404
|
+
// A failed lookup must not permanently disqualify the connection:
|
|
2405
|
+
// the connector may just have been initialising. A later event
|
|
2406
|
+
// retries.
|
|
2407
|
+
walletConnectPeerLookups.delete(connection);
|
|
2408
|
+
});
|
|
2137
2409
|
};
|
|
2138
2410
|
/**
|
|
2139
2411
|
* Clean up all subscriptions
|