@formo/analytics 1.38.1 → 1.38.2
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 +10 -1
- package/dist/cjs/src/FormoAnalytics.js +11 -1
- package/dist/cjs/src/evm/EvmEventTracker.d.ts +100 -9
- package/dist/cjs/src/evm/EvmEventTracker.js +357 -19
- package/dist/cjs/src/evm/EvmProviderRegistry.d.ts +34 -2
- package/dist/cjs/src/evm/EvmProviderRegistry.js +61 -4
- package/dist/cjs/src/evm/EvmRequestTracker.d.ts +9 -4
- package/dist/cjs/src/evm/EvmRequestTracker.js +26 -16
- 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 +30 -1
- package/dist/cjs/src/wagmi/WagmiEventHandler.js +80 -1
- package/dist/cjs/src/wagmi/types.d.ts +6 -0
- package/dist/cjs/src/wagmi/utils.js +9 -1
- package/dist/esm/src/FormoAnalytics.d.ts +10 -1
- package/dist/esm/src/FormoAnalytics.js +11 -1
- package/dist/esm/src/evm/EvmEventTracker.d.ts +100 -9
- package/dist/esm/src/evm/EvmEventTracker.js +357 -19
- package/dist/esm/src/evm/EvmProviderRegistry.d.ts +34 -2
- package/dist/esm/src/evm/EvmProviderRegistry.js +61 -4
- package/dist/esm/src/evm/EvmRequestTracker.d.ts +9 -4
- package/dist/esm/src/evm/EvmRequestTracker.js +26 -16
- 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 +30 -1
- package/dist/esm/src/wagmi/WagmiEventHandler.js +80 -1
- package/dist/esm/src/wagmi/types.d.ts +6 -0
- package/dist/esm/src/wagmi/utils.js +9 -1
- package/dist/index.umd.min.js +1 -1
- package/package.json +2 -2
|
@@ -45,6 +45,24 @@ export declare class EvmProviderRegistry {
|
|
|
45
45
|
private listeners;
|
|
46
46
|
/** The window-injected provider, once detected, so it is not re-wrapped. */
|
|
47
47
|
private injectedDetail?;
|
|
48
|
+
/**
|
|
49
|
+
* Attribution supplied by the integration layer for a provider that was
|
|
50
|
+
* never announced: the wagmi fallback wrap names a connector's provider
|
|
51
|
+
* after the CONNECTOR, so request-derived events carry the same wallet
|
|
52
|
+
* name as the hook-driven events from the same connection. Without it
|
|
53
|
+
* the name came from flag sniffing, and a custom or embedded connector
|
|
54
|
+
* whose provider exposes no recognised flag split one wallet's activity
|
|
55
|
+
* between "Injected Provider" and the connector's name.
|
|
56
|
+
*
|
|
57
|
+
* A RESOLVER, read at each `infoFor`, not a value: the name is live for
|
|
58
|
+
* the connector the integration layer bound it to (a WalletConnect
|
|
59
|
+
* session that resolves or changes its peer renames without a re-wrap),
|
|
60
|
+
* and the integration layer names events on its hook path with the same
|
|
61
|
+
* function, so the two paths cannot disagree. Which connector a
|
|
62
|
+
* provider is bound to is the integration layer's decision; it is not
|
|
63
|
+
* necessarily the connector that is current when the request runs.
|
|
64
|
+
*/
|
|
65
|
+
private attributions;
|
|
48
66
|
constructor(deps: EvmProviderRegistryDeps);
|
|
49
67
|
get all(): readonly EIP6963ProviderDetail[];
|
|
50
68
|
isTracked(provider: EIP1193Provider): boolean;
|
|
@@ -62,11 +80,25 @@ export declare class EvmProviderRegistry {
|
|
|
62
80
|
};
|
|
63
81
|
/** Add a discovered provider once. Returns false if already present. */
|
|
64
82
|
add(detail: EIP6963ProviderDetail): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Record (or, with `undefined`, forget) the integration layer's own
|
|
85
|
+
* attribution resolver for a provider. See `attributions`.
|
|
86
|
+
*/
|
|
87
|
+
rememberAttribution(provider: EIP1193Provider | undefined, resolve: (() => {
|
|
88
|
+
name: string;
|
|
89
|
+
rdns?: string;
|
|
90
|
+
} | undefined) | undefined): void;
|
|
91
|
+
/** The supplied attribution for a provider, if any resolves right now. */
|
|
92
|
+
private suppliedAttributionFor;
|
|
65
93
|
/**
|
|
66
94
|
* A provider's display name and rdns.
|
|
67
95
|
*
|
|
68
|
-
* EIP-6963 metadata is authoritative when we have it
|
|
69
|
-
*
|
|
96
|
+
* EIP-6963 metadata is authoritative when we have it. A supplied
|
|
97
|
+
* attribution (the connector a wagmi app connected through) comes next:
|
|
98
|
+
* it describes the SESSION, which is what the hook-driven events report.
|
|
99
|
+
* Otherwise fall back to sniffing the injected provider, which is all a
|
|
100
|
+
* pre-6963 wallet offers; a supplied name without an rdns keeps the
|
|
101
|
+
* sniffed rdns.
|
|
70
102
|
*/
|
|
71
103
|
infoFor(provider: EIP1193Provider): {
|
|
72
104
|
name: string;
|
|
@@ -74,6 +74,24 @@ var EvmProviderRegistry = /** @class */ (function () {
|
|
|
74
74
|
this.chainGenerations = new WeakMap();
|
|
75
75
|
/** Listeners this SDK attached, so teardown can remove exactly those. */
|
|
76
76
|
this.listeners = new Map();
|
|
77
|
+
/**
|
|
78
|
+
* Attribution supplied by the integration layer for a provider that was
|
|
79
|
+
* never announced: the wagmi fallback wrap names a connector's provider
|
|
80
|
+
* after the CONNECTOR, so request-derived events carry the same wallet
|
|
81
|
+
* name as the hook-driven events from the same connection. Without it
|
|
82
|
+
* the name came from flag sniffing, and a custom or embedded connector
|
|
83
|
+
* whose provider exposes no recognised flag split one wallet's activity
|
|
84
|
+
* between "Injected Provider" and the connector's name.
|
|
85
|
+
*
|
|
86
|
+
* A RESOLVER, read at each `infoFor`, not a value: the name is live for
|
|
87
|
+
* the connector the integration layer bound it to (a WalletConnect
|
|
88
|
+
* session that resolves or changes its peer renames without a re-wrap),
|
|
89
|
+
* and the integration layer names events on its hook path with the same
|
|
90
|
+
* function, so the two paths cannot disagree. Which connector a
|
|
91
|
+
* provider is bound to is the integration layer's decision; it is not
|
|
92
|
+
* necessarily the connector that is current when the request runs.
|
|
93
|
+
*/
|
|
94
|
+
this.attributions = new WeakMap();
|
|
77
95
|
}
|
|
78
96
|
Object.defineProperty(EvmProviderRegistry.prototype, "all", {
|
|
79
97
|
// ── the provider set ─────────────────────────────────────────────────────
|
|
@@ -132,19 +150,55 @@ var EvmProviderRegistry = /** @class */ (function () {
|
|
|
132
150
|
this.seen.add(provider);
|
|
133
151
|
return true;
|
|
134
152
|
};
|
|
153
|
+
/**
|
|
154
|
+
* Record (or, with `undefined`, forget) the integration layer's own
|
|
155
|
+
* attribution resolver for a provider. See `attributions`.
|
|
156
|
+
*/
|
|
157
|
+
EvmProviderRegistry.prototype.rememberAttribution = function (provider, resolve) {
|
|
158
|
+
if (!provider)
|
|
159
|
+
return;
|
|
160
|
+
if (!resolve) {
|
|
161
|
+
this.attributions.delete(provider);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
this.attributions.set(provider, resolve);
|
|
165
|
+
};
|
|
166
|
+
/** The supplied attribution for a provider, if any resolves right now. */
|
|
167
|
+
EvmProviderRegistry.prototype.suppliedAttributionFor = function (provider) {
|
|
168
|
+
var resolve = this.attributions.get(provider);
|
|
169
|
+
if (!resolve)
|
|
170
|
+
return undefined;
|
|
171
|
+
try {
|
|
172
|
+
var info = resolve();
|
|
173
|
+
return (info === null || info === void 0 ? void 0 : info.name) ? info : undefined;
|
|
174
|
+
}
|
|
175
|
+
catch (_a) {
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
178
|
+
};
|
|
135
179
|
/**
|
|
136
180
|
* A provider's display name and rdns.
|
|
137
181
|
*
|
|
138
|
-
* EIP-6963 metadata is authoritative when we have it
|
|
139
|
-
*
|
|
182
|
+
* EIP-6963 metadata is authoritative when we have it. A supplied
|
|
183
|
+
* attribution (the connector a wagmi app connected through) comes next:
|
|
184
|
+
* it describes the SESSION, which is what the hook-driven events report.
|
|
185
|
+
* Otherwise fall back to sniffing the injected provider, which is all a
|
|
186
|
+
* pre-6963 wallet offers; a supplied name without an rdns keeps the
|
|
187
|
+
* sniffed rdns.
|
|
140
188
|
*/
|
|
141
189
|
EvmProviderRegistry.prototype.infoFor = function (provider) {
|
|
142
190
|
var announced = this.details.find(function (p) { return p.provider === provider; });
|
|
191
|
+
var supplied = announced
|
|
192
|
+
? undefined
|
|
193
|
+
: this.suppliedAttributionFor(provider);
|
|
143
194
|
var info = announced
|
|
144
195
|
? { name: announced.info.name, rdns: announced.info.rdns }
|
|
145
196
|
: (function () {
|
|
197
|
+
var _a;
|
|
146
198
|
var injected = detectInjectedProviderInfo(provider);
|
|
147
|
-
return
|
|
199
|
+
return supplied
|
|
200
|
+
? { name: supplied.name, rdns: (_a = supplied.rdns) !== null && _a !== void 0 ? _a : injected.rdns }
|
|
201
|
+
: { name: injected.name, rdns: injected.rdns };
|
|
148
202
|
})();
|
|
149
203
|
// WalletConnect names the TRANSPORT; the session's peer names the
|
|
150
204
|
// wallet. Resolved live, per read: a session established after the
|
|
@@ -154,7 +208,10 @@ var EvmProviderRegistry = /** @class */ (function () {
|
|
|
154
208
|
// is included because a flagless WalletConnect-compatible provider
|
|
155
209
|
// registered BEFORE its session exists detects as nothing at all;
|
|
156
210
|
// the peer appearing later is itself the proof of what it was, so
|
|
157
|
-
// the rdns upgrades with it.
|
|
211
|
+
// the rdns upgrades with it. A supplied name gets the same treatment
|
|
212
|
+
// and no more: the integration layer resolves its own peer names
|
|
213
|
+
// where it wants them, and a branded connector must keep its name on
|
|
214
|
+
// both paths.
|
|
158
215
|
if (info.name === "WalletConnect" || info.name === "Injected Provider") {
|
|
159
216
|
var peer = readWalletConnectPeer(provider);
|
|
160
217
|
if (peer === null || peer === void 0 ? void 0 : peer.name) {
|
|
@@ -83,10 +83,15 @@ export declare class EvmRequestTracker {
|
|
|
83
83
|
/**
|
|
84
84
|
* Wallet attribution for request-derived events.
|
|
85
85
|
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* made
|
|
86
|
+
* Resolved through the registry at the START of each request and held
|
|
87
|
+
* for that request's whole lifecycle, receipt included. Reading it per
|
|
88
|
+
* status let a connector switch (two connectors sharing one provider) or
|
|
89
|
+
* a session change made while a prompt was open split one operation
|
|
90
|
+
* between two wallet names. Still live across requests: a WalletConnect
|
|
91
|
+
* session names its actual signer ("MetaMask Wallet", "Ledger Live") -
|
|
92
|
+
* the live-test rows had provider_name EMPTY on every signature and
|
|
93
|
+
* transaction, which made per-wallet activity unanswerable in the
|
|
94
|
+
* warehouse.
|
|
90
95
|
*/
|
|
91
96
|
private attributionFor;
|
|
92
97
|
private buildSignatureEventPayload;
|
|
@@ -296,7 +296,7 @@ var EvmRequestTracker = /** @class */ (function () {
|
|
|
296
296
|
*/
|
|
297
297
|
EvmRequestTracker.prototype.dispatchWrappedRequest = function (_a, provider_1, request_1) {
|
|
298
298
|
return __awaiter(this, arguments, void 0, function (_b, provider, request) {
|
|
299
|
-
var generation_1, responsePromise, capturedChainId_1, response_1, error_1, rpcError, txPromise, txChainId_1, transactionHash_1, error_2, rpcError;
|
|
299
|
+
var generation_1, responsePromise, capturedChainId_1, attribution_1, response_1, error_1, rpcError, txPromise, txChainId_1, attribution_2, transactionHash_1, error_2, rpcError;
|
|
300
300
|
var _this = this;
|
|
301
301
|
var _c, _d, _e, _f;
|
|
302
302
|
var method = _b.method, params = _b.params;
|
|
@@ -339,6 +339,7 @@ var EvmRequestTracker = /** @class */ (function () {
|
|
|
339
339
|
// below is never reported as unhandled. The real handling is there.
|
|
340
340
|
responsePromise.catch(function () { return undefined; });
|
|
341
341
|
capturedChainId_1 = this.registry.resolveChainId(provider);
|
|
342
|
+
attribution_1 = this.attributionFor(provider);
|
|
342
343
|
// Fire-and-forget tracking
|
|
343
344
|
(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
344
345
|
var e_1;
|
|
@@ -346,7 +347,7 @@ var EvmRequestTracker = /** @class */ (function () {
|
|
|
346
347
|
switch (_a.label) {
|
|
347
348
|
case 0:
|
|
348
349
|
_a.trys.push([0, 2, , 3]);
|
|
349
|
-
return [4 /*yield*/, this.deps.signature(__assign({ status: SignatureStatus.REQUESTED }, this.buildSignatureEventPayload(method, params, undefined, capturedChainId_1, provider)),
|
|
350
|
+
return [4 /*yield*/, this.deps.signature(__assign({ status: SignatureStatus.REQUESTED }, this.buildSignatureEventPayload(method, params, undefined, capturedChainId_1, provider)), attribution_1)];
|
|
350
351
|
case 1:
|
|
351
352
|
_a.sent();
|
|
352
353
|
return [3 /*break*/, 3];
|
|
@@ -372,7 +373,7 @@ var EvmRequestTracker = /** @class */ (function () {
|
|
|
372
373
|
switch (_a.label) {
|
|
373
374
|
case 0:
|
|
374
375
|
_a.trys.push([0, 2, , 3]);
|
|
375
|
-
return [4 /*yield*/, this.deps.signature(__assign({ status: SignatureStatus.CONFIRMED }, this.buildSignatureEventPayload(method, params, response_1, capturedChainId_1, provider)),
|
|
376
|
+
return [4 /*yield*/, this.deps.signature(__assign({ status: SignatureStatus.CONFIRMED }, this.buildSignatureEventPayload(method, params, response_1, capturedChainId_1, provider)), attribution_1)];
|
|
376
377
|
case 1:
|
|
377
378
|
_a.sent();
|
|
378
379
|
return [3 /*break*/, 3];
|
|
@@ -397,7 +398,7 @@ var EvmRequestTracker = /** @class */ (function () {
|
|
|
397
398
|
switch (_a.label) {
|
|
398
399
|
case 0:
|
|
399
400
|
_a.trys.push([0, 2, , 3]);
|
|
400
|
-
return [4 /*yield*/, this.deps.signature(__assign({ status: SignatureStatus.REJECTED }, this.buildSignatureEventPayload(method, params, undefined, capturedChainId_1, provider)),
|
|
401
|
+
return [4 /*yield*/, this.deps.signature(__assign({ status: SignatureStatus.REJECTED }, this.buildSignatureEventPayload(method, params, undefined, capturedChainId_1, provider)), attribution_1)];
|
|
401
402
|
case 1:
|
|
402
403
|
_a.sent();
|
|
403
404
|
return [3 /*break*/, 3];
|
|
@@ -436,6 +437,7 @@ var EvmRequestTracker = /** @class */ (function () {
|
|
|
436
437
|
txPromise = request({ method: method, params: params });
|
|
437
438
|
txPromise.catch(function () { return undefined; });
|
|
438
439
|
txChainId_1 = this.registry.resolveChainId(provider);
|
|
440
|
+
attribution_2 = this.attributionFor(provider);
|
|
439
441
|
(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
440
442
|
var payload, e_4;
|
|
441
443
|
return __generator(this, function (_a) {
|
|
@@ -445,7 +447,7 @@ var EvmRequestTracker = /** @class */ (function () {
|
|
|
445
447
|
return [4 /*yield*/, this.buildTransactionEventPayload(params, provider, txChainId_1)];
|
|
446
448
|
case 1:
|
|
447
449
|
payload = _a.sent();
|
|
448
|
-
return [4 /*yield*/, this.deps.transaction(__assign({ status: TransactionStatus.STARTED }, payload),
|
|
450
|
+
return [4 /*yield*/, this.deps.transaction(__assign({ status: TransactionStatus.STARTED }, payload), attribution_2)];
|
|
449
451
|
case 2:
|
|
450
452
|
_a.sent();
|
|
451
453
|
return [3 /*break*/, 4];
|
|
@@ -472,11 +474,11 @@ var EvmRequestTracker = /** @class */ (function () {
|
|
|
472
474
|
return [4 /*yield*/, this.buildTransactionEventPayload(params, provider, txChainId_1)];
|
|
473
475
|
case 1:
|
|
474
476
|
payload = _a.sent();
|
|
475
|
-
return [4 /*yield*/, this.deps.transaction(__assign(__assign({ status: TransactionStatus.BROADCASTED }, payload), { transactionHash: transactionHash_1 }),
|
|
477
|
+
return [4 /*yield*/, this.deps.transaction(__assign(__assign({ status: TransactionStatus.BROADCASTED }, payload), { transactionHash: transactionHash_1 }), attribution_2)];
|
|
476
478
|
case 2:
|
|
477
479
|
_a.sent();
|
|
478
480
|
// Start async polling for transaction receipt
|
|
479
|
-
this.pollTransactionReceipt(provider, transactionHash_1, payload);
|
|
481
|
+
this.pollTransactionReceipt(provider, transactionHash_1, payload, attribution_2);
|
|
480
482
|
return [3 /*break*/, 4];
|
|
481
483
|
case 3:
|
|
482
484
|
e_5 = _a.sent();
|
|
@@ -501,7 +503,7 @@ var EvmRequestTracker = /** @class */ (function () {
|
|
|
501
503
|
return [4 /*yield*/, this.buildTransactionEventPayload(params, provider, txChainId_1)];
|
|
502
504
|
case 1:
|
|
503
505
|
payload = _a.sent();
|
|
504
|
-
return [4 /*yield*/, this.deps.transaction(__assign({ status: TransactionStatus.REJECTED }, payload),
|
|
506
|
+
return [4 /*yield*/, this.deps.transaction(__assign({ status: TransactionStatus.REJECTED }, payload), attribution_2)];
|
|
505
507
|
case 2:
|
|
506
508
|
_a.sent();
|
|
507
509
|
return [3 /*break*/, 4];
|
|
@@ -523,10 +525,15 @@ var EvmRequestTracker = /** @class */ (function () {
|
|
|
523
525
|
/**
|
|
524
526
|
* Wallet attribution for request-derived events.
|
|
525
527
|
*
|
|
526
|
-
*
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
* made
|
|
528
|
+
* Resolved through the registry at the START of each request and held
|
|
529
|
+
* for that request's whole lifecycle, receipt included. Reading it per
|
|
530
|
+
* status let a connector switch (two connectors sharing one provider) or
|
|
531
|
+
* a session change made while a prompt was open split one operation
|
|
532
|
+
* between two wallet names. Still live across requests: a WalletConnect
|
|
533
|
+
* session names its actual signer ("MetaMask Wallet", "Ledger Live") -
|
|
534
|
+
* the live-test rows had provider_name EMPTY on every signature and
|
|
535
|
+
* transaction, which made per-wallet activity unanswerable in the
|
|
536
|
+
* warehouse.
|
|
530
537
|
*/
|
|
531
538
|
EvmRequestTracker.prototype.attributionFor = function (provider) {
|
|
532
539
|
var info = this.registry.infoFor(provider);
|
|
@@ -596,8 +603,11 @@ var EvmRequestTracker = /** @class */ (function () {
|
|
|
596
603
|
/**
|
|
597
604
|
* Polls for transaction receipt and emits tx.status = CONFIRMED or REVERTED.
|
|
598
605
|
*/
|
|
599
|
-
EvmRequestTracker.prototype.pollTransactionReceipt = function (provider_1, transactionHash_2, payload_1) {
|
|
600
|
-
return __awaiter(this, arguments, void 0, function (provider, transactionHash, payload,
|
|
606
|
+
EvmRequestTracker.prototype.pollTransactionReceipt = function (provider_1, transactionHash_2, payload_1, attribution_3) {
|
|
607
|
+
return __awaiter(this, arguments, void 0, function (provider, transactionHash, payload,
|
|
608
|
+
// Snapshot from the broadcast: a connector or session change during
|
|
609
|
+
// the poll window must not relabel the receipt.
|
|
610
|
+
attribution, maxAttempts, intervalMs) {
|
|
601
611
|
var attempts, poll;
|
|
602
612
|
var _this = this;
|
|
603
613
|
if (maxAttempts === void 0) { maxAttempts = 10; }
|
|
@@ -626,7 +636,7 @@ var EvmRequestTracker = /** @class */ (function () {
|
|
|
626
636
|
// status: 1 = success, 0 = reverted
|
|
627
637
|
if (receipt.status === "0x1" || receipt.status === 1) {
|
|
628
638
|
this.deps
|
|
629
|
-
.transaction(__assign(__assign({ status: TransactionStatus.CONFIRMED }, payload), { transactionHash: transactionHash }),
|
|
639
|
+
.transaction(__assign(__assign({ status: TransactionStatus.CONFIRMED }, payload), { transactionHash: transactionHash }), attribution)
|
|
630
640
|
.catch(function (e) {
|
|
631
641
|
return logger.error("Formo: Failed to track transaction confirmation", e);
|
|
632
642
|
});
|
|
@@ -634,7 +644,7 @@ var EvmRequestTracker = /** @class */ (function () {
|
|
|
634
644
|
}
|
|
635
645
|
else if (receipt.status === "0x0" || receipt.status === 0) {
|
|
636
646
|
this.deps
|
|
637
|
-
.transaction(__assign(__assign({ status: TransactionStatus.REVERTED }, payload), { transactionHash: transactionHash }),
|
|
647
|
+
.transaction(__assign(__assign({ status: TransactionStatus.REVERTED }, payload), { transactionHash: transactionHash }), attribution)
|
|
638
648
|
.catch(function (e) {
|
|
639
649
|
return logger.error("Formo: Failed to track transaction revert", e);
|
|
640
650
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "1.38.
|
|
1
|
+
export declare const version = "1.38.2";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/esm/src/version.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* wrapping approach when Wagmi mode is enabled.
|
|
7
7
|
*/
|
|
8
8
|
import { FormoAnalytics } from "../FormoAnalytics";
|
|
9
|
-
import {
|
|
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
|
*/
|
|
@@ -71,6 +71,16 @@ var RESERVED_FIELDS = new Set([
|
|
|
71
71
|
"transactionHash",
|
|
72
72
|
"function_name",
|
|
73
73
|
"function_args",
|
|
74
|
+
// Wallet attribution. Function args are spread AFTER the attribution
|
|
75
|
+
// properties, so an ABI input named `providerName` would silently
|
|
76
|
+
// relabel the wallet on every broadcast and receipt event. `rdns` is
|
|
77
|
+
// reserved with it even though THIS path (wagmi mutation attribution)
|
|
78
|
+
// emits only the name: elsewhere in the SDK - the EIP-1193 request path
|
|
79
|
+
// and connect events - `rdns` is the wallet-identity key, so an ABI
|
|
80
|
+
// input by that name would land in the same warehouse column as real
|
|
81
|
+
// wallet identities.
|
|
82
|
+
"providerName",
|
|
83
|
+
"rdns",
|
|
74
84
|
]);
|
|
75
85
|
/**
|
|
76
86
|
* Connections already announced to a destination during this page load.
|
|
@@ -2333,6 +2343,75 @@ var WagmiEventHandler = /** @class */ (function () {
|
|
|
2333
2343
|
});
|
|
2334
2344
|
return found;
|
|
2335
2345
|
};
|
|
2346
|
+
/**
|
|
2347
|
+
* A specific connector's name and rdns, for the fallback-wrapped
|
|
2348
|
+
* provider's request-derived events.
|
|
2349
|
+
*
|
|
2350
|
+
* The NAME is exactly what the hook path emits for that connector
|
|
2351
|
+
* (`getConnectorName`: the live WalletConnect peer for a WalletConnect
|
|
2352
|
+
* connector, the connector's own name otherwise), so a branded connector
|
|
2353
|
+
* keeps its name on both paths and a session that changes wallets
|
|
2354
|
+
* renames on both. The rdns is the connector's when wagmi knows it as
|
|
2355
|
+
* ONE value (EIP-6963 discovered connectors carry theirs, some as a
|
|
2356
|
+
* one-element list); a connector that matches several rdns values does
|
|
2357
|
+
* not say which one this provider is, so nothing is passed and the
|
|
2358
|
+
* registry keeps the sniffed one.
|
|
2359
|
+
*/
|
|
2360
|
+
WagmiEventHandler.prototype.attributionForConnector = function (connector, state) {
|
|
2361
|
+
var name = this.nameForConnector(connector, state);
|
|
2362
|
+
if (!name) {
|
|
2363
|
+
return undefined;
|
|
2364
|
+
}
|
|
2365
|
+
var raw = connector.rdns;
|
|
2366
|
+
var rdns = typeof raw === "string" && raw.length > 0
|
|
2367
|
+
? raw
|
|
2368
|
+
: Array.isArray(raw) && raw.length === 1 && typeof raw[0] === "string" && raw[0].length > 0
|
|
2369
|
+
? raw[0]
|
|
2370
|
+
: undefined;
|
|
2371
|
+
return __assign({ name: name }, (rdns && { rdns: rdns }));
|
|
2372
|
+
};
|
|
2373
|
+
/**
|
|
2374
|
+
* Resolver handed to the registry at wrap time, read at each request
|
|
2375
|
+
* start. BOUND to the connector whose `getProvider` resolved to the
|
|
2376
|
+
* wrapped provider, not to whichever connector is current: an app can
|
|
2377
|
+
* keep a wallet client over a previous connector's provider and issue a
|
|
2378
|
+
* request through it after switching, and that request belongs to the
|
|
2379
|
+
* wallet that handles it. The peer name is still read live. A provider
|
|
2380
|
+
* SHARED by two connectors is re-bound when the new connector's
|
|
2381
|
+
* resolution lands (one microtask for an injected connector); a request
|
|
2382
|
+
* issued inside that gap keeps the previous label.
|
|
2383
|
+
*/
|
|
2384
|
+
WagmiEventHandler.prototype.boundConnectorAttribution = function (connector) {
|
|
2385
|
+
var _this = this;
|
|
2386
|
+
return function () {
|
|
2387
|
+
if (_this.disposed)
|
|
2388
|
+
return undefined;
|
|
2389
|
+
try {
|
|
2390
|
+
return _this.attributionForConnector(connector, _this.getState());
|
|
2391
|
+
}
|
|
2392
|
+
catch (_a) {
|
|
2393
|
+
return undefined;
|
|
2394
|
+
}
|
|
2395
|
+
};
|
|
2396
|
+
};
|
|
2397
|
+
/** `getConnectorName` for a SPECIFIC connector, current or not. */
|
|
2398
|
+
WagmiEventHandler.prototype.nameForConnector = function (connector, state) {
|
|
2399
|
+
var _a;
|
|
2400
|
+
var cached = walletConnectPeerNames.get(connector);
|
|
2401
|
+
if (cached) {
|
|
2402
|
+
return cached;
|
|
2403
|
+
}
|
|
2404
|
+
var current = state.current
|
|
2405
|
+
? (_a = state.connections.get(state.current)) === null || _a === void 0 ? void 0 : _a.connector
|
|
2406
|
+
: undefined;
|
|
2407
|
+
if (current === connector) {
|
|
2408
|
+
// Backstop kick, as in getConnectorName; only the current connection
|
|
2409
|
+
// has a session to look up.
|
|
2410
|
+
this.kickWalletConnectPeerLookup(state);
|
|
2411
|
+
}
|
|
2412
|
+
var name = connector.name;
|
|
2413
|
+
return typeof name === "string" && name.length > 0 ? name : undefined;
|
|
2414
|
+
};
|
|
2336
2415
|
/**
|
|
2337
2416
|
* Get the connector name from Wagmi state
|
|
2338
2417
|
*/
|
|
@@ -2470,7 +2549,7 @@ var WagmiEventHandler = /** @class */ (function () {
|
|
|
2470
2549
|
return;
|
|
2471
2550
|
}
|
|
2472
2551
|
var chainId = (_b = _this.getActiveConnectionChainId(live)) !== null && _b !== void 0 ? _b : live.chainId;
|
|
2473
|
-
var wrapped = (_d = (_c = _this.formo)._wrapWagmiProvider) === null || _d === void 0 ? void 0 : _d.call(_c, provider, typeof chainId === "number" ? chainId : undefined);
|
|
2552
|
+
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));
|
|
2474
2553
|
if (wrapped !== true) {
|
|
2475
2554
|
// The provider was refused (invalid shape, frozen provider,
|
|
2476
2555
|
// 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
|
|
@@ -185,7 +185,15 @@ export function buildSafeFunctionArgs(functionArgs, reservedFields) {
|
|
|
185
185
|
var result = {};
|
|
186
186
|
for (var _i = 0, _a = Object.entries(functionArgs); _i < _a.length; _i++) {
|
|
187
187
|
var _b = _a[_i], key = _b[0], val = _b[1];
|
|
188
|
-
|
|
188
|
+
// A prefixed key must not land on another argument's own name: an ABI
|
|
189
|
+
// with both `to` and `arg_to` would otherwise keep only one of them,
|
|
190
|
+
// whichever came later. Keep prefixing until the name is free.
|
|
191
|
+
var safeKey = key;
|
|
192
|
+
if (reservedFields.has(key)) {
|
|
193
|
+
do {
|
|
194
|
+
safeKey = "arg_".concat(safeKey);
|
|
195
|
+
} while (safeKey in functionArgs);
|
|
196
|
+
}
|
|
189
197
|
result[safeKey] = val;
|
|
190
198
|
// If the value is a nested object (struct), flatten it
|
|
191
199
|
// Skip flattened keys that would overwrite existing top-level args
|