@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.
- 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 +36 -40
- package/dist/cjs/src/evm/EvmRequestTracker.js +216 -115
- package/dist/cjs/src/evm/batch.d.ts +94 -0
- package/dist/cjs/src/evm/batch.js +130 -0
- 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 +87 -0
- package/dist/cjs/src/wagmi/WagmiEventHandler.js +536 -13
- 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 +36 -40
- package/dist/esm/src/evm/EvmRequestTracker.js +215 -114
- package/dist/esm/src/evm/batch.d.ts +94 -0
- package/dist/esm/src/evm/batch.js +123 -0
- 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 +87 -0
- package/dist/esm/src/wagmi/WagmiEventHandler.js +536 -13
- package/dist/index.umd.min.js +1 -1
- 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,123 @@
|
|
|
1
|
+
import { TransactionStatus } from "../types/events";
|
|
2
|
+
/**
|
|
3
|
+
* The batch identifier from a `wallet_sendCalls` result.
|
|
4
|
+
*
|
|
5
|
+
* EIP-5792 settled on `{ id }`, but wallets shipped against the earlier
|
|
6
|
+
* draft return a bare string. Both are accepted so a wallet on either
|
|
7
|
+
* version is still grouped.
|
|
8
|
+
*/
|
|
9
|
+
export function readBatchId(result) {
|
|
10
|
+
if (typeof result === "string" && result.length > 0)
|
|
11
|
+
return result;
|
|
12
|
+
if (result && typeof result === "object") {
|
|
13
|
+
var id = result.id;
|
|
14
|
+
if (typeof id === "string" && id.length > 0)
|
|
15
|
+
return id;
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The numeric EIP-5792 status code from a settlement result.
|
|
21
|
+
*
|
|
22
|
+
* A wallet answers `wallet_getCallsStatus` with a numeric `status`; viem's
|
|
23
|
+
* `getCallsStatus` renames that to `statusCode` and puts a summary string in
|
|
24
|
+
* `status` instead. Both shapes arrive here depending on the capture path,
|
|
25
|
+
* so read the number wherever it is and never trust the string.
|
|
26
|
+
*/
|
|
27
|
+
export function readBatchStatusCode(res) {
|
|
28
|
+
if (typeof (res === null || res === void 0 ? void 0 : res.statusCode) === "number")
|
|
29
|
+
return res.statusCode;
|
|
30
|
+
if (typeof (res === null || res === void 0 ? void 0 : res.status) === "number")
|
|
31
|
+
return res.status;
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The chain a settled batch reports itself on.
|
|
36
|
+
*
|
|
37
|
+
* EIP-5792 v2 puts `chainId` in the `wallet_getCallsStatus` response as hex;
|
|
38
|
+
* viem returns it as a number. Either way it names the chain the batch
|
|
39
|
+
* actually settled on, which outranks a chain merely inferred from the
|
|
40
|
+
* connection at broadcast time - the wallet can move chains while the
|
|
41
|
+
* prompt is up.
|
|
42
|
+
*/
|
|
43
|
+
export function readBatchChainId(res) {
|
|
44
|
+
var raw = res === null || res === void 0 ? void 0 : res.chainId;
|
|
45
|
+
if (typeof raw === "number" && Number.isFinite(raw) && raw > 0)
|
|
46
|
+
return raw;
|
|
47
|
+
if (typeof raw === "string") {
|
|
48
|
+
var parsed = parseInt(raw, 16);
|
|
49
|
+
if (Number.isFinite(parsed) && parsed > 0)
|
|
50
|
+
return parsed;
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* How one call in a settled batch ended.
|
|
56
|
+
*
|
|
57
|
+
* A per-call receipt is authoritative where it exists: that is what makes a
|
|
58
|
+
* partially reverted non-atomic batch report honestly rather than tarring
|
|
59
|
+
* every call with the batch's worst outcome. A receipt whose own status is
|
|
60
|
+
* unreadable falls back to the batch verdict rather than being assumed good.
|
|
61
|
+
*
|
|
62
|
+
* Receipt statuses come in two spellings: raw RPC (`"0x0"`/`"0x1"`, or the
|
|
63
|
+
* numbers) and viem-formatted (`"reverted"`/`"success"`), because the wagmi
|
|
64
|
+
* path sees receipts after viem has normalised them.
|
|
65
|
+
*
|
|
66
|
+
* The codes are EIP-5792's: 200 confirmed, 400 failed BEFORE landing on
|
|
67
|
+
* chain, 500 reverted, 600 partially reverted. 400 is a rejection, not a
|
|
68
|
+
* revert - nothing was mined, so calling it reverted would misreport gas
|
|
69
|
+
* spent and on-chain activity that never happened.
|
|
70
|
+
*
|
|
71
|
+
* Returns undefined when the call cannot be decided, which happens on 600
|
|
72
|
+
* for a call the wallet gave no receipt for.
|
|
73
|
+
*/
|
|
74
|
+
export function batchCallOutcome(code, receipt) {
|
|
75
|
+
var receiptStatus = receipt === null || receipt === void 0 ? void 0 : receipt.status;
|
|
76
|
+
if (receiptStatus !== undefined) {
|
|
77
|
+
return receiptStatus === "0x0" ||
|
|
78
|
+
receiptStatus === 0 ||
|
|
79
|
+
receiptStatus === "reverted"
|
|
80
|
+
? TransactionStatus.REVERTED
|
|
81
|
+
: TransactionStatus.CONFIRMED;
|
|
82
|
+
}
|
|
83
|
+
if (code >= 600)
|
|
84
|
+
return undefined;
|
|
85
|
+
if (code >= 500)
|
|
86
|
+
return TransactionStatus.REVERTED;
|
|
87
|
+
if (code >= 400)
|
|
88
|
+
return TransactionStatus.REJECTED;
|
|
89
|
+
return TransactionStatus.CONFIRMED;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The receipt that decides call `index`, honouring atomic execution.
|
|
93
|
+
*
|
|
94
|
+
* An atomic batch lands as ONE on-chain transaction, so the wallet returns a
|
|
95
|
+
* single receipt covering every call. Indexing receipts positionally there
|
|
96
|
+
* would hand the shared hash to call 0 and leave its siblings hashless and
|
|
97
|
+
* decided only by the batch verdict. Every call in an atomic batch shares
|
|
98
|
+
* the one receipt - same hash, same fate - which is also what makes
|
|
99
|
+
* `count(distinct transaction_hash)` count on-chain transactions correctly.
|
|
100
|
+
*
|
|
101
|
+
* The wallet's own `atomic` flag is authoritative in BOTH directions. An
|
|
102
|
+
* explicit `atomic: false` with a single receipt is a real shape - a
|
|
103
|
+
* non-atomic batch whose execution stopped after one call mined - and
|
|
104
|
+
* sharing that receipt would hand calls that never reached the chain a
|
|
105
|
+
* transaction hash they do not have. Only when the field is ABSENT (a
|
|
106
|
+
* wallet predating it, reached over raw EIP-1193; viem fills the field in,
|
|
107
|
+
* so the wagmi path never lands here) does the conservative inference
|
|
108
|
+
* apply: one receipt for several calls on a batch that is NOT partially
|
|
109
|
+
* reverted can only be atomic execution (600 explicitly means some calls
|
|
110
|
+
* reverted and others did not, which one shared transaction cannot do).
|
|
111
|
+
*/
|
|
112
|
+
export function batchReceiptForCall(res, index, callCount) {
|
|
113
|
+
var _a;
|
|
114
|
+
var receipts = Array.isArray(res === null || res === void 0 ? void 0 : res.receipts) ? res.receipts : [];
|
|
115
|
+
var code = (_a = readBatchStatusCode(res)) !== null && _a !== void 0 ? _a : 0;
|
|
116
|
+
var atomic = (res === null || res === void 0 ? void 0 : res.atomic) === true ||
|
|
117
|
+
((res === null || res === void 0 ? void 0 : res.atomic) === undefined &&
|
|
118
|
+
receipts.length === 1 &&
|
|
119
|
+
callCount > 1 &&
|
|
120
|
+
code < 600);
|
|
121
|
+
return atomic ? receipts[0] : receipts[index];
|
|
122
|
+
}
|
|
123
|
+
//# 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
|
*
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Provider detection utilities for identifying wallet providers
|
|
3
3
|
*/
|
|
4
|
+
var __assign = (this && this.__assign) || function () {
|
|
5
|
+
__assign = Object.assign || function(t) {
|
|
6
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
7
|
+
s = arguments[i];
|
|
8
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
9
|
+
t[p] = s[p];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
return __assign.apply(this, arguments);
|
|
14
|
+
};
|
|
4
15
|
/**
|
|
5
16
|
* Default icon for providers without custom icons
|
|
6
17
|
*/
|
|
@@ -76,6 +87,55 @@ export function detectInjectedProviderInfo(provider) {
|
|
|
76
87
|
icon: DEFAULT_PROVIDER_ICON,
|
|
77
88
|
};
|
|
78
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Was this error the USER declining, whatever transport delivered it?
|
|
92
|
+
*
|
|
93
|
+
* Three dialects say "the user said no":
|
|
94
|
+
* - EIP-1193: code 4001 (UserRejectedRequest).
|
|
95
|
+
* - WalletConnect sdkErrors: codes 5000-5005 (USER_REJECTED and its
|
|
96
|
+
* variants). A LIVE MetaMask Mobile session rejecting a transaction
|
|
97
|
+
* produced one of these and the SDK's 4001-only match reported nothing -
|
|
98
|
+
* every WalletConnect rejection was silently uncounted.
|
|
99
|
+
* - viem: a typed UserRejectedRequestError, sometimes without the numeric
|
|
100
|
+
* code surviving the wrapping.
|
|
101
|
+
*
|
|
102
|
+
* The real code often hides under `cause` (viem nests, WC wraps), so the
|
|
103
|
+
* chain is walked a few levels.
|
|
104
|
+
*/
|
|
105
|
+
export function isUserRejectionError(error) {
|
|
106
|
+
var cursor = error;
|
|
107
|
+
for (var depth = 0; cursor && depth < 5; depth++) {
|
|
108
|
+
var code = cursor.code;
|
|
109
|
+
if (code === 4001 ||
|
|
110
|
+
(typeof code === "number" && code >= 5000 && code <= 5005) ||
|
|
111
|
+
cursor.name === "UserRejectedRequestError") {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
cursor = cursor.cause;
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The wallet on the far side of a WalletConnect session.
|
|
120
|
+
*
|
|
121
|
+
* WalletConnect is a transport, not a wallet: the signing wallet (Ledger
|
|
122
|
+
* Live, MetaMask Mobile, Safe, ...) identifies itself in the session's peer
|
|
123
|
+
* metadata. Reporting only "WalletConnect" hides every wallet behind it -
|
|
124
|
+
* production showed Ledger at effectively zero while its sessions were being
|
|
125
|
+
* tracked under the transport's name. Reads synchronous state only; never
|
|
126
|
+
* issues an RPC.
|
|
127
|
+
*/
|
|
128
|
+
export function readWalletConnectPeer(provider) {
|
|
129
|
+
var _a;
|
|
130
|
+
var session = provider.session;
|
|
131
|
+
var metadata = (_a = session === null || session === void 0 ? void 0 : session.peer) === null || _a === void 0 ? void 0 : _a.metadata;
|
|
132
|
+
if (!metadata || typeof metadata.name !== "string" || metadata.name.length === 0) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
return __assign({ name: metadata.name }, (typeof metadata.url === "string" && metadata.url.length > 0
|
|
136
|
+
? { url: metadata.url }
|
|
137
|
+
: {}));
|
|
138
|
+
}
|
|
79
139
|
/**
|
|
80
140
|
* Validates that a provider implements the required EIP-1193 interface
|
|
81
141
|
*
|
|
@@ -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
|
|
@@ -1,5 +1,5 @@
|
|
|
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
|
//# 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,3 +1,19 @@
|
|
|
1
1
|
export var WRAPPED_REQUEST_SYMBOL = Symbol("formoWrappedRequest");
|
|
2
2
|
export var WRAPPED_REQUEST_REF_SYMBOL = Symbol("formoWrappedRequestRef");
|
|
3
|
+
/**
|
|
4
|
+
* The SDK instance a provider's installed wrapper currently reports to.
|
|
5
|
+
*
|
|
6
|
+
* The wrapper survives an SDK rebuild (nothing restores `provider.request`),
|
|
7
|
+
* and its closure holds the instance that installed it - whose event queue
|
|
8
|
+
* is CLOSED after cleanup. Without this slot, a rebuilt instance saw
|
|
9
|
+
* "already wrapped", reported success, and every request-derived event
|
|
10
|
+
* silently died in the old instance's queue. The slot holds the LIST of
|
|
11
|
+
* instances that registered this provider, in registration order; the
|
|
12
|
+
* wrapper routes each call to the newest one still live. A list rather
|
|
13
|
+
* than a single ref for two reasons: with several live instances (multi
|
|
14
|
+
* write-key pages) a cleanup degrades to newest-live-wins instead of
|
|
15
|
+
* dead-instance-wins, and the list is attached at install time, so
|
|
16
|
+
* rebinding mutates it and works even on a provider frozen AFTER wrapping.
|
|
17
|
+
*/
|
|
18
|
+
export var WRAPPED_REQUEST_OWNER_SYMBOL = Symbol("formoWrappedRequestOwner");
|
|
3
19
|
//# 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/esm/src/version.js
CHANGED
|
@@ -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
|
*/
|