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