@gardenfi/core 2.1.2 → 2.1.3
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/index.cjs +8 -8
- package/dist/index.js +150 -161
- package/dist/src/lib/garden/garden.d.ts +1 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -173,7 +173,7 @@ let ys = class {
|
|
|
173
173
|
}
|
|
174
174
|
};
|
|
175
175
|
Dn = /* @__PURE__ */ new WeakMap(), $n = /* @__PURE__ */ new WeakMap(), jn = /* @__PURE__ */ new WeakMap();
|
|
176
|
-
const
|
|
176
|
+
const re = (e) => new ys(!0, e), $ = (e, ...t) => {
|
|
177
177
|
if (typeof e == "string" && t && t.length > 0) {
|
|
178
178
|
let r = [e, ...t].map((n) => {
|
|
179
179
|
if (n) {
|
|
@@ -656,7 +656,7 @@ Rs.write = function(e, t, r, n, i, s) {
|
|
|
656
656
|
return f;
|
|
657
657
|
case "utf8":
|
|
658
658
|
case "utf-8":
|
|
659
|
-
return
|
|
659
|
+
return te(l).length;
|
|
660
660
|
case "ucs2":
|
|
661
661
|
case "ucs-2":
|
|
662
662
|
case "utf16le":
|
|
@@ -668,7 +668,7 @@ Rs.write = function(e, t, r, n, i, s) {
|
|
|
668
668
|
return $r(l).length;
|
|
669
669
|
default:
|
|
670
670
|
if (_)
|
|
671
|
-
return m ? -1 :
|
|
671
|
+
return m ? -1 : te(l).length;
|
|
672
672
|
c = ("" + c).toLowerCase(), _ = !0;
|
|
673
673
|
}
|
|
674
674
|
}
|
|
@@ -826,7 +826,7 @@ Rs.write = function(e, t, r, n, i, s) {
|
|
|
826
826
|
return L;
|
|
827
827
|
}
|
|
828
828
|
function O(l, c, f, m) {
|
|
829
|
-
return br(
|
|
829
|
+
return br(te(c, l.length - f), l, f, m);
|
|
830
830
|
}
|
|
831
831
|
function q(l, c, f, m) {
|
|
832
832
|
return br(Ot(c), l, f, m);
|
|
@@ -988,13 +988,13 @@ Rs.write = function(e, t, r, n, i, s) {
|
|
|
988
988
|
}, a.prototype.readBigUInt64LE = Ye(function(c) {
|
|
989
989
|
c = c >>> 0, N(c, "offset");
|
|
990
990
|
const f = this[c], m = this[c + 7];
|
|
991
|
-
(f === void 0 || m === void 0) &&
|
|
991
|
+
(f === void 0 || m === void 0) && D(c, this.length - 8);
|
|
992
992
|
const _ = f + this[++c] * 2 ** 8 + this[++c] * 2 ** 16 + this[++c] * 2 ** 24, P = this[++c] + this[++c] * 2 ** 8 + this[++c] * 2 ** 16 + m * 2 ** 24;
|
|
993
993
|
return BigInt(_) + (BigInt(P) << BigInt(32));
|
|
994
994
|
}), a.prototype.readBigUInt64BE = Ye(function(c) {
|
|
995
995
|
c = c >>> 0, N(c, "offset");
|
|
996
996
|
const f = this[c], m = this[c + 7];
|
|
997
|
-
(f === void 0 || m === void 0) &&
|
|
997
|
+
(f === void 0 || m === void 0) && D(c, this.length - 8);
|
|
998
998
|
const _ = f * 2 ** 24 + this[++c] * 2 ** 16 + this[++c] * 2 ** 8 + this[++c], P = this[++c] * 2 ** 24 + this[++c] * 2 ** 16 + this[++c] * 2 ** 8 + m;
|
|
999
999
|
return (BigInt(_) << BigInt(32)) + BigInt(P);
|
|
1000
1000
|
}), a.prototype.readIntLE = function(c, f, m) {
|
|
@@ -1026,13 +1026,13 @@ Rs.write = function(e, t, r, n, i, s) {
|
|
|
1026
1026
|
}, a.prototype.readBigInt64LE = Ye(function(c) {
|
|
1027
1027
|
c = c >>> 0, N(c, "offset");
|
|
1028
1028
|
const f = this[c], m = this[c + 7];
|
|
1029
|
-
(f === void 0 || m === void 0) &&
|
|
1029
|
+
(f === void 0 || m === void 0) && D(c, this.length - 8);
|
|
1030
1030
|
const _ = this[c + 4] + this[c + 5] * 2 ** 8 + this[c + 6] * 2 ** 16 + (m << 24);
|
|
1031
1031
|
return (BigInt(_) << BigInt(32)) + BigInt(f + this[++c] * 2 ** 8 + this[++c] * 2 ** 16 + this[++c] * 2 ** 24);
|
|
1032
1032
|
}), a.prototype.readBigInt64BE = Ye(function(c) {
|
|
1033
1033
|
c = c >>> 0, N(c, "offset");
|
|
1034
1034
|
const f = this[c], m = this[c + 7];
|
|
1035
|
-
(f === void 0 || m === void 0) &&
|
|
1035
|
+
(f === void 0 || m === void 0) && D(c, this.length - 8);
|
|
1036
1036
|
const _ = (f << 24) + // Overflow
|
|
1037
1037
|
this[++c] * 2 ** 16 + this[++c] * 2 ** 8 + this[++c];
|
|
1038
1038
|
return (BigInt(_) << BigInt(32)) + BigInt(this[++c] * 2 ** 24 + this[++c] * 2 ** 16 + this[++c] * 2 ** 8 + m);
|
|
@@ -1246,7 +1246,7 @@ Rs.write = function(e, t, r, n, i, s) {
|
|
|
1246
1246
|
return `${l.slice(0, f)}${c}`;
|
|
1247
1247
|
}
|
|
1248
1248
|
function b(l, c, f) {
|
|
1249
|
-
N(c, "offset"), (l[c] === void 0 || l[c + f] === void 0) &&
|
|
1249
|
+
N(c, "offset"), (l[c] === void 0 || l[c + f] === void 0) && D(c, l.length - (f + 1));
|
|
1250
1250
|
}
|
|
1251
1251
|
function w(l, c, f, m, _, P) {
|
|
1252
1252
|
if (l > f || l < c) {
|
|
@@ -1260,7 +1260,7 @@ Rs.write = function(e, t, r, n, i, s) {
|
|
|
1260
1260
|
if (typeof l != "number")
|
|
1261
1261
|
throw new F.ERR_INVALID_ARG_TYPE(c, "number", l);
|
|
1262
1262
|
}
|
|
1263
|
-
function
|
|
1263
|
+
function D(l, c, f) {
|
|
1264
1264
|
throw Math.floor(l) !== l ? (N(l, f), new F.ERR_OUT_OF_RANGE("offset", "an integer", l)) : c < 0 ? new F.ERR_BUFFER_OUT_OF_BOUNDS() : new F.ERR_OUT_OF_RANGE(
|
|
1265
1265
|
"offset",
|
|
1266
1266
|
`>= 0 and <= ${c}`,
|
|
@@ -1274,7 +1274,7 @@ Rs.write = function(e, t, r, n, i, s) {
|
|
|
1274
1274
|
l = l + "=";
|
|
1275
1275
|
return l;
|
|
1276
1276
|
}
|
|
1277
|
-
function
|
|
1277
|
+
function te(l, c) {
|
|
1278
1278
|
c = c || 1 / 0;
|
|
1279
1279
|
let f;
|
|
1280
1280
|
const m = l.length;
|
|
@@ -6257,9 +6257,9 @@ class hh {
|
|
|
6257
6257
|
async fetchBlockNumbers() {
|
|
6258
6258
|
try {
|
|
6259
6259
|
const t = await xt.get(this.url);
|
|
6260
|
-
return
|
|
6260
|
+
return re(t);
|
|
6261
6261
|
} catch (t) {
|
|
6262
|
-
return
|
|
6262
|
+
return $("Failed to fetch block numbers", t);
|
|
6263
6263
|
}
|
|
6264
6264
|
}
|
|
6265
6265
|
}
|
|
@@ -6303,9 +6303,9 @@ class dh {
|
|
|
6303
6303
|
retryCount: 0,
|
|
6304
6304
|
...i
|
|
6305
6305
|
});
|
|
6306
|
-
return o.error ?
|
|
6306
|
+
return o.error ? $(o.error) : o.result ? re(o.result) : $("GetQuote: Unexpected error, result is undefined");
|
|
6307
6307
|
} catch (s) {
|
|
6308
|
-
return
|
|
6308
|
+
return $("GetQuote:", String(s));
|
|
6309
6309
|
}
|
|
6310
6310
|
}
|
|
6311
6311
|
async getAttestedQuote(t) {
|
|
@@ -6316,9 +6316,9 @@ class dh {
|
|
|
6316
6316
|
"Content-Type": "application/json"
|
|
6317
6317
|
}
|
|
6318
6318
|
});
|
|
6319
|
-
return r.error ?
|
|
6319
|
+
return r.error ? $(r.error) : r.result ? re(r.result) : $("GetAttestedQuote: Unexpected error, result is undefined");
|
|
6320
6320
|
} catch (r) {
|
|
6321
|
-
return console.log("error :", r),
|
|
6321
|
+
return console.log("error :", r), $("GetAttestedQuote:", String(r));
|
|
6322
6322
|
}
|
|
6323
6323
|
}
|
|
6324
6324
|
async getStrategies() {
|
|
@@ -6326,9 +6326,9 @@ class dh {
|
|
|
6326
6326
|
const t = await xt.get(
|
|
6327
6327
|
this.quoteUrl.endpoint("/strategies")
|
|
6328
6328
|
);
|
|
6329
|
-
if (t.error) return
|
|
6329
|
+
if (t.error) return $(t.error);
|
|
6330
6330
|
if (!t.result)
|
|
6331
|
-
return
|
|
6331
|
+
return $("GetStrategies: Unexpected error, result is undefined");
|
|
6332
6332
|
const r = {};
|
|
6333
6333
|
for (const n of Object.values(t.result)) {
|
|
6334
6334
|
const i = jf(
|
|
@@ -6344,9 +6344,9 @@ class dh {
|
|
|
6344
6344
|
fee: n.fee
|
|
6345
6345
|
};
|
|
6346
6346
|
}
|
|
6347
|
-
return
|
|
6347
|
+
return re(r);
|
|
6348
6348
|
} catch (t) {
|
|
6349
|
-
return
|
|
6349
|
+
return $("GetStrategies:", String(t));
|
|
6350
6350
|
}
|
|
6351
6351
|
}
|
|
6352
6352
|
}
|
|
@@ -7102,8 +7102,8 @@ function vc() {
|
|
|
7102
7102
|
}
|
|
7103
7103
|
var N = A.objectMode ? 1 : z.length;
|
|
7104
7104
|
A.length += N;
|
|
7105
|
-
var
|
|
7106
|
-
if (
|
|
7105
|
+
var D = A.length < A.highWaterMark;
|
|
7106
|
+
if (D || (A.needDrain = !0), A.writing || A.corked) {
|
|
7107
7107
|
var he = A.lastBufferedRequest;
|
|
7108
7108
|
A.lastBufferedRequest = {
|
|
7109
7109
|
chunk: z,
|
|
@@ -7114,7 +7114,7 @@ function vc() {
|
|
|
7114
7114
|
}, he ? he.next = A.lastBufferedRequest : A.bufferedRequest = A.lastBufferedRequest, A.bufferedRequestCount += 1;
|
|
7115
7115
|
} else
|
|
7116
7116
|
G(k, A, !1, N, z, K, b);
|
|
7117
|
-
return
|
|
7117
|
+
return D;
|
|
7118
7118
|
}
|
|
7119
7119
|
function G(k, A, F, z, K, b, w) {
|
|
7120
7120
|
A.writelen = z, A.writecb = w, A.writing = !0, A.sync = !0, A.destroyed ? A.onwrite(new T("write")) : F ? k._writev(K, A.onwrite) : k._write(K, b, A.onwrite), A.sync = !1;
|
|
@@ -7151,8 +7151,8 @@ function vc() {
|
|
|
7151
7151
|
K.allBuffers = N, G(k, A, !0, A.length, K, "", b.finish), A.pendingcb++, A.lastBufferedRequest = null, b.next ? (A.corkedRequestsFree = b.next, b.next = null) : A.corkedRequestsFree = new e(A), A.bufferedRequestCount = 0;
|
|
7152
7152
|
} else {
|
|
7153
7153
|
for (; F; ) {
|
|
7154
|
-
var
|
|
7155
|
-
if (G(k, A, !1,
|
|
7154
|
+
var D = F.chunk, he = F.encoding, Y = F.callback, te = A.objectMode ? 1 : D.length;
|
|
7155
|
+
if (G(k, A, !1, te, D, he, Y), F = F.next, A.bufferedRequestCount--, A.writing)
|
|
7156
7156
|
break;
|
|
7157
7157
|
}
|
|
7158
7158
|
F === null && (A.lastBufferedRequest = null);
|
|
@@ -7658,22 +7658,22 @@ function xc() {
|
|
|
7658
7658
|
}), O.prototype.destroy = d.destroy, O.prototype._undestroy = d.undestroy, O.prototype._destroy = function(b, w) {
|
|
7659
7659
|
w(b);
|
|
7660
7660
|
}, O.prototype.push = function(b, w) {
|
|
7661
|
-
var N = this._readableState,
|
|
7662
|
-
return N.objectMode ?
|
|
7661
|
+
var N = this._readableState, D;
|
|
7662
|
+
return N.objectMode ? D = !0 : typeof b == "string" && (w = w || N.defaultEncoding, w !== N.encoding && (b = n.from(b, w), w = ""), D = !0), q(this, b, w, !1, D);
|
|
7663
7663
|
}, O.prototype.unshift = function(b) {
|
|
7664
7664
|
return q(this, b, null, !0, !1);
|
|
7665
7665
|
};
|
|
7666
|
-
function q(b, w, N,
|
|
7666
|
+
function q(b, w, N, D, he) {
|
|
7667
7667
|
u("readableAddChunk", w);
|
|
7668
7668
|
var Y = b._readableState;
|
|
7669
7669
|
if (w === null)
|
|
7670
7670
|
Y.reading = !1, ge(b, Y);
|
|
7671
7671
|
else {
|
|
7672
|
-
var
|
|
7673
|
-
if (he || (
|
|
7674
|
-
S(b,
|
|
7672
|
+
var te;
|
|
7673
|
+
if (he || (te = j(Y, w)), te)
|
|
7674
|
+
S(b, te);
|
|
7675
7675
|
else if (Y.objectMode || w && w.length > 0)
|
|
7676
|
-
if (typeof w != "string" && !Y.objectMode && Object.getPrototypeOf(w) !== n.prototype && (w = s(w)),
|
|
7676
|
+
if (typeof w != "string" && !Y.objectMode && Object.getPrototypeOf(w) !== n.prototype && (w = s(w)), D)
|
|
7677
7677
|
Y.endEmitted ? S(b, new R()) : C(b, Y, w, !0);
|
|
7678
7678
|
else if (Y.ended)
|
|
7679
7679
|
S(b, new B());
|
|
@@ -7682,12 +7682,12 @@ function xc() {
|
|
|
7682
7682
|
return !1;
|
|
7683
7683
|
Y.reading = !1, Y.decoder && !N ? (w = Y.decoder.write(w), Y.objectMode || w.length !== 0 ? C(b, Y, w, !1) : Ve(b, Y)) : C(b, Y, w, !1);
|
|
7684
7684
|
}
|
|
7685
|
-
else
|
|
7685
|
+
else D || (Y.reading = !1, Ve(b, Y));
|
|
7686
7686
|
}
|
|
7687
7687
|
return !Y.ended && (Y.length < Y.highWaterMark || Y.length === 0);
|
|
7688
7688
|
}
|
|
7689
|
-
function C(b, w, N,
|
|
7690
|
-
w.flowing && w.length === 0 && !w.sync ? (w.awaitDrain = 0, b.emit("data", N)) : (w.length += w.objectMode ? 1 : N.length,
|
|
7689
|
+
function C(b, w, N, D) {
|
|
7690
|
+
w.flowing && w.length === 0 && !w.sync ? (w.awaitDrain = 0, b.emit("data", N)) : (w.length += w.objectMode ? 1 : N.length, D ? w.buffer.unshift(N) : w.buffer.push(N), w.needReadable && Ge(b)), Ve(b, w);
|
|
7691
7691
|
}
|
|
7692
7692
|
function j(b, w) {
|
|
7693
7693
|
var N;
|
|
@@ -7699,9 +7699,9 @@ function xc() {
|
|
|
7699
7699
|
U || (U = ri.StringDecoder);
|
|
7700
7700
|
var w = new U(b);
|
|
7701
7701
|
this._readableState.decoder = w, this._readableState.encoding = this._readableState.decoder.encoding;
|
|
7702
|
-
for (var N = this._readableState.buffer.head,
|
|
7703
|
-
|
|
7704
|
-
return this._readableState.buffer.clear(),
|
|
7702
|
+
for (var N = this._readableState.buffer.head, D = ""; N !== null; )
|
|
7703
|
+
D += w.write(N.data), N = N.next;
|
|
7704
|
+
return this._readableState.buffer.clear(), D !== "" && this._readableState.buffer.push(D), this._readableState.length = D.length, this;
|
|
7705
7705
|
};
|
|
7706
7706
|
var G = 1073741824;
|
|
7707
7707
|
function V(b) {
|
|
@@ -7717,8 +7717,8 @@ function xc() {
|
|
|
7717
7717
|
return u("read: emitReadable", w.length, w.ended), w.length === 0 && w.ended ? F(this) : Ge(this), null;
|
|
7718
7718
|
if (b = Z(b, w), b === 0 && w.ended)
|
|
7719
7719
|
return w.length === 0 && F(this), null;
|
|
7720
|
-
var
|
|
7721
|
-
u("need readable",
|
|
7720
|
+
var D = w.needReadable;
|
|
7721
|
+
u("need readable", D), (w.length === 0 || w.length - b < w.highWaterMark) && (D = !0, u("length less than watermark", D)), w.ended || w.reading ? (D = !1, u("reading or ended", D)) : D && (u("do read"), w.reading = !0, w.sync = !0, w.length === 0 && (w.needReadable = !0), this._read(w.highWaterMark), w.sync = !1, w.reading || (b = Z(N, w)));
|
|
7722
7722
|
var he;
|
|
7723
7723
|
return b > 0 ? he = A(b, w) : he = null, he === null ? (w.needReadable = w.length <= w.highWaterMark, b = 0) : (w.length -= b, w.awaitDrain = 0), w.length === 0 && (w.ended || (w.needReadable = !0), N !== b && w.ended && F(this)), he !== null && this.emit("data", he), he;
|
|
7724
7724
|
};
|
|
@@ -7753,22 +7753,22 @@ function xc() {
|
|
|
7753
7753
|
O.prototype._read = function(b) {
|
|
7754
7754
|
S(this, new T("_read()"));
|
|
7755
7755
|
}, O.prototype.pipe = function(b, w) {
|
|
7756
|
-
var N = this,
|
|
7757
|
-
switch (
|
|
7756
|
+
var N = this, D = this._readableState;
|
|
7757
|
+
switch (D.pipesCount) {
|
|
7758
7758
|
case 0:
|
|
7759
|
-
|
|
7759
|
+
D.pipes = b;
|
|
7760
7760
|
break;
|
|
7761
7761
|
case 1:
|
|
7762
|
-
|
|
7762
|
+
D.pipes = [D.pipes, b];
|
|
7763
7763
|
break;
|
|
7764
7764
|
default:
|
|
7765
|
-
|
|
7765
|
+
D.pipes.push(b);
|
|
7766
7766
|
break;
|
|
7767
7767
|
}
|
|
7768
|
-
|
|
7768
|
+
D.pipesCount += 1, u("pipe count=%d opts=%j", D.pipesCount, w);
|
|
7769
7769
|
var he = (!w || w.end !== !1) && b !== process.stdout && b !== process.stderr, Y = he ? Ot : Jt;
|
|
7770
|
-
|
|
7771
|
-
function
|
|
7770
|
+
D.endEmitted ? process.nextTick(Y) : N.once("end", Y), b.on("unpipe", te);
|
|
7771
|
+
function te(l, c) {
|
|
7772
7772
|
u("onunpipe"), l === N && c && c.hasUnpiped === !1 && (c.hasUnpiped = !0, br());
|
|
7773
7773
|
}
|
|
7774
7774
|
function Ot() {
|
|
@@ -7778,13 +7778,13 @@ function xc() {
|
|
|
7778
7778
|
b.on("drain", mr);
|
|
7779
7779
|
var $r = !1;
|
|
7780
7780
|
function br() {
|
|
7781
|
-
u("cleanup"), b.removeListener("close", jr), b.removeListener("finish", Ye), b.removeListener("drain", mr), b.removeListener("error", Xt), b.removeListener("unpipe",
|
|
7781
|
+
u("cleanup"), b.removeListener("close", jr), b.removeListener("finish", Ye), b.removeListener("drain", mr), b.removeListener("error", Xt), b.removeListener("unpipe", te), N.removeListener("end", Ot), N.removeListener("end", Jt), N.removeListener("data", We), $r = !0, D.awaitDrain && (!b._writableState || b._writableState.needDrain) && mr();
|
|
7782
7782
|
}
|
|
7783
7783
|
N.on("data", We);
|
|
7784
7784
|
function We(l) {
|
|
7785
7785
|
u("ondata");
|
|
7786
7786
|
var c = b.write(l);
|
|
7787
|
-
u("dest.write", c), c === !1 && ((
|
|
7787
|
+
u("dest.write", c), c === !1 && ((D.pipesCount === 1 && D.pipes === b || D.pipesCount > 1 && K(D.pipes, b) !== -1) && !$r && (u("false write response, pause", D.awaitDrain), D.awaitDrain++), N.pause());
|
|
7788
7788
|
}
|
|
7789
7789
|
function Xt(l) {
|
|
7790
7790
|
u("onerror", l), Jt(), b.removeListener("error", Xt), t(b, "error") === 0 && S(b, l);
|
|
@@ -7801,7 +7801,7 @@ function xc() {
|
|
|
7801
7801
|
function Jt() {
|
|
7802
7802
|
u("unpipe"), N.unpipe(b);
|
|
7803
7803
|
}
|
|
7804
|
-
return b.emit("pipe", N),
|
|
7804
|
+
return b.emit("pipe", N), D.flowing || (u("pipe resume"), N.resume()), b;
|
|
7805
7805
|
};
|
|
7806
7806
|
function le(b) {
|
|
7807
7807
|
return function() {
|
|
@@ -7817,18 +7817,18 @@ function xc() {
|
|
|
7817
7817
|
if (w.pipesCount === 1)
|
|
7818
7818
|
return b && b !== w.pipes ? this : (b || (b = w.pipes), w.pipes = null, w.pipesCount = 0, w.flowing = !1, b && b.emit("unpipe", this, N), this);
|
|
7819
7819
|
if (!b) {
|
|
7820
|
-
var
|
|
7820
|
+
var D = w.pipes, he = w.pipesCount;
|
|
7821
7821
|
w.pipes = null, w.pipesCount = 0, w.flowing = !1;
|
|
7822
|
-
for (var Y = 0; Y < he; Y++)
|
|
7822
|
+
for (var Y = 0; Y < he; Y++) D[Y].emit("unpipe", this, {
|
|
7823
7823
|
hasUnpiped: !1
|
|
7824
7824
|
});
|
|
7825
7825
|
return this;
|
|
7826
7826
|
}
|
|
7827
|
-
var
|
|
7828
|
-
return
|
|
7827
|
+
var te = K(w.pipes, b);
|
|
7828
|
+
return te === -1 ? this : (w.pipes.splice(te, 1), w.pipesCount -= 1, w.pipesCount === 1 && (w.pipes = w.pipes[0]), b.emit("unpipe", this, N), this);
|
|
7829
7829
|
}, O.prototype.on = function(b, w) {
|
|
7830
|
-
var N = r.prototype.on.call(this, b, w),
|
|
7831
|
-
return b === "data" ? (
|
|
7830
|
+
var N = r.prototype.on.call(this, b, w), D = this._readableState;
|
|
7831
|
+
return b === "data" ? (D.readableListening = this.listenerCount("readable") > 0, D.flowing !== !1 && this.resume()) : b === "readable" && !D.endEmitted && !D.readableListening && (D.readableListening = D.needReadable = !0, D.flowing = !1, D.emittedReadable = !1, u("on readable", D.length, D.reading), D.length ? Ge(this) : D.reading || process.nextTick(ze, this)), N;
|
|
7832
7832
|
}, O.prototype.addListener = O.prototype.on, O.prototype.removeListener = function(b, w) {
|
|
7833
7833
|
var N = r.prototype.removeListener.call(this, b, w);
|
|
7834
7834
|
return b === "readable" && process.nextTick(_e, this), N;
|
|
@@ -7861,17 +7861,17 @@ function xc() {
|
|
|
7861
7861
|
for (u("flow", w.flowing); w.flowing && b.read() !== null; ) ;
|
|
7862
7862
|
}
|
|
7863
7863
|
O.prototype.wrap = function(b) {
|
|
7864
|
-
var w = this, N = this._readableState,
|
|
7864
|
+
var w = this, N = this._readableState, D = !1;
|
|
7865
7865
|
b.on("end", function() {
|
|
7866
7866
|
if (u("wrapped end"), N.decoder && !N.ended) {
|
|
7867
|
-
var
|
|
7868
|
-
|
|
7867
|
+
var te = N.decoder.end();
|
|
7868
|
+
te && te.length && w.push(te);
|
|
7869
7869
|
}
|
|
7870
7870
|
w.push(null);
|
|
7871
|
-
}), b.on("data", function(
|
|
7872
|
-
if (u("wrapped data"), N.decoder && (
|
|
7873
|
-
var Ot = w.push(
|
|
7874
|
-
Ot || (
|
|
7871
|
+
}), b.on("data", function(te) {
|
|
7872
|
+
if (u("wrapped data"), N.decoder && (te = N.decoder.write(te)), !(N.objectMode && te == null) && !(!N.objectMode && (!te || !te.length))) {
|
|
7873
|
+
var Ot = w.push(te);
|
|
7874
|
+
Ot || (D = !0, b.pause());
|
|
7875
7875
|
}
|
|
7876
7876
|
});
|
|
7877
7877
|
for (var he in b)
|
|
@@ -7882,8 +7882,8 @@ function xc() {
|
|
|
7882
7882
|
}(he));
|
|
7883
7883
|
for (var Y = 0; Y < E.length; Y++)
|
|
7884
7884
|
b.on(E[Y], this.emit.bind(this, E[Y]));
|
|
7885
|
-
return this._read = function(
|
|
7886
|
-
u("wrapped _read",
|
|
7885
|
+
return this._read = function(te) {
|
|
7886
|
+
u("wrapped _read", te), D && (D = !1, b.resume());
|
|
7887
7887
|
}, this;
|
|
7888
7888
|
}, typeof Symbol == "function" && (O.prototype[Symbol.asyncIterator] = function() {
|
|
7889
7889
|
return x === void 0 && (x = rd()), x(this);
|
|
@@ -7942,7 +7942,7 @@ function xc() {
|
|
|
7942
7942
|
return g === void 0 && (g = nd()), g(O, b, w);
|
|
7943
7943
|
});
|
|
7944
7944
|
function K(b, w) {
|
|
7945
|
-
for (var N = 0,
|
|
7945
|
+
for (var N = 0, D = b.length; N < D; N++)
|
|
7946
7946
|
if (b[N] === w) return N;
|
|
7947
7947
|
return -1;
|
|
7948
7948
|
}
|
|
@@ -9621,13 +9621,13 @@ class si extends Sa {
|
|
|
9621
9621
|
return new si(void 0, t);
|
|
9622
9622
|
}
|
|
9623
9623
|
async initialize() {
|
|
9624
|
-
if (this.digestKey) return
|
|
9624
|
+
if (this.digestKey) return re("Already initialized");
|
|
9625
9625
|
const t = await this.deriveDigestKeyFromWalletClient();
|
|
9626
|
-
return t.error ?
|
|
9626
|
+
return t.error ? $(t.error) : (this.emit("initialized", !0), re("Initialized"));
|
|
9627
9627
|
}
|
|
9628
9628
|
async deriveDigestKeyFromWalletClient() {
|
|
9629
|
-
if (!this.walletClient) return
|
|
9630
|
-
if (!this.walletClient.account) return
|
|
9629
|
+
if (!this.walletClient) return $("No walletClient found");
|
|
9630
|
+
if (!this.walletClient.account) return $("No account found");
|
|
9631
9631
|
try {
|
|
9632
9632
|
const t = await this.walletClient.signTypedData({
|
|
9633
9633
|
account: this.walletClient.account,
|
|
@@ -9653,38 +9653,38 @@ class si extends Sa {
|
|
|
9653
9653
|
Nonce: 1n
|
|
9654
9654
|
}
|
|
9655
9655
|
});
|
|
9656
|
-
return this.digestKey = tr(kn(t)), this.emit("initialized", !0),
|
|
9656
|
+
return this.digestKey = tr(kn(t)), this.emit("initialized", !0), re(this.digestKey);
|
|
9657
9657
|
} catch (t) {
|
|
9658
|
-
return
|
|
9658
|
+
return $("Failed to initialize: " + t);
|
|
9659
9659
|
}
|
|
9660
9660
|
}
|
|
9661
9661
|
async getDigestKey() {
|
|
9662
9662
|
if (!this.digestKey && !this.walletClient)
|
|
9663
|
-
return
|
|
9663
|
+
return $("No private key or wallet client found");
|
|
9664
9664
|
if (!this.digestKey && this.walletClient) {
|
|
9665
9665
|
const t = await this.deriveDigestKeyFromWalletClient();
|
|
9666
9666
|
if (t.error)
|
|
9667
|
-
return
|
|
9667
|
+
return $(t.error);
|
|
9668
9668
|
}
|
|
9669
|
-
return this.digestKey ?
|
|
9669
|
+
return this.digestKey ? re(this.digestKey) : $("No private key found");
|
|
9670
9670
|
}
|
|
9671
9671
|
async generateSecret(t) {
|
|
9672
9672
|
const r = await this.signMessage(t);
|
|
9673
|
-
if (r.error) return
|
|
9673
|
+
if (r.error) return $(r.error);
|
|
9674
9674
|
const n = kn(Mn(r.val)), i = kn(n);
|
|
9675
|
-
return
|
|
9675
|
+
return re({ secret: n, secretHash: i });
|
|
9676
9676
|
}
|
|
9677
9677
|
async signMessage(t) {
|
|
9678
9678
|
if (!this.digestKey) {
|
|
9679
9679
|
const h = await this.getDigestKey();
|
|
9680
|
-
if (h.error) return
|
|
9680
|
+
if (h.error) return $(h.error);
|
|
9681
9681
|
this.digestKey = h.val;
|
|
9682
9682
|
}
|
|
9683
9683
|
const r = tp(ir), n = "Garden.fi" + t.toString(), i = Buffer.from(n, "utf8"), s = kn(i), o = Buffer.from(tr(this.digestKey), "hex");
|
|
9684
9684
|
if (o.length !== 32)
|
|
9685
|
-
return
|
|
9685
|
+
return $("Invalid private key length. Expected 32 bytes.");
|
|
9686
9686
|
const u = r.fromPrivateKey(o).sign(Buffer.from(tr(s), "hex"));
|
|
9687
|
-
return
|
|
9687
|
+
return re(u.toString("hex"));
|
|
9688
9688
|
}
|
|
9689
9689
|
}
|
|
9690
9690
|
const rp = [
|
|
@@ -11711,14 +11711,14 @@ const ci = {
|
|
|
11711
11711
|
if (r)
|
|
11712
11712
|
try {
|
|
11713
11713
|
if (r.id === ((n = t.chain) == null ? void 0 : n.id))
|
|
11714
|
-
return
|
|
11714
|
+
return re({ message: "Already on the network", walletClient: t });
|
|
11715
11715
|
await t.switchChain({ id: r.id });
|
|
11716
11716
|
const i = uo({
|
|
11717
11717
|
account: t.account,
|
|
11718
11718
|
chain: r,
|
|
11719
11719
|
transport: lo(t.transport)
|
|
11720
11720
|
});
|
|
11721
|
-
return
|
|
11721
|
+
return re({
|
|
11722
11722
|
message: "Switched chain",
|
|
11723
11723
|
walletClient: i
|
|
11724
11724
|
});
|
|
@@ -11731,18 +11731,18 @@ const ci = {
|
|
|
11731
11731
|
chain: r,
|
|
11732
11732
|
transport: lo(window.ethereum)
|
|
11733
11733
|
});
|
|
11734
|
-
return
|
|
11734
|
+
return re({
|
|
11735
11735
|
message: "Added network",
|
|
11736
11736
|
walletClient: s
|
|
11737
11737
|
});
|
|
11738
11738
|
} catch {
|
|
11739
|
-
return
|
|
11739
|
+
return $("Failed to add network");
|
|
11740
11740
|
}
|
|
11741
11741
|
else
|
|
11742
|
-
return
|
|
11742
|
+
return $("Failed to switch network");
|
|
11743
11743
|
}
|
|
11744
11744
|
else
|
|
11745
|
-
return
|
|
11745
|
+
return $("Chain not supported");
|
|
11746
11746
|
}, Vy = (e) => typeof e == "object" && e !== null && "code" in e && e.code === 4902;
|
|
11747
11747
|
class zy {
|
|
11748
11748
|
constructor(t, r, n) {
|
|
@@ -12996,11 +12996,11 @@ const hf = [
|
|
|
12996
12996
|
retryInterval: 3e3,
|
|
12997
12997
|
successStates: [Rf.SUCCEEDED]
|
|
12998
12998
|
}
|
|
12999
|
-
),
|
|
12999
|
+
), re(d.transaction_hash);
|
|
13000
13000
|
}
|
|
13001
|
-
return
|
|
13001
|
+
return re("Allowance already approved");
|
|
13002
13002
|
} catch (s) {
|
|
13003
|
-
return
|
|
13003
|
+
return $(
|
|
13004
13004
|
`Failed to check or approve allowance: ${s instanceof Error ? s.message : String(s)}`
|
|
13005
13005
|
);
|
|
13006
13006
|
}
|
|
@@ -13285,10 +13285,10 @@ class Yy {
|
|
|
13285
13285
|
return this.account.address;
|
|
13286
13286
|
}
|
|
13287
13287
|
async initiate(t) {
|
|
13288
|
-
if (!this.account.address) return
|
|
13288
|
+
if (!this.account.address) return $("No account address");
|
|
13289
13289
|
const { create_order: r, source_swap: n } = t, { redeemer: i, amount: s } = n;
|
|
13290
13290
|
if (!s || !i || !r.secret_hash || !r.timelock)
|
|
13291
|
-
return
|
|
13291
|
+
return $("Invalid order");
|
|
13292
13292
|
try {
|
|
13293
13293
|
const o = new Ps(
|
|
13294
13294
|
pf,
|
|
@@ -13301,7 +13301,7 @@ class Yy {
|
|
|
13301
13301
|
BigInt(s),
|
|
13302
13302
|
this.nodeUrl
|
|
13303
13303
|
);
|
|
13304
|
-
if (h.error) return
|
|
13304
|
+
if (h.error) return $(h.error);
|
|
13305
13305
|
const d = {
|
|
13306
13306
|
domain: Wy,
|
|
13307
13307
|
primaryType: "Initiate",
|
|
@@ -13328,9 +13328,9 @@ class Yy {
|
|
|
13328
13328
|
}
|
|
13329
13329
|
}
|
|
13330
13330
|
);
|
|
13331
|
-
return I.error ?
|
|
13331
|
+
return I.error ? $(I.error) : I.result ? re(I.result) : $("Init: No result found");
|
|
13332
13332
|
} catch (o) {
|
|
13333
|
-
return
|
|
13333
|
+
return $(String(o));
|
|
13334
13334
|
}
|
|
13335
13335
|
}
|
|
13336
13336
|
async redeem(t, r) {
|
|
@@ -13348,21 +13348,21 @@ class Yy {
|
|
|
13348
13348
|
}
|
|
13349
13349
|
}
|
|
13350
13350
|
);
|
|
13351
|
-
return n.error ?
|
|
13351
|
+
return n.error ? $(n.error) : n.result ? re(n.result) : $("Redeem: No result found");
|
|
13352
13352
|
} catch (n) {
|
|
13353
|
-
return
|
|
13353
|
+
return $(String(n));
|
|
13354
13354
|
}
|
|
13355
13355
|
}
|
|
13356
13356
|
async refund() {
|
|
13357
|
-
return
|
|
13357
|
+
return $("Refund is taken care of by the relayer");
|
|
13358
13358
|
}
|
|
13359
13359
|
}
|
|
13360
13360
|
class yf extends Sa {
|
|
13361
13361
|
constructor(t) {
|
|
13362
13362
|
if (super(), this.environment = _t.TESTNET, this.getOrderThreshold = 20, this.refundSacpCache = /* @__PURE__ */ new Map(), this.bitcoinRedeemCache = new lh(), typeof t.digestKey == "string") {
|
|
13363
|
-
const
|
|
13364
|
-
if (
|
|
13365
|
-
this._digestKey =
|
|
13363
|
+
const n = oo.from(t.digestKey);
|
|
13364
|
+
if (n.error) throw new Error(n.error);
|
|
13365
|
+
this._digestKey = n.val;
|
|
13366
13366
|
} else
|
|
13367
13367
|
this._digestKey = t.digestKey;
|
|
13368
13368
|
if (typeof t.environment == "string") {
|
|
@@ -13373,6 +13373,11 @@ class yf extends Sa {
|
|
|
13373
13373
|
} else
|
|
13374
13374
|
this._api = t.environment;
|
|
13375
13375
|
this._quote = t.quote ?? new dh(this._api.quote), this._auth = t.auth ?? ao.fromDigestKey(new vt(this._api.auth), this._digestKey), this._orderbook = t.orderbook ?? new _f(new vt(this._api.orderbook)), this._evmHTLC = t.htlc.evm, this._starknetHTLC = t.htlc.starknet, this._secretManager = t.secretManager ?? si.fromDigestKey(this._digestKey.digestKey), this.orderExecutorCache = new uh(), this._blockNumberFetcher = t.blockNumberFetcher ?? new hh(this._api.info, this.environment);
|
|
13376
|
+
const r = new Sf(Gf(this.environment));
|
|
13377
|
+
this._btcWallet = Af.fromPrivateKey(
|
|
13378
|
+
this._digestKey.digestKey,
|
|
13379
|
+
r
|
|
13380
|
+
);
|
|
13376
13381
|
}
|
|
13377
13382
|
static fromWallets(t) {
|
|
13378
13383
|
let r;
|
|
@@ -13427,19 +13432,11 @@ class yf extends Sa {
|
|
|
13427
13432
|
get digestKey() {
|
|
13428
13433
|
return this._digestKey;
|
|
13429
13434
|
}
|
|
13430
|
-
async initializeSMandBTCWallet() {
|
|
13431
|
-
if (this._secretManager.isInitialized && this._btcWallet)
|
|
13432
|
-
return te(this._btcWallet);
|
|
13433
|
-
const t = await this._secretManager.getDigestKey();
|
|
13434
|
-
if (t.error) return D(t.error);
|
|
13435
|
-
const r = new Sf(Gf(this.environment));
|
|
13436
|
-
return this._btcWallet = Af.fromPrivateKey(t.val, r), te(this._btcWallet);
|
|
13437
|
-
}
|
|
13438
13435
|
async swap(t) {
|
|
13439
13436
|
const r = await this.validateAndFillParams(t);
|
|
13440
|
-
if (r.error) return
|
|
13437
|
+
if (r.error) return $(r.error);
|
|
13441
13438
|
const { sendAddress: n, receiveAddress: i, timelock: s } = r.val, o = Date.now().toString(), a = await this._secretManager.generateSecret(o);
|
|
13442
|
-
if (a.error) return
|
|
13439
|
+
if (a.error) return $(a.error);
|
|
13443
13440
|
const { strategyId: u, btcAddress: h } = t.additionalData, d = {
|
|
13444
13441
|
strategy_id: u,
|
|
13445
13442
|
...h && {
|
|
@@ -13461,49 +13458,41 @@ class yf extends Sa {
|
|
|
13461
13458
|
min_destination_confirmations: t.minDestinationConfirmations ?? 0,
|
|
13462
13459
|
additional_data: d
|
|
13463
13460
|
}, v = await this._quote.getAttestedQuote(y);
|
|
13464
|
-
if (v.error) return
|
|
13461
|
+
if (v.error) return $(v.error);
|
|
13465
13462
|
const p = await this._orderbook.createOrder(
|
|
13466
13463
|
v.val,
|
|
13467
13464
|
this.auth
|
|
13468
13465
|
);
|
|
13469
|
-
if (p.error) return
|
|
13466
|
+
if (p.error) return $(p.error);
|
|
13470
13467
|
const I = await this.pollOrder(p.val);
|
|
13471
|
-
return I.error ?
|
|
13468
|
+
return I.error ? $(I.error) : re(I.val);
|
|
13472
13469
|
}
|
|
13473
13470
|
async validateAndFillParams(t) {
|
|
13474
|
-
if (!t.additionalData.strategyId) return
|
|
13471
|
+
if (!t.additionalData.strategyId) return $("StrategyId is required");
|
|
13475
13472
|
if (!t.fromAsset || !t.toAsset)
|
|
13476
|
-
return
|
|
13473
|
+
return $("Source and destination assets are required for swap");
|
|
13477
13474
|
if (t.fromAsset.chain === t.toAsset.chain && t.fromAsset.atomicSwapAddress === t.toAsset.atomicSwapAddress)
|
|
13478
|
-
return
|
|
13475
|
+
return $("Source and destination assets cannot be the same");
|
|
13479
13476
|
if (An(t.fromAsset.chain) && !An(t.toAsset.chain) || !An(t.fromAsset.chain) && An(t.toAsset.chain))
|
|
13480
|
-
return
|
|
13477
|
+
return $(
|
|
13481
13478
|
"Both assets should be on the same network (either mainnet or testnet)"
|
|
13482
13479
|
);
|
|
13483
13480
|
const r = this.validateAmount(t.sendAmount);
|
|
13484
|
-
if (r.error) return
|
|
13481
|
+
if (r.error) return $(r.error);
|
|
13485
13482
|
const n = this.validateAmount(t.receiveAmount);
|
|
13486
|
-
if (n.error) return
|
|
13483
|
+
if (n.error) return $(n.error);
|
|
13487
13484
|
if (r < n)
|
|
13488
|
-
return
|
|
13485
|
+
return $("Send amount should be greater than receive amount");
|
|
13489
13486
|
const i = vf(t.fromAsset.chain);
|
|
13490
|
-
if (!i) return
|
|
13491
|
-
if (Ui(t.fromAsset.chain) || Ui(t.toAsset.chain))
|
|
13492
|
-
|
|
13493
|
-
|
|
13494
|
-
|
|
13495
|
-
);
|
|
13496
|
-
const a = await this.initializeSMandBTCWallet();
|
|
13497
|
-
if (a.error) return D(a.error);
|
|
13498
|
-
if (!this._btcWallet)
|
|
13499
|
-
return D(
|
|
13500
|
-
"btcWallet is required for bitcoin chain. Please provide btcWallet in the constructor"
|
|
13501
|
-
);
|
|
13502
|
-
}
|
|
13487
|
+
if (!i) return $("Unsupported chain for timelock");
|
|
13488
|
+
if ((Ui(t.fromAsset.chain) || Ui(t.toAsset.chain)) && !t.additionalData.btcAddress)
|
|
13489
|
+
return $(
|
|
13490
|
+
"btcAddress in additionalData is required if source or destination chain is bitcoin, it is used as refund or redeem address."
|
|
13491
|
+
);
|
|
13503
13492
|
const s = await this.getAddresses(t.fromAsset.chain);
|
|
13504
|
-
if (s.error) return
|
|
13493
|
+
if (s.error) return $(s.error);
|
|
13505
13494
|
const o = await this.getAddresses(t.toAsset.chain);
|
|
13506
|
-
return o.error ?
|
|
13495
|
+
return o.error ? $(o.error) : re({
|
|
13507
13496
|
sendAddress: s.val,
|
|
13508
13497
|
receiveAddress: o.val,
|
|
13509
13498
|
timelock: t.timelock ?? i
|
|
@@ -13513,37 +13502,37 @@ class yf extends Sa {
|
|
|
13513
13502
|
var n;
|
|
13514
13503
|
switch (Li(t)) {
|
|
13515
13504
|
case dt.EVM:
|
|
13516
|
-
return this._evmHTLC ?
|
|
13505
|
+
return this._evmHTLC ? re(this._evmHTLC.htlcActorAddress) : $("Please provide evmHTLC when initializing garden");
|
|
13517
13506
|
case dt.Bitcoin: {
|
|
13518
13507
|
const i = await ((n = this._btcWallet) == null ? void 0 : n.getPublicKey());
|
|
13519
|
-
return !i || !$f(i) ?
|
|
13508
|
+
return !i || !$f(i) ? $("Invalid btc public key") : re(Zt(i));
|
|
13520
13509
|
}
|
|
13521
13510
|
case dt.Starknet:
|
|
13522
|
-
return this._starknetHTLC ?
|
|
13511
|
+
return this._starknetHTLC ? re(this._starknetHTLC.htlcActorAddress) : $("Please provide starknetHTLC when initializing garden");
|
|
13523
13512
|
default:
|
|
13524
|
-
return
|
|
13513
|
+
return $("Unsupported chain");
|
|
13525
13514
|
}
|
|
13526
13515
|
}
|
|
13527
13516
|
validateAmount(t) {
|
|
13528
13517
|
if (t == null || t.includes("."))
|
|
13529
|
-
return
|
|
13518
|
+
return $("Invalid amount ", t);
|
|
13530
13519
|
const r = new If(t);
|
|
13531
|
-
return !r.isInteger() || r.isNaN() || r.lt(0) || r.isLessThanOrEqualTo(0) ?
|
|
13520
|
+
return !r.isInteger() || r.isNaN() || r.lt(0) || r.isLessThanOrEqualTo(0) ? $("Invalid amount ", t) : re(r);
|
|
13532
13521
|
}
|
|
13533
13522
|
async pollOrder(t) {
|
|
13534
13523
|
let r = await this._orderbook.getOrder(t, !0), n = 0;
|
|
13535
13524
|
for (; n < this.getOrderThreshold; ) {
|
|
13536
13525
|
if (await xf(1e3), n++, r.error) {
|
|
13537
13526
|
if (!r.error.includes("result is undefined"))
|
|
13538
|
-
return
|
|
13527
|
+
return $(r.error);
|
|
13539
13528
|
} else if (r.val && r.val.create_order.create_id.toLowerCase() === t.toLowerCase())
|
|
13540
|
-
return
|
|
13529
|
+
return re(r.val);
|
|
13541
13530
|
r = await this._orderbook.getOrder(t, !0);
|
|
13542
13531
|
}
|
|
13543
|
-
return
|
|
13532
|
+
return $(`Order not found, createOrder id: ${t}`);
|
|
13544
13533
|
}
|
|
13545
13534
|
async execute(t = 5e3) {
|
|
13546
|
-
return await this.
|
|
13535
|
+
return await this._orderbook.subscribeOrders(
|
|
13547
13536
|
this._digestKey.userId,
|
|
13548
13537
|
!0,
|
|
13549
13538
|
t,
|
|
@@ -13844,9 +13833,9 @@ class yf extends Sa {
|
|
|
13844
13833
|
}
|
|
13845
13834
|
async filterExpiredAndAssignStatus(t) {
|
|
13846
13835
|
var i;
|
|
13847
|
-
if (t.length === 0) return
|
|
13836
|
+
if (t.length === 0) return re([]);
|
|
13848
13837
|
const r = await ((i = this._blockNumberFetcher) == null ? void 0 : i.fetchBlockNumbers());
|
|
13849
|
-
if (r.error) return
|
|
13838
|
+
if (r.error) return $(r.error);
|
|
13850
13839
|
const n = [];
|
|
13851
13840
|
for (let s = 0; s < t.length; s++) {
|
|
13852
13841
|
const o = t[s];
|
|
@@ -13867,11 +13856,11 @@ class yf extends Sa {
|
|
|
13867
13856
|
status: y
|
|
13868
13857
|
});
|
|
13869
13858
|
}
|
|
13870
|
-
return
|
|
13859
|
+
return re(n);
|
|
13871
13860
|
}
|
|
13872
13861
|
async broadcastRedeemTx(t, r) {
|
|
13873
13862
|
try {
|
|
13874
|
-
if (!this._api) return
|
|
13863
|
+
if (!this._api) return $("API not found");
|
|
13875
13864
|
const n = new vt(this._api.evmRelay).endpoint("/bitcoin/redeem "), i = await this._auth.getAuthHeaders(), o = await (await fetch(n, {
|
|
13876
13865
|
method: "POST",
|
|
13877
13866
|
headers: {
|
|
@@ -13883,9 +13872,9 @@ class yf extends Sa {
|
|
|
13883
13872
|
order_id: r
|
|
13884
13873
|
})
|
|
13885
13874
|
})).json();
|
|
13886
|
-
return o.status === "Ok" && o.result ?
|
|
13875
|
+
return o.status === "Ok" && o.result ? re(o.result) : $(o.error);
|
|
13887
13876
|
} catch (n) {
|
|
13888
|
-
return
|
|
13877
|
+
return $("Failed to broadcast redeem tx: " + n);
|
|
13889
13878
|
}
|
|
13890
13879
|
}
|
|
13891
13880
|
}
|
|
@@ -13920,9 +13909,9 @@ class pm {
|
|
|
13920
13909
|
BigInt(t.source_swap.amount),
|
|
13921
13910
|
this.nodeUrl
|
|
13922
13911
|
);
|
|
13923
|
-
if (a.error) return
|
|
13912
|
+
if (a.error) return $(a.error);
|
|
13924
13913
|
} catch (a) {
|
|
13925
|
-
return
|
|
13914
|
+
return $(`Allowance check failed: ${a}`);
|
|
13926
13915
|
}
|
|
13927
13916
|
const o = await this.account.execute({
|
|
13928
13917
|
contractAddress: t.source_swap.asset,
|
|
@@ -13937,9 +13926,9 @@ class pm {
|
|
|
13937
13926
|
});
|
|
13938
13927
|
if (!o.transaction_hash)
|
|
13939
13928
|
throw new Error("Failed to initiate HTLC transaction");
|
|
13940
|
-
return
|
|
13929
|
+
return re(o.transaction_hash);
|
|
13941
13930
|
} catch (r) {
|
|
13942
|
-
return
|
|
13931
|
+
return $(`HTLC Initiation Error: ${r}`);
|
|
13943
13932
|
}
|
|
13944
13933
|
}
|
|
13945
13934
|
/**
|
|
@@ -13959,9 +13948,9 @@ class pm {
|
|
|
13959
13948
|
secret: ps(r)
|
|
13960
13949
|
})
|
|
13961
13950
|
});
|
|
13962
|
-
return s.transaction_hash ?
|
|
13951
|
+
return s.transaction_hash ? re(s.transaction_hash) : $("Failed to redeem HTLC transaction");
|
|
13963
13952
|
} catch {
|
|
13964
|
-
return
|
|
13953
|
+
return $("HTLC Redeem Error");
|
|
13965
13954
|
}
|
|
13966
13955
|
}
|
|
13967
13956
|
/**
|
|
@@ -13979,9 +13968,9 @@ class pm {
|
|
|
13979
13968
|
orderId: r
|
|
13980
13969
|
}
|
|
13981
13970
|
});
|
|
13982
|
-
return i.transaction_hash ?
|
|
13971
|
+
return i.transaction_hash ? re(i.transaction_hash) : $("Failed to refund HTLC transaction");
|
|
13983
13972
|
} catch {
|
|
13984
|
-
return
|
|
13973
|
+
return $("HTLC Refund Error");
|
|
13985
13974
|
}
|
|
13986
13975
|
}
|
|
13987
13976
|
}
|