@hashgraphonline/standards-sdk 0.1.103-canary.2 → 0.1.103-canary.5
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/es/standards-sdk.es108.js +1 -1
- package/dist/es/standards-sdk.es109.js +1 -1
- package/dist/es/standards-sdk.es110.js +5 -5
- package/dist/es/standards-sdk.es112.js +1 -1
- package/dist/es/standards-sdk.es123.js +53 -201
- package/dist/es/standards-sdk.es123.js.map +1 -1
- package/dist/es/standards-sdk.es124.js +167 -51
- package/dist/es/standards-sdk.es124.js.map +1 -1
- package/dist/es/standards-sdk.es125.js +289 -139
- package/dist/es/standards-sdk.es125.js.map +1 -1
- package/dist/es/standards-sdk.es126.js +298 -274
- package/dist/es/standards-sdk.es126.js.map +1 -1
- package/dist/es/standards-sdk.es127.js +369 -262
- package/dist/es/standards-sdk.es127.js.map +1 -1
- package/dist/es/standards-sdk.es128.js +194 -316
- package/dist/es/standards-sdk.es128.js.map +1 -1
- package/dist/es/standards-sdk.es129.js +64 -319
- package/dist/es/standards-sdk.es129.js.map +1 -1
- package/dist/es/standards-sdk.es130.js +194 -66
- package/dist/es/standards-sdk.es130.js.map +1 -1
- package/dist/es/standards-sdk.es51.js +1 -1
- package/dist/es/standards-sdk.es53.js +1 -1
- package/dist/es/standards-sdk.es98.js +5 -5
- package/package.json +1 -1
|
@@ -1,79 +1,207 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (!bytes) {
|
|
1
|
+
import { I as InscriptionSDK } from "./standards-sdk.es119.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) {
|
|
47
46
|
return null;
|
|
48
47
|
}
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
48
|
+
const now = Date.now();
|
|
49
|
+
if (now - entry.timestamp > entry.ttlMs) {
|
|
50
|
+
this.cache.delete(cacheKey);
|
|
51
51
|
return null;
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
+
}
|
|
56
67
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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);
|
|
63
119
|
}
|
|
64
120
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
121
|
+
this.cache.set(configKey, {
|
|
122
|
+
sdk,
|
|
123
|
+
timestamp: Date.now(),
|
|
124
|
+
config: configKey
|
|
125
|
+
});
|
|
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;
|
|
68
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);
|
|
69
170
|
}
|
|
70
|
-
function
|
|
71
|
-
const
|
|
72
|
-
|
|
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
|
+
}
|
|
199
|
+
}
|
|
73
200
|
}
|
|
74
201
|
export {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
202
|
+
cacheQuote,
|
|
203
|
+
getCachedQuote,
|
|
204
|
+
getOrCreateSDK,
|
|
205
|
+
validateQuoteParameters
|
|
78
206
|
};
|
|
79
207
|
//# sourceMappingURL=standards-sdk.es130.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es130.js","sources":["../../src/utils/parsers/parser-utils.ts"],"sourcesContent":["import { proto } from '@hashgraph/proto';\nimport { ContractId, Transaction } from '@hashgraph/sdk';\nimport { Buffer } from 'buffer';\n\nexport function parseKey(\n key: proto.IKey | null | undefined,\n): string | undefined {\n if (!key) {\n return undefined;\n }\n\n if (key.contractID) {\n return `ContractID: ${new ContractId(\n key.contractID.shardNum ?? 0,\n key.contractID.realmNum ?? 0,\n key.contractID.contractNum ?? 0,\n ).toString()}`;\n }\n if (key.ed25519) {\n return `ED25519: ${Buffer.from(key.ed25519).toString('hex')}`;\n }\n if (key.ECDSASecp256k1) {\n return `ECDSA_secp256k1: ${Buffer.from(key.ECDSASecp256k1).toString(\n 'hex',\n )}`;\n }\n if (key?.keyList?.keys?.length > 0) {\n const keys = key.keyList.keys.map(k => parseKey(k)).filter(Boolean);\n return `KeyList (${keys.length} keys): [${keys.join(', ')}]`;\n }\n if (key?.thresholdKey?.keys?.keys?.length > 0) {\n const keys = key.thresholdKey.keys.keys\n .map(k => parseKey(k))\n .filter(Boolean);\n return `ThresholdKey (${key.thresholdKey.threshold} of ${\n keys.length\n }): [${keys.join(', ')}]`;\n }\n if (key.delegatableContractId) {\n return `DelegatableContractID: ${new ContractId(\n key.delegatableContractId.shardNum ?? 0,\n key.delegatableContractId.realmNum ?? 0,\n key.delegatableContractId.contractNum ?? 0,\n ).toString()}`;\n }\n if (Object.keys(key).length === 0) {\n return 'Empty Key Structure';\n }\n\n return 'Unknown or Unset Key Type';\n}\n\n/**\n * Extract TransactionBody from Transaction object using protobuf parsing\n * This replaces fragile constructor name checking with reliable protobuf data\n */\nexport function extractTransactionBody(\n transaction: Transaction,\n): proto.ITransactionBody | null {\n try {\n const bytes = transaction.toBytes ? transaction.toBytes() : undefined;\n if (!bytes) {\n return null;\n }\n\n const decoded = proto.TransactionList.decode(bytes);\n if (!decoded.transactionList || decoded.transactionList.length === 0) {\n return null;\n }\n\n const tx = decoded.transactionList[0];\n\n if (tx.bodyBytes && tx.bodyBytes.length > 0) {\n return proto.TransactionBody.decode(tx.bodyBytes);\n }\n\n if (tx.signedTransactionBytes && tx.signedTransactionBytes.length > 0) {\n const signedTx = proto.SignedTransaction.decode(\n tx.signedTransactionBytes,\n );\n if (signedTx.bodyBytes) {\n return proto.TransactionBody.decode(signedTx.bodyBytes);\n }\n }\n\n return null;\n } catch (error) {\n return null;\n }\n}\n\n/**\n * Check if transaction has specific transaction type using protobuf data\n * This replaces constructor name checking with reliable protobuf field detection\n */\nexport function hasTransactionType(\n transaction: Transaction,\n transactionField: keyof proto.ITransactionBody,\n): boolean {\n const txBody = extractTransactionBody(transaction);\n return !!(txBody && txBody[transactionField]);\n}\n"],"names":[],"mappings":";;;AAIO,SAAS,SACd,KACoB;AACpB,MAAI,CAAC,KAAK;A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,OAAO;AACV,aAAO;AAAA,IACT;AAEA,UAAM,UAAU,MAAM,gBAAgB,OAAO,KAAK;AAClD,QAAI,CAAC,QAAQ,mBAAmB,QAAQ,gBAAgB,WAAW,GAAG;AACpE,aAAO;AAAA,IACT;AAEA,UAAM,KAAK,QAAQ,gBAAgB,CAAC;AAEpC,QAAI,GAAG,aAAa,GAAG,UAAU,SAAS,GAAG;AAC3C,aAAO,MAAM,gBAAgB,OAAO,GAAG,SAAS;AAAA,IAClD;AAEA,QAAI,GAAG,0BAA0B,GAAG,uBAAuB,SAAS,GAAG;AACrE,YAAM,WAAW,MAAM,kBAAkB;AAAA,QACvC,GAAG;AAAA,MAAA;AAEL,UAAI,SAAS,WAAW;AACtB,eAAO,MAAM,gBAAgB,OAAO,SAAS,SAAS;AAAA,MACxD;AAAA,IACF;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,WAAO;AAAA,EACT;AACF;AAMO,SAAS,mBACd,aACA,kBACS;AACT,QAAM,SAAS,uBAAuB,WAAW;AACjD,SAAO,CAAC,EAAE,UAAU,OAAO,gBAAgB;AAC7C;"}
|
|
1
|
+
{"version":3,"file":"standards-sdk.es130.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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AAI,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,5 +1,5 @@
|
|
|
1
1
|
import { getCryptoAdapter } from "./standards-sdk.es107.js";
|
|
2
|
-
import { base58Encode } from "./standards-sdk.
|
|
2
|
+
import { base58Encode } from "./standards-sdk.es123.js";
|
|
3
3
|
import { canonicalizeAgentData } from "./standards-sdk.es50.js";
|
|
4
4
|
function encodeMultibaseB58btc(input) {
|
|
5
5
|
const bytes = Buffer.from(input, "utf8");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HieroDidResolver } from "./standards-sdk.es54.js";
|
|
2
2
|
import { parseHcs14Did } from "./standards-sdk.es51.js";
|
|
3
|
-
import { multibaseB58btcDecode } from "./standards-sdk.
|
|
3
|
+
import { multibaseB58btcDecode } from "./standards-sdk.es123.js";
|
|
4
4
|
class ResolverRegistry {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.resolvers = [];
|
|
@@ -5,11 +5,11 @@ import { ethers } from "ethers";
|
|
|
5
5
|
import { TransactionParsingError } from "./standards-sdk.es99.js";
|
|
6
6
|
import { resolveTransactionSummary } from "./standards-sdk.es100.js";
|
|
7
7
|
import { HTSParser } from "./standards-sdk.es108.js";
|
|
8
|
-
import { HCSParser } from "./standards-sdk.
|
|
9
|
-
import { FileParser } from "./standards-sdk.
|
|
10
|
-
import { CryptoParser } from "./standards-sdk.
|
|
11
|
-
import { SCSParser } from "./standards-sdk.
|
|
12
|
-
import { UtilParser } from "./standards-sdk.
|
|
8
|
+
import { HCSParser } from "./standards-sdk.es124.js";
|
|
9
|
+
import { FileParser } from "./standards-sdk.es125.js";
|
|
10
|
+
import { CryptoParser } from "./standards-sdk.es126.js";
|
|
11
|
+
import { SCSParser } from "./standards-sdk.es127.js";
|
|
12
|
+
import { UtilParser } from "./standards-sdk.es128.js";
|
|
13
13
|
import { ScheduleParser } from "./standards-sdk.es109.js";
|
|
14
14
|
import { transactionParserRegistry } from "./standards-sdk.es110.js";
|
|
15
15
|
import { getTransactionTypeFromBody, getHumanReadableTransactionType } from "./standards-sdk.es111.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hashgraphonline/standards-sdk",
|
|
3
|
-
"version": "0.1.103-canary.
|
|
3
|
+
"version": "0.1.103-canary.5",
|
|
4
4
|
"description": "The Hashgraph Online Standards SDK provides a complete implementation of the Hashgraph Consensus Standards (HCS), giving developers all the tools needed to build applications on Hedera.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|