@formo/analytics 1.28.0 → 1.28.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formo/analytics",
3
- "version": "1.28.0",
3
+ "version": "1.28.2",
4
4
  "packageManager": "pnpm@9.0.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,30 +0,0 @@
1
- /**
2
- * ERC-8021 Builder Code Extraction
3
- *
4
- * Extracts builder codes from transaction calldata by parsing the ERC-8021
5
- * data suffix. The suffix is appended to the end of calldata and parsed
6
- * backwards:
7
- *
8
- * [original calldata] [schemaData] [schemaId (1 byte)] [ercMarker (16 bytes)]
9
- *
10
- * Schema 0 (canonical registry):
11
- * [codes (variable ASCII)] [codesLength (1 byte)] [schemaId 0x00] [ercMarker]
12
- *
13
- * Schema 1 (custom registry):
14
- * [registryAddress (20 bytes)] [chainId (variable)] [chainIdLength (1 byte)]
15
- * [codes (variable ASCII)] [codesLength (1 byte)] [schemaId 0x01] [ercMarker]
16
- *
17
- * - ercMarker: 0x80218021802180218021802180218021 (16 bytes)
18
- * - codes: ASCII-encoded entity codes delimited by 0x2C (comma)
19
- *
20
- * @see https://docs.base.org/base-chain/builder-codes/builder-codes
21
- * @see https://www.erc8021.com/
22
- */
23
- /**
24
- * Extract builder codes from transaction calldata by parsing the ERC-8021 suffix.
25
- *
26
- * @param data - The transaction calldata hex string (with or without 0x prefix)
27
- * @returns A comma-separated string of builder codes (e.g. "uniswap,base"), or undefined if no valid ERC-8021 suffix is found
28
- */
29
- export declare function extractBuilderCodes(data: string | undefined | null): string | undefined;
30
- //# sourceMappingURL=builderCode.d.ts.map
@@ -1,143 +0,0 @@
1
- "use strict";
2
- /**
3
- * ERC-8021 Builder Code Extraction
4
- *
5
- * Extracts builder codes from transaction calldata by parsing the ERC-8021
6
- * data suffix. The suffix is appended to the end of calldata and parsed
7
- * backwards:
8
- *
9
- * [original calldata] [schemaData] [schemaId (1 byte)] [ercMarker (16 bytes)]
10
- *
11
- * Schema 0 (canonical registry):
12
- * [codes (variable ASCII)] [codesLength (1 byte)] [schemaId 0x00] [ercMarker]
13
- *
14
- * Schema 1 (custom registry):
15
- * [registryAddress (20 bytes)] [chainId (variable)] [chainIdLength (1 byte)]
16
- * [codes (variable ASCII)] [codesLength (1 byte)] [schemaId 0x01] [ercMarker]
17
- *
18
- * - ercMarker: 0x80218021802180218021802180218021 (16 bytes)
19
- * - codes: ASCII-encoded entity codes delimited by 0x2C (comma)
20
- *
21
- * @see https://docs.base.org/base-chain/builder-codes/builder-codes
22
- * @see https://www.erc8021.com/
23
- */
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.extractBuilderCodes = extractBuilderCodes;
26
- /** The 16-byte ERC-8021 marker appended at the very end of calldata */
27
- var ERC_MARKER = "80218021802180218021802180218021";
28
- /** Length of the ERC marker in hex characters (16 bytes = 32 hex chars) */
29
- var ERC_MARKER_HEX_LENGTH = 32;
30
- /** Supported schema IDs */
31
- var SCHEMA_ID_CANONICAL = "00";
32
- var SCHEMA_ID_CUSTOM_REGISTRY = "01";
33
- /** Comma delimiter (0x2C) used to separate multiple codes */
34
- var COMMA_BYTE = 0x2c;
35
- /**
36
- * Decode the codes field from a hex string into a comma-separated string.
37
- * Validates that all bytes are printable ASCII (0x20–0x7E).
38
- *
39
- * @param codesHex - Hex string of the codes field
40
- * @returns Comma-separated builder codes string, or undefined if invalid
41
- */
42
- function decodeCodes(codesHex) {
43
- var bytes = [];
44
- for (var i = 0; i < codesHex.length; i += 2) {
45
- var byte = parseInt(codesHex.slice(i, i + 2), 16);
46
- // Reject NaN (invalid hex), non-printable or non-ASCII bytes
47
- if (isNaN(byte) || byte < 0x20 || byte > 0x7e) {
48
- return undefined;
49
- }
50
- bytes.push(byte);
51
- }
52
- // Split on comma delimiter and decode each code as ASCII
53
- var codes = [];
54
- var current = [];
55
- for (var _i = 0, bytes_1 = bytes; _i < bytes_1.length; _i++) {
56
- var byte = bytes_1[_i];
57
- if (byte === COMMA_BYTE) {
58
- if (current.length > 0) {
59
- codes.push(String.fromCharCode.apply(String, current));
60
- current = [];
61
- }
62
- }
63
- else {
64
- current.push(byte);
65
- }
66
- }
67
- // Push the last code segment
68
- if (current.length > 0) {
69
- codes.push(String.fromCharCode.apply(String, current));
70
- }
71
- return codes.length > 0 ? codes.join(",") : undefined;
72
- }
73
- /**
74
- * Read codesLength and codes from the hex string ending at the given position.
75
- *
76
- * @param hex - Full hex string (lowercase, no 0x prefix)
77
- * @param endPos - Hex char position where codesLength byte ends (i.e. start of schemaId)
78
- * @returns Object with decoded codes string and the hex char position where codes start, or undefined
79
- */
80
- function readCodes(hex, endPos) {
81
- // Read codesLength (1 byte before endPos)
82
- var codesLengthStart = endPos - 2;
83
- if (codesLengthStart < 0) {
84
- return undefined;
85
- }
86
- var codesLength = parseInt(hex.slice(codesLengthStart, endPos), 16);
87
- if (codesLength === 0 || isNaN(codesLength)) {
88
- return undefined;
89
- }
90
- // Read the codes field
91
- var codesHexLength = codesLength * 2;
92
- var codesStart = codesLengthStart - codesHexLength;
93
- if (codesStart < 0) {
94
- return undefined;
95
- }
96
- var codesHex = hex.slice(codesStart, codesLengthStart);
97
- var codes = decodeCodes(codesHex);
98
- if (!codes) {
99
- return undefined;
100
- }
101
- return { codes: codes, codesStart: codesStart };
102
- }
103
- /**
104
- * Extract builder codes from transaction calldata by parsing the ERC-8021 suffix.
105
- *
106
- * @param data - The transaction calldata hex string (with or without 0x prefix)
107
- * @returns A comma-separated string of builder codes (e.g. "uniswap,base"), or undefined if no valid ERC-8021 suffix is found
108
- */
109
- function extractBuilderCodes(data) {
110
- if (!data || typeof data !== "string") {
111
- return undefined;
112
- }
113
- // Normalize: remove 0x prefix and work with lowercase hex
114
- var hex = data.startsWith("0x") || data.startsWith("0X")
115
- ? data.slice(2).toLowerCase()
116
- : data.toLowerCase();
117
- // Minimum suffix: 1+ byte codes + 1 byte codesLength + 1 byte schemaId + 16 bytes marker = 19 bytes = 38 hex chars
118
- if (hex.length < 38) {
119
- return undefined;
120
- }
121
- // Step 1: Check last 16 bytes for ERC marker
122
- var markerStart = hex.length - ERC_MARKER_HEX_LENGTH;
123
- var marker = hex.slice(markerStart);
124
- if (marker !== ERC_MARKER) {
125
- return undefined;
126
- }
127
- // Step 2: Read schemaId (1 byte before the marker)
128
- var schemaIdStart = markerStart - 2;
129
- if (schemaIdStart < 0) {
130
- return undefined;
131
- }
132
- var schemaId = hex.slice(schemaIdStart, markerStart);
133
- // Step 3: Parse based on schemaId
134
- if (schemaId === SCHEMA_ID_CANONICAL || schemaId === SCHEMA_ID_CUSTOM_REGISTRY) {
135
- // Both Schema 0 and Schema 1 have codes in the same position
136
- // (immediately before schemaId when parsing backwards)
137
- var result = readCodes(hex, schemaIdStart);
138
- return result === null || result === void 0 ? void 0 : result.codes;
139
- }
140
- // Unknown schema - cannot parse
141
- return undefined;
142
- }
143
- //# sourceMappingURL=builderCode.js.map
@@ -1,30 +0,0 @@
1
- /**
2
- * ERC-8021 Builder Code Extraction
3
- *
4
- * Extracts builder codes from transaction calldata by parsing the ERC-8021
5
- * data suffix. The suffix is appended to the end of calldata and parsed
6
- * backwards:
7
- *
8
- * [original calldata] [schemaData] [schemaId (1 byte)] [ercMarker (16 bytes)]
9
- *
10
- * Schema 0 (canonical registry):
11
- * [codes (variable ASCII)] [codesLength (1 byte)] [schemaId 0x00] [ercMarker]
12
- *
13
- * Schema 1 (custom registry):
14
- * [registryAddress (20 bytes)] [chainId (variable)] [chainIdLength (1 byte)]
15
- * [codes (variable ASCII)] [codesLength (1 byte)] [schemaId 0x01] [ercMarker]
16
- *
17
- * - ercMarker: 0x80218021802180218021802180218021 (16 bytes)
18
- * - codes: ASCII-encoded entity codes delimited by 0x2C (comma)
19
- *
20
- * @see https://docs.base.org/base-chain/builder-codes/builder-codes
21
- * @see https://www.erc8021.com/
22
- */
23
- /**
24
- * Extract builder codes from transaction calldata by parsing the ERC-8021 suffix.
25
- *
26
- * @param data - The transaction calldata hex string (with or without 0x prefix)
27
- * @returns A comma-separated string of builder codes (e.g. "uniswap,base"), or undefined if no valid ERC-8021 suffix is found
28
- */
29
- export declare function extractBuilderCodes(data: string | undefined | null): string | undefined;
30
- //# sourceMappingURL=builderCode.d.ts.map
@@ -1,140 +0,0 @@
1
- /**
2
- * ERC-8021 Builder Code Extraction
3
- *
4
- * Extracts builder codes from transaction calldata by parsing the ERC-8021
5
- * data suffix. The suffix is appended to the end of calldata and parsed
6
- * backwards:
7
- *
8
- * [original calldata] [schemaData] [schemaId (1 byte)] [ercMarker (16 bytes)]
9
- *
10
- * Schema 0 (canonical registry):
11
- * [codes (variable ASCII)] [codesLength (1 byte)] [schemaId 0x00] [ercMarker]
12
- *
13
- * Schema 1 (custom registry):
14
- * [registryAddress (20 bytes)] [chainId (variable)] [chainIdLength (1 byte)]
15
- * [codes (variable ASCII)] [codesLength (1 byte)] [schemaId 0x01] [ercMarker]
16
- *
17
- * - ercMarker: 0x80218021802180218021802180218021 (16 bytes)
18
- * - codes: ASCII-encoded entity codes delimited by 0x2C (comma)
19
- *
20
- * @see https://docs.base.org/base-chain/builder-codes/builder-codes
21
- * @see https://www.erc8021.com/
22
- */
23
- /** The 16-byte ERC-8021 marker appended at the very end of calldata */
24
- var ERC_MARKER = "80218021802180218021802180218021";
25
- /** Length of the ERC marker in hex characters (16 bytes = 32 hex chars) */
26
- var ERC_MARKER_HEX_LENGTH = 32;
27
- /** Supported schema IDs */
28
- var SCHEMA_ID_CANONICAL = "00";
29
- var SCHEMA_ID_CUSTOM_REGISTRY = "01";
30
- /** Comma delimiter (0x2C) used to separate multiple codes */
31
- var COMMA_BYTE = 0x2c;
32
- /**
33
- * Decode the codes field from a hex string into a comma-separated string.
34
- * Validates that all bytes are printable ASCII (0x20–0x7E).
35
- *
36
- * @param codesHex - Hex string of the codes field
37
- * @returns Comma-separated builder codes string, or undefined if invalid
38
- */
39
- function decodeCodes(codesHex) {
40
- var bytes = [];
41
- for (var i = 0; i < codesHex.length; i += 2) {
42
- var byte = parseInt(codesHex.slice(i, i + 2), 16);
43
- // Reject NaN (invalid hex), non-printable or non-ASCII bytes
44
- if (isNaN(byte) || byte < 0x20 || byte > 0x7e) {
45
- return undefined;
46
- }
47
- bytes.push(byte);
48
- }
49
- // Split on comma delimiter and decode each code as ASCII
50
- var codes = [];
51
- var current = [];
52
- for (var _i = 0, bytes_1 = bytes; _i < bytes_1.length; _i++) {
53
- var byte = bytes_1[_i];
54
- if (byte === COMMA_BYTE) {
55
- if (current.length > 0) {
56
- codes.push(String.fromCharCode.apply(String, current));
57
- current = [];
58
- }
59
- }
60
- else {
61
- current.push(byte);
62
- }
63
- }
64
- // Push the last code segment
65
- if (current.length > 0) {
66
- codes.push(String.fromCharCode.apply(String, current));
67
- }
68
- return codes.length > 0 ? codes.join(",") : undefined;
69
- }
70
- /**
71
- * Read codesLength and codes from the hex string ending at the given position.
72
- *
73
- * @param hex - Full hex string (lowercase, no 0x prefix)
74
- * @param endPos - Hex char position where codesLength byte ends (i.e. start of schemaId)
75
- * @returns Object with decoded codes string and the hex char position where codes start, or undefined
76
- */
77
- function readCodes(hex, endPos) {
78
- // Read codesLength (1 byte before endPos)
79
- var codesLengthStart = endPos - 2;
80
- if (codesLengthStart < 0) {
81
- return undefined;
82
- }
83
- var codesLength = parseInt(hex.slice(codesLengthStart, endPos), 16);
84
- if (codesLength === 0 || isNaN(codesLength)) {
85
- return undefined;
86
- }
87
- // Read the codes field
88
- var codesHexLength = codesLength * 2;
89
- var codesStart = codesLengthStart - codesHexLength;
90
- if (codesStart < 0) {
91
- return undefined;
92
- }
93
- var codesHex = hex.slice(codesStart, codesLengthStart);
94
- var codes = decodeCodes(codesHex);
95
- if (!codes) {
96
- return undefined;
97
- }
98
- return { codes: codes, codesStart: codesStart };
99
- }
100
- /**
101
- * Extract builder codes from transaction calldata by parsing the ERC-8021 suffix.
102
- *
103
- * @param data - The transaction calldata hex string (with or without 0x prefix)
104
- * @returns A comma-separated string of builder codes (e.g. "uniswap,base"), or undefined if no valid ERC-8021 suffix is found
105
- */
106
- export function extractBuilderCodes(data) {
107
- if (!data || typeof data !== "string") {
108
- return undefined;
109
- }
110
- // Normalize: remove 0x prefix and work with lowercase hex
111
- var hex = data.startsWith("0x") || data.startsWith("0X")
112
- ? data.slice(2).toLowerCase()
113
- : data.toLowerCase();
114
- // Minimum suffix: 1+ byte codes + 1 byte codesLength + 1 byte schemaId + 16 bytes marker = 19 bytes = 38 hex chars
115
- if (hex.length < 38) {
116
- return undefined;
117
- }
118
- // Step 1: Check last 16 bytes for ERC marker
119
- var markerStart = hex.length - ERC_MARKER_HEX_LENGTH;
120
- var marker = hex.slice(markerStart);
121
- if (marker !== ERC_MARKER) {
122
- return undefined;
123
- }
124
- // Step 2: Read schemaId (1 byte before the marker)
125
- var schemaIdStart = markerStart - 2;
126
- if (schemaIdStart < 0) {
127
- return undefined;
128
- }
129
- var schemaId = hex.slice(schemaIdStart, markerStart);
130
- // Step 3: Parse based on schemaId
131
- if (schemaId === SCHEMA_ID_CANONICAL || schemaId === SCHEMA_ID_CUSTOM_REGISTRY) {
132
- // Both Schema 0 and Schema 1 have codes in the same position
133
- // (immediately before schemaId when parsing backwards)
134
- var result = readCodes(hex, schemaIdStart);
135
- return result === null || result === void 0 ? void 0 : result.codes;
136
- }
137
- // Unknown schema - cannot parse
138
- return undefined;
139
- }
140
- //# sourceMappingURL=builderCode.js.map