@rhinestone/service-sdk 0.2.2 → 0.2.4
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/chains.d.ts +3 -1
- package/dist/chains.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -0
- package/dist/serialization.d.ts +29 -0
- package/dist/serialization.d.ts.map +1 -0
- package/dist/serialization.js +106 -0
- package/package.json +6 -2
package/dist/chains.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { FeeValuesEIP1559, PublicClient } from 'viem';
|
|
2
|
-
|
|
2
|
+
type FeeEstimationClient = Pick<PublicClient, 'estimateFeesPerGas' | 'getFeeHistory'>;
|
|
3
|
+
export declare function estimateGasFees(client: FeeEstimationClient, chainId: number): Promise<FeeValuesEIP1559>;
|
|
4
|
+
export {};
|
|
3
5
|
//# sourceMappingURL=chains.d.ts.map
|
package/dist/chains.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../src/chains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../src/chains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAG1D,KAAK,mBAAmB,GAAG,IAAI,CAC7B,YAAY,EACZ,oBAAoB,GAAG,eAAe,CACvC,CAAA;AAKD,wBAAsB,eAAe,CACnC,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,gBAAgB,CAAC,CAK3B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './serialization';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./serialization"), exports);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare const DEFAULT_BIGINT_CONVERSION_MAX_DEPTH = 100;
|
|
2
|
+
export interface ConvertBigIntFieldsOptions {
|
|
3
|
+
/** Maximum object/array nesting depth before conversion throws. */
|
|
4
|
+
maxDepth?: number;
|
|
5
|
+
/** Convert finite numbers to strings too. Defaults to false. */
|
|
6
|
+
convertFiniteNumbers?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/** JSON.stringify replacer that converts bigint values to strings. */
|
|
9
|
+
export declare const bigintReplacer: (_: string, value: unknown) => unknown;
|
|
10
|
+
/**
|
|
11
|
+
* Recursively converts bigint values to decimal strings.
|
|
12
|
+
*
|
|
13
|
+
* Intended for JSON-like plain objects/arrays. Pass `convertFiniteNumbers: true`
|
|
14
|
+
* for canonical-signing payloads that need number-like fields encoded as strings.
|
|
15
|
+
*
|
|
16
|
+
* Throws on circular references or excessive nesting instead of silently
|
|
17
|
+
* producing lossy placeholder values.
|
|
18
|
+
*/
|
|
19
|
+
export declare function convertBigIntFields(value: unknown, options?: ConvertBigIntFieldsOptions): unknown;
|
|
20
|
+
/**
|
|
21
|
+
* JSON.stringify with guarded bigint conversion.
|
|
22
|
+
*
|
|
23
|
+
* Preserves JSON.stringify semantics for `toJSON` (for example, Date -> ISO
|
|
24
|
+
* string) while adding bigint conversion plus circular/depth guards.
|
|
25
|
+
*/
|
|
26
|
+
export declare function stringifyBigIntFields(value: unknown, options?: ConvertBigIntFieldsOptions & {
|
|
27
|
+
space?: string | number;
|
|
28
|
+
}): string;
|
|
29
|
+
//# sourceMappingURL=serialization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mCAAmC,MAAM,CAAA;AAEtD,MAAM,WAAW,0BAA0B;IACzC,mEAAmE;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,gEAAgE;IAChE,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B;AAED,sEAAsE;AACtE,eAAO,MAAM,cAAc,GAAI,GAAG,MAAM,EAAE,OAAO,OAAO,YACF,CAAA;AAEtD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,0BAA+B,GACvC,OAAO,CAWT;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,0BAA0B,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAO,GACrE,MAAM,CAMR"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bigintReplacer = exports.DEFAULT_BIGINT_CONVERSION_MAX_DEPTH = void 0;
|
|
4
|
+
exports.convertBigIntFields = convertBigIntFields;
|
|
5
|
+
exports.stringifyBigIntFields = stringifyBigIntFields;
|
|
6
|
+
exports.DEFAULT_BIGINT_CONVERSION_MAX_DEPTH = 100;
|
|
7
|
+
/** JSON.stringify replacer that converts bigint values to strings. */
|
|
8
|
+
const bigintReplacer = (_, value) => typeof value === 'bigint' ? value.toString() : value;
|
|
9
|
+
exports.bigintReplacer = bigintReplacer;
|
|
10
|
+
/**
|
|
11
|
+
* Recursively converts bigint values to decimal strings.
|
|
12
|
+
*
|
|
13
|
+
* Intended for JSON-like plain objects/arrays. Pass `convertFiniteNumbers: true`
|
|
14
|
+
* for canonical-signing payloads that need number-like fields encoded as strings.
|
|
15
|
+
*
|
|
16
|
+
* Throws on circular references or excessive nesting instead of silently
|
|
17
|
+
* producing lossy placeholder values.
|
|
18
|
+
*/
|
|
19
|
+
function convertBigIntFields(value, options = {}) {
|
|
20
|
+
const maxDepth = normalizeMaxDepth(options.maxDepth);
|
|
21
|
+
const convertFiniteNumbers = options.convertFiniteNumbers ?? false;
|
|
22
|
+
return convertBigIntFieldsInner(value, new WeakSet(), 0, maxDepth, convertFiniteNumbers);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* JSON.stringify with guarded bigint conversion.
|
|
26
|
+
*
|
|
27
|
+
* Preserves JSON.stringify semantics for `toJSON` (for example, Date -> ISO
|
|
28
|
+
* string) while adding bigint conversion plus circular/depth guards.
|
|
29
|
+
*/
|
|
30
|
+
function stringifyBigIntFields(value, options = {}) {
|
|
31
|
+
return JSON.stringify(value, createGuardedBigIntReplacer(options), options.space);
|
|
32
|
+
}
|
|
33
|
+
function createGuardedBigIntReplacer(options) {
|
|
34
|
+
const maxDepth = normalizeMaxDepth(options.maxDepth);
|
|
35
|
+
const convertFiniteNumbers = options.convertFiniteNumbers ?? false;
|
|
36
|
+
const ancestors = [];
|
|
37
|
+
return function guardedBigIntReplacer(_key, value) {
|
|
38
|
+
if (typeof value === 'bigint') {
|
|
39
|
+
return value.toString();
|
|
40
|
+
}
|
|
41
|
+
if (typeof value === 'number') {
|
|
42
|
+
return convertFiniteNumbers && Number.isFinite(value)
|
|
43
|
+
? value.toString()
|
|
44
|
+
: value;
|
|
45
|
+
}
|
|
46
|
+
if (value === null || typeof value !== 'object') {
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this) {
|
|
50
|
+
ancestors.pop();
|
|
51
|
+
}
|
|
52
|
+
if (ancestors.includes(value)) {
|
|
53
|
+
throw new Error('convertBigIntFields: circular reference detected');
|
|
54
|
+
}
|
|
55
|
+
if (ancestors.length >= maxDepth) {
|
|
56
|
+
throw new Error(`convertBigIntFields: max depth exceeded (${maxDepth})`);
|
|
57
|
+
}
|
|
58
|
+
ancestors.push(value);
|
|
59
|
+
return value;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function convertBigIntFieldsInner(value, seen, depth, maxDepth, convertFiniteNumbers) {
|
|
63
|
+
if (value === null || value === undefined) {
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
if (typeof value === 'bigint') {
|
|
67
|
+
return value.toString();
|
|
68
|
+
}
|
|
69
|
+
if (typeof value === 'number') {
|
|
70
|
+
return convertFiniteNumbers && Number.isFinite(value)
|
|
71
|
+
? value.toString()
|
|
72
|
+
: value;
|
|
73
|
+
}
|
|
74
|
+
if (typeof value !== 'object') {
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
if (seen.has(value)) {
|
|
78
|
+
throw new Error('convertBigIntFields: circular reference detected');
|
|
79
|
+
}
|
|
80
|
+
if (depth >= maxDepth) {
|
|
81
|
+
throw new Error(`convertBigIntFields: max depth exceeded (${maxDepth})`);
|
|
82
|
+
}
|
|
83
|
+
seen.add(value);
|
|
84
|
+
try {
|
|
85
|
+
if (Array.isArray(value)) {
|
|
86
|
+
return value.map((item) => convertBigIntFieldsInner(item, seen, depth + 1, maxDepth, convertFiniteNumbers));
|
|
87
|
+
}
|
|
88
|
+
const result = {};
|
|
89
|
+
for (const key in value) {
|
|
90
|
+
if (Object.hasOwn(value, key)) {
|
|
91
|
+
result[key] = convertBigIntFieldsInner(value[key], seen, depth + 1, maxDepth, convertFiniteNumbers);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
seen.delete(value);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function normalizeMaxDepth(maxDepth) {
|
|
101
|
+
const resolved = maxDepth ?? exports.DEFAULT_BIGINT_CONVERSION_MAX_DEPTH;
|
|
102
|
+
if (!Number.isInteger(resolved) || resolved < 0) {
|
|
103
|
+
throw new TypeError('convertBigIntFields: maxDepth must be a non-negative integer');
|
|
104
|
+
}
|
|
105
|
+
return resolved;
|
|
106
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rhinestone/service-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Shared SDK for Rhinestone services",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Rhinestone",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"exports": {
|
|
15
15
|
".": "./dist/index.js",
|
|
16
16
|
"./chains": "./dist/chains.js",
|
|
17
|
-
"./opentelemetry": "./dist/opentelemetry/index.js"
|
|
17
|
+
"./opentelemetry": "./dist/opentelemetry/index.js",
|
|
18
|
+
"./serialization": "./dist/serialization.js"
|
|
18
19
|
},
|
|
19
20
|
"typesVersions": {
|
|
20
21
|
"*": {
|
|
@@ -23,6 +24,9 @@
|
|
|
23
24
|
],
|
|
24
25
|
"opentelemetry": [
|
|
25
26
|
"dist/opentelemetry/index.d.ts"
|
|
27
|
+
],
|
|
28
|
+
"serialization": [
|
|
29
|
+
"dist/serialization.d.ts"
|
|
26
30
|
]
|
|
27
31
|
}
|
|
28
32
|
},
|