@pear-protocol/symmio-client 0.3.19 → 0.3.20
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.js +39 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -25
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.js +39 -25
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +39 -25
- package/dist/react/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react/index.mjs
CHANGED
|
@@ -25229,17 +25229,29 @@ function normalizeSignParams(raw) {
|
|
|
25229
25229
|
return raw ?? {};
|
|
25230
25230
|
}
|
|
25231
25231
|
function unwrapMuonResult(result) {
|
|
25232
|
-
const
|
|
25233
|
-
if (!
|
|
25232
|
+
const envelope = result["result"];
|
|
25233
|
+
if (!envelope) {
|
|
25234
25234
|
throw new SymmioSDKError("Invalid Muon response: missing result", "MUON_PARSE_ERROR");
|
|
25235
25235
|
}
|
|
25236
|
-
const
|
|
25236
|
+
const meta = envelope["data"] ?? {};
|
|
25237
25237
|
return {
|
|
25238
|
-
|
|
25239
|
-
|
|
25240
|
-
|
|
25238
|
+
envelope,
|
|
25239
|
+
meta,
|
|
25240
|
+
computed: meta["result"] ?? {},
|
|
25241
|
+
signParams: normalizeSignParams(meta["signParams"] ?? envelope["signParams"]),
|
|
25242
|
+
signatures: meta["signatures"] ?? envelope["signatures"] ?? [],
|
|
25243
|
+
init: meta["init"] ?? envelope["init"]
|
|
25241
25244
|
};
|
|
25242
25245
|
}
|
|
25246
|
+
function requireBigInt(value, field) {
|
|
25247
|
+
if (value === void 0 || value === null || value === "") {
|
|
25248
|
+
throw new SymmioSDKError(
|
|
25249
|
+
`Invalid Muon response: missing "${field}"`,
|
|
25250
|
+
"MUON_PARSE_ERROR"
|
|
25251
|
+
);
|
|
25252
|
+
}
|
|
25253
|
+
return BigInt(value);
|
|
25254
|
+
}
|
|
25243
25255
|
function extractSchnorrSign(signParams, signatures, init) {
|
|
25244
25256
|
const inline = signParams["sigs"];
|
|
25245
25257
|
if (inline?.signature !== void 0) {
|
|
@@ -25269,41 +25281,43 @@ function extractSchnorrSign(signParams, signatures, init) {
|
|
|
25269
25281
|
nonce: nonceAddress
|
|
25270
25282
|
};
|
|
25271
25283
|
}
|
|
25272
|
-
function gatewaySigOf(signatures) {
|
|
25284
|
+
function gatewaySigOf(envelope, signatures) {
|
|
25285
|
+
const shield = envelope["shieldSignature"] ?? envelope["nodeSignature"] ?? envelope["gatewaySignature"];
|
|
25286
|
+
if (typeof shield === "string" && shield.length > 0) return shield;
|
|
25273
25287
|
return signatures?.[0]?.["signature"] ?? "0x";
|
|
25274
25288
|
}
|
|
25275
25289
|
function parseSingleUpnlSig(result) {
|
|
25276
|
-
const { signParams, signatures, init } = unwrapMuonResult(result);
|
|
25290
|
+
const { signParams, signatures, init, envelope, meta, computed } = unwrapMuonResult(result);
|
|
25277
25291
|
return {
|
|
25278
|
-
reqId: signParams["reqId"],
|
|
25279
|
-
timestamp:
|
|
25280
|
-
upnl:
|
|
25281
|
-
gatewaySignature: gatewaySigOf(signatures),
|
|
25292
|
+
reqId: signParams["reqId"] ?? envelope["reqId"],
|
|
25293
|
+
timestamp: requireBigInt(signParams["timestamp"] ?? meta["timestamp"], "timestamp"),
|
|
25294
|
+
upnl: requireBigInt(signParams["upnl"] ?? computed["uPnl"], "upnl"),
|
|
25295
|
+
gatewaySignature: gatewaySigOf(envelope, signatures),
|
|
25282
25296
|
sigs: extractSchnorrSign(signParams, signatures, init)
|
|
25283
25297
|
};
|
|
25284
25298
|
}
|
|
25285
25299
|
function parseSingleUpnlAndPriceSig(result) {
|
|
25286
|
-
const { signParams, signatures, init } = unwrapMuonResult(result);
|
|
25300
|
+
const { signParams, signatures, init, envelope, meta, computed } = unwrapMuonResult(result);
|
|
25287
25301
|
return {
|
|
25288
|
-
reqId: signParams["reqId"],
|
|
25289
|
-
timestamp:
|
|
25290
|
-
upnl:
|
|
25291
|
-
price:
|
|
25292
|
-
gatewaySignature: gatewaySigOf(signatures),
|
|
25302
|
+
reqId: signParams["reqId"] ?? envelope["reqId"],
|
|
25303
|
+
timestamp: requireBigInt(signParams["timestamp"] ?? meta["timestamp"], "timestamp"),
|
|
25304
|
+
upnl: requireBigInt(signParams["upnl"] ?? computed["uPnl"], "upnl"),
|
|
25305
|
+
price: requireBigInt(signParams["price"] ?? computed["price"], "price"),
|
|
25306
|
+
gatewaySignature: gatewaySigOf(envelope, signatures),
|
|
25293
25307
|
sigs: extractSchnorrSign(signParams, signatures, init)
|
|
25294
25308
|
};
|
|
25295
25309
|
}
|
|
25296
25310
|
function parseBatchSig(result) {
|
|
25297
|
-
const { signParams, signatures, init } = unwrapMuonResult(result);
|
|
25298
|
-
const prices = signParams["prices"];
|
|
25299
|
-
const symbolIds = signParams["symbolIds"];
|
|
25311
|
+
const { signParams, signatures, init, envelope, meta, computed } = unwrapMuonResult(result);
|
|
25312
|
+
const prices = signParams["prices"] ?? computed["prices"];
|
|
25313
|
+
const symbolIds = signParams["symbolIds"] ?? computed["symbolIds"];
|
|
25300
25314
|
return {
|
|
25301
|
-
reqId: signParams["reqId"],
|
|
25302
|
-
timestamp:
|
|
25303
|
-
upnl:
|
|
25315
|
+
reqId: signParams["reqId"] ?? envelope["reqId"],
|
|
25316
|
+
timestamp: requireBigInt(signParams["timestamp"] ?? meta["timestamp"], "timestamp"),
|
|
25317
|
+
upnl: requireBigInt(signParams["upnl"] ?? computed["uPnl"], "upnl"),
|
|
25304
25318
|
prices: (prices ?? []).map((p) => BigInt(p)),
|
|
25305
25319
|
symbolIds: (symbolIds ?? []).map((s) => BigInt(s)),
|
|
25306
|
-
gatewaySignature: gatewaySigOf(signatures),
|
|
25320
|
+
gatewaySignature: gatewaySigOf(envelope, signatures),
|
|
25307
25321
|
sigs: extractSchnorrSign(signParams, signatures, init)
|
|
25308
25322
|
};
|
|
25309
25323
|
}
|