@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/index.mjs
CHANGED
|
@@ -23352,17 +23352,29 @@ function normalizeSignParams(raw) {
|
|
|
23352
23352
|
return raw ?? {};
|
|
23353
23353
|
}
|
|
23354
23354
|
function unwrapMuonResult(result) {
|
|
23355
|
-
const
|
|
23356
|
-
if (!
|
|
23355
|
+
const envelope = result["result"];
|
|
23356
|
+
if (!envelope) {
|
|
23357
23357
|
throw new SymmioSDKError("Invalid Muon response: missing result", "MUON_PARSE_ERROR");
|
|
23358
23358
|
}
|
|
23359
|
-
const
|
|
23359
|
+
const meta = envelope["data"] ?? {};
|
|
23360
23360
|
return {
|
|
23361
|
-
|
|
23362
|
-
|
|
23363
|
-
|
|
23361
|
+
envelope,
|
|
23362
|
+
meta,
|
|
23363
|
+
computed: meta["result"] ?? {},
|
|
23364
|
+
signParams: normalizeSignParams(meta["signParams"] ?? envelope["signParams"]),
|
|
23365
|
+
signatures: meta["signatures"] ?? envelope["signatures"] ?? [],
|
|
23366
|
+
init: meta["init"] ?? envelope["init"]
|
|
23364
23367
|
};
|
|
23365
23368
|
}
|
|
23369
|
+
function requireBigInt(value, field) {
|
|
23370
|
+
if (value === void 0 || value === null || value === "") {
|
|
23371
|
+
throw new SymmioSDKError(
|
|
23372
|
+
`Invalid Muon response: missing "${field}"`,
|
|
23373
|
+
"MUON_PARSE_ERROR"
|
|
23374
|
+
);
|
|
23375
|
+
}
|
|
23376
|
+
return BigInt(value);
|
|
23377
|
+
}
|
|
23366
23378
|
function extractSchnorrSign(signParams, signatures, init) {
|
|
23367
23379
|
const inline = signParams["sigs"];
|
|
23368
23380
|
if (inline?.signature !== void 0) {
|
|
@@ -23392,41 +23404,43 @@ function extractSchnorrSign(signParams, signatures, init) {
|
|
|
23392
23404
|
nonce: nonceAddress
|
|
23393
23405
|
};
|
|
23394
23406
|
}
|
|
23395
|
-
function gatewaySigOf(signatures) {
|
|
23407
|
+
function gatewaySigOf(envelope, signatures) {
|
|
23408
|
+
const shield = envelope["shieldSignature"] ?? envelope["nodeSignature"] ?? envelope["gatewaySignature"];
|
|
23409
|
+
if (typeof shield === "string" && shield.length > 0) return shield;
|
|
23396
23410
|
return signatures?.[0]?.["signature"] ?? "0x";
|
|
23397
23411
|
}
|
|
23398
23412
|
function parseSingleUpnlSig(result) {
|
|
23399
|
-
const { signParams, signatures, init } = unwrapMuonResult(result);
|
|
23413
|
+
const { signParams, signatures, init, envelope, meta, computed } = unwrapMuonResult(result);
|
|
23400
23414
|
return {
|
|
23401
|
-
reqId: signParams["reqId"],
|
|
23402
|
-
timestamp:
|
|
23403
|
-
upnl:
|
|
23404
|
-
gatewaySignature: gatewaySigOf(signatures),
|
|
23415
|
+
reqId: signParams["reqId"] ?? envelope["reqId"],
|
|
23416
|
+
timestamp: requireBigInt(signParams["timestamp"] ?? meta["timestamp"], "timestamp"),
|
|
23417
|
+
upnl: requireBigInt(signParams["upnl"] ?? computed["uPnl"], "upnl"),
|
|
23418
|
+
gatewaySignature: gatewaySigOf(envelope, signatures),
|
|
23405
23419
|
sigs: extractSchnorrSign(signParams, signatures, init)
|
|
23406
23420
|
};
|
|
23407
23421
|
}
|
|
23408
23422
|
function parseSingleUpnlAndPriceSig(result) {
|
|
23409
|
-
const { signParams, signatures, init } = unwrapMuonResult(result);
|
|
23423
|
+
const { signParams, signatures, init, envelope, meta, computed } = unwrapMuonResult(result);
|
|
23410
23424
|
return {
|
|
23411
|
-
reqId: signParams["reqId"],
|
|
23412
|
-
timestamp:
|
|
23413
|
-
upnl:
|
|
23414
|
-
price:
|
|
23415
|
-
gatewaySignature: gatewaySigOf(signatures),
|
|
23425
|
+
reqId: signParams["reqId"] ?? envelope["reqId"],
|
|
23426
|
+
timestamp: requireBigInt(signParams["timestamp"] ?? meta["timestamp"], "timestamp"),
|
|
23427
|
+
upnl: requireBigInt(signParams["upnl"] ?? computed["uPnl"], "upnl"),
|
|
23428
|
+
price: requireBigInt(signParams["price"] ?? computed["price"], "price"),
|
|
23429
|
+
gatewaySignature: gatewaySigOf(envelope, signatures),
|
|
23416
23430
|
sigs: extractSchnorrSign(signParams, signatures, init)
|
|
23417
23431
|
};
|
|
23418
23432
|
}
|
|
23419
23433
|
function parseBatchSig(result) {
|
|
23420
|
-
const { signParams, signatures, init } = unwrapMuonResult(result);
|
|
23421
|
-
const prices = signParams["prices"];
|
|
23422
|
-
const symbolIds = signParams["symbolIds"];
|
|
23434
|
+
const { signParams, signatures, init, envelope, meta, computed } = unwrapMuonResult(result);
|
|
23435
|
+
const prices = signParams["prices"] ?? computed["prices"];
|
|
23436
|
+
const symbolIds = signParams["symbolIds"] ?? computed["symbolIds"];
|
|
23423
23437
|
return {
|
|
23424
|
-
reqId: signParams["reqId"],
|
|
23425
|
-
timestamp:
|
|
23426
|
-
upnl:
|
|
23438
|
+
reqId: signParams["reqId"] ?? envelope["reqId"],
|
|
23439
|
+
timestamp: requireBigInt(signParams["timestamp"] ?? meta["timestamp"], "timestamp"),
|
|
23440
|
+
upnl: requireBigInt(signParams["upnl"] ?? computed["uPnl"], "upnl"),
|
|
23427
23441
|
prices: (prices ?? []).map((p) => BigInt(p)),
|
|
23428
23442
|
symbolIds: (symbolIds ?? []).map((s) => BigInt(s)),
|
|
23429
|
-
gatewaySignature: gatewaySigOf(signatures),
|
|
23443
|
+
gatewaySignature: gatewaySigOf(envelope, signatures),
|
|
23430
23444
|
sigs: extractSchnorrSign(signParams, signatures, init)
|
|
23431
23445
|
};
|
|
23432
23446
|
}
|