@continuumdao/ctm-mpc-defi 0.2.61 → 0.2.62
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.
|
@@ -1114,6 +1114,18 @@ function orderBroadcasterChoices(rows) {
|
|
|
1114
1114
|
function defaultBroadcasterChoice(rows) {
|
|
1115
1115
|
return rows.find((row) => row.coversGas) ?? rows[0];
|
|
1116
1116
|
}
|
|
1117
|
+
function currentBroadcasterChoice(rows, feesId, railgunAddress, refused) {
|
|
1118
|
+
const id = feesId.trim();
|
|
1119
|
+
if (id && !refused.has(id)) {
|
|
1120
|
+
const exact = rows.find((row2) => row2.feesId === id);
|
|
1121
|
+
if (exact) return { row: exact, refreshed: false };
|
|
1122
|
+
}
|
|
1123
|
+
const address = railgunAddress.trim();
|
|
1124
|
+
if (!address) return void 0;
|
|
1125
|
+
const same = rows.filter((row2) => row2.railgunAddress === address && !refused.has(row2.feesId));
|
|
1126
|
+
const row = same.find((item) => item.coversGas) ?? same[0];
|
|
1127
|
+
return row ? { row, refreshed: true } : void 0;
|
|
1128
|
+
}
|
|
1117
1129
|
function nextCoveringBroadcaster(rows, refused) {
|
|
1118
1130
|
return rows.find((row) => row.coversGas && !refused.has(row.feesId));
|
|
1119
1131
|
}
|
|
@@ -1350,9 +1362,11 @@ async function listRailgunBroadcasters(args) {
|
|
|
1350
1362
|
tokenDecimals: row.tokenDecimals
|
|
1351
1363
|
}));
|
|
1352
1364
|
}
|
|
1353
|
-
function broadcasterNote(row,
|
|
1365
|
+
function broadcasterNote(row, mode) {
|
|
1354
1366
|
const ratioLabel = row.ratio ? `${row.ratio}:1` : "the selected fee";
|
|
1355
|
-
|
|
1367
|
+
if (mode === "next") return `Trying the next broadcaster at ${ratioLabel}`;
|
|
1368
|
+
if (mode === "refreshed") return `The chosen fee expired. Broadcaster ${ratioLabel}`;
|
|
1369
|
+
return `Broadcaster ${ratioLabel}`;
|
|
1356
1370
|
}
|
|
1357
1371
|
function poiListsPresent(pois) {
|
|
1358
1372
|
return Object.values(pois).some((leaves) => Object.keys(leaves).length > 0);
|
|
@@ -1417,7 +1431,9 @@ async function submitFreshProof(args) {
|
|
|
1417
1431
|
}
|
|
1418
1432
|
await args.assertSpendable?.();
|
|
1419
1433
|
const refused = /* @__PURE__ */ new Set();
|
|
1420
|
-
|
|
1434
|
+
const chosenFeesId = args.broadcasterFeesId?.trim() ?? "";
|
|
1435
|
+
const chosenAddress = args.broadcasterAddress?.trim() ?? "";
|
|
1436
|
+
let feesId = chosenFeesId;
|
|
1421
1437
|
let lastError = new Error("No Railgun broadcaster is available for this token.");
|
|
1422
1438
|
let builds = 0;
|
|
1423
1439
|
while (builds < MAX_GAS_BROADCASTERS) {
|
|
@@ -1430,11 +1446,8 @@ async function submitFreshProof(args) {
|
|
|
1430
1446
|
kind: args.kind,
|
|
1431
1447
|
waitMs: BROADCASTER_PROOF_WAIT_MS
|
|
1432
1448
|
});
|
|
1433
|
-
const
|
|
1434
|
-
|
|
1435
|
-
throw new Error("That broadcaster fee expired. Refresh the list and choose again.");
|
|
1436
|
-
}
|
|
1437
|
-
const row = requested ?? nextCoveringBroadcaster(rows, refused) ?? (refused.size === 0 ? defaultBroadcasterChoice(rows) : void 0);
|
|
1449
|
+
const picked = refused.size === 0 ? currentBroadcasterChoice(rows, feesId, chosenAddress, refused) : void 0;
|
|
1450
|
+
const row = picked?.row ?? nextCoveringBroadcaster(rows, refused) ?? (refused.size === 0 ? defaultBroadcasterChoice(rows) : void 0);
|
|
1438
1451
|
if (!row || !broadcasterFeeStillValid(row.expiration)) {
|
|
1439
1452
|
if (!row) break;
|
|
1440
1453
|
refused.add(row.feesId);
|
|
@@ -1444,7 +1457,9 @@ async function submitFreshProof(args) {
|
|
|
1444
1457
|
}
|
|
1445
1458
|
builds += 1;
|
|
1446
1459
|
feesId = row.feesId;
|
|
1447
|
-
|
|
1460
|
+
const replaced = Boolean(chosenFeesId) && row.feesId !== chosenFeesId;
|
|
1461
|
+
const mode = refused.size > 0 ? "next" : replaced ? "refreshed" : "selected";
|
|
1462
|
+
args.onBroadcasterNote?.(broadcasterNote(row, mode));
|
|
1448
1463
|
const broadcaster = row.selected;
|
|
1449
1464
|
const proved = await args.build(broadcaster);
|
|
1450
1465
|
if (!broadcasterFeeStillValid(broadcaster.tokenFee.expiration)) {
|
|
@@ -1641,6 +1656,7 @@ async function provePrivateTransfer(args) {
|
|
|
1641
1656
|
kind: "transfer",
|
|
1642
1657
|
chain,
|
|
1643
1658
|
tokenAddress,
|
|
1659
|
+
broadcasterAddress: args.broadcasterAddress,
|
|
1644
1660
|
broadcasterFeesId: args.broadcasterFeesId,
|
|
1645
1661
|
onBroadcasterSearch: args.onBroadcasterSearch,
|
|
1646
1662
|
onBroadcasterNote: args.onBroadcasterNote,
|
|
@@ -1727,6 +1743,7 @@ async function proveUnshield(args) {
|
|
|
1727
1743
|
kind: "unshield",
|
|
1728
1744
|
chain,
|
|
1729
1745
|
tokenAddress,
|
|
1746
|
+
broadcasterAddress: args.broadcasterAddress,
|
|
1730
1747
|
broadcasterFeesId: args.broadcasterFeesId,
|
|
1731
1748
|
onBroadcasterSearch: args.onBroadcasterSearch,
|
|
1732
1749
|
onBroadcasterNote: args.onBroadcasterNote,
|