@molpha/sdk 0.2.0-dev-20261001125531 → 0.2.0-dev-20261002062009
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 +19 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1304,7 +1304,25 @@ async function parseGatewayErrorDetail(res) {
|
|
|
1304
1304
|
function normalizeHex(value) {
|
|
1305
1305
|
return (value.startsWith("0x") || value.startsWith("0X") ? value.slice(2) : value).toLowerCase();
|
|
1306
1306
|
}
|
|
1307
|
-
function
|
|
1307
|
+
function flattenGatewayData(data) {
|
|
1308
|
+
const nested = data.attestation;
|
|
1309
|
+
if (!nested) return data;
|
|
1310
|
+
const { attestation: _nested, ...rest } = data;
|
|
1311
|
+
const { payload, signature } = nested;
|
|
1312
|
+
return {
|
|
1313
|
+
...rest,
|
|
1314
|
+
...payload?.sourceId !== void 0 ? { sourceId: payload.sourceId } : {},
|
|
1315
|
+
...payload?.value !== void 0 ? { valuePacked: payload.value } : {},
|
|
1316
|
+
...payload?.canonicalTimestamp !== void 0 ? { timestamp: payload.canonicalTimestamp } : {},
|
|
1317
|
+
...payload?.registryVersion !== void 0 ? { registryVersion: payload.registryVersion } : {},
|
|
1318
|
+
...payload?.signaturesRequired !== void 0 ? { signaturesRequired: payload.signaturesRequired } : {},
|
|
1319
|
+
...signature?.signersBitmap !== void 0 ? { signersBitmap: signature.signersBitmap } : {},
|
|
1320
|
+
...signature?.signature !== void 0 ? { s: signature.signature } : {},
|
|
1321
|
+
...signature?.commitment !== void 0 ? { commitmentAddr: signature.commitment } : {}
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
function toResult(raw, ctx) {
|
|
1325
|
+
const data = flattenGatewayData(raw);
|
|
1308
1326
|
if (data.sourceId !== void 0 && normalizeHex(data.sourceId) !== ctx.sourceId) {
|
|
1309
1327
|
throw new GatewayError(
|
|
1310
1328
|
`Gateway response sourceId ${data.sourceId} does not match the requested ${ctx.sourceId}`
|