@hashgraphonline/standards-sdk 0.0.41 → 0.0.43
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/hcs-10/base-client.d.ts +3 -4
- package/dist/es/hcs-10/browser.d.ts +41 -42
- package/dist/es/hcs-10/registrations.d.ts +36 -0
- package/dist/es/hcs-10/sdk.d.ts +1 -1
- package/dist/es/hcs-11/index.d.ts +30 -4
- package/dist/es/index.d.ts +0 -2
- package/dist/es/inscribe/types.d.ts +0 -2
- package/dist/es/services/mirror-node.d.ts +4 -130
- package/dist/es/services/types.d.ts +139 -0
- package/dist/es/standards-sdk.es.js +954 -296
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/es/utils/logger.d.ts +4 -17
- package/dist/es/utils/progress-reporter.d.ts +1 -1
- package/dist/umd/hcs-10/base-client.d.ts +3 -4
- package/dist/umd/hcs-10/browser.d.ts +41 -42
- package/dist/umd/hcs-10/registrations.d.ts +36 -0
- package/dist/umd/hcs-10/sdk.d.ts +1 -1
- package/dist/umd/hcs-11/index.d.ts +30 -4
- package/dist/umd/index.d.ts +0 -2
- package/dist/umd/inscribe/types.d.ts +0 -2
- package/dist/umd/services/mirror-node.d.ts +4 -130
- package/dist/umd/services/types.d.ts +139 -0
- package/dist/umd/standards-sdk.umd.js +5 -5
- package/dist/umd/standards-sdk.umd.js.map +1 -1
- package/dist/umd/utils/logger.d.ts +4 -17
- package/dist/umd/utils/progress-reporter.d.ts +1 -1
- package/package.json +3 -1
|
@@ -17,92 +17,639 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
17
17
|
return __privateGet(obj, member, getter);
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
var _names, _data, _dataLength, _Writer_instances, writeData_fn, _data2, _offset, _bytesRead, _parent, _maxInflation, _Reader_instances, incrementBytesRead_fn, peekBytes_fn, _options, _offset2, _tokens, _TokenString_instances, subTokenString_fn, _ParamType_instances, walkAsync_fn, _AbiCoder_instances, getCoder_fn, _errors, _events, _functions, _abiCoder, _Interface_instances, getFunction_fn, getEvent_fn;
|
|
21
|
-
import { ContractId, AccountId, Client, PrivateKey, Transaction, PublicKey, Status, AccountUpdateTransaction, AccountCreateTransaction, Hbar, CustomFixedFee, KeyList, TopicCreateTransaction, TopicMessageSubmitTransaction, TopicId } from "@hashgraph/sdk";
|
|
20
|
+
var _a, _names, _data, _dataLength, _Writer_instances, writeData_fn, _data2, _offset, _bytesRead, _parent, _maxInflation, _Reader_instances, incrementBytesRead_fn, peekBytes_fn, _options, _offset2, _tokens, _TokenString_instances, subTokenString_fn, _ParamType_instances, walkAsync_fn, _AbiCoder_instances, getCoder_fn, _errors, _events, _functions, _abiCoder, _Interface_instances, getFunction_fn, getEvent_fn;
|
|
21
|
+
import { ContractId, AccountId, Client, PrivateKey, Transaction, PublicKey, Timestamp, Status, AccountUpdateTransaction, AccountCreateTransaction, Hbar, CustomFixedFee, KeyList, TopicCreateTransaction, TopicMessageSubmitTransaction, TopicId } from "@hashgraph/sdk";
|
|
22
22
|
import { proto } from "@hashgraph/proto";
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
function getDefaultExportFromCjs$1(x) {
|
|
24
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
25
|
+
}
|
|
26
|
+
function getAugmentedNamespace(n2) {
|
|
27
|
+
if (Object.prototype.hasOwnProperty.call(n2, "__esModule")) return n2;
|
|
28
|
+
var f = n2.default;
|
|
29
|
+
if (typeof f == "function") {
|
|
30
|
+
var a = function a2() {
|
|
31
|
+
if (this instanceof a2) {
|
|
32
|
+
return Reflect.construct(f, arguments, this.constructor);
|
|
33
|
+
}
|
|
34
|
+
return f.apply(this, arguments);
|
|
35
|
+
};
|
|
36
|
+
a.prototype = f.prototype;
|
|
37
|
+
} else a = {};
|
|
38
|
+
Object.defineProperty(a, "__esModule", { value: true });
|
|
39
|
+
Object.keys(n2).forEach(function(k) {
|
|
40
|
+
var d = Object.getOwnPropertyDescriptor(n2, k);
|
|
41
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function() {
|
|
44
|
+
return n2[k];
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
return a;
|
|
49
|
+
}
|
|
50
|
+
var browser$1 = { exports: {} };
|
|
51
|
+
var quickFormatUnescaped;
|
|
52
|
+
var hasRequiredQuickFormatUnescaped;
|
|
53
|
+
function requireQuickFormatUnescaped() {
|
|
54
|
+
if (hasRequiredQuickFormatUnescaped) return quickFormatUnescaped;
|
|
55
|
+
hasRequiredQuickFormatUnescaped = 1;
|
|
56
|
+
function tryStringify(o) {
|
|
57
|
+
try {
|
|
58
|
+
return JSON.stringify(o);
|
|
59
|
+
} catch (e) {
|
|
60
|
+
return '"[Circular]"';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
quickFormatUnescaped = format;
|
|
64
|
+
function format(f, args, opts) {
|
|
65
|
+
var ss = opts && opts.stringify || tryStringify;
|
|
66
|
+
var offset = 1;
|
|
67
|
+
if (typeof f === "object" && f !== null) {
|
|
68
|
+
var len = args.length + offset;
|
|
69
|
+
if (len === 1) return f;
|
|
70
|
+
var objects = new Array(len);
|
|
71
|
+
objects[0] = ss(f);
|
|
72
|
+
for (var index = 1; index < len; index++) {
|
|
73
|
+
objects[index] = ss(args[index]);
|
|
74
|
+
}
|
|
75
|
+
return objects.join(" ");
|
|
76
|
+
}
|
|
77
|
+
if (typeof f !== "string") {
|
|
78
|
+
return f;
|
|
79
|
+
}
|
|
80
|
+
var argLen = args.length;
|
|
81
|
+
if (argLen === 0) return f;
|
|
82
|
+
var str = "";
|
|
83
|
+
var a = 1 - offset;
|
|
84
|
+
var lastPos = -1;
|
|
85
|
+
var flen = f && f.length || 0;
|
|
86
|
+
for (var i = 0; i < flen; ) {
|
|
87
|
+
if (f.charCodeAt(i) === 37 && i + 1 < flen) {
|
|
88
|
+
lastPos = lastPos > -1 ? lastPos : 0;
|
|
89
|
+
switch (f.charCodeAt(i + 1)) {
|
|
90
|
+
case 100:
|
|
91
|
+
// 'd'
|
|
92
|
+
case 102:
|
|
93
|
+
if (a >= argLen)
|
|
94
|
+
break;
|
|
95
|
+
if (args[a] == null) break;
|
|
96
|
+
if (lastPos < i)
|
|
97
|
+
str += f.slice(lastPos, i);
|
|
98
|
+
str += Number(args[a]);
|
|
99
|
+
lastPos = i + 2;
|
|
100
|
+
i++;
|
|
101
|
+
break;
|
|
102
|
+
case 105:
|
|
103
|
+
if (a >= argLen)
|
|
104
|
+
break;
|
|
105
|
+
if (args[a] == null) break;
|
|
106
|
+
if (lastPos < i)
|
|
107
|
+
str += f.slice(lastPos, i);
|
|
108
|
+
str += Math.floor(Number(args[a]));
|
|
109
|
+
lastPos = i + 2;
|
|
110
|
+
i++;
|
|
111
|
+
break;
|
|
112
|
+
case 79:
|
|
113
|
+
// 'O'
|
|
114
|
+
case 111:
|
|
115
|
+
// 'o'
|
|
116
|
+
case 106:
|
|
117
|
+
if (a >= argLen)
|
|
118
|
+
break;
|
|
119
|
+
if (args[a] === void 0) break;
|
|
120
|
+
if (lastPos < i)
|
|
121
|
+
str += f.slice(lastPos, i);
|
|
122
|
+
var type = typeof args[a];
|
|
123
|
+
if (type === "string") {
|
|
124
|
+
str += "'" + args[a] + "'";
|
|
125
|
+
lastPos = i + 2;
|
|
126
|
+
i++;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
if (type === "function") {
|
|
130
|
+
str += args[a].name || "<anonymous>";
|
|
131
|
+
lastPos = i + 2;
|
|
132
|
+
i++;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
str += ss(args[a]);
|
|
136
|
+
lastPos = i + 2;
|
|
137
|
+
i++;
|
|
138
|
+
break;
|
|
139
|
+
case 115:
|
|
140
|
+
if (a >= argLen)
|
|
141
|
+
break;
|
|
142
|
+
if (lastPos < i)
|
|
143
|
+
str += f.slice(lastPos, i);
|
|
144
|
+
str += String(args[a]);
|
|
145
|
+
lastPos = i + 2;
|
|
146
|
+
i++;
|
|
147
|
+
break;
|
|
148
|
+
case 37:
|
|
149
|
+
if (lastPos < i)
|
|
150
|
+
str += f.slice(lastPos, i);
|
|
151
|
+
str += "%";
|
|
152
|
+
lastPos = i + 2;
|
|
153
|
+
i++;
|
|
154
|
+
a--;
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
++a;
|
|
158
|
+
}
|
|
159
|
+
++i;
|
|
160
|
+
}
|
|
161
|
+
if (lastPos === -1)
|
|
162
|
+
return f;
|
|
163
|
+
else if (lastPos < flen) {
|
|
164
|
+
str += f.slice(lastPos);
|
|
165
|
+
}
|
|
166
|
+
return str;
|
|
167
|
+
}
|
|
168
|
+
return quickFormatUnescaped;
|
|
169
|
+
}
|
|
170
|
+
var hasRequiredBrowser$1;
|
|
171
|
+
function requireBrowser$1() {
|
|
172
|
+
if (hasRequiredBrowser$1) return browser$1.exports;
|
|
173
|
+
hasRequiredBrowser$1 = 1;
|
|
174
|
+
const format = requireQuickFormatUnescaped();
|
|
175
|
+
browser$1.exports = pino2;
|
|
176
|
+
const _console = pfGlobalThisOrFallback().console || {};
|
|
177
|
+
const stdSerializers = {
|
|
178
|
+
mapHttpRequest: mock,
|
|
179
|
+
mapHttpResponse: mock,
|
|
180
|
+
wrapRequestSerializer: passthrough,
|
|
181
|
+
wrapResponseSerializer: passthrough,
|
|
182
|
+
wrapErrorSerializer: passthrough,
|
|
183
|
+
req: mock,
|
|
184
|
+
res: mock,
|
|
185
|
+
err: asErrValue,
|
|
186
|
+
errWithCause: asErrValue
|
|
187
|
+
};
|
|
188
|
+
function levelToValue(level, logger) {
|
|
189
|
+
return level === "silent" ? Infinity : logger.levels.values[level];
|
|
190
|
+
}
|
|
191
|
+
const baseLogFunctionSymbol = Symbol("pino.logFuncs");
|
|
192
|
+
const hierarchySymbol = Symbol("pino.hierarchy");
|
|
193
|
+
const logFallbackMap = {
|
|
194
|
+
error: "log",
|
|
195
|
+
fatal: "error",
|
|
196
|
+
warn: "error",
|
|
197
|
+
info: "log",
|
|
198
|
+
debug: "log",
|
|
199
|
+
trace: "log"
|
|
200
|
+
};
|
|
201
|
+
function appendChildLogger(parentLogger, childLogger) {
|
|
202
|
+
const newEntry = {
|
|
203
|
+
logger: childLogger,
|
|
204
|
+
parent: parentLogger[hierarchySymbol]
|
|
205
|
+
};
|
|
206
|
+
childLogger[hierarchySymbol] = newEntry;
|
|
29
207
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
208
|
+
function setupBaseLogFunctions(logger, levels, proto2) {
|
|
209
|
+
const logFunctions = {};
|
|
210
|
+
levels.forEach((level) => {
|
|
211
|
+
logFunctions[level] = proto2[level] ? proto2[level] : _console[level] || _console[logFallbackMap[level] || "log"] || noop2;
|
|
212
|
+
});
|
|
213
|
+
logger[baseLogFunctionSymbol] = logFunctions;
|
|
214
|
+
}
|
|
215
|
+
function shouldSerialize(serialize, serializers) {
|
|
216
|
+
if (Array.isArray(serialize)) {
|
|
217
|
+
const hasToFilter = serialize.filter(function(k) {
|
|
218
|
+
return k !== "!stdSerializers.err";
|
|
219
|
+
});
|
|
220
|
+
return hasToFilter;
|
|
221
|
+
} else if (serialize === true) {
|
|
222
|
+
return Object.keys(serializers);
|
|
33
223
|
}
|
|
34
|
-
return
|
|
224
|
+
return false;
|
|
35
225
|
}
|
|
36
|
-
|
|
37
|
-
|
|
226
|
+
function pino2(opts) {
|
|
227
|
+
opts = opts || {};
|
|
228
|
+
opts.browser = opts.browser || {};
|
|
229
|
+
const transmit2 = opts.browser.transmit;
|
|
230
|
+
if (transmit2 && typeof transmit2.send !== "function") {
|
|
231
|
+
throw Error("pino: transmit option must have a send function");
|
|
232
|
+
}
|
|
233
|
+
const proto2 = opts.browser.write || _console;
|
|
234
|
+
if (opts.browser.write) opts.browser.asObject = true;
|
|
235
|
+
const serializers = opts.serializers || {};
|
|
236
|
+
const serialize = shouldSerialize(opts.browser.serialize, serializers);
|
|
237
|
+
let stdErrSerialize = opts.browser.serialize;
|
|
238
|
+
if (Array.isArray(opts.browser.serialize) && opts.browser.serialize.indexOf("!stdSerializers.err") > -1) stdErrSerialize = false;
|
|
239
|
+
const customLevels = Object.keys(opts.customLevels || {});
|
|
240
|
+
const levels = ["error", "fatal", "warn", "info", "debug", "trace"].concat(customLevels);
|
|
241
|
+
if (typeof proto2 === "function") {
|
|
242
|
+
levels.forEach(function(level2) {
|
|
243
|
+
proto2[level2] = proto2;
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
if (opts.enabled === false || opts.browser.disabled) opts.level = "silent";
|
|
247
|
+
const level = opts.level || "info";
|
|
248
|
+
const logger = Object.create(proto2);
|
|
249
|
+
if (!logger.log) logger.log = noop2;
|
|
250
|
+
setupBaseLogFunctions(logger, levels, proto2);
|
|
251
|
+
appendChildLogger({}, logger);
|
|
252
|
+
Object.defineProperty(logger, "levelVal", {
|
|
253
|
+
get: getLevelVal
|
|
254
|
+
});
|
|
255
|
+
Object.defineProperty(logger, "level", {
|
|
256
|
+
get: getLevel,
|
|
257
|
+
set: setLevel
|
|
258
|
+
});
|
|
259
|
+
const setOpts = {
|
|
260
|
+
transmit: transmit2,
|
|
261
|
+
serialize,
|
|
262
|
+
asObject: opts.browser.asObject,
|
|
263
|
+
formatters: opts.browser.formatters,
|
|
264
|
+
levels,
|
|
265
|
+
timestamp: getTimeFunction(opts),
|
|
266
|
+
messageKey: opts.messageKey || "msg",
|
|
267
|
+
onChild: opts.onChild || noop2
|
|
268
|
+
};
|
|
269
|
+
logger.levels = getLevels(opts);
|
|
270
|
+
logger.level = level;
|
|
271
|
+
logger.setMaxListeners = logger.getMaxListeners = logger.emit = logger.addListener = logger.on = logger.prependListener = logger.once = logger.prependOnceListener = logger.removeListener = logger.removeAllListeners = logger.listeners = logger.listenerCount = logger.eventNames = logger.write = logger.flush = noop2;
|
|
272
|
+
logger.serializers = serializers;
|
|
273
|
+
logger._serialize = serialize;
|
|
274
|
+
logger._stdErrSerialize = stdErrSerialize;
|
|
275
|
+
logger.child = function(...args) {
|
|
276
|
+
return child.call(this, setOpts, ...args);
|
|
277
|
+
};
|
|
278
|
+
if (transmit2) logger._logEvent = createLogEventShape();
|
|
279
|
+
function getLevelVal() {
|
|
280
|
+
return levelToValue(this.level, this);
|
|
281
|
+
}
|
|
282
|
+
function getLevel() {
|
|
283
|
+
return this._level;
|
|
284
|
+
}
|
|
285
|
+
function setLevel(level2) {
|
|
286
|
+
if (level2 !== "silent" && !this.levels.values[level2]) {
|
|
287
|
+
throw Error("unknown level " + level2);
|
|
288
|
+
}
|
|
289
|
+
this._level = level2;
|
|
290
|
+
set(this, setOpts, logger, "error");
|
|
291
|
+
set(this, setOpts, logger, "fatal");
|
|
292
|
+
set(this, setOpts, logger, "warn");
|
|
293
|
+
set(this, setOpts, logger, "info");
|
|
294
|
+
set(this, setOpts, logger, "debug");
|
|
295
|
+
set(this, setOpts, logger, "trace");
|
|
296
|
+
customLevels.forEach((level3) => {
|
|
297
|
+
set(this, setOpts, logger, level3);
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
function child(setOpts2, bindings, childOptions) {
|
|
301
|
+
if (!bindings) {
|
|
302
|
+
throw new Error("missing bindings for child Pino");
|
|
303
|
+
}
|
|
304
|
+
childOptions = childOptions || {};
|
|
305
|
+
if (serialize && bindings.serializers) {
|
|
306
|
+
childOptions.serializers = bindings.serializers;
|
|
307
|
+
}
|
|
308
|
+
const childOptionsSerializers = childOptions.serializers;
|
|
309
|
+
if (serialize && childOptionsSerializers) {
|
|
310
|
+
var childSerializers = Object.assign({}, serializers, childOptionsSerializers);
|
|
311
|
+
var childSerialize = opts.browser.serialize === true ? Object.keys(childSerializers) : serialize;
|
|
312
|
+
delete bindings.serializers;
|
|
313
|
+
applySerializers([bindings], childSerialize, childSerializers, this._stdErrSerialize);
|
|
314
|
+
}
|
|
315
|
+
function Child(parent) {
|
|
316
|
+
this._childLevel = (parent._childLevel | 0) + 1;
|
|
317
|
+
this.bindings = bindings;
|
|
318
|
+
if (childSerializers) {
|
|
319
|
+
this.serializers = childSerializers;
|
|
320
|
+
this._serialize = childSerialize;
|
|
321
|
+
}
|
|
322
|
+
if (transmit2) {
|
|
323
|
+
this._logEvent = createLogEventShape(
|
|
324
|
+
[].concat(parent._logEvent.bindings, bindings)
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
Child.prototype = this;
|
|
329
|
+
const newLogger = new Child(this);
|
|
330
|
+
appendChildLogger(this, newLogger);
|
|
331
|
+
newLogger.child = function(...args) {
|
|
332
|
+
return child.call(this, setOpts2, ...args);
|
|
333
|
+
};
|
|
334
|
+
newLogger.level = childOptions.level || this.level;
|
|
335
|
+
setOpts2.onChild(newLogger);
|
|
336
|
+
return newLogger;
|
|
337
|
+
}
|
|
338
|
+
return logger;
|
|
38
339
|
}
|
|
39
|
-
|
|
40
|
-
|
|
340
|
+
function getLevels(opts) {
|
|
341
|
+
const customLevels = opts.customLevels || {};
|
|
342
|
+
const values = Object.assign({}, pino2.levels.values, customLevels);
|
|
343
|
+
const labels = Object.assign({}, pino2.levels.labels, invertObject(customLevels));
|
|
344
|
+
return {
|
|
345
|
+
values,
|
|
346
|
+
labels
|
|
347
|
+
};
|
|
41
348
|
}
|
|
42
|
-
|
|
43
|
-
|
|
349
|
+
function invertObject(obj) {
|
|
350
|
+
const inverted = {};
|
|
351
|
+
Object.keys(obj).forEach(function(key) {
|
|
352
|
+
inverted[obj[key]] = key;
|
|
353
|
+
});
|
|
354
|
+
return inverted;
|
|
355
|
+
}
|
|
356
|
+
pino2.levels = {
|
|
357
|
+
values: {
|
|
358
|
+
fatal: 60,
|
|
359
|
+
error: 50,
|
|
360
|
+
warn: 40,
|
|
361
|
+
info: 30,
|
|
362
|
+
debug: 20,
|
|
363
|
+
trace: 10
|
|
364
|
+
},
|
|
365
|
+
labels: {
|
|
366
|
+
10: "trace",
|
|
367
|
+
20: "debug",
|
|
368
|
+
30: "info",
|
|
369
|
+
40: "warn",
|
|
370
|
+
50: "error",
|
|
371
|
+
60: "fatal"
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
pino2.stdSerializers = stdSerializers;
|
|
375
|
+
pino2.stdTimeFunctions = Object.assign({}, { nullTime, epochTime, unixTime, isoTime });
|
|
376
|
+
function getBindingChain(logger) {
|
|
377
|
+
const bindings = [];
|
|
378
|
+
if (logger.bindings) {
|
|
379
|
+
bindings.push(logger.bindings);
|
|
380
|
+
}
|
|
381
|
+
let hierarchy = logger[hierarchySymbol];
|
|
382
|
+
while (hierarchy.parent) {
|
|
383
|
+
hierarchy = hierarchy.parent;
|
|
384
|
+
if (hierarchy.logger.bindings) {
|
|
385
|
+
bindings.push(hierarchy.logger.bindings);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return bindings.reverse();
|
|
389
|
+
}
|
|
390
|
+
function set(self2, opts, rootLogger, level) {
|
|
391
|
+
Object.defineProperty(self2, level, {
|
|
392
|
+
value: levelToValue(self2.level, rootLogger) > levelToValue(level, rootLogger) ? noop2 : rootLogger[baseLogFunctionSymbol][level],
|
|
393
|
+
writable: true,
|
|
394
|
+
enumerable: true,
|
|
395
|
+
configurable: true
|
|
396
|
+
});
|
|
397
|
+
if (self2[level] === noop2) {
|
|
398
|
+
if (!opts.transmit) return;
|
|
399
|
+
const transmitLevel = opts.transmit.level || self2.level;
|
|
400
|
+
const transmitValue = levelToValue(transmitLevel, rootLogger);
|
|
401
|
+
const methodValue = levelToValue(level, rootLogger);
|
|
402
|
+
if (methodValue < transmitValue) return;
|
|
403
|
+
}
|
|
404
|
+
self2[level] = createWrap(self2, opts, rootLogger, level);
|
|
405
|
+
const bindings = getBindingChain(self2);
|
|
406
|
+
if (bindings.length === 0) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
self2[level] = prependBindingsInArguments(bindings, self2[level]);
|
|
44
410
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
411
|
+
function prependBindingsInArguments(bindings, logFunc) {
|
|
412
|
+
return function() {
|
|
413
|
+
return logFunc.apply(this, [...bindings, ...arguments]);
|
|
414
|
+
};
|
|
49
415
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
416
|
+
function createWrap(self2, opts, rootLogger, level) {
|
|
417
|
+
return /* @__PURE__ */ function(write) {
|
|
418
|
+
return function LOG() {
|
|
419
|
+
const ts = opts.timestamp();
|
|
420
|
+
const args = new Array(arguments.length);
|
|
421
|
+
const proto2 = Object.getPrototypeOf && Object.getPrototypeOf(this) === _console ? _console : this;
|
|
422
|
+
for (var i = 0; i < args.length; i++) args[i] = arguments[i];
|
|
423
|
+
var argsIsSerialized = false;
|
|
424
|
+
if (opts.serialize) {
|
|
425
|
+
applySerializers(args, this._serialize, this.serializers, this._stdErrSerialize);
|
|
426
|
+
argsIsSerialized = true;
|
|
427
|
+
}
|
|
428
|
+
if (opts.asObject || opts.formatters) {
|
|
429
|
+
write.call(proto2, asObject(this, level, args, ts, opts));
|
|
430
|
+
} else write.apply(proto2, args);
|
|
431
|
+
if (opts.transmit) {
|
|
432
|
+
const transmitLevel = opts.transmit.level || self2._level;
|
|
433
|
+
const transmitValue = levelToValue(transmitLevel, rootLogger);
|
|
434
|
+
const methodValue = levelToValue(level, rootLogger);
|
|
435
|
+
if (methodValue < transmitValue) return;
|
|
436
|
+
transmit(this, {
|
|
437
|
+
ts,
|
|
438
|
+
methodLevel: level,
|
|
439
|
+
methodValue,
|
|
440
|
+
transmitValue: rootLogger.levels.values[opts.transmit.level || self2._level],
|
|
441
|
+
send: opts.transmit.send,
|
|
442
|
+
val: levelToValue(self2._level, rootLogger)
|
|
443
|
+
}, args, argsIsSerialized);
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
}(self2[baseLogFunctionSymbol][level]);
|
|
447
|
+
}
|
|
448
|
+
function asObject(logger, level, args, ts, opts) {
|
|
449
|
+
const {
|
|
450
|
+
level: levelFormatter,
|
|
451
|
+
log: logObjectFormatter = (obj) => obj
|
|
452
|
+
} = opts.formatters || {};
|
|
453
|
+
const argsCloned = args.slice();
|
|
454
|
+
let msg = argsCloned[0];
|
|
455
|
+
const logObject = {};
|
|
456
|
+
if (ts) {
|
|
457
|
+
logObject.time = ts;
|
|
458
|
+
}
|
|
459
|
+
if (levelFormatter) {
|
|
460
|
+
const formattedLevel = levelFormatter(level, logger.levels.values[level]);
|
|
461
|
+
Object.assign(logObject, formattedLevel);
|
|
462
|
+
} else {
|
|
463
|
+
logObject.level = logger.levels.values[level];
|
|
464
|
+
}
|
|
465
|
+
let lvl = (logger._childLevel | 0) + 1;
|
|
466
|
+
if (lvl < 1) lvl = 1;
|
|
467
|
+
if (msg !== null && typeof msg === "object") {
|
|
468
|
+
while (lvl-- && typeof argsCloned[0] === "object") {
|
|
469
|
+
Object.assign(logObject, argsCloned.shift());
|
|
470
|
+
}
|
|
471
|
+
msg = argsCloned.length ? format(argsCloned.shift(), argsCloned) : void 0;
|
|
472
|
+
} else if (typeof msg === "string") msg = format(argsCloned.shift(), argsCloned);
|
|
473
|
+
if (msg !== void 0) logObject[opts.messageKey] = msg;
|
|
474
|
+
const formattedLogObject = logObjectFormatter(logObject);
|
|
475
|
+
return formattedLogObject;
|
|
476
|
+
}
|
|
477
|
+
function applySerializers(args, serialize, serializers, stdErrSerialize) {
|
|
478
|
+
for (const i in args) {
|
|
479
|
+
if (stdErrSerialize && args[i] instanceof Error) {
|
|
480
|
+
args[i] = pino2.stdSerializers.err(args[i]);
|
|
481
|
+
} else if (typeof args[i] === "object" && !Array.isArray(args[i]) && serialize) {
|
|
482
|
+
for (const k in args[i]) {
|
|
483
|
+
if (serialize.indexOf(k) > -1 && k in serializers) {
|
|
484
|
+
args[i][k] = serializers[k](args[i][k]);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
function transmit(logger, opts, args, argsIsSerialized = false) {
|
|
491
|
+
const send = opts.send;
|
|
492
|
+
const ts = opts.ts;
|
|
493
|
+
const methodLevel = opts.methodLevel;
|
|
494
|
+
const methodValue = opts.methodValue;
|
|
495
|
+
const val = opts.val;
|
|
496
|
+
const bindings = logger._logEvent.bindings;
|
|
497
|
+
if (!argsIsSerialized) {
|
|
498
|
+
applySerializers(
|
|
499
|
+
args,
|
|
500
|
+
logger._serialize || Object.keys(logger.serializers),
|
|
501
|
+
logger.serializers,
|
|
502
|
+
logger._stdErrSerialize === void 0 ? true : logger._stdErrSerialize
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
logger._logEvent.ts = ts;
|
|
506
|
+
logger._logEvent.messages = args.filter(function(arg) {
|
|
507
|
+
return bindings.indexOf(arg) === -1;
|
|
508
|
+
});
|
|
509
|
+
logger._logEvent.level.label = methodLevel;
|
|
510
|
+
logger._logEvent.level.value = methodValue;
|
|
511
|
+
send(methodLevel, logger._logEvent, val);
|
|
512
|
+
logger._logEvent = createLogEventShape(bindings);
|
|
513
|
+
}
|
|
514
|
+
function createLogEventShape(bindings) {
|
|
515
|
+
return {
|
|
516
|
+
ts: 0,
|
|
517
|
+
messages: [],
|
|
518
|
+
bindings: bindings || [],
|
|
519
|
+
level: { label: "", value: 0 }
|
|
56
520
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
521
|
+
}
|
|
522
|
+
function asErrValue(err2) {
|
|
523
|
+
const obj = {
|
|
524
|
+
type: err2.constructor.name,
|
|
525
|
+
msg: err2.message,
|
|
526
|
+
stack: err2.stack
|
|
527
|
+
};
|
|
528
|
+
for (const key in err2) {
|
|
529
|
+
if (obj[key] === void 0) {
|
|
530
|
+
obj[key] = err2[key];
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
return obj;
|
|
534
|
+
}
|
|
535
|
+
function getTimeFunction(opts) {
|
|
536
|
+
if (typeof opts.timestamp === "function") {
|
|
537
|
+
return opts.timestamp;
|
|
538
|
+
}
|
|
539
|
+
if (opts.timestamp === false) {
|
|
540
|
+
return nullTime;
|
|
541
|
+
}
|
|
542
|
+
return epochTime;
|
|
543
|
+
}
|
|
544
|
+
function mock() {
|
|
545
|
+
return {};
|
|
546
|
+
}
|
|
547
|
+
function passthrough(a) {
|
|
548
|
+
return a;
|
|
549
|
+
}
|
|
550
|
+
function noop2() {
|
|
551
|
+
}
|
|
552
|
+
function nullTime() {
|
|
553
|
+
return false;
|
|
554
|
+
}
|
|
555
|
+
function epochTime() {
|
|
556
|
+
return Date.now();
|
|
557
|
+
}
|
|
558
|
+
function unixTime() {
|
|
559
|
+
return Math.round(Date.now() / 1e3);
|
|
560
|
+
}
|
|
561
|
+
function isoTime() {
|
|
562
|
+
return new Date(Date.now()).toISOString();
|
|
563
|
+
}
|
|
564
|
+
function pfGlobalThisOrFallback() {
|
|
565
|
+
function defd(o) {
|
|
566
|
+
return typeof o !== "undefined" && o;
|
|
567
|
+
}
|
|
568
|
+
try {
|
|
569
|
+
if (typeof globalThis !== "undefined") return globalThis;
|
|
570
|
+
Object.defineProperty(Object.prototype, "globalThis", {
|
|
571
|
+
get: function() {
|
|
572
|
+
delete Object.prototype.globalThis;
|
|
573
|
+
return this.globalThis = this;
|
|
574
|
+
},
|
|
575
|
+
configurable: true
|
|
576
|
+
});
|
|
577
|
+
return globalThis;
|
|
578
|
+
} catch (e) {
|
|
579
|
+
return defd(self) || defd(window) || defd(this) || {};
|
|
79
580
|
}
|
|
80
581
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
582
|
+
browser$1.exports.default = pino2;
|
|
583
|
+
browser$1.exports.pino = pino2;
|
|
584
|
+
return browser$1.exports;
|
|
585
|
+
}
|
|
586
|
+
var browserExports$1 = requireBrowser$1();
|
|
587
|
+
const pino = /* @__PURE__ */ getDefaultExportFromCjs$1(browserExports$1);
|
|
588
|
+
let Logger$1 = (_a = class {
|
|
589
|
+
constructor(options = {}) {
|
|
590
|
+
const level = options.level || "info";
|
|
591
|
+
this.moduleContext = options.module || "app";
|
|
592
|
+
const pinoOptions = {
|
|
593
|
+
level,
|
|
594
|
+
enabled: !options.silent,
|
|
595
|
+
transport: options.prettyPrint !== false ? {
|
|
596
|
+
target: "pino-pretty",
|
|
597
|
+
options: {
|
|
598
|
+
colorize: true,
|
|
599
|
+
translateTime: "SYS:standard",
|
|
600
|
+
ignore: "pid,hostname"
|
|
601
|
+
}
|
|
602
|
+
} : void 0
|
|
603
|
+
};
|
|
604
|
+
this.logger = pino(pinoOptions);
|
|
605
|
+
}
|
|
606
|
+
static getInstance(options = {}) {
|
|
607
|
+
const moduleKey = options.module || "default";
|
|
608
|
+
if (!_a.instances.has(moduleKey)) {
|
|
609
|
+
_a.instances.set(moduleKey, new _a(options));
|
|
85
610
|
}
|
|
86
|
-
|
|
87
|
-
|
|
611
|
+
return _a.instances.get(moduleKey);
|
|
612
|
+
}
|
|
613
|
+
setLogLevel(level) {
|
|
614
|
+
this.logger.level = level;
|
|
615
|
+
}
|
|
616
|
+
setSilent(silent) {
|
|
617
|
+
if (silent) {
|
|
618
|
+
this.logger.level = "silent";
|
|
88
619
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
620
|
+
}
|
|
621
|
+
setModule(module) {
|
|
622
|
+
this.moduleContext = module;
|
|
92
623
|
}
|
|
93
624
|
debug(message, data) {
|
|
94
|
-
|
|
625
|
+
if (data) {
|
|
626
|
+
this.logger.debug({ module: this.moduleContext, ...data }, message);
|
|
627
|
+
} else {
|
|
628
|
+
this.logger.debug({ module: this.moduleContext }, message);
|
|
629
|
+
}
|
|
95
630
|
}
|
|
96
631
|
info(message, data) {
|
|
97
|
-
|
|
632
|
+
if (data) {
|
|
633
|
+
this.logger.info({ module: this.moduleContext, ...data }, message);
|
|
634
|
+
} else {
|
|
635
|
+
this.logger.info({ module: this.moduleContext }, message);
|
|
636
|
+
}
|
|
98
637
|
}
|
|
99
638
|
warn(message, data) {
|
|
100
|
-
|
|
639
|
+
if (data) {
|
|
640
|
+
this.logger.warn({ module: this.moduleContext, ...data }, message);
|
|
641
|
+
} else {
|
|
642
|
+
this.logger.warn({ module: this.moduleContext }, message);
|
|
643
|
+
}
|
|
101
644
|
}
|
|
102
645
|
error(message, data) {
|
|
103
|
-
|
|
646
|
+
if (data) {
|
|
647
|
+
this.logger.error({ module: this.moduleContext, ...data }, message);
|
|
648
|
+
} else {
|
|
649
|
+
this.logger.error({ module: this.moduleContext }, message);
|
|
650
|
+
}
|
|
104
651
|
}
|
|
105
|
-
};
|
|
652
|
+
}, _a.instances = /* @__PURE__ */ new Map(), _a);
|
|
106
653
|
const sleep = (ms2) => {
|
|
107
654
|
return new Promise((resolve) => setTimeout(resolve, ms2));
|
|
108
655
|
};
|
|
@@ -783,8 +1330,8 @@ class HCS {
|
|
|
783
1330
|
}
|
|
784
1331
|
}
|
|
785
1332
|
}
|
|
786
|
-
const isServer
|
|
787
|
-
if (!isServer
|
|
1333
|
+
const isServer = typeof window === "undefined";
|
|
1334
|
+
if (!isServer) {
|
|
788
1335
|
window.HCS = new HCS();
|
|
789
1336
|
window.HCS.init().then(() => {
|
|
790
1337
|
console.log("All HCS resources loaded");
|
|
@@ -1911,9 +2458,9 @@ _parent = new WeakMap();
|
|
|
1911
2458
|
_maxInflation = new WeakMap();
|
|
1912
2459
|
_Reader_instances = new WeakSet();
|
|
1913
2460
|
incrementBytesRead_fn = function(count) {
|
|
1914
|
-
var
|
|
2461
|
+
var _a3;
|
|
1915
2462
|
if (__privateGet(this, _parent)) {
|
|
1916
|
-
return __privateMethod(
|
|
2463
|
+
return __privateMethod(_a3 = __privateGet(this, _parent), _Reader_instances, incrementBytesRead_fn).call(_a3, count);
|
|
1917
2464
|
}
|
|
1918
2465
|
__privateSet(this, _bytesRead, __privateGet(this, _bytesRead) + count);
|
|
1919
2466
|
assert(__privateGet(this, _maxInflation) < 1 || __privateGet(this, _bytesRead) <= __privateGet(this, _maxInflation) * this.dataLength, `compressed ABI data exceeds inflation ratio of ${__privateGet(this, _maxInflation)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`, "BUFFER_OVERRUN", {
|
|
@@ -4036,8 +4583,8 @@ walkAsync_fn = function(promises, value, process2, setValue) {
|
|
|
4036
4583
|
const childType = this.arrayChildren;
|
|
4037
4584
|
const result2 = value.slice();
|
|
4038
4585
|
result2.forEach((value2, index) => {
|
|
4039
|
-
var
|
|
4040
|
-
__privateMethod(
|
|
4586
|
+
var _a3;
|
|
4587
|
+
__privateMethod(_a3 = childType, _ParamType_instances, walkAsync_fn).call(_a3, promises, value2, process2, (value3) => {
|
|
4041
4588
|
result2[index] = value3;
|
|
4042
4589
|
});
|
|
4043
4590
|
});
|
|
@@ -4067,8 +4614,8 @@ walkAsync_fn = function(promises, value, process2, setValue) {
|
|
|
4067
4614
|
throw new Error("array is wrong length");
|
|
4068
4615
|
}
|
|
4069
4616
|
result2.forEach((value2, index) => {
|
|
4070
|
-
var
|
|
4071
|
-
__privateMethod(
|
|
4617
|
+
var _a3;
|
|
4618
|
+
__privateMethod(_a3 = components[index], _ParamType_instances, walkAsync_fn).call(_a3, promises, value2, process2, (value3) => {
|
|
4072
4619
|
result2[index] = value3;
|
|
4073
4620
|
});
|
|
4074
4621
|
});
|
|
@@ -8433,7 +8980,7 @@ const _Logger = class _Logger2 {
|
|
|
8433
8980
|
}
|
|
8434
8981
|
};
|
|
8435
8982
|
__publicField2(_Logger, "instance");
|
|
8436
|
-
let
|
|
8983
|
+
let Logger = _Logger;
|
|
8437
8984
|
class ValidationError extends Error {
|
|
8438
8985
|
constructor(message) {
|
|
8439
8986
|
super(message);
|
|
@@ -8452,7 +8999,7 @@ class Auth {
|
|
|
8452
8999
|
this.baseUrl = config.baseUrl || "https://kiloscribe.com";
|
|
8453
9000
|
}
|
|
8454
9001
|
async authenticate() {
|
|
8455
|
-
var
|
|
9002
|
+
var _a22, _b2, _c;
|
|
8456
9003
|
const requestSignatureResponse = await axios$1.get(
|
|
8457
9004
|
`${this.baseUrl}/api/auth/request-signature`,
|
|
8458
9005
|
{
|
|
@@ -8461,7 +9008,7 @@ class Auth {
|
|
|
8461
9008
|
}
|
|
8462
9009
|
}
|
|
8463
9010
|
);
|
|
8464
|
-
if (!((
|
|
9011
|
+
if (!((_a22 = requestSignatureResponse.data) == null ? void 0 : _a22.message)) {
|
|
8465
9012
|
throw new Error("Failed to get signature message");
|
|
8466
9013
|
}
|
|
8467
9014
|
const message = requestSignatureResponse.data.message;
|
|
@@ -8505,7 +9052,7 @@ class ClientAuth {
|
|
|
8505
9052
|
this.logger = config.logger;
|
|
8506
9053
|
}
|
|
8507
9054
|
async authenticate() {
|
|
8508
|
-
var
|
|
9055
|
+
var _a22, _b2, _c;
|
|
8509
9056
|
const requestSignatureResponse = await axios$1.get(
|
|
8510
9057
|
`${this.baseUrl}/api/auth/request-signature`,
|
|
8511
9058
|
{
|
|
@@ -8514,7 +9061,7 @@ class ClientAuth {
|
|
|
8514
9061
|
}
|
|
8515
9062
|
}
|
|
8516
9063
|
);
|
|
8517
|
-
if (!((
|
|
9064
|
+
if (!((_a22 = requestSignatureResponse.data) == null ? void 0 : _a22.message)) {
|
|
8518
9065
|
throw new Error("Failed to get signature message");
|
|
8519
9066
|
}
|
|
8520
9067
|
const message = requestSignatureResponse.data.message;
|
|
@@ -8898,9 +9445,9 @@ class AbstractTokenizer {
|
|
|
8898
9445
|
return length;
|
|
8899
9446
|
}
|
|
8900
9447
|
async close() {
|
|
8901
|
-
var
|
|
9448
|
+
var _a22;
|
|
8902
9449
|
await this.abort();
|
|
8903
|
-
await ((
|
|
9450
|
+
await ((_a22 = this.onClose) == null ? void 0 : _a22.call(this));
|
|
8904
9451
|
}
|
|
8905
9452
|
normalizeOptions(uint8Array, options) {
|
|
8906
9453
|
if (!this.supportsRandomAccess() && options && options.position !== void 0 && options.position < this.position) {
|
|
@@ -9169,7 +9716,7 @@ var freb = function(eb, start) {
|
|
|
9169
9716
|
}
|
|
9170
9717
|
return { b: b2, r };
|
|
9171
9718
|
};
|
|
9172
|
-
var
|
|
9719
|
+
var _a2 = freb(fleb, 2), fl = _a2.b, revfl = _a2.r;
|
|
9173
9720
|
fl[28] = 258, revfl[258] = 28;
|
|
9174
9721
|
var _b = freb(fdeb, 0), fd = _b.b;
|
|
9175
9722
|
var rev = new u16(32768);
|
|
@@ -12033,7 +12580,7 @@ const _InscriptionSDK = class _InscriptionSDK2 {
|
|
|
12033
12580
|
constructor(config) {
|
|
12034
12581
|
__publicField2(this, "client");
|
|
12035
12582
|
__publicField2(this, "config");
|
|
12036
|
-
__publicField2(this, "logger",
|
|
12583
|
+
__publicField2(this, "logger", Logger.getInstance());
|
|
12037
12584
|
this.config = config;
|
|
12038
12585
|
if (!config.apiKey) {
|
|
12039
12586
|
throw new ValidationError("API key is required");
|
|
@@ -12049,7 +12596,7 @@ const _InscriptionSDK = class _InscriptionSDK2 {
|
|
|
12049
12596
|
baseURL: "https://v2-api.tier.bot/api",
|
|
12050
12597
|
headers
|
|
12051
12598
|
});
|
|
12052
|
-
this.logger =
|
|
12599
|
+
this.logger = Logger.getInstance();
|
|
12053
12600
|
}
|
|
12054
12601
|
async getFileMetadata(url) {
|
|
12055
12602
|
try {
|
|
@@ -12190,7 +12737,7 @@ const _InscriptionSDK = class _InscriptionSDK2 {
|
|
|
12190
12737
|
* @throws Error if the inscription fails
|
|
12191
12738
|
*/
|
|
12192
12739
|
async startInscription(request) {
|
|
12193
|
-
var
|
|
12740
|
+
var _a22, _b2;
|
|
12194
12741
|
try {
|
|
12195
12742
|
this.validateRequest(request);
|
|
12196
12743
|
let mimeType = request.file.mimeType;
|
|
@@ -12248,7 +12795,7 @@ const _InscriptionSDK = class _InscriptionSDK2 {
|
|
|
12248
12795
|
}
|
|
12249
12796
|
if (axios$1.isAxiosError(error)) {
|
|
12250
12797
|
throw new Error(
|
|
12251
|
-
((_b2 = (
|
|
12798
|
+
((_b2 = (_a22 = error.response) == null ? void 0 : _a22.data) == null ? void 0 : _b2.message) || "Failed to start inscription"
|
|
12252
12799
|
);
|
|
12253
12800
|
}
|
|
12254
12801
|
throw error;
|
|
@@ -12444,7 +12991,7 @@ const _InscriptionSDK = class _InscriptionSDK2 {
|
|
|
12444
12991
|
static async createWithAuth(config) {
|
|
12445
12992
|
const auth = config.type === "client" ? new ClientAuth({
|
|
12446
12993
|
...config,
|
|
12447
|
-
logger:
|
|
12994
|
+
logger: Logger.getInstance()
|
|
12448
12995
|
}) : new Auth(config);
|
|
12449
12996
|
const { apiKey } = await auth.authenticate();
|
|
12450
12997
|
return new _InscriptionSDK2({
|
|
@@ -12453,7 +13000,7 @@ const _InscriptionSDK = class _InscriptionSDK2 {
|
|
|
12453
13000
|
});
|
|
12454
13001
|
}
|
|
12455
13002
|
async waitForInscription(txId, maxAttempts = 30, intervalMs = 4e3, checkCompletion = false, progressCallback) {
|
|
12456
|
-
var
|
|
13003
|
+
var _a22;
|
|
12457
13004
|
let attempts = 0;
|
|
12458
13005
|
let highestPercentSoFar = 0;
|
|
12459
13006
|
const reportProgress = (stage, message, percent, details) => {
|
|
@@ -12520,7 +13067,7 @@ const _InscriptionSDK = class _InscriptionSDK2 {
|
|
|
12520
13067
|
}
|
|
12521
13068
|
);
|
|
12522
13069
|
const isHashinal = result.mode === "hashinal";
|
|
12523
|
-
const isDynamic = ((
|
|
13070
|
+
const isDynamic = ((_a22 = result.fileStandard) == null ? void 0 : _a22.toString()) === "6";
|
|
12524
13071
|
if (isHashinal && result.topic_id && result.jsonTopicId) {
|
|
12525
13072
|
if (!checkCompletion || result.completed) {
|
|
12526
13073
|
reportProgress(
|
|
@@ -15052,9 +15599,7 @@ class HederaMirrorNode {
|
|
|
15052
15599
|
return this.baseUrl;
|
|
15053
15600
|
}
|
|
15054
15601
|
async getPublicKey(accountId) {
|
|
15055
|
-
|
|
15056
|
-
this.logger.info(`Getting public key for account ${accountId}`);
|
|
15057
|
-
}
|
|
15602
|
+
this.logger.info(`Getting public key for account ${accountId}`);
|
|
15058
15603
|
const accountInfo = await this.requestAccount(accountId);
|
|
15059
15604
|
try {
|
|
15060
15605
|
if (!accountInfo || !accountInfo.key) {
|
|
@@ -15070,18 +15615,29 @@ class HederaMirrorNode {
|
|
|
15070
15615
|
}
|
|
15071
15616
|
}
|
|
15072
15617
|
async getAccountMemo(accountId) {
|
|
15073
|
-
|
|
15074
|
-
|
|
15075
|
-
|
|
15076
|
-
|
|
15077
|
-
|
|
15078
|
-
|
|
15079
|
-
|
|
15080
|
-
|
|
15081
|
-
|
|
15618
|
+
const maxRetries = 3;
|
|
15619
|
+
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
15620
|
+
try {
|
|
15621
|
+
const accountInfoUrl = `${this.baseUrl}/api/v1/accounts/${accountId}`;
|
|
15622
|
+
const response = await axios.get(accountInfoUrl);
|
|
15623
|
+
const accountInfo = response.data;
|
|
15624
|
+
if (accountInfo && accountInfo.memo) {
|
|
15625
|
+
return accountInfo.memo;
|
|
15626
|
+
}
|
|
15627
|
+
this.logger.error(`No memo found for account ${accountId}`);
|
|
15628
|
+
if (attempt < maxRetries - 1) {
|
|
15629
|
+
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
15630
|
+
}
|
|
15631
|
+
} catch (error) {
|
|
15632
|
+
this.logger.error(
|
|
15633
|
+
`Error getting account memo (attempt ${attempt + 1}): ${error.message}`
|
|
15634
|
+
);
|
|
15635
|
+
if (attempt < maxRetries - 1) {
|
|
15636
|
+
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
15637
|
+
}
|
|
15082
15638
|
}
|
|
15083
|
-
return null;
|
|
15084
15639
|
}
|
|
15640
|
+
return null;
|
|
15085
15641
|
}
|
|
15086
15642
|
async getTopicInfo(topicId) {
|
|
15087
15643
|
try {
|
|
@@ -15089,11 +15645,7 @@ class HederaMirrorNode {
|
|
|
15089
15645
|
const response = await axios.get(topicInfoUrl);
|
|
15090
15646
|
return response.data;
|
|
15091
15647
|
} catch (error) {
|
|
15092
|
-
|
|
15093
|
-
this.logger.error(
|
|
15094
|
-
`Error retrieving topic information: ${error.message}`
|
|
15095
|
-
);
|
|
15096
|
-
}
|
|
15648
|
+
this.logger.error(`Error retrieving topic information: ${error.message}`);
|
|
15097
15649
|
throw new Error(`Failed to retrieve topic information: ${error.message}`);
|
|
15098
15650
|
}
|
|
15099
15651
|
}
|
|
@@ -15102,16 +15654,25 @@ class HederaMirrorNode {
|
|
|
15102
15654
|
const topicInfo = await this.getTopicInfo(topicId);
|
|
15103
15655
|
return topicInfo.custom_fees;
|
|
15104
15656
|
} catch (error) {
|
|
15105
|
-
|
|
15106
|
-
this.logger.error(`Error retrieving topic fees: ${error.message}`);
|
|
15107
|
-
}
|
|
15657
|
+
this.logger.error(`Error retrieving topic fees: ${error.message}`);
|
|
15108
15658
|
return null;
|
|
15109
15659
|
}
|
|
15110
15660
|
}
|
|
15111
|
-
async
|
|
15112
|
-
|
|
15113
|
-
|
|
15661
|
+
async getHBARPrice(date) {
|
|
15662
|
+
try {
|
|
15663
|
+
const timestamp = Timestamp.fromDate(date).toString();
|
|
15664
|
+
const request = await fetch(
|
|
15665
|
+
`https://mainnet-public.mirrornode.hedera.com/api/v1/network/exchangerate?timestamp=${timestamp}`
|
|
15666
|
+
);
|
|
15667
|
+
const response = await request.json();
|
|
15668
|
+
const usdPrice = Number(response?.current_rate?.cent_equivalent) / Number(response?.current_rate?.hbar_equivalent) / 100;
|
|
15669
|
+
return usdPrice;
|
|
15670
|
+
} catch (e) {
|
|
15671
|
+
return null;
|
|
15114
15672
|
}
|
|
15673
|
+
}
|
|
15674
|
+
async getTopicMessages(topicId) {
|
|
15675
|
+
this.logger.info(`Querying messages for topic ${topicId}`);
|
|
15115
15676
|
let nextUrl = `${this.baseUrl}/api/v1/topics/${topicId}/messages`;
|
|
15116
15677
|
const messages = [];
|
|
15117
15678
|
while (nextUrl) {
|
|
@@ -15121,47 +15682,47 @@ class HederaMirrorNode {
|
|
|
15121
15682
|
if (data.messages && data.messages.length > 0) {
|
|
15122
15683
|
for (const message of data.messages) {
|
|
15123
15684
|
try {
|
|
15124
|
-
if (!message.message)
|
|
15685
|
+
if (!message.message) {
|
|
15686
|
+
continue;
|
|
15687
|
+
}
|
|
15125
15688
|
let messageContent;
|
|
15126
15689
|
try {
|
|
15127
15690
|
if (this.isServerEnvironment) {
|
|
15128
|
-
messageContent = Buffer.from(
|
|
15691
|
+
messageContent = Buffer.from(
|
|
15692
|
+
message.message,
|
|
15693
|
+
"base64"
|
|
15694
|
+
).toString("utf-8");
|
|
15129
15695
|
} else {
|
|
15130
15696
|
messageContent = new TextDecoder().decode(
|
|
15131
|
-
Uint8Array.from(
|
|
15697
|
+
Uint8Array.from(
|
|
15698
|
+
atob(message.message),
|
|
15699
|
+
(c) => c.charCodeAt(0)
|
|
15700
|
+
)
|
|
15132
15701
|
);
|
|
15133
15702
|
}
|
|
15134
15703
|
} catch (error) {
|
|
15135
|
-
|
|
15136
|
-
this.logger.error(`Error decoding message: ${error}`);
|
|
15137
|
-
}
|
|
15704
|
+
this.logger.error(`Error decoding message: ${error}`);
|
|
15138
15705
|
continue;
|
|
15139
15706
|
}
|
|
15140
15707
|
let messageJson;
|
|
15141
15708
|
try {
|
|
15142
15709
|
messageJson = JSON.parse(messageContent);
|
|
15143
15710
|
} catch (error) {
|
|
15144
|
-
|
|
15145
|
-
|
|
15146
|
-
|
|
15147
|
-
);
|
|
15148
|
-
}
|
|
15711
|
+
this.logger.error(
|
|
15712
|
+
`Invalid JSON message content: ${messageContent}`
|
|
15713
|
+
);
|
|
15149
15714
|
return;
|
|
15150
15715
|
}
|
|
15151
15716
|
messageJson.sequence_number = message.sequence_number;
|
|
15152
15717
|
messages.push(messageJson);
|
|
15153
15718
|
} catch (error) {
|
|
15154
|
-
|
|
15155
|
-
this.logger.error(`Error processing message: ${error.message}`);
|
|
15156
|
-
}
|
|
15719
|
+
this.logger.error(`Error processing message: ${error.message}`);
|
|
15157
15720
|
}
|
|
15158
15721
|
}
|
|
15159
15722
|
}
|
|
15160
15723
|
nextUrl = data.links?.next ? `${this.baseUrl}${data.links.next}` : "";
|
|
15161
15724
|
} catch (error) {
|
|
15162
|
-
|
|
15163
|
-
this.logger.error(`Error querying topic messages: ${error.message}`);
|
|
15164
|
-
}
|
|
15725
|
+
this.logger.error(`Error querying topic messages: ${error.message}`);
|
|
15165
15726
|
throw new Error(`Failed to query topic messages: ${error.message}`);
|
|
15166
15727
|
}
|
|
15167
15728
|
}
|
|
@@ -15178,9 +15739,7 @@ class HederaMirrorNode {
|
|
|
15178
15739
|
}
|
|
15179
15740
|
return response.data;
|
|
15180
15741
|
} catch (error) {
|
|
15181
|
-
|
|
15182
|
-
this.logger.error(`Failed to fetch account: ${error.message}`);
|
|
15183
|
-
}
|
|
15742
|
+
this.logger.error(`Failed to fetch account: ${error.message}`);
|
|
15184
15743
|
throw new Error(`Failed to fetch account: ${error.message}`);
|
|
15185
15744
|
}
|
|
15186
15745
|
}
|
|
@@ -15189,9 +15748,9 @@ class HederaMirrorNode {
|
|
|
15189
15748
|
const key = proto.Key.decode(keyBytes);
|
|
15190
15749
|
return this.evaluateKeyAccess(key, userPublicKey);
|
|
15191
15750
|
} catch (error) {
|
|
15192
|
-
|
|
15193
|
-
|
|
15194
|
-
|
|
15751
|
+
this.logger.error(
|
|
15752
|
+
`Error decoding protobuf key: ${error instanceof Error ? error.message : String(error)}`
|
|
15753
|
+
);
|
|
15195
15754
|
return false;
|
|
15196
15755
|
}
|
|
15197
15756
|
}
|
|
@@ -15229,9 +15788,9 @@ class HederaMirrorNode {
|
|
|
15229
15788
|
return true;
|
|
15230
15789
|
}
|
|
15231
15790
|
} catch (err2) {
|
|
15232
|
-
|
|
15233
|
-
|
|
15234
|
-
|
|
15791
|
+
this.logger.debug(
|
|
15792
|
+
`Error in nested key: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
15793
|
+
);
|
|
15235
15794
|
}
|
|
15236
15795
|
}
|
|
15237
15796
|
}
|
|
@@ -15250,7 +15809,10 @@ class ProgressReporter {
|
|
|
15250
15809
|
constructor(options = {}) {
|
|
15251
15810
|
this.module = options.module || "Progress";
|
|
15252
15811
|
this.callback = options.callback;
|
|
15253
|
-
this.logger = options.logger
|
|
15812
|
+
this.logger = options.logger || new Logger$1({
|
|
15813
|
+
level: "info",
|
|
15814
|
+
module: "ProgressReporter"
|
|
15815
|
+
});
|
|
15254
15816
|
this.logProgress = options.logProgress ?? true;
|
|
15255
15817
|
this.minPercent = options.minPercent ?? 0;
|
|
15256
15818
|
this.maxPercent = options.maxPercent ?? 100;
|
|
@@ -15337,7 +15899,7 @@ class ProgressReporter {
|
|
|
15337
15899
|
...data,
|
|
15338
15900
|
progressPercent: scaledPercent
|
|
15339
15901
|
};
|
|
15340
|
-
if (this.logProgress
|
|
15902
|
+
if (this.logProgress) {
|
|
15341
15903
|
this.logger.debug(
|
|
15342
15904
|
`[${this.module}] [${data.stage.toUpperCase()}] ${data.message} (${scaledPercent.toFixed(1)}%)`,
|
|
15343
15905
|
data.details
|
|
@@ -15347,9 +15909,7 @@ class ProgressReporter {
|
|
|
15347
15909
|
try {
|
|
15348
15910
|
this.callback(progressData);
|
|
15349
15911
|
} catch (err2) {
|
|
15350
|
-
|
|
15351
|
-
this.logger.warn(`Error in progress callback: ${err2}`);
|
|
15352
|
-
}
|
|
15912
|
+
this.logger.warn(`Error in progress callback: ${err2}`);
|
|
15353
15913
|
}
|
|
15354
15914
|
}
|
|
15355
15915
|
}
|
|
@@ -15802,30 +16362,6 @@ async function waitForInscriptionConfirmation(sdk, transactionId, maxAttempts =
|
|
|
15802
16362
|
throw error;
|
|
15803
16363
|
}
|
|
15804
16364
|
}
|
|
15805
|
-
function getAugmentedNamespace(n2) {
|
|
15806
|
-
if (Object.prototype.hasOwnProperty.call(n2, "__esModule")) return n2;
|
|
15807
|
-
var f = n2.default;
|
|
15808
|
-
if (typeof f == "function") {
|
|
15809
|
-
var a = function a2() {
|
|
15810
|
-
if (this instanceof a2) {
|
|
15811
|
-
return Reflect.construct(f, arguments, this.constructor);
|
|
15812
|
-
}
|
|
15813
|
-
return f.apply(this, arguments);
|
|
15814
|
-
};
|
|
15815
|
-
a.prototype = f.prototype;
|
|
15816
|
-
} else a = {};
|
|
15817
|
-
Object.defineProperty(a, "__esModule", { value: true });
|
|
15818
|
-
Object.keys(n2).forEach(function(k) {
|
|
15819
|
-
var d = Object.getOwnPropertyDescriptor(n2, k);
|
|
15820
|
-
Object.defineProperty(a, k, d.get ? d : {
|
|
15821
|
-
enumerable: true,
|
|
15822
|
-
get: function() {
|
|
15823
|
-
return n2[k];
|
|
15824
|
-
}
|
|
15825
|
-
});
|
|
15826
|
-
});
|
|
15827
|
-
return a;
|
|
15828
|
-
}
|
|
15829
16365
|
var mimeTypes = {};
|
|
15830
16366
|
const require$$0 = {
|
|
15831
16367
|
"application/1d-interleaved-parityfec": { "source": "iana" },
|
|
@@ -18751,13 +19287,13 @@ function processCreateParams(params) {
|
|
|
18751
19287
|
if (errorMap2)
|
|
18752
19288
|
return { errorMap: errorMap2, description };
|
|
18753
19289
|
const customMap = (iss, ctx) => {
|
|
18754
|
-
var
|
|
19290
|
+
var _a3, _b2;
|
|
18755
19291
|
const { message } = params;
|
|
18756
19292
|
if (iss.code === "invalid_enum_value") {
|
|
18757
19293
|
return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
|
|
18758
19294
|
}
|
|
18759
19295
|
if (typeof ctx.data === "undefined") {
|
|
18760
|
-
return { message: (
|
|
19296
|
+
return { message: (_a3 = message !== null && message !== void 0 ? message : required_error) !== null && _a3 !== void 0 ? _a3 : ctx.defaultError };
|
|
18761
19297
|
}
|
|
18762
19298
|
if (iss.code !== "invalid_type")
|
|
18763
19299
|
return { message: ctx.defaultError };
|
|
@@ -18813,11 +19349,11 @@ class ZodType {
|
|
|
18813
19349
|
throw result.error;
|
|
18814
19350
|
}
|
|
18815
19351
|
safeParse(data, params) {
|
|
18816
|
-
var
|
|
19352
|
+
var _a3;
|
|
18817
19353
|
const ctx = {
|
|
18818
19354
|
common: {
|
|
18819
19355
|
issues: [],
|
|
18820
|
-
async: (
|
|
19356
|
+
async: (_a3 = params === null || params === void 0 ? void 0 : params.async) !== null && _a3 !== void 0 ? _a3 : false,
|
|
18821
19357
|
contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap
|
|
18822
19358
|
},
|
|
18823
19359
|
path: (params === null || params === void 0 ? void 0 : params.path) || [],
|
|
@@ -18830,7 +19366,7 @@ class ZodType {
|
|
|
18830
19366
|
return handleResult(ctx, result);
|
|
18831
19367
|
}
|
|
18832
19368
|
"~validate"(data) {
|
|
18833
|
-
var
|
|
19369
|
+
var _a3, _b2;
|
|
18834
19370
|
const ctx = {
|
|
18835
19371
|
common: {
|
|
18836
19372
|
issues: [],
|
|
@@ -18851,7 +19387,7 @@ class ZodType {
|
|
|
18851
19387
|
issues: ctx.common.issues
|
|
18852
19388
|
};
|
|
18853
19389
|
} catch (err2) {
|
|
18854
|
-
if ((_b2 = (
|
|
19390
|
+
if ((_b2 = (_a3 = err2 === null || err2 === void 0 ? void 0 : err2.message) === null || _a3 === void 0 ? void 0 : _a3.toLowerCase()) === null || _b2 === void 0 ? void 0 : _b2.includes("encountered")) {
|
|
18855
19391
|
this["~standard"].async = true;
|
|
18856
19392
|
}
|
|
18857
19393
|
ctx.common = {
|
|
@@ -19112,7 +19648,7 @@ function isValidJWT(jwt, alg) {
|
|
|
19112
19648
|
if (alg && decoded.alg !== alg)
|
|
19113
19649
|
return false;
|
|
19114
19650
|
return true;
|
|
19115
|
-
} catch (
|
|
19651
|
+
} catch (_a3) {
|
|
19116
19652
|
return false;
|
|
19117
19653
|
}
|
|
19118
19654
|
}
|
|
@@ -19271,7 +19807,7 @@ class ZodString extends ZodType {
|
|
|
19271
19807
|
} else if (check.kind === "url") {
|
|
19272
19808
|
try {
|
|
19273
19809
|
new URL(input.data);
|
|
19274
|
-
} catch (
|
|
19810
|
+
} catch (_a3) {
|
|
19275
19811
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
19276
19812
|
addIssueToContext(ctx, {
|
|
19277
19813
|
validation: "url",
|
|
@@ -19483,7 +20019,7 @@ class ZodString extends ZodType {
|
|
|
19483
20019
|
return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
|
|
19484
20020
|
}
|
|
19485
20021
|
datetime(options) {
|
|
19486
|
-
var
|
|
20022
|
+
var _a3, _b2;
|
|
19487
20023
|
if (typeof options === "string") {
|
|
19488
20024
|
return this._addCheck({
|
|
19489
20025
|
kind: "datetime",
|
|
@@ -19496,7 +20032,7 @@ class ZodString extends ZodType {
|
|
|
19496
20032
|
return this._addCheck({
|
|
19497
20033
|
kind: "datetime",
|
|
19498
20034
|
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
|
19499
|
-
offset: (
|
|
20035
|
+
offset: (_a3 = options === null || options === void 0 ? void 0 : options.offset) !== null && _a3 !== void 0 ? _a3 : false,
|
|
19500
20036
|
local: (_b2 = options === null || options === void 0 ? void 0 : options.local) !== null && _b2 !== void 0 ? _b2 : false,
|
|
19501
20037
|
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
|
19502
20038
|
});
|
|
@@ -19665,11 +20201,11 @@ class ZodString extends ZodType {
|
|
|
19665
20201
|
}
|
|
19666
20202
|
}
|
|
19667
20203
|
ZodString.create = (params) => {
|
|
19668
|
-
var
|
|
20204
|
+
var _a3;
|
|
19669
20205
|
return new ZodString({
|
|
19670
20206
|
checks: [],
|
|
19671
20207
|
typeName: ZodFirstPartyTypeKind.ZodString,
|
|
19672
|
-
coerce: (
|
|
20208
|
+
coerce: (_a3 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a3 !== void 0 ? _a3 : false,
|
|
19673
20209
|
...processCreateParams(params)
|
|
19674
20210
|
});
|
|
19675
20211
|
};
|
|
@@ -19922,7 +20458,7 @@ class ZodBigInt extends ZodType {
|
|
|
19922
20458
|
if (this._def.coerce) {
|
|
19923
20459
|
try {
|
|
19924
20460
|
input.data = BigInt(input.data);
|
|
19925
|
-
} catch (
|
|
20461
|
+
} catch (_a3) {
|
|
19926
20462
|
return this._getInvalidInput(input);
|
|
19927
20463
|
}
|
|
19928
20464
|
}
|
|
@@ -20077,11 +20613,11 @@ class ZodBigInt extends ZodType {
|
|
|
20077
20613
|
}
|
|
20078
20614
|
}
|
|
20079
20615
|
ZodBigInt.create = (params) => {
|
|
20080
|
-
var
|
|
20616
|
+
var _a3;
|
|
20081
20617
|
return new ZodBigInt({
|
|
20082
20618
|
checks: [],
|
|
20083
20619
|
typeName: ZodFirstPartyTypeKind.ZodBigInt,
|
|
20084
|
-
coerce: (
|
|
20620
|
+
coerce: (_a3 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a3 !== void 0 ? _a3 : false,
|
|
20085
20621
|
...processCreateParams(params)
|
|
20086
20622
|
});
|
|
20087
20623
|
};
|
|
@@ -20587,8 +21123,8 @@ class ZodObject extends ZodType {
|
|
|
20587
21123
|
unknownKeys: "strict",
|
|
20588
21124
|
...message !== void 0 ? {
|
|
20589
21125
|
errorMap: (issue, ctx) => {
|
|
20590
|
-
var
|
|
20591
|
-
const defaultError = (_c = (_b2 = (
|
|
21126
|
+
var _a3, _b2, _c, _d;
|
|
21127
|
+
const defaultError = (_c = (_b2 = (_a3 = this._def).errorMap) === null || _b2 === void 0 ? void 0 : _b2.call(_a3, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
|
|
20592
21128
|
if (issue.code === "unrecognized_keys")
|
|
20593
21129
|
return {
|
|
20594
21130
|
message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError
|
|
@@ -22054,21 +22590,21 @@ function cleanParams(params, data) {
|
|
|
22054
22590
|
function custom(check, _params = {}, fatal) {
|
|
22055
22591
|
if (check)
|
|
22056
22592
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
22057
|
-
var
|
|
22593
|
+
var _a3, _b2;
|
|
22058
22594
|
const r = check(data);
|
|
22059
22595
|
if (r instanceof Promise) {
|
|
22060
22596
|
return r.then((r2) => {
|
|
22061
|
-
var
|
|
22597
|
+
var _a4, _b3;
|
|
22062
22598
|
if (!r2) {
|
|
22063
22599
|
const params = cleanParams(_params, data);
|
|
22064
|
-
const _fatal = (_b3 = (
|
|
22600
|
+
const _fatal = (_b3 = (_a4 = params.fatal) !== null && _a4 !== void 0 ? _a4 : fatal) !== null && _b3 !== void 0 ? _b3 : true;
|
|
22065
22601
|
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
22066
22602
|
}
|
|
22067
22603
|
});
|
|
22068
22604
|
}
|
|
22069
22605
|
if (!r) {
|
|
22070
22606
|
const params = cleanParams(_params, data);
|
|
22071
|
-
const _fatal = (_b2 = (
|
|
22607
|
+
const _fatal = (_b2 = (_a3 = params.fatal) !== null && _a3 !== void 0 ? _a3 : fatal) !== null && _b2 !== void 0 ? _b2 : true;
|
|
22072
22608
|
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
22073
22609
|
}
|
|
22074
22610
|
return;
|
|
@@ -22400,6 +22936,10 @@ class HCS11Client {
|
|
|
22400
22936
|
this.client = config.network === "mainnet" ? Client.forMainnet() : Client.forTestnet();
|
|
22401
22937
|
this.auth = config.auth;
|
|
22402
22938
|
this.network = config.network;
|
|
22939
|
+
this.mirrorNode = new HederaMirrorNode(
|
|
22940
|
+
this.network,
|
|
22941
|
+
this.logger
|
|
22942
|
+
);
|
|
22403
22943
|
if (this.auth.privateKey) {
|
|
22404
22944
|
const privateKey = PrivateKey.fromString(this.auth.privateKey);
|
|
22405
22945
|
this.client.setOperator(this.auth.operatorId, privateKey);
|
|
@@ -22784,6 +23324,14 @@ class HCS11Client {
|
|
|
22784
23324
|
};
|
|
22785
23325
|
}
|
|
22786
23326
|
}
|
|
23327
|
+
/**
|
|
23328
|
+
* Creates and inscribes a profile.
|
|
23329
|
+
*
|
|
23330
|
+
* @param profile - The profile to create and inscribe.
|
|
23331
|
+
* @param updateAccountMemo - Whether to update the account memo with the profile.
|
|
23332
|
+
* @param options - Optional configuration options.
|
|
23333
|
+
* @returns A promise that resolves to the inscription result.
|
|
23334
|
+
*/
|
|
22787
23335
|
async createAndInscribeProfile(profile, updateAccountMemo = true, options) {
|
|
22788
23336
|
const progressCallback = options?.progressCallback;
|
|
22789
23337
|
const progressReporter = new ProgressReporter({
|
|
@@ -22837,6 +23385,12 @@ class HCS11Client {
|
|
|
22837
23385
|
});
|
|
22838
23386
|
return inscriptionResult;
|
|
22839
23387
|
}
|
|
23388
|
+
/**
|
|
23389
|
+
* Gets the capabilities from the capability names.
|
|
23390
|
+
*
|
|
23391
|
+
* @param capabilityNames - The capability names to get the capabilities for.
|
|
23392
|
+
* @returns The capabilities.
|
|
23393
|
+
*/
|
|
22840
23394
|
async getCapabilitiesFromTags(capabilityNames) {
|
|
22841
23395
|
const capabilities = [];
|
|
22842
23396
|
if (capabilityNames.length === 0) {
|
|
@@ -22859,6 +23413,12 @@ class HCS11Client {
|
|
|
22859
23413
|
}
|
|
22860
23414
|
return capabilities;
|
|
22861
23415
|
}
|
|
23416
|
+
/**
|
|
23417
|
+
* Gets the agent type from the metadata.
|
|
23418
|
+
*
|
|
23419
|
+
* @param metadata - The metadata of the agent.
|
|
23420
|
+
* @returns The agent type.
|
|
23421
|
+
*/
|
|
22862
23422
|
getAgentTypeFromMetadata(metadata) {
|
|
22863
23423
|
if (metadata.type === "autonomous") {
|
|
22864
23424
|
return 1;
|
|
@@ -22866,14 +23426,21 @@ class HCS11Client {
|
|
|
22866
23426
|
return 0;
|
|
22867
23427
|
}
|
|
22868
23428
|
}
|
|
23429
|
+
/**
|
|
23430
|
+
* Fetches a profile from the account memo.
|
|
23431
|
+
*
|
|
23432
|
+
* @param accountId - The account ID of the agent to fetch the profile for.
|
|
23433
|
+
* @param network - The network to use for the fetch.
|
|
23434
|
+
* @returns A promise that resolves to the profile.
|
|
23435
|
+
*/
|
|
22869
23436
|
async fetchProfileByAccountId(accountId, network) {
|
|
22870
23437
|
try {
|
|
22871
|
-
this.logger.info(
|
|
22872
|
-
|
|
22873
|
-
this.network
|
|
23438
|
+
this.logger.info(
|
|
23439
|
+
`Fetching profile for account ${accountId.toString()} on ${this.network}`
|
|
22874
23440
|
);
|
|
22875
|
-
const memo = await mirrorNode.getAccountMemo(accountId.toString());
|
|
22876
|
-
|
|
23441
|
+
const memo = await this.mirrorNode.getAccountMemo(accountId.toString());
|
|
23442
|
+
this.logger.info(`Got account memo: ${memo}`);
|
|
23443
|
+
if (!memo?.startsWith("hcs-11:")) {
|
|
22877
23444
|
return {
|
|
22878
23445
|
success: false,
|
|
22879
23446
|
error: `Account ${accountId.toString()} does not have a valid HCS-11 memo`
|
|
@@ -22881,7 +23448,7 @@ class HCS11Client {
|
|
|
22881
23448
|
}
|
|
22882
23449
|
this.logger.info(`Found HCS-11 memo: ${memo}`);
|
|
22883
23450
|
const protocolReference = memo.substring(7);
|
|
22884
|
-
if (protocolReference
|
|
23451
|
+
if (protocolReference?.startsWith("hcs://")) {
|
|
22885
23452
|
const hcsFormat = protocolReference.match(/hcs:\/\/(\d+)\/(.+)/);
|
|
22886
23453
|
if (!hcsFormat) {
|
|
22887
23454
|
return {
|
|
@@ -22914,8 +23481,9 @@ class HCS11Client {
|
|
|
22914
23481
|
success: true,
|
|
22915
23482
|
profile: profileData,
|
|
22916
23483
|
topicInfo: {
|
|
22917
|
-
|
|
22918
|
-
|
|
23484
|
+
inboundTopic: profileData.inboundTopicId,
|
|
23485
|
+
outboundTopic: profileData.outboundTopicId,
|
|
23486
|
+
profileTopicId
|
|
22919
23487
|
}
|
|
22920
23488
|
};
|
|
22921
23489
|
} catch (cdnError) {
|
|
@@ -22937,8 +23505,9 @@ class HCS11Client {
|
|
|
22937
23505
|
success: true,
|
|
22938
23506
|
profile: profileData,
|
|
22939
23507
|
topicInfo: {
|
|
22940
|
-
|
|
22941
|
-
|
|
23508
|
+
inboundTopic: profileData.inboundTopicId,
|
|
23509
|
+
outboundTopic: profileData.outboundTopicId,
|
|
23510
|
+
profileTopicId: profileData.profileTopicId
|
|
22942
23511
|
}
|
|
22943
23512
|
};
|
|
22944
23513
|
} else if (protocolReference.startsWith("ar://")) {
|
|
@@ -22955,8 +23524,9 @@ class HCS11Client {
|
|
|
22955
23524
|
success: true,
|
|
22956
23525
|
profile: profileData,
|
|
22957
23526
|
topicInfo: {
|
|
22958
|
-
|
|
22959
|
-
|
|
23527
|
+
inboundTopic: profileData.inboundTopicId,
|
|
23528
|
+
outboundTopic: profileData.outboundTopicId,
|
|
23529
|
+
profileTopicId: profileData.profileTopicId
|
|
22960
23530
|
}
|
|
22961
23531
|
};
|
|
22962
23532
|
} else {
|
|
@@ -22975,6 +23545,15 @@ class HCS11Client {
|
|
|
22975
23545
|
}
|
|
22976
23546
|
}
|
|
22977
23547
|
class Registration {
|
|
23548
|
+
/**
|
|
23549
|
+
* Checks the status of a registration request.
|
|
23550
|
+
*
|
|
23551
|
+
* @param transactionId - The transaction ID of the registration.
|
|
23552
|
+
* @param network - The network to use for the registration.
|
|
23553
|
+
* @param baseUrl - The base URL of the guarded registry.
|
|
23554
|
+
* @param logger - The logger to use for logging.
|
|
23555
|
+
* @returns A promise that resolves to the registration status response.
|
|
23556
|
+
*/
|
|
22978
23557
|
async checkRegistrationStatus(transactionId, network, baseUrl, logger) {
|
|
22979
23558
|
try {
|
|
22980
23559
|
const response = await fetch(`${baseUrl}/api/request-confirm`, {
|
|
@@ -23000,6 +23579,17 @@ class Registration {
|
|
|
23000
23579
|
throw error;
|
|
23001
23580
|
}
|
|
23002
23581
|
}
|
|
23582
|
+
/**
|
|
23583
|
+
* Waits for a registration to be confirmed.
|
|
23584
|
+
*
|
|
23585
|
+
* @param transactionId - The transaction ID of the registration.
|
|
23586
|
+
* @param network - The network to use for the registration.
|
|
23587
|
+
* @param baseUrl - The base URL of the guarded registry.
|
|
23588
|
+
* @param maxAttempts - The maximum number of attempts to check the registration status.
|
|
23589
|
+
* @param delayMs - The delay in milliseconds between attempts.
|
|
23590
|
+
* @param logger - The logger to use for logging.
|
|
23591
|
+
* @returns A promise that resolves to true if the registration is confirmed, false otherwise.
|
|
23592
|
+
*/
|
|
23003
23593
|
async waitForRegistrationConfirmation(transactionId, network, baseUrl, maxAttempts = 60, delayMs = 2e3, logger) {
|
|
23004
23594
|
let attempts = 0;
|
|
23005
23595
|
while (attempts < maxAttempts) {
|
|
@@ -23039,7 +23629,16 @@ class Registration {
|
|
|
23039
23629
|
}
|
|
23040
23630
|
return false;
|
|
23041
23631
|
}
|
|
23042
|
-
|
|
23632
|
+
/**
|
|
23633
|
+
* Executes a registration request for an agent.
|
|
23634
|
+
*
|
|
23635
|
+
* @param accountId - The account ID of the agent to register.
|
|
23636
|
+
* @param network - The network to use for the registration.
|
|
23637
|
+
* @param baseUrl - The base URL of the guarded registry.
|
|
23638
|
+
* @param logger - The logger to use for logging.
|
|
23639
|
+
* @returns A promise that resolves to the registration result.
|
|
23640
|
+
*/
|
|
23641
|
+
async executeRegistration(accountId, network = "mainnet", baseUrl = "https://moonscape.tech", logger) {
|
|
23043
23642
|
try {
|
|
23044
23643
|
if (logger) {
|
|
23045
23644
|
logger.info("Registering agent with guarded registry");
|
|
@@ -23049,10 +23648,22 @@ class Registration {
|
|
|
23049
23648
|
network,
|
|
23050
23649
|
auth: { operatorId: "0.0.0" }
|
|
23051
23650
|
});
|
|
23651
|
+
logger?.info(
|
|
23652
|
+
"Fetching profile by account ID",
|
|
23653
|
+
`${accountId}-${network}`
|
|
23654
|
+
);
|
|
23052
23655
|
const profileResult = await hcs11Client.fetchProfileByAccountId(
|
|
23053
23656
|
accountId,
|
|
23054
23657
|
network
|
|
23055
23658
|
);
|
|
23659
|
+
logger?.info("Profile fetched", profileResult);
|
|
23660
|
+
if (profileResult.error) {
|
|
23661
|
+
logger?.error("Error fetching profile", profileResult.error);
|
|
23662
|
+
return {
|
|
23663
|
+
error: profileResult.error,
|
|
23664
|
+
success: false
|
|
23665
|
+
};
|
|
23666
|
+
}
|
|
23056
23667
|
if (!profileResult.success || !profileResult.profile) {
|
|
23057
23668
|
if (logger) {
|
|
23058
23669
|
logger.error("Profile not found for agent registration");
|
|
@@ -23139,7 +23750,14 @@ class Registration {
|
|
|
23139
23750
|
};
|
|
23140
23751
|
}
|
|
23141
23752
|
}
|
|
23142
|
-
|
|
23753
|
+
/**
|
|
23754
|
+
* Finds registrations based on the provided options.
|
|
23755
|
+
*
|
|
23756
|
+
* @param options - The options for searching registrations.
|
|
23757
|
+
* @param baseUrl - The base URL of the guarded registry.
|
|
23758
|
+
* @returns A promise that resolves to the registration search result.
|
|
23759
|
+
*/
|
|
23760
|
+
async findRegistrations(options = {}, baseUrl = "https://moonscape.tech") {
|
|
23143
23761
|
try {
|
|
23144
23762
|
const queryParams = new URLSearchParams();
|
|
23145
23763
|
options.tags?.forEach((tag) => queryParams.append("tags", tag));
|
|
@@ -23196,7 +23814,8 @@ class HCS10BaseClient extends Registration {
|
|
|
23196
23814
|
this.network = config.network;
|
|
23197
23815
|
this.logger = Logger$1.getInstance({
|
|
23198
23816
|
level: config.logLevel || "info",
|
|
23199
|
-
module: "HCS10-BaseClient"
|
|
23817
|
+
module: "HCS10-BaseClient",
|
|
23818
|
+
prettyPrint: config.prettyPrint
|
|
23200
23819
|
});
|
|
23201
23820
|
this.mirrorNode = new HederaMirrorNode(
|
|
23202
23821
|
config.network,
|
|
@@ -23248,24 +23867,6 @@ class HCS10BaseClient extends Registration {
|
|
|
23248
23867
|
async getAccountMemo(accountId) {
|
|
23249
23868
|
return await this.mirrorNode.getAccountMemo(accountId);
|
|
23250
23869
|
}
|
|
23251
|
-
async getTopicInfoFromMemo(memo) {
|
|
23252
|
-
const match = memo.match(/^hcs-10:(\d+\.\d+\.\d+):(\d+\.\d+\.\d+)$/);
|
|
23253
|
-
if (!match) return null;
|
|
23254
|
-
const [, inboundTopic, outboundTopic] = match;
|
|
23255
|
-
return { inboundTopic, outboundTopic };
|
|
23256
|
-
}
|
|
23257
|
-
async getTopicInfo(accountId) {
|
|
23258
|
-
const cacheKey = `${accountId}-${this.network}`;
|
|
23259
|
-
const cached = HCS10Cache.getInstance().get(cacheKey);
|
|
23260
|
-
if (cached) return cached;
|
|
23261
|
-
const accountMemo = await this.getAccountMemo(accountId);
|
|
23262
|
-
if (!accountMemo) return null;
|
|
23263
|
-
const topicInfo = await this.getTopicInfoFromMemo(accountMemo);
|
|
23264
|
-
if (topicInfo) {
|
|
23265
|
-
HCS10Cache.getInstance().set(cacheKey, topicInfo);
|
|
23266
|
-
}
|
|
23267
|
-
return topicInfo;
|
|
23268
|
-
}
|
|
23269
23870
|
async retrieveProfile(accountId) {
|
|
23270
23871
|
this.logger.info(`Retrieving profile for account: ${accountId}`);
|
|
23271
23872
|
try {
|
|
@@ -23277,36 +23878,35 @@ class HCS10BaseClient extends Registration {
|
|
|
23277
23878
|
},
|
|
23278
23879
|
logLevel: "info"
|
|
23279
23880
|
});
|
|
23280
|
-
const profileResult = await hcs11Client.fetchProfileByAccountId(
|
|
23281
|
-
|
|
23881
|
+
const profileResult = await hcs11Client.fetchProfileByAccountId(
|
|
23882
|
+
accountId,
|
|
23883
|
+
this.network
|
|
23884
|
+
);
|
|
23885
|
+
if (!profileResult?.success) {
|
|
23886
|
+
this.logger.error(
|
|
23887
|
+
`Failed to retrieve profile for account ID: ${accountId}`,
|
|
23888
|
+
profileResult?.error
|
|
23889
|
+
);
|
|
23282
23890
|
return {
|
|
23283
23891
|
profile: null,
|
|
23284
23892
|
success: false,
|
|
23285
|
-
error: profileResult
|
|
23893
|
+
error: profileResult?.error || `Failed to retrieve profile for account ID: ${accountId}`
|
|
23286
23894
|
};
|
|
23287
23895
|
}
|
|
23288
23896
|
const profile = profileResult.profile;
|
|
23289
23897
|
let topicInfo = null;
|
|
23290
|
-
if (profileResult.topicInfo?.
|
|
23898
|
+
if (profileResult.topicInfo?.inboundTopic && profileResult.topicInfo?.outboundTopic && profileResult.topicInfo?.profileTopicId) {
|
|
23291
23899
|
topicInfo = {
|
|
23292
|
-
inboundTopic: profileResult.topicInfo.
|
|
23293
|
-
outboundTopic: profileResult.topicInfo.
|
|
23900
|
+
inboundTopic: profileResult.topicInfo.inboundTopic,
|
|
23901
|
+
outboundTopic: profileResult.topicInfo.outboundTopic,
|
|
23902
|
+
profileTopicId: profileResult.topicInfo.profileTopicId
|
|
23294
23903
|
};
|
|
23295
23904
|
const cacheKey = `${accountId}-${this.network}`;
|
|
23296
23905
|
HCS10Cache.getInstance().set(cacheKey, topicInfo);
|
|
23297
23906
|
}
|
|
23298
|
-
let profileTopicId = "";
|
|
23299
|
-
const accountMemo = await this.getAccountMemo(accountId);
|
|
23300
|
-
if (accountMemo && accountMemo.startsWith("hcs-11:")) {
|
|
23301
|
-
const hrlMatch = accountMemo.match(/^hcs-11:hcs:\/\/(\d+)\/(.+)$/);
|
|
23302
|
-
if (hrlMatch) {
|
|
23303
|
-
profileTopicId = hrlMatch[2];
|
|
23304
|
-
}
|
|
23305
|
-
}
|
|
23306
23907
|
return {
|
|
23307
23908
|
profile,
|
|
23308
23909
|
topicInfo,
|
|
23309
|
-
profileTopicId,
|
|
23310
23910
|
success: true
|
|
23311
23911
|
};
|
|
23312
23912
|
} catch (error) {
|
|
@@ -23320,12 +23920,10 @@ class HCS10BaseClient extends Registration {
|
|
|
23320
23920
|
}
|
|
23321
23921
|
async retrieveOutboundConnectTopic(accountId) {
|
|
23322
23922
|
this.logger.info(`Retrieving topics for account: ${accountId}`);
|
|
23323
|
-
const cachedInfo = await this.getTopicInfo(accountId);
|
|
23324
|
-
if (cachedInfo) return cachedInfo;
|
|
23325
23923
|
try {
|
|
23326
23924
|
const profileResponse = await this.retrieveProfile(accountId);
|
|
23327
|
-
if (!profileResponse
|
|
23328
|
-
throw new Error(profileResponse.error);
|
|
23925
|
+
if (!profileResponse?.success) {
|
|
23926
|
+
throw new Error(profileResponse.error || "Failed to retrieve profile");
|
|
23329
23927
|
}
|
|
23330
23928
|
const profile = profileResponse.profile;
|
|
23331
23929
|
if (!profile.inboundTopicId || !profile.outboundTopicId) {
|
|
@@ -23335,7 +23933,8 @@ class HCS10BaseClient extends Registration {
|
|
|
23335
23933
|
}
|
|
23336
23934
|
const topicInfo = {
|
|
23337
23935
|
inboundTopic: profile.inboundTopicId,
|
|
23338
|
-
outboundTopic: profile.outboundTopicId
|
|
23936
|
+
outboundTopic: profile.outboundTopicId,
|
|
23937
|
+
profileTopicId: profile.profileTopicId
|
|
23339
23938
|
};
|
|
23340
23939
|
const cacheKey = `${accountId}-${this.network}`;
|
|
23341
23940
|
HCS10Cache.getInstance().set(cacheKey, topicInfo);
|
|
@@ -23570,7 +24169,8 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
23570
24169
|
constructor(config) {
|
|
23571
24170
|
super({
|
|
23572
24171
|
network: config.network,
|
|
23573
|
-
logLevel: config.logLevel
|
|
24172
|
+
logLevel: config.logLevel,
|
|
24173
|
+
prettyPrint: config.prettyPrint
|
|
23574
24174
|
});
|
|
23575
24175
|
this.client = config.network === "mainnet" ? Client.forMainnet() : Client.forTestnet();
|
|
23576
24176
|
this.operatorPrivateKey = PrivateKey.fromString(config.operatorPrivateKey);
|
|
@@ -23583,7 +24183,7 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
23583
24183
|
level: config.logLevel || "info",
|
|
23584
24184
|
module: "HCS-SDK"
|
|
23585
24185
|
});
|
|
23586
|
-
this.guardedRegistryBaseUrl = config.guardedRegistryBaseUrl || "https://
|
|
24186
|
+
this.guardedRegistryBaseUrl = config.guardedRegistryBaseUrl || "https://moonscape.tech";
|
|
23587
24187
|
this.feeAmount = config.feeAmount || 5;
|
|
23588
24188
|
this.hcs11Client = new HCS11Client({
|
|
23589
24189
|
network: config.network,
|
|
@@ -23666,12 +24266,18 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
23666
24266
|
config.inboundTopicType === InboundTopicType.FEE_BASED ? config.feeConfig : void 0
|
|
23667
24267
|
);
|
|
23668
24268
|
this.logger.info(`Created new inbound topic ID: ${inboundTopicId}`);
|
|
23669
|
-
|
|
23670
|
-
|
|
23671
|
-
|
|
23672
|
-
|
|
23673
|
-
|
|
23674
|
-
|
|
24269
|
+
let pfpTopicId = config.existingPfpTopicId || "";
|
|
24270
|
+
if (!pfpTopicId && config.pfpBuffer && config.pfpBuffer.length > 0) {
|
|
24271
|
+
this.logger.info("Inscribing new profile picture");
|
|
24272
|
+
const pfpResult = await this.inscribePfp(
|
|
24273
|
+
config.pfpBuffer,
|
|
24274
|
+
config.pfpFileName
|
|
24275
|
+
);
|
|
24276
|
+
pfpTopicId = pfpResult.pfpTopicId;
|
|
24277
|
+
this.logger.info(`Profile picture inscribed with topic ID: ${pfpTopicId}`);
|
|
24278
|
+
} else if (config.existingPfpTopicId) {
|
|
24279
|
+
this.logger.info(`Using existing profile picture with topic ID: ${config.existingPfpTopicId}`);
|
|
24280
|
+
}
|
|
23675
24281
|
const profileResult = await this.storeHCS11Profile(
|
|
23676
24282
|
config.name,
|
|
23677
24283
|
config.description,
|
|
@@ -23679,8 +24285,9 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
23679
24285
|
outboundTopicId,
|
|
23680
24286
|
config.capabilities,
|
|
23681
24287
|
config.metadata,
|
|
23682
|
-
config.pfpBuffer,
|
|
23683
|
-
config.pfpFileName
|
|
24288
|
+
config.pfpBuffer && config.pfpBuffer.length > 0 ? config.pfpBuffer : void 0,
|
|
24289
|
+
config.pfpFileName,
|
|
24290
|
+
config.existingPfpTopicId
|
|
23684
24291
|
);
|
|
23685
24292
|
const profileTopicId = profileResult.profileTopicId;
|
|
23686
24293
|
this.logger.info(`Profile stored with topic ID: ${profileTopicId}`);
|
|
@@ -23742,21 +24349,22 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
23742
24349
|
* @param pfpFileName Optional profile picture filename
|
|
23743
24350
|
* @returns Response with topic IDs and transaction ID
|
|
23744
24351
|
*/
|
|
23745
|
-
async storeHCS11Profile(agentName, agentDescription, inboundTopicId, outboundTopicId, capabilities = [], metadata, pfpBuffer, pfpFileName) {
|
|
24352
|
+
async storeHCS11Profile(agentName, agentDescription, inboundTopicId, outboundTopicId, capabilities = [], metadata, pfpBuffer, pfpFileName, existingPfpTopicId) {
|
|
23746
24353
|
try {
|
|
23747
|
-
let pfpTopicId;
|
|
23748
|
-
if (pfpBuffer && pfpFileName) {
|
|
24354
|
+
let pfpTopicId = existingPfpTopicId || "";
|
|
24355
|
+
if (!pfpTopicId && pfpBuffer && pfpFileName) {
|
|
24356
|
+
this.logger.info("Inscribing profile picture for HCS-11 profile");
|
|
23749
24357
|
const pfpResult = await this.inscribePfp(pfpBuffer, pfpFileName);
|
|
23750
24358
|
if (!pfpResult.success) {
|
|
23751
|
-
this.logger.error(
|
|
23752
|
-
"Failed to inscribe profile picture, continuing without PFP"
|
|
23753
|
-
);
|
|
24359
|
+
this.logger.error("Failed to inscribe profile picture, continuing without PFP");
|
|
23754
24360
|
} else {
|
|
23755
24361
|
pfpTopicId = pfpResult.pfpTopicId;
|
|
23756
24362
|
}
|
|
24363
|
+
} else if (existingPfpTopicId) {
|
|
24364
|
+
this.logger.info(`Using existing profile picture with topic ID: ${existingPfpTopicId} for HCS-11 profile`);
|
|
23757
24365
|
}
|
|
23758
24366
|
const agentType = this.hcs11Client.getAgentTypeFromMetadata({
|
|
23759
|
-
type: metadata.type
|
|
24367
|
+
type: metadata.type || "autonomous"
|
|
23760
24368
|
});
|
|
23761
24369
|
const formattedSocials = metadata.socials ? Object.entries(metadata.socials).filter(([_, handle]) => handle).map(([platform2, handle]) => ({
|
|
23762
24370
|
platform: platform2 === "x" ? "twitter" : platform2,
|
|
@@ -24322,7 +24930,9 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
24322
24930
|
network: config.network,
|
|
24323
24931
|
operatorId: account.accountId,
|
|
24324
24932
|
operatorPrivateKey: account.privateKey,
|
|
24325
|
-
operatorPublicKey: PrivateKey.fromString(
|
|
24933
|
+
operatorPublicKey: PrivateKey.fromString(
|
|
24934
|
+
account.privateKey
|
|
24935
|
+
).publicKey.toString(),
|
|
24326
24936
|
logLevel: "info",
|
|
24327
24937
|
guardedRegistryBaseUrl: baseUrl
|
|
24328
24938
|
});
|
|
@@ -24397,6 +25007,8 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
24397
25007
|
return {
|
|
24398
25008
|
...registrationResult,
|
|
24399
25009
|
metadata: {
|
|
25010
|
+
accountId: account.accountId,
|
|
25011
|
+
privateKey: account.privateKey,
|
|
24400
25012
|
operatorId,
|
|
24401
25013
|
inboundTopicId,
|
|
24402
25014
|
outboundTopicId,
|
|
@@ -24405,7 +25017,9 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
24405
25017
|
}
|
|
24406
25018
|
};
|
|
24407
25019
|
} catch (error) {
|
|
24408
|
-
this.logger.error(
|
|
25020
|
+
this.logger.error(
|
|
25021
|
+
`Failed to create and register agent: ${error.message}`
|
|
25022
|
+
);
|
|
24409
25023
|
return {
|
|
24410
25024
|
error: error.message,
|
|
24411
25025
|
success: false
|
|
@@ -24498,7 +25112,9 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
24498
25112
|
state.createdResources = [];
|
|
24499
25113
|
}
|
|
24500
25114
|
if (registrationResult.transactionId) {
|
|
24501
|
-
state.createdResources.push(
|
|
25115
|
+
state.createdResources.push(
|
|
25116
|
+
`registration:${registrationResult.transactionId}`
|
|
25117
|
+
);
|
|
24502
25118
|
}
|
|
24503
25119
|
if (progressCallback) {
|
|
24504
25120
|
progressCallback({
|
|
@@ -24646,8 +25262,6 @@ class AgentBuilder {
|
|
|
24646
25262
|
}
|
|
24647
25263
|
setExistingProfilePicture(pfpTopicId) {
|
|
24648
25264
|
this.config.existingPfpTopicId = pfpTopicId;
|
|
24649
|
-
this.config.pfpBuffer = Buffer.from([]);
|
|
24650
|
-
this.config.pfpFileName = "existing-pfp.png";
|
|
24651
25265
|
return this;
|
|
24652
25266
|
}
|
|
24653
25267
|
setNetwork(network) {
|
|
@@ -24698,21 +25312,23 @@ class AgentBuilder {
|
|
|
24698
25312
|
return this.config;
|
|
24699
25313
|
}
|
|
24700
25314
|
}
|
|
24701
|
-
const isBrowser
|
|
25315
|
+
const isBrowser = typeof window !== "undefined";
|
|
24702
25316
|
class BrowserHCSClient extends HCS10BaseClient {
|
|
24703
25317
|
constructor(config) {
|
|
24704
25318
|
super({
|
|
24705
25319
|
network: config.network,
|
|
24706
|
-
logLevel: config.logLevel
|
|
25320
|
+
logLevel: config.logLevel,
|
|
25321
|
+
prettyPrint: config.prettyPrint
|
|
24707
25322
|
});
|
|
24708
25323
|
this.hcs11Client = null;
|
|
24709
25324
|
this.hwc = config.hwc;
|
|
24710
25325
|
this.guardedRegistryBaseUrl = config.guardedRegistryBaseUrl || "https://moonscape.tech";
|
|
24711
25326
|
this.logger = Logger$1.getInstance({
|
|
24712
25327
|
level: config.logLevel || "info",
|
|
24713
|
-
module: "HCS-Browser"
|
|
25328
|
+
module: "HCS-Browser",
|
|
25329
|
+
prettyPrint: config.prettyPrint
|
|
24714
25330
|
});
|
|
24715
|
-
if (isBrowser
|
|
25331
|
+
if (isBrowser) {
|
|
24716
25332
|
try {
|
|
24717
25333
|
const { accountId, signer } = this.getAccountAndSigner();
|
|
24718
25334
|
this.hcs11Client = new HCS11Client({
|
|
@@ -24917,6 +25533,20 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
24917
25533
|
};
|
|
24918
25534
|
return await this.submitPayload(topicId, payload);
|
|
24919
25535
|
}
|
|
25536
|
+
/**
|
|
25537
|
+
* Creates an agent directly, but does not register.
|
|
25538
|
+
* We highly recommend calling createAndRegisterAgent instead.
|
|
25539
|
+
*
|
|
25540
|
+
* @param pfpBuffer - The buffer containing the PFP image.
|
|
25541
|
+
* @param pfpFileName - The name of the file containing the PFP image.
|
|
25542
|
+
* @param agentName - The name of the agent.
|
|
25543
|
+
* @param agentDescription - The description of the agent.
|
|
25544
|
+
* @param capabilities - The capabilities of the agent.
|
|
25545
|
+
* @param metadata - The metadata of the agent.
|
|
25546
|
+
* @param existingPfpTopicId - The topic ID of the existing PFP.
|
|
25547
|
+
* @param options - Optional configuration options.
|
|
25548
|
+
* @returns A promise that resolves to the agent creation state.
|
|
25549
|
+
*/
|
|
24920
25550
|
async createAgent(pfpBuffer, pfpFileName, agentName, agentDescription, capabilities, metadata, existingPfpTopicId, options) {
|
|
24921
25551
|
try {
|
|
24922
25552
|
const progressCallback = options?.progressCallback;
|
|
@@ -25043,9 +25673,13 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
25043
25673
|
progressReporter.preparing("Profile picture created", 60, { state });
|
|
25044
25674
|
} else {
|
|
25045
25675
|
state.pfpTopicId = existingPfpTopicId || state.pfpTopicId;
|
|
25046
|
-
progressReporter.preparing(
|
|
25047
|
-
state
|
|
25048
|
-
|
|
25676
|
+
progressReporter.preparing(
|
|
25677
|
+
`Using existing profile picture: ${state.pfpTopicId}`,
|
|
25678
|
+
60,
|
|
25679
|
+
{
|
|
25680
|
+
state
|
|
25681
|
+
}
|
|
25682
|
+
);
|
|
25049
25683
|
}
|
|
25050
25684
|
if (!state.profileTopicId) {
|
|
25051
25685
|
state.currentStage = "profile";
|
|
@@ -25283,16 +25917,16 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
25283
25917
|
});
|
|
25284
25918
|
if (state.currentStage !== "complete" || !state.inboundTopicId || !state.outboundTopicId || !state.profileTopicId) {
|
|
25285
25919
|
const agentResult = await this.createAgent(
|
|
25286
|
-
config.pfpBuffer,
|
|
25287
|
-
config.pfpFileName,
|
|
25920
|
+
config.pfpBuffer || Buffer.from([]),
|
|
25921
|
+
config.pfpFileName || "default.png",
|
|
25288
25922
|
config.name,
|
|
25289
25923
|
config.description,
|
|
25290
25924
|
config.capabilities,
|
|
25291
25925
|
config.metadata,
|
|
25292
|
-
config.existingPfpTopicId
|
|
25926
|
+
config.existingPfpTopicId,
|
|
25293
25927
|
{
|
|
25294
25928
|
progressCallback: (progress) => {
|
|
25295
|
-
const adjustedPercent = progress.progressPercent * 0.3;
|
|
25929
|
+
const adjustedPercent = (progress.progressPercent || 0) * 0.3;
|
|
25296
25930
|
progressReporter.report({
|
|
25297
25931
|
stage: progress.stage,
|
|
25298
25932
|
message: progress.message,
|
|
@@ -25307,13 +25941,15 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
25307
25941
|
}
|
|
25308
25942
|
);
|
|
25309
25943
|
if (!agentResult.success) {
|
|
25310
|
-
throw new Error(
|
|
25944
|
+
throw new Error(
|
|
25945
|
+
agentResult.error || "Failed to create agent with topics"
|
|
25946
|
+
);
|
|
25311
25947
|
}
|
|
25312
25948
|
state = agentResult.state;
|
|
25313
25949
|
state.agentMetadata = config.metadata;
|
|
25314
25950
|
}
|
|
25315
25951
|
progressReporter.preparing(
|
|
25316
|
-
|
|
25952
|
+
`Agent creation status: ${state.currentStage}, ${state.completedPercentage}%`,
|
|
25317
25953
|
30,
|
|
25318
25954
|
{ state }
|
|
25319
25955
|
);
|
|
@@ -25321,6 +25957,9 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
25321
25957
|
if (state.currentStage !== "complete" || !state.createdResources?.includes(
|
|
25322
25958
|
`registration:${state.inboundTopicId}`
|
|
25323
25959
|
)) {
|
|
25960
|
+
if (options?.baseUrl) {
|
|
25961
|
+
this.guardedRegistryBaseUrl = options.baseUrl;
|
|
25962
|
+
}
|
|
25324
25963
|
const registrationResult = await this.registerAgentWithGuardedRegistry(
|
|
25325
25964
|
accountId,
|
|
25326
25965
|
config.network,
|
|
@@ -25353,14 +25992,18 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
25353
25992
|
state
|
|
25354
25993
|
});
|
|
25355
25994
|
return {
|
|
25356
|
-
|
|
25357
|
-
|
|
25358
|
-
|
|
25359
|
-
|
|
25360
|
-
|
|
25361
|
-
|
|
25362
|
-
|
|
25363
|
-
|
|
25995
|
+
success: true,
|
|
25996
|
+
state,
|
|
25997
|
+
metadata: {
|
|
25998
|
+
accountId,
|
|
25999
|
+
operatorId: `${state.inboundTopicId}@${accountId}`,
|
|
26000
|
+
inboundTopicId: state.inboundTopicId,
|
|
26001
|
+
outboundTopicId: state.outboundTopicId,
|
|
26002
|
+
profileTopicId: state.profileTopicId,
|
|
26003
|
+
pfpTopicId: state.pfpTopicId,
|
|
26004
|
+
privateKey: null,
|
|
26005
|
+
...state.agentMetadata
|
|
26006
|
+
}
|
|
25364
26007
|
};
|
|
25365
26008
|
} catch (error) {
|
|
25366
26009
|
throw new Error(`Failed to create and register agent: ${error.message}`);
|
|
@@ -25400,7 +26043,10 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
25400
26043
|
pfpTopicId = pfpResult.pfpTopicId;
|
|
25401
26044
|
}
|
|
25402
26045
|
} else if (existingPfpTopicId) {
|
|
25403
|
-
progressReporter.preparing(
|
|
26046
|
+
progressReporter.preparing(
|
|
26047
|
+
`Using existing profile picture: ${existingPfpTopicId}`,
|
|
26048
|
+
30
|
|
26049
|
+
);
|
|
25404
26050
|
} else {
|
|
25405
26051
|
progressReporter.preparing("No profile picture provided", 30);
|
|
25406
26052
|
}
|
|
@@ -25466,7 +26112,8 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
25466
26112
|
return {
|
|
25467
26113
|
profileTopicId: "",
|
|
25468
26114
|
success: false,
|
|
25469
|
-
error: "HCS11Client is not available in this environment"
|
|
26115
|
+
error: "HCS11Client is not available in this environment",
|
|
26116
|
+
transactionId: ""
|
|
25470
26117
|
};
|
|
25471
26118
|
}
|
|
25472
26119
|
const profile = this.hcs11Client.createAIAgentProfile(
|
|
@@ -25519,7 +26166,8 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
25519
26166
|
return {
|
|
25520
26167
|
profileTopicId: "",
|
|
25521
26168
|
success: false,
|
|
25522
|
-
error: profileResult.error || "Failed to inscribe profile"
|
|
26169
|
+
error: profileResult.error || "Failed to inscribe profile",
|
|
26170
|
+
transactionId: profileResult.transactionId || ""
|
|
25523
26171
|
};
|
|
25524
26172
|
}
|
|
25525
26173
|
progressReporter.completed("Profile stored successfully", {
|
|
@@ -25528,14 +26176,16 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
25528
26176
|
return {
|
|
25529
26177
|
profileTopicId: profileResult.profileTopicId,
|
|
25530
26178
|
pfpTopicId,
|
|
25531
|
-
success: true
|
|
26179
|
+
success: true,
|
|
26180
|
+
transactionId: profileResult.transactionId || ""
|
|
25532
26181
|
};
|
|
25533
26182
|
} catch (error) {
|
|
25534
26183
|
this.logger.error(`Error storing HCS11 profile: ${error.message}`);
|
|
25535
26184
|
return {
|
|
25536
26185
|
profileTopicId: "",
|
|
25537
26186
|
success: false,
|
|
25538
|
-
error: error.message
|
|
26187
|
+
error: error.message,
|
|
26188
|
+
transactionId: ""
|
|
25539
26189
|
};
|
|
25540
26190
|
}
|
|
25541
26191
|
}
|
|
@@ -25631,6 +26281,14 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
25631
26281
|
}
|
|
25632
26282
|
return { accountId, signer };
|
|
25633
26283
|
}
|
|
26284
|
+
/**
|
|
26285
|
+
* Inscribes a profile picture (PFP) on HCS-11.
|
|
26286
|
+
*
|
|
26287
|
+
* @param buffer - The buffer containing the PFP image.
|
|
26288
|
+
* @param fileName - The name of the file containing the PFP image.
|
|
26289
|
+
* @param options - Optional configuration options.
|
|
26290
|
+
* @returns A promise that resolves to the topic ID of the inscribed PFP.
|
|
26291
|
+
*/
|
|
25634
26292
|
async inscribePfp(buffer, fileName, options) {
|
|
25635
26293
|
try {
|
|
25636
26294
|
const progressCallback = options?.progressCallback;
|
|
@@ -25646,7 +26304,8 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
25646
26304
|
return {
|
|
25647
26305
|
pfpTopicId: "",
|
|
25648
26306
|
success: false,
|
|
25649
|
-
error: "HCS11Client is not available in this environment"
|
|
26307
|
+
error: "HCS11Client is not available in this environment",
|
|
26308
|
+
transactionId: ""
|
|
25650
26309
|
};
|
|
25651
26310
|
}
|
|
25652
26311
|
progressReporter.preparing("Preparing to inscribe profile picture", 10);
|
|
@@ -25674,7 +26333,8 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
25674
26333
|
return {
|
|
25675
26334
|
pfpTopicId: "",
|
|
25676
26335
|
success: false,
|
|
25677
|
-
error: imageResult.error || "Failed to inscribe profile picture"
|
|
26336
|
+
error: imageResult.error || "Failed to inscribe profile picture",
|
|
26337
|
+
transactionId: imageResult.transactionId || ""
|
|
25678
26338
|
};
|
|
25679
26339
|
}
|
|
25680
26340
|
progressReporter.completed("Successfully inscribed profile picture", {
|
|
@@ -25685,20 +26345,20 @@ class BrowserHCSClient extends HCS10BaseClient {
|
|
|
25685
26345
|
);
|
|
25686
26346
|
return {
|
|
25687
26347
|
pfpTopicId: imageResult.imageTopicId,
|
|
25688
|
-
success: true
|
|
26348
|
+
success: true,
|
|
26349
|
+
transactionId: imageResult.transactionId || ""
|
|
25689
26350
|
};
|
|
25690
26351
|
} catch (error) {
|
|
25691
26352
|
this.logger.error(`Error inscribing profile picture: ${error.message}`);
|
|
25692
26353
|
return {
|
|
25693
26354
|
pfpTopicId: "",
|
|
25694
26355
|
success: false,
|
|
25695
|
-
error: error.message
|
|
26356
|
+
error: error.message,
|
|
26357
|
+
transactionId: ""
|
|
25696
26358
|
};
|
|
25697
26359
|
}
|
|
25698
26360
|
}
|
|
25699
26361
|
}
|
|
25700
|
-
const isBrowser = typeof window !== "undefined";
|
|
25701
|
-
const isServer = !isBrowser;
|
|
25702
26362
|
export {
|
|
25703
26363
|
AIAgentCapability,
|
|
25704
26364
|
AIAgentType,
|
|
@@ -25728,8 +26388,6 @@ export {
|
|
|
25728
26388
|
capabilityNameToCapabilityMap,
|
|
25729
26389
|
inscribe,
|
|
25730
26390
|
inscribeWithSigner,
|
|
25731
|
-
isBrowser,
|
|
25732
|
-
isServer,
|
|
25733
26391
|
retrieveInscription,
|
|
25734
26392
|
sleep
|
|
25735
26393
|
};
|