@hashgraphonline/standards-sdk 0.1.107 → 0.1.109

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.
@@ -1,207 +1,20 @@
1
- import { I as InscriptionSDK } from "./standards-sdk.es122.js";
2
- class QuoteCache {
3
- constructor() {
4
- this.cache = /* @__PURE__ */ new Map();
5
- this.maxSize = 100;
6
- this.defaultTtlMs = 5 * 60 * 1e3;
7
- }
8
- // 5 minutes
9
- /**
10
- * Generate cache key from input parameters
11
- */
12
- generateKey(key) {
13
- return `${key.inputHash}-${key.clientConfigHash}-${key.optionsHash}`;
14
- }
15
- /**
16
- * Hash object to string for cache key
17
- */
18
- hashObject(obj) {
19
- return Buffer.from(JSON.stringify(obj)).toString("base64").slice(0, 16);
20
- }
21
- /**
22
- * Create cache key from parameters
23
- */
24
- createCacheKey(input, clientConfig, options) {
25
- return {
26
- inputHash: this.hashObject(input),
27
- clientConfigHash: this.hashObject({
28
- accountId: clientConfig.accountId,
29
- network: clientConfig.network
30
- }),
31
- optionsHash: this.hashObject({
32
- mode: options.mode,
33
- apiKey: options.apiKey ? "present" : "absent",
34
- network: options.network,
35
- metadata: options.metadata
36
- })
37
- };
38
- }
39
- /**
40
- * Get cached quote if available and not expired
41
- */
42
- get(key) {
43
- const cacheKey = this.generateKey(key);
44
- const entry = this.cache.get(cacheKey);
45
- if (!entry) {
46
- return null;
47
- }
48
- const now = Date.now();
49
- if (now - entry.timestamp > entry.ttlMs) {
50
- this.cache.delete(cacheKey);
51
- return null;
52
- }
53
- this.cache.delete(cacheKey);
54
- this.cache.set(cacheKey, entry);
55
- return entry.quote;
56
- }
57
- /**
58
- * Store quote in cache
59
- */
60
- set(key, quote, ttlMs = this.defaultTtlMs) {
61
- const cacheKey = this.generateKey(key);
62
- if (this.cache.size >= this.maxSize) {
63
- const firstKey = this.cache.keys().next().value;
64
- if (firstKey) {
65
- this.cache.delete(firstKey);
66
- }
67
- }
68
- this.cache.set(cacheKey, {
69
- quote,
70
- timestamp: Date.now(),
71
- ttlMs
72
- });
73
- }
74
- /**
75
- * Clear all cached entries
76
- */
77
- clear() {
78
- this.cache.clear();
79
- }
80
- }
81
- class SDKCache {
82
- constructor() {
83
- this.cache = /* @__PURE__ */ new Map();
84
- this.maxSize = 10;
85
- this.defaultTtlMs = 30 * 60 * 1e3;
86
- }
87
- // 30 minutes
88
- /**
89
- * Generate config key for SDK instance
90
- */
91
- generateConfigKey(config) {
92
- return Buffer.from(JSON.stringify(config)).toString("base64");
93
- }
94
- /**
95
- * Get cached SDK instance
96
- */
97
- get(config) {
98
- const configKey = this.generateConfigKey(config);
99
- const entry = this.cache.get(configKey);
100
- if (!entry) {
101
- return null;
102
- }
103
- const now = Date.now();
104
- if (now - entry.timestamp > this.defaultTtlMs) {
105
- this.cache.delete(configKey);
106
- return null;
107
- }
108
- return entry.sdk;
109
- }
110
- /**
111
- * Store SDK instance in cache
112
- */
113
- set(config, sdk) {
114
- const configKey = this.generateConfigKey(config);
115
- if (this.cache.size >= this.maxSize) {
116
- const firstKey = this.cache.keys().next().value;
117
- if (firstKey) {
118
- this.cache.delete(firstKey);
119
- }
120
- }
121
- this.cache.set(configKey, {
122
- sdk,
123
- timestamp: Date.now(),
124
- config: configKey
1
+ import { Logger } from "./standards-sdk.es93.js";
2
+ import { HederaMirrorNode } from "./standards-sdk.es113.js";
3
+ class HCS5BaseClient {
4
+ /**
5
+ * Create a new HCS-5 base client
6
+ */
7
+ constructor(config) {
8
+ this.network = config.network;
9
+ this.logger = config.logger || Logger.getInstance({
10
+ level: config.logLevel || "info",
11
+ module: "HCS5Client",
12
+ silent: config.silent
125
13
  });
126
- }
127
- /**
128
- * Clear all cached SDK instances
129
- */
130
- clear() {
131
- this.cache.clear();
132
- }
133
- }
134
- const quoteCache = new QuoteCache();
135
- const sdkCache = new SDKCache();
136
- async function getOrCreateSDK(clientConfig, options, existingSDK) {
137
- if (existingSDK) {
138
- return existingSDK;
139
- }
140
- const cacheConfig = {
141
- apiKey: options.apiKey,
142
- accountId: clientConfig.accountId,
143
- network: clientConfig.network || "mainnet",
144
- authType: options.apiKey ? "api" : "server"
145
- };
146
- const cachedSDK = sdkCache.get(cacheConfig);
147
- if (cachedSDK) {
148
- return cachedSDK;
149
- }
150
- let sdk;
151
- if (options.apiKey) {
152
- sdk = new InscriptionSDK({
153
- apiKey: options.apiKey,
154
- network: clientConfig.network || "mainnet"
155
- });
156
- } else {
157
- sdk = await InscriptionSDK.createWithAuth({
158
- type: "server",
159
- accountId: clientConfig.accountId,
160
- privateKey: typeof clientConfig.privateKey === "string" ? clientConfig.privateKey : clientConfig.privateKey.toString(),
161
- network: clientConfig.network || "mainnet"
162
- });
163
- }
164
- sdkCache.set(cacheConfig, sdk);
165
- return sdk;
166
- }
167
- function getCachedQuote(input, clientConfig, options) {
168
- const cacheKey = quoteCache.createCacheKey(input, clientConfig, options);
169
- return quoteCache.get(cacheKey);
170
- }
171
- function cacheQuote(input, clientConfig, options, quote) {
172
- const cacheKey = quoteCache.createCacheKey(input, clientConfig, options);
173
- const quoteTtlMs = 10 * 60 * 1e3;
174
- quoteCache.set(cacheKey, quote, quoteTtlMs);
175
- }
176
- function validateQuoteParameters(input, clientConfig, options) {
177
- if (!input || typeof input !== "object" || !("type" in input)) {
178
- throw new Error("Invalid inscription input: type is required");
179
- }
180
- if (!clientConfig || !clientConfig.accountId) {
181
- throw new Error("Invalid client config: accountId is required");
182
- }
183
- if (!options) {
184
- throw new Error("Options are required");
185
- }
186
- if (options.mode === "hashinal") {
187
- if (!options.metadata) {
188
- throw new Error("Hashinal mode requires metadata");
189
- }
190
- const requiredFields = ["name", "creator", "description", "type"];
191
- const missingFields = requiredFields.filter(
192
- (field) => !options.metadata || !options.metadata[field]
193
- );
194
- if (missingFields.length > 0) {
195
- throw new Error(
196
- `Missing required Hashinal metadata fields: ${missingFields.join(", ")}`
197
- );
198
- }
14
+ this.mirrorNode = new HederaMirrorNode(this.network, this.logger);
199
15
  }
200
16
  }
201
17
  export {
202
- cacheQuote,
203
- getCachedQuote,
204
- getOrCreateSDK,
205
- validateQuoteParameters
18
+ HCS5BaseClient
206
19
  };
207
20
  //# sourceMappingURL=standards-sdk.es123.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"standards-sdk.es123.js","sources":["../../src/inscribe/quote-cache.ts"],"sourcesContent":["/**\n * Performance optimization utilities for quote generation\n */\n\nimport { InscriptionSDK } from '@kiloscribe/inscription-sdk';\nimport { HederaClientConfig, InscriptionOptions, QuoteResult, NodeHederaClientConfig } from './types';\n\ninterface CacheKey {\n inputHash: string;\n clientConfigHash: string;\n optionsHash: string;\n}\n\ninterface CacheEntry {\n quote: QuoteResult;\n timestamp: number;\n ttlMs: number;\n}\n\ninterface SDKCacheEntry {\n sdk: InscriptionSDK;\n timestamp: number;\n config: string;\n}\n\n/**\n * LRU Cache for quote results to improve performance\n */\nclass QuoteCache {\n private cache = new Map<string, CacheEntry>();\n private maxSize = 100;\n private defaultTtlMs = 5 * 60 * 1000; // 5 minutes\n\n /**\n * Generate cache key from input parameters\n */\n private generateKey(key: CacheKey): string {\n return `${key.inputHash}-${key.clientConfigHash}-${key.optionsHash}`;\n }\n\n /**\n * Hash object to string for cache key\n */\n private hashObject(obj: unknown): string {\n return Buffer.from(JSON.stringify(obj)).toString('base64').slice(0, 16);\n }\n\n /**\n * Create cache key from parameters\n */\n createCacheKey(\n input: unknown,\n clientConfig: NodeHederaClientConfig,\n options: InscriptionOptions,\n ): CacheKey {\n return {\n inputHash: this.hashObject(input),\n clientConfigHash: this.hashObject({\n accountId: clientConfig.accountId,\n network: clientConfig.network,\n }),\n optionsHash: this.hashObject({\n mode: options.mode,\n apiKey: options.apiKey ? 'present' : 'absent',\n network: options.network,\n metadata: options.metadata,\n }),\n };\n }\n\n /**\n * Get cached quote if available and not expired\n */\n get(key: CacheKey): QuoteResult | null {\n const cacheKey = this.generateKey(key);\n const entry = this.cache.get(cacheKey);\n\n if (!entry) {\n return null;\n }\n\n const now = Date.now();\n if (now - entry.timestamp > entry.ttlMs) {\n this.cache.delete(cacheKey);\n return null;\n }\n\n this.cache.delete(cacheKey);\n this.cache.set(cacheKey, entry);\n\n return entry.quote;\n }\n\n /**\n * Store quote in cache\n */\n set(\n key: CacheKey,\n quote: QuoteResult,\n ttlMs: number = this.defaultTtlMs,\n ): void {\n const cacheKey = this.generateKey(key);\n\n if (this.cache.size >= this.maxSize) {\n const firstKey = this.cache.keys().next().value;\n if (firstKey) {\n this.cache.delete(firstKey);\n }\n }\n\n this.cache.set(cacheKey, {\n quote,\n timestamp: Date.now(),\n ttlMs,\n });\n }\n\n /**\n * Clear all cached entries\n */\n clear(): void {\n this.cache.clear();\n }\n}\n\n/**\n * SDK instance cache for reuse\n */\nclass SDKCache {\n private cache = new Map<string, SDKCacheEntry>();\n private maxSize = 10;\n private defaultTtlMs = 30 * 60 * 1000; // 30 minutes\n\n /**\n * Generate config key for SDK instance\n */\n private generateConfigKey(config: unknown): string {\n return Buffer.from(JSON.stringify(config)).toString('base64');\n }\n\n /**\n * Get cached SDK instance\n */\n get(config: Record<string, unknown>): InscriptionSDK | null {\n const configKey = this.generateConfigKey(config);\n const entry = this.cache.get(configKey);\n\n if (!entry) {\n return null;\n }\n\n const now = Date.now();\n if (now - entry.timestamp > this.defaultTtlMs) {\n this.cache.delete(configKey);\n return null;\n }\n\n return entry.sdk;\n }\n\n /**\n * Store SDK instance in cache\n */\n set(config: Record<string, unknown>, sdk: InscriptionSDK): void {\n const configKey = this.generateConfigKey(config);\n\n if (this.cache.size >= this.maxSize) {\n const firstKey = this.cache.keys().next().value;\n if (firstKey) {\n this.cache.delete(firstKey);\n }\n }\n\n this.cache.set(configKey, {\n sdk,\n timestamp: Date.now(),\n config: configKey,\n });\n }\n\n /**\n * Clear all cached SDK instances\n */\n clear(): void {\n this.cache.clear();\n }\n}\n\nconst quoteCache = new QuoteCache();\nconst sdkCache = new SDKCache();\n\n/**\n * Get or create SDK instance with caching\n */\nexport async function getOrCreateSDK(\n clientConfig: NodeHederaClientConfig,\n options: InscriptionOptions,\n existingSDK?: InscriptionSDK,\n): Promise<InscriptionSDK> {\n if (existingSDK) {\n return existingSDK;\n }\n\n const cacheConfig = {\n apiKey: options.apiKey,\n accountId: clientConfig.accountId,\n network: clientConfig.network || 'mainnet',\n authType: options.apiKey ? 'api' : 'server',\n };\n\n const cachedSDK = sdkCache.get(cacheConfig);\n if (cachedSDK) {\n return cachedSDK;\n }\n\n let sdk: InscriptionSDK;\n\n if (options.apiKey) {\n sdk = new InscriptionSDK({\n apiKey: options.apiKey,\n network: clientConfig.network || 'mainnet',\n });\n } else {\n sdk = await InscriptionSDK.createWithAuth({\n type: 'server',\n accountId: clientConfig.accountId,\n privateKey:\n typeof clientConfig.privateKey === 'string'\n ? clientConfig.privateKey\n : clientConfig.privateKey.toString(),\n network: clientConfig.network || 'mainnet',\n });\n }\n\n sdkCache.set(cacheConfig, sdk);\n return sdk;\n}\n\n/**\n * Check if quote is cached and return it if valid\n */\nexport function getCachedQuote(\n input: unknown,\n clientConfig: NodeHederaClientConfig,\n options: InscriptionOptions,\n): QuoteResult | null {\n const cacheKey = quoteCache.createCacheKey(input, clientConfig, options);\n return quoteCache.get(cacheKey);\n}\n\n/**\n * Cache a generated quote\n */\nexport function cacheQuote(\n input: unknown,\n clientConfig: NodeHederaClientConfig,\n options: InscriptionOptions,\n quote: QuoteResult,\n): void {\n const cacheKey = quoteCache.createCacheKey(input, clientConfig, options);\n const quoteTtlMs = 10 * 60 * 1000;\n quoteCache.set(cacheKey, quote, quoteTtlMs);\n}\n\n/**\n * Pre-validate parameters for early error detection\n */\nexport function validateQuoteParameters(\n input: unknown,\n clientConfig: NodeHederaClientConfig,\n options: InscriptionOptions,\n): void {\n if (!input || typeof input !== 'object' || !('type' in input)) {\n throw new Error('Invalid inscription input: type is required');\n }\n\n if (!clientConfig || !clientConfig.accountId) {\n throw new Error('Invalid client config: accountId is required');\n }\n\n if (!options) {\n throw new Error('Options are required');\n }\n\n if (options.mode === 'hashinal') {\n if (!options.metadata) {\n throw new Error('Hashinal mode requires metadata');\n }\n\n const requiredFields = ['name', 'creator', 'description', 'type'];\n const missingFields = requiredFields.filter(\n field => !options.metadata || !options.metadata[field],\n );\n\n if (missingFields.length > 0) {\n throw new Error(\n `Missing required Hashinal metadata fields: ${missingFields.join(', ')}`,\n );\n }\n }\n}\n\n/**\n * Clear all caches (useful for testing or memory management)\n */\nexport function clearAllCaches(): void {\n quoteCache.clear();\n sdkCache.clear();\n}\n"],"names":[],"mappings":";AA4BA,MAAM,WAAW;AAAA,EAAjB,cAAA;AACE,SAAQ,4BAAY,IAAA;AACpB,SAAQ,UAAU;AAClB,SAAQ,eAAe,IAAI,KAAK;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKxB,YAAY,KAAuB;AACzC,WAAO,GAAG,IAAI,SAAS,IAAI,IAAI,gBAAgB,IAAI,IAAI,WAAW;AAAA,EACpE;AAAA;AAAA;AAAA;AAAA,EAKQ,WAAW,KAAsB;AACvC,WAAO,OAAO,KAAK,KAAK,UAAU,GAAG,CAAC,EAAE,SAAS,QAAQ,EAAE,MAAM,GAAG,EAAE;AAAA,EACxE;AAAA;AAAA;AAAA;AAAA,EAKA,eACE,OACA,cACA,SACU;AACV,WAAO;AAAA,MACL,WAAW,KAAK,WAAW,KAAK;AAAA,MAChC,kBAAkB,KAAK,WAAW;AAAA,QAChC,WAAW,aAAa;AAAA,QACxB,SAAS,aAAa;AAAA,MAAA,CACvB;AAAA,MACD,aAAa,KAAK,WAAW;AAAA,QAC3B,MAAM,QAAQ;AAAA,QACd,QAAQ,QAAQ,SAAS,YAAY;AAAA,QACrC,SAAS,QAAQ;AAAA,QACjB,UAAU,QAAQ;AAAA,MAAA,CACnB;AAAA,IAAA;AAAA,EAEL;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,KAAmC;AACrC,UAAM,WAAW,KAAK,YAAY,GAAG;AACrC,UAAM,QAAQ,KAAK,MAAM,IAAI,Q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IAAA,CAClC;AAAA,EACH;AAEA,WAAS,IAAI,aAAa,GAAG;AAC7B,SAAO;AACT;AAKO,SAAS,eACd,OACA,cACA,SACoB;AACpB,QAAM,WAAW,WAAW,eAAe,OAAO,cAAc,OAAO;AACvE,SAAO,WAAW,IAAI,QAAQ;AAChC;AAKO,SAAS,WACd,OACA,cACA,SACA,OACM;AACN,QAAM,WAAW,WAAW,eAAe,OAAO,cAAc,OAAO;AACvE,QAAM,aAAa,KAAK,KAAK;AAC7B,aAAW,IAAI,UAAU,OAAO,UAAU;AAC5C;AAKO,SAAS,wBACd,OACA,cACA,SACM;AACN,MAAI,CAAC,SAAS,OAAO,UAAU,YAAY,EAAE,UAAU,QAAQ;AAC7D,UAAM,IAAI,MAAM,6CAA6C;AAAA,EAC/D;AAEA,MAAI,CAAC,gBAAgB,CAAC,aAAa,WAAW;AAC5C,UAAM,IAAI,MAAM,8CAA8C;AAAA,EAChE;AAEA,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,sBAAsB;AAAA,EACxC;AAEA,MAAI,QAAQ,SAAS,YAAY;AAC/B,QAAI,CAAC,QAAQ,UAAU;AACrB,YAAM,IAAI,MAAM,iCAAiC;AAAA,IACnD;AAEA,UAAM,iBAAiB,CAAC,QAAQ,WAAW,eAAe,MAAM;AAChE,UAAM,gBAAgB,eAAe;AAAA,MACnC,WAAS,CAAC,QAAQ,YAAY,CAAC,QAAQ,SAAS,KAAK;AAAA,IAAA;AAGvD,QAAI,cAAc,SAAS,GAAG;AAC5B,YAAM,IAAI;AAAA,QACR,8CAA8C,cAAc,KAAK,IAAI,CAAC;AAAA,MAAA;AAAA,IAE1E;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"standards-sdk.es123.js","sources":["../../src/hcs-5/base-client.ts"],"sourcesContent":["import { Logger, ILogger } from '../utils/logger';\nimport { HederaMirrorNode } from '../services/mirror-node';\nimport { HCS5ClientConfig } from './types';\nimport { NetworkType } from '../utils/types';\n\n/**\n * Base client for HCS-5 operations\n */\nexport abstract class HCS5BaseClient {\n protected logger: ILogger;\n protected mirrorNode: HederaMirrorNode;\n protected network: NetworkType;\n\n /**\n * Create a new HCS-5 base client\n */\n constructor(config: HCS5ClientConfig) {\n this.network = config.network;\n this.logger =\n config.logger ||\n Logger.getInstance({\n level: config.logLevel || 'info',\n module: 'HCS5Client',\n silent: config.silent,\n });\n\n this.mirrorNode = new HederaMirrorNode(this.network, this.logger);\n }\n}\n"],"names":[],"mappings":";;AAQO,MAAe,eAAe;AAAA;AAAA;AAAA;AAAA,EAQnC,YAAY,QAA0B;AACpC,SAAK,UAAU,OAAO;AACtB,SAAK,SACH,OAAO,UACP,OAAO,YAAY;AAAA,MACjB,OAAO,OAAO,YAAY;AAAA,MAC1B,QAAQ;AAAA,MACR,QAAQ,OAAO;AAAA,IAAA,CAChB;AAEH,SAAK,aAAa,IAAI,iBAAiB,KAAK,SAAS,KAAK,MAAM;AAAA,EAClE;AACF;"}
@@ -1,20 +1,207 @@
1
- import { Logger } from "./standards-sdk.es93.js";
2
- import { HederaMirrorNode } from "./standards-sdk.es113.js";
3
- class HCS5BaseClient {
4
- /**
5
- * Create a new HCS-5 base client
6
- */
7
- constructor(config) {
8
- this.network = config.network;
9
- this.logger = config.logger || Logger.getInstance({
10
- level: config.logLevel || "info",
11
- module: "HCS5Client",
12
- silent: config.silent
1
+ import { I as InscriptionSDK } from "./standards-sdk.es122.js";
2
+ class QuoteCache {
3
+ constructor() {
4
+ this.cache = /* @__PURE__ */ new Map();
5
+ this.maxSize = 100;
6
+ this.defaultTtlMs = 5 * 60 * 1e3;
7
+ }
8
+ // 5 minutes
9
+ /**
10
+ * Generate cache key from input parameters
11
+ */
12
+ generateKey(key) {
13
+ return `${key.inputHash}-${key.clientConfigHash}-${key.optionsHash}`;
14
+ }
15
+ /**
16
+ * Hash object to string for cache key
17
+ */
18
+ hashObject(obj) {
19
+ return Buffer.from(JSON.stringify(obj)).toString("base64").slice(0, 16);
20
+ }
21
+ /**
22
+ * Create cache key from parameters
23
+ */
24
+ createCacheKey(input, clientConfig, options) {
25
+ return {
26
+ inputHash: this.hashObject(input),
27
+ clientConfigHash: this.hashObject({
28
+ accountId: clientConfig.accountId,
29
+ network: clientConfig.network
30
+ }),
31
+ optionsHash: this.hashObject({
32
+ mode: options.mode,
33
+ apiKey: options.apiKey ? "present" : "absent",
34
+ network: options.network,
35
+ metadata: options.metadata
36
+ })
37
+ };
38
+ }
39
+ /**
40
+ * Get cached quote if available and not expired
41
+ */
42
+ get(key) {
43
+ const cacheKey = this.generateKey(key);
44
+ const entry = this.cache.get(cacheKey);
45
+ if (!entry) {
46
+ return null;
47
+ }
48
+ const now = Date.now();
49
+ if (now - entry.timestamp > entry.ttlMs) {
50
+ this.cache.delete(cacheKey);
51
+ return null;
52
+ }
53
+ this.cache.delete(cacheKey);
54
+ this.cache.set(cacheKey, entry);
55
+ return entry.quote;
56
+ }
57
+ /**
58
+ * Store quote in cache
59
+ */
60
+ set(key, quote, ttlMs = this.defaultTtlMs) {
61
+ const cacheKey = this.generateKey(key);
62
+ if (this.cache.size >= this.maxSize) {
63
+ const firstKey = this.cache.keys().next().value;
64
+ if (firstKey) {
65
+ this.cache.delete(firstKey);
66
+ }
67
+ }
68
+ this.cache.set(cacheKey, {
69
+ quote,
70
+ timestamp: Date.now(),
71
+ ttlMs
72
+ });
73
+ }
74
+ /**
75
+ * Clear all cached entries
76
+ */
77
+ clear() {
78
+ this.cache.clear();
79
+ }
80
+ }
81
+ class SDKCache {
82
+ constructor() {
83
+ this.cache = /* @__PURE__ */ new Map();
84
+ this.maxSize = 10;
85
+ this.defaultTtlMs = 30 * 60 * 1e3;
86
+ }
87
+ // 30 minutes
88
+ /**
89
+ * Generate config key for SDK instance
90
+ */
91
+ generateConfigKey(config) {
92
+ return Buffer.from(JSON.stringify(config)).toString("base64");
93
+ }
94
+ /**
95
+ * Get cached SDK instance
96
+ */
97
+ get(config) {
98
+ const configKey = this.generateConfigKey(config);
99
+ const entry = this.cache.get(configKey);
100
+ if (!entry) {
101
+ return null;
102
+ }
103
+ const now = Date.now();
104
+ if (now - entry.timestamp > this.defaultTtlMs) {
105
+ this.cache.delete(configKey);
106
+ return null;
107
+ }
108
+ return entry.sdk;
109
+ }
110
+ /**
111
+ * Store SDK instance in cache
112
+ */
113
+ set(config, sdk) {
114
+ const configKey = this.generateConfigKey(config);
115
+ if (this.cache.size >= this.maxSize) {
116
+ const firstKey = this.cache.keys().next().value;
117
+ if (firstKey) {
118
+ this.cache.delete(firstKey);
119
+ }
120
+ }
121
+ this.cache.set(configKey, {
122
+ sdk,
123
+ timestamp: Date.now(),
124
+ config: configKey
13
125
  });
14
- this.mirrorNode = new HederaMirrorNode(this.network, this.logger);
126
+ }
127
+ /**
128
+ * Clear all cached SDK instances
129
+ */
130
+ clear() {
131
+ this.cache.clear();
132
+ }
133
+ }
134
+ const quoteCache = new QuoteCache();
135
+ const sdkCache = new SDKCache();
136
+ async function getOrCreateSDK(clientConfig, options, existingSDK) {
137
+ if (existingSDK) {
138
+ return existingSDK;
139
+ }
140
+ const cacheConfig = {
141
+ apiKey: options.apiKey,
142
+ accountId: clientConfig.accountId,
143
+ network: clientConfig.network || "mainnet",
144
+ authType: options.apiKey ? "api" : "server"
145
+ };
146
+ const cachedSDK = sdkCache.get(cacheConfig);
147
+ if (cachedSDK) {
148
+ return cachedSDK;
149
+ }
150
+ let sdk;
151
+ if (options.apiKey) {
152
+ sdk = new InscriptionSDK({
153
+ apiKey: options.apiKey,
154
+ network: clientConfig.network || "mainnet"
155
+ });
156
+ } else {
157
+ sdk = await InscriptionSDK.createWithAuth({
158
+ type: "server",
159
+ accountId: clientConfig.accountId,
160
+ privateKey: typeof clientConfig.privateKey === "string" ? clientConfig.privateKey : clientConfig.privateKey.toString(),
161
+ network: clientConfig.network || "mainnet"
162
+ });
163
+ }
164
+ sdkCache.set(cacheConfig, sdk);
165
+ return sdk;
166
+ }
167
+ function getCachedQuote(input, clientConfig, options) {
168
+ const cacheKey = quoteCache.createCacheKey(input, clientConfig, options);
169
+ return quoteCache.get(cacheKey);
170
+ }
171
+ function cacheQuote(input, clientConfig, options, quote) {
172
+ const cacheKey = quoteCache.createCacheKey(input, clientConfig, options);
173
+ const quoteTtlMs = 10 * 60 * 1e3;
174
+ quoteCache.set(cacheKey, quote, quoteTtlMs);
175
+ }
176
+ function validateQuoteParameters(input, clientConfig, options) {
177
+ if (!input || typeof input !== "object" || !("type" in input)) {
178
+ throw new Error("Invalid inscription input: type is required");
179
+ }
180
+ if (!clientConfig || !clientConfig.accountId) {
181
+ throw new Error("Invalid client config: accountId is required");
182
+ }
183
+ if (!options) {
184
+ throw new Error("Options are required");
185
+ }
186
+ if (options.mode === "hashinal") {
187
+ if (!options.metadata) {
188
+ throw new Error("Hashinal mode requires metadata");
189
+ }
190
+ const requiredFields = ["name", "creator", "description", "type"];
191
+ const missingFields = requiredFields.filter(
192
+ (field) => !options.metadata || !options.metadata[field]
193
+ );
194
+ if (missingFields.length > 0) {
195
+ throw new Error(
196
+ `Missing required Hashinal metadata fields: ${missingFields.join(", ")}`
197
+ );
198
+ }
15
199
  }
16
200
  }
17
201
  export {
18
- HCS5BaseClient
202
+ cacheQuote,
203
+ getCachedQuote,
204
+ getOrCreateSDK,
205
+ validateQuoteParameters
19
206
  };
20
207
  //# sourceMappingURL=standards-sdk.es124.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"standards-sdk.es124.js","sources":["../../src/hcs-5/base-client.ts"],"sourcesContent":["import { Logger, ILogger } from '../utils/logger';\nimport { HederaMirrorNode } from '../services/mirror-node';\nimport { HCS5ClientConfig } from './types';\nimport { NetworkType } from '../utils/types';\n\n/**\n * Base client for HCS-5 operations\n */\nexport abstract class HCS5BaseClient {\n protected logger: ILogger;\n protected mirrorNode: HederaMirrorNode;\n protected network: NetworkType;\n\n /**\n * Create a new HCS-5 base client\n */\n constructor(config: HCS5ClientConfig) {\n this.network = config.network;\n this.logger =\n config.logger ||\n Logger.getInstance({\n level: config.logLevel || 'info',\n module: 'HCS5Client',\n silent: config.silent,\n });\n\n this.mirrorNode = new HederaMirrorNode(this.network, this.logger);\n }\n}\n"],"names":[],"mappings":";;AAQO,MAAe,eAAe;AAAA;AAAA;AAAA;AAAA,EAQnC,YAAY,QAA0B;AACpC,SAAK,UAAU,OAAO;AACtB,SAAK,SACH,OAAO,UACP,OAAO,YAAY;AAAA,MACjB,OAAO,OAAO,YAAY;AAAA,MAC1B,QAAQ;AAAA,MACR,QAAQ,OAAO;AAAA,IAAA,CAChB;AAEH,SAAK,aAAa,IAAI,iBAAiB,KAAK,SAAS,KAAK,MAAM;AAAA,EAClE;AACF;"}
1
+ {"version":3,"file":"standards-sdk.es124.js","sources":["../../src/inscribe/quote-cache.ts"],"sourcesContent":["/**\n * Performance optimization utilities for quote generation\n */\n\nimport { InscriptionSDK } from '@kiloscribe/inscription-sdk';\nimport { HederaClientConfig, InscriptionOptions, QuoteResult, NodeHederaClientConfig } from './types';\n\ninterface CacheKey {\n inputHash: string;\n clientConfigHash: string;\n optionsHash: string;\n}\n\ninterface CacheEntry {\n quote: QuoteResult;\n timestamp: number;\n ttlMs: number;\n}\n\ninterface SDKCacheEntry {\n sdk: InscriptionSDK;\n timestamp: number;\n config: string;\n}\n\n/**\n * LRU Cache for quote results to improve performance\n */\nclass QuoteCache {\n private cache = new Map<string, CacheEntry>();\n private maxSize = 100;\n private defaultTtlMs = 5 * 60 * 1000; // 5 minutes\n\n /**\n * Generate cache key from input parameters\n */\n private generateKey(key: CacheKey): string {\n return `${key.inputHash}-${key.clientConfigHash}-${key.optionsHash}`;\n }\n\n /**\n * Hash object to string for cache key\n */\n private hashObject(obj: unknown): string {\n return Buffer.from(JSON.stringify(obj)).toString('base64').slice(0, 16);\n }\n\n /**\n * Create cache key from parameters\n */\n createCacheKey(\n input: unknown,\n clientConfig: NodeHederaClientConfig,\n options: InscriptionOptions,\n ): CacheKey {\n return {\n inputHash: this.hashObject(input),\n clientConfigHash: this.hashObject({\n accountId: clientConfig.accountId,\n network: clientConfig.network,\n }),\n optionsHash: this.hashObject({\n mode: options.mode,\n apiKey: options.apiKey ? 'present' : 'absent',\n network: options.network,\n metadata: options.metadata,\n }),\n };\n }\n\n /**\n * Get cached quote if available and not expired\n */\n get(key: CacheKey): QuoteResult | null {\n const cacheKey = this.generateKey(key);\n const entry = this.cache.get(cacheKey);\n\n if (!entry) {\n return null;\n }\n\n const now = Date.now();\n if (now - entry.timestamp > entry.ttlMs) {\n this.cache.delete(cacheKey);\n return null;\n }\n\n this.cache.delete(cacheKey);\n this.cache.set(cacheKey, entry);\n\n return entry.quote;\n }\n\n /**\n * Store quote in cache\n */\n set(\n key: CacheKey,\n quote: QuoteResult,\n ttlMs: number = this.defaultTtlMs,\n ): void {\n const cacheKey = this.generateKey(key);\n\n if (this.cache.size >= this.maxSize) {\n const firstKey = this.cache.keys().next().value;\n if (firstKey) {\n this.cache.delete(firstKey);\n }\n }\n\n this.cache.set(cacheKey, {\n quote,\n timestamp: Date.now(),\n ttlMs,\n });\n }\n\n /**\n * Clear all cached entries\n */\n clear(): void {\n this.cache.clear();\n }\n}\n\n/**\n * SDK instance cache for reuse\n */\nclass SDKCache {\n private cache = new Map<string, SDKCacheEntry>();\n private maxSize = 10;\n private defaultTtlMs = 30 * 60 * 1000; // 30 minutes\n\n /**\n * Generate config key for SDK instance\n */\n private generateConfigKey(config: unknown): string {\n return Buffer.from(JSON.stringify(config)).toString('base64');\n }\n\n /**\n * Get cached SDK instance\n */\n get(config: Record<string, unknown>): InscriptionSDK | null {\n const configKey = this.generateConfigKey(config);\n const entry = this.cache.get(configKey);\n\n if (!entry) {\n return null;\n }\n\n const now = Date.now();\n if (now - entry.timestamp > this.defaultTtlMs) {\n this.cache.delete(configKey);\n return null;\n }\n\n return entry.sdk;\n }\n\n /**\n * Store SDK instance in cache\n */\n set(config: Record<string, unknown>, sdk: InscriptionSDK): void {\n const configKey = this.generateConfigKey(config);\n\n if (this.cache.size >= this.maxSize) {\n const firstKey = this.cache.keys().next().value;\n if (firstKey) {\n this.cache.delete(firstKey);\n }\n }\n\n this.cache.set(configKey, {\n sdk,\n timestamp: Date.now(),\n config: configKey,\n });\n }\n\n /**\n * Clear all cached SDK instances\n */\n clear(): void {\n this.cache.clear();\n }\n}\n\nconst quoteCache = new QuoteCache();\nconst sdkCache = new SDKCache();\n\n/**\n * Get or create SDK instance with caching\n */\nexport async function getOrCreateSDK(\n clientConfig: NodeHederaClientConfig,\n options: InscriptionOptions,\n existingSDK?: InscriptionSDK,\n): Promise<InscriptionSDK> {\n if (existingSDK) {\n return existingSDK;\n }\n\n const cacheConfig = {\n apiKey: options.apiKey,\n accountId: clientConfig.accountId,\n network: clientConfig.network || 'mainnet',\n authType: options.apiKey ? 'api' : 'server',\n };\n\n const cachedSDK = sdkCache.get(cacheConfig);\n if (cachedSDK) {\n return cachedSDK;\n }\n\n let sdk: InscriptionSDK;\n\n if (options.apiKey) {\n sdk = new InscriptionSDK({\n apiKey: options.apiKey,\n network: clientConfig.network || 'mainnet',\n });\n } else {\n sdk = await InscriptionSDK.createWithAuth({\n type: 'server',\n accountId: clientConfig.accountId,\n privateKey:\n typeof clientConfig.privateKey === 'string'\n ? clientConfig.privateKey\n : clientConfig.privateKey.toString(),\n network: clientConfig.network || 'mainnet',\n });\n }\n\n sdkCache.set(cacheConfig, sdk);\n return sdk;\n}\n\n/**\n * Check if quote is cached and return it if valid\n */\nexport function getCachedQuote(\n input: unknown,\n clientConfig: NodeHederaClientConfig,\n options: InscriptionOptions,\n): QuoteResult | null {\n const cacheKey = quoteCache.createCacheKey(input, clientConfig, options);\n return quoteCache.get(cacheKey);\n}\n\n/**\n * Cache a generated quote\n */\nexport function cacheQuote(\n input: unknown,\n clientConfig: NodeHederaClientConfig,\n options: InscriptionOptions,\n quote: QuoteResult,\n): void {\n const cacheKey = quoteCache.createCacheKey(input, clientConfig, options);\n const quoteTtlMs = 10 * 60 * 1000;\n quoteCache.set(cacheKey, quote, quoteTtlMs);\n}\n\n/**\n * Pre-validate parameters for early error detection\n */\nexport function validateQuoteParameters(\n input: unknown,\n clientConfig: NodeHederaClientConfig,\n options: InscriptionOptions,\n): void {\n if (!input || typeof input !== 'object' || !('type' in input)) {\n throw new Error('Invalid inscription input: type is required');\n }\n\n if (!clientConfig || !clientConfig.accountId) {\n throw new Error('Invalid client config: accountId is required');\n }\n\n if (!options) {\n throw new Error('Options are required');\n }\n\n if (options.mode === 'hashinal') {\n if (!options.metadata) {\n throw new Error('Hashinal mode requires metadata');\n }\n\n const requiredFields = ['name', 'creator', 'description', 'type'];\n const missingFields = requiredFields.filter(\n field => !options.metadata || !options.metadata[field],\n );\n\n if (missingFields.length > 0) {\n throw new Error(\n `Missing required Hashinal metadata fields: ${missingFields.join(', ')}`,\n );\n }\n }\n}\n\n/**\n * Clear all caches (useful for testing or memory management)\n */\nexport function clearAllCaches(): void {\n quoteCache.clear();\n sdkCache.clear();\n}\n"],"names":[],"mappings":";AA4BA,MAAM,WAAW;AAAA,EAAjB,cAAA;AACE,SAAQ,4BAAY,IAAA;AACpB,SAAQ,UAAU;AAClB,SAAQ,eAAe,IAAI,KAAK;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKxB,YAAY,KAAuB;AACzC,WAAO,GAAG,IAAI,SAAS,IAAI,IAAI,gBAAgB,IAAI,IAAI,WAAW;AAAA,EACpE;AAAA;AAAA;AAAA;AAAA,EAKQ,WAAW,KAAsB;AACvC,WAAO,OAAO,KAAK,KAAK,UAAU,GAAG,CAAC,EAAE,SAAS,QAAQ,EAAE,MAAM,GAAG,EAAE;AAAA,EACxE;AAAA;AAAA;AAAA;AAAA,EAKA,eACE,OACA,cACA,SACU;AACV,WAAO;AAAA,MACL,WAAW,KAAK,WAAW,KAAK;AAAA,MAChC,kBAAkB,KAAK,WAAW;AAAA,QAChC,WAAW,aAAa;AAAA,QACxB,SAAS,aAAa;AAAA,MAAA,CACvB;AAAA,MACD,aAAa,KAAK,WAAW;AAAA,QAC3B,MAAM,QA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c,KAAK,IAAI,CAAC;AAAA,MAAA;AAAA,IAE1E;AAAA,EACF;AACF;"}
@@ -1,4 +1,4 @@
1
- import { HCS5BaseClient } from "./standards-sdk.es124.js";
1
+ import { HCS5BaseClient } from "./standards-sdk.es123.js";
2
2
  import { buildHcs1Hrl } from "./standards-sdk.es58.js";
3
3
  import { PrivateKey } from "@hashgraph/sdk";
4
4
  import { inscribeWithSigner } from "./standards-sdk.es112.js";
@@ -1,4 +1,4 @@
1
- import { HCS5BaseClient } from "./standards-sdk.es124.js";
1
+ import { HCS5BaseClient } from "./standards-sdk.es123.js";
2
2
  import { buildHcs1Hrl } from "./standards-sdk.es58.js";
3
3
  import { AccountId } from "@hashgraph/sdk";
4
4
  import { inscribe } from "./standards-sdk.es112.js";
@@ -1,4 +1,4 @@
1
- import pino from "pino";
1
+ import { inspect } from "util";
2
2
  let loggerFactory = null;
3
3
  function setLoggerFactory(factory) {
4
4
  loggerFactory = factory;
@@ -9,30 +9,15 @@ const _Logger = class _Logger {
9
9
  if (loggerFactory) {
10
10
  return loggerFactory(options);
11
11
  }
12
- const globalDisable = process.env.DISABLE_LOGS === "true";
13
- const isTestEnv = process.env.JEST_WORKER_ID !== void 0 || process.env.NODE_ENV === "test";
14
- const shouldSilence = options.silent || globalDisable;
15
- const level = shouldSilence ? "silent" : options.level || "info";
12
+ const globalDisable = typeof process !== "undefined" && process.env?.DISABLE_LOGS === "true";
13
+ this.silent = options.silent || globalDisable;
14
+ this.level = this.silent ? "silent" : options.level || "info";
16
15
  this.moduleContext = options.module || "app";
17
- const shouldEnablePrettyPrint = !shouldSilence && options.prettyPrint !== false && !isTestEnv;
18
- const pinoOptions = {
19
- level,
20
- enabled: !shouldSilence,
21
- transport: shouldEnablePrettyPrint ? {
22
- target: "pino-pretty",
23
- options: {
24
- colorize: true,
25
- translateTime: "SYS:standard",
26
- ignore: "pid,hostname"
27
- }
28
- } : void 0
29
- };
30
- const destination = isTestEnv ? pino.destination({ sync: true }) : void 0;
31
- this.logger = pino(pinoOptions, destination);
16
+ this.prettyPrint = !this.silent && options.prettyPrint !== false;
32
17
  }
33
18
  static getInstance(options = {}) {
34
19
  const moduleKey = options.module || "default";
35
- const globalDisable = process.env.DISABLE_LOGS === "true";
20
+ const globalDisable = typeof process !== "undefined" && process.env?.DISABLE_LOGS === "true";
36
21
  if (globalDisable && _Logger.instances.has(moduleKey)) {
37
22
  const existingLogger = _Logger.instances.get(moduleKey);
38
23
  if (existingLogger.getLevel() !== "silent") {
@@ -46,14 +31,15 @@ const _Logger = class _Logger {
46
31
  return _Logger.instances.get(moduleKey);
47
32
  }
48
33
  setLogLevel(level) {
49
- this.logger.level = level;
34
+ this.level = level;
50
35
  }
51
36
  getLevel() {
52
- return this.logger.level;
37
+ return this.level;
53
38
  }
54
39
  setSilent(silent) {
40
+ this.silent = silent;
55
41
  if (silent) {
56
- this.logger.level = "silent";
42
+ this.level = "silent";
57
43
  }
58
44
  }
59
45
  setModule(module) {
@@ -81,30 +67,66 @@ const _Logger = class _Logger {
81
67
  const msg = stringArgs.join(" ");
82
68
  return objectArgs.length > 0 ? { msg, data: objectArgs } : { msg };
83
69
  }
84
- debug(...args) {
70
+ shouldLog(level) {
71
+ if (this.silent || this.level === "silent") {
72
+ return false;
73
+ }
74
+ const levels = ["trace", "debug", "info", "warn", "error", "silent"];
75
+ const currentLevelIndex = levels.indexOf(this.level);
76
+ const targetLevelIndex = levels.indexOf(level);
77
+ return targetLevelIndex >= currentLevelIndex;
78
+ }
79
+ getConsoleMethod(level) {
80
+ if (level === "error") {
81
+ return console.error;
82
+ }
83
+ if (level === "warn") {
84
+ return console.warn;
85
+ }
86
+ if (level === "debug") {
87
+ return console.debug;
88
+ }
89
+ return console.log;
90
+ }
91
+ writeLog(level, ...args) {
92
+ if (!this.shouldLog(level)) {
93
+ return;
94
+ }
85
95
  const { msg, data } = this.formatArgs(args);
86
- const logObj = { module: this.moduleContext, ...data && { data } };
87
- this.logger.debug(logObj, msg);
96
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
97
+ const consoleMethod = this.getConsoleMethod(level);
98
+ if (this.prettyPrint) {
99
+ const levelFormatted = level.toUpperCase().padEnd(5);
100
+ let output = `${timestamp} ${levelFormatted} [${this.moduleContext}] ${msg}`;
101
+ if (data) {
102
+ output += "\n" + inspect(data, { colors: true, depth: 3 });
103
+ }
104
+ consoleMethod(output);
105
+ } else {
106
+ const logObj = {
107
+ timestamp,
108
+ level,
109
+ module: this.moduleContext,
110
+ message: msg,
111
+ ...data && { data }
112
+ };
113
+ consoleMethod(JSON.stringify(logObj));
114
+ }
115
+ }
116
+ debug(...args) {
117
+ this.writeLog("debug", ...args);
88
118
  }
89
119
  info(...args) {
90
- const { msg, data } = this.formatArgs(args);
91
- const logObj = { module: this.moduleContext, ...data && { data } };
92
- this.logger.info(logObj, msg);
120
+ this.writeLog("info", ...args);
93
121
  }
94
122
  warn(...args) {
95
- const { msg, data } = this.formatArgs(args);
96
- const logObj = { module: this.moduleContext, ...data && { data } };
97
- this.logger.warn(logObj, msg);
123
+ this.writeLog("warn", ...args);
98
124
  }
99
125
  error(...args) {
100
- const { msg, data } = this.formatArgs(args);
101
- const logObj = { module: this.moduleContext, ...data && { data } };
102
- this.logger.error(logObj, msg);
126
+ this.writeLog("error", ...args);
103
127
  }
104
128
  trace(...args) {
105
- const { msg, data } = this.formatArgs(args);
106
- const logObj = { module: this.moduleContext, ...data && { data } };
107
- this.logger.trace(logObj, msg);
129
+ this.writeLog("trace", ...args);
108
130
  }
109
131
  /**
110
132
  * Clear all logger instances