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